Skip to content

test(ShipmentFilters): add component test suite — issue #615 - #642

Merged
Onomebello merged 1 commit into
Navin-xmr:devfrom
Demilade10:issue-615
Jul 30, 2026
Merged

test(ShipmentFilters): add component test suite — issue #615#642
Onomebello merged 1 commit into
Navin-xmr:devfrom
Demilade10:issue-615

Conversation

@Demilade10

@Demilade10 Demilade10 commented Jul 30, 2026

Copy link
Copy Markdown

Issue

Closes #615

Description

Adds a Vitest + React Testing Library test suite for the ShipmentFilters
component at frontend/src/pages/Shipments/ShipmentFilters/ShipmentFilters.test.tsx.

9 tests covering all 6 acceptance criteria from the issue:

Test Criterion
Renders without crashing, verifies onFilterChange called on mount Renders without crashing
Status chip selects → callback contains correct status value Status filter change
Status chip deselects on second click Status filter change
Date range picker: pick two days → apply → dateFrom/dateTo in callback Date range filter
"Clear All Filters" button resets all values to defaults Clear filters
Individual chip remove button fires callback with empty status array Clear filters
All controls queryable via getByRole / getByPlaceholderText Accessible labels
Active-filter count badge appears when a filter is applied No results state signal
Chip-strip "Clear All" button also resets to defaults Clear filters (alt path)

Implementation notes:

  • MemoryRouter wraps the component to satisfy useSearchParams — no mocking needed
  • Real timers + await act(flushDebounce) (350 ms) handle the component's 300 ms debounce
  • userEvent for all chip/button interactions; fireEvent.change for text inputs
  • vi.fn() spies on onFilterChange throughout
  • No any types

Testing

  • Ran pnpm run lint — no errors in new file (pre-existing errors in other files unrelated to this PR)
  • Ran pnpm run build — pre-existing build errors in unrelated files; new file introduces none
  • Ran pnpm run test "ShipmentFilters"9/9 tests pass
  • Tested in browser — N/A (test-only PR)

Screenshots/Recording

Screenshot 2026-07-30 105711

…615)

- Renders without crashing, verifies onFilterChange called on mount
- Status chip toggle: selects and deselects, asserts callback payload
- Date range filter: opens picker, picks two days, applies, asserts dateFrom/dateTo
- Clear All Filters button resets all values to EMPTY_FILTERS
- Individual chip remove via active-filter strip
- Accessibility: role/placeholder queries for all filter controls
- Active filter count badge reflects applied filter count
- Clear All chip-strip button path also tested

Uses MemoryRouter for useSearchParams, real timers + act(flushDebounce)
for 300ms debounce, userEvent for chip clicks, vi.fn() spies throughout.
No any types.
@vercel

vercel Bot commented Jul 30, 2026

Copy link
Copy Markdown

@Demilade10 is attempting to deploy a commit to the dinahmaccodes' projects Team on Vercel.

A member of the Team first needs to authorize it.

@Onomebello
Onomebello merged commit 6be2d2d into Navin-xmr:dev Jul 30, 2026
0 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants