Test: Component: Driver Job Marketplace Advanced Search Filters - #528
Open
Deb-Auth wants to merge 1 commit into
Open
Test: Component: Driver Job Marketplace Advanced Search Filters#528Deb-Auth wants to merge 1 commit into
Deb-Auth wants to merge 1 commit into
Conversation
|
@Deb-Auth Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes #496
Summary
Adds automated tests for the state management of the location and cargo type filters in the driver job marketplace, together with the filter controls themselves.
The marketplace at
/driver/jobshad no advanced search filters at the time of writing, so there was no filter state to test. This PR adds them following the project's Component -> Hook -> Service layering, wires them into the existing job board page, and then tests the state management thoroughly.What was added
services/driverJobService.ts— aCargoTypeunion (general,fragile,perishable,hazardous,oversized,refrigerated), aCARGO_TYPESlist for rendering, and an optionalcargoTypefield onDeliveryJob. The field is optional so the change is backwards-compatible with jobs the backend has not yet backfilled.hooks/useJobFilters.ts— owns the advanced-search state.availableLocationsandavailableCargoTypesare derived from the current job pool, de-duplicated and sorted, so the dropdowns never offer a value that would return nothing.features/driver/components/JobFilters.tsx— the presentational control strip: keyword input, location select, cargo type select, a live match count and a Clear All action that appears only while a filter is active.app/(dashboard)/driver/jobs/page.tsx— renders the filters above the grid, drives the grid fromfilteredJobs, and adds a distinct "No jobs match your filters" state so an empty filtered result is not confused with an empty marketplace.Test coverage
hooks/__tests__/useJobFilters.test.ts(17 tests)resetFiltersclears all three at once; active filters survive a refresh of the job pool.hasActiveFiltersstill true; jobs without a cargo type are excluded once a cargo type filter is set; an empty job pool does not throw.features/driver/components/__tests__/JobFilters.test.tsx(14 tests)useJobFiltersto the realJobFiltersand asserts that the visible job list narrows as filters are applied and is restored on reset.Mocking of external dependencies
The filter layer is pure state over data already in memory, so it needs no transport mocks.
driverJobService(axios) is untouched by these tests and is never reached from them, which keeps the suite deterministic.Verification
npx jest hooks/__tests__/useJobFilters.test.ts features/driver/components/__tests__/JobFilters.test.tsx— 31 tests pass.pnpm test— the full suite goes from 921 to 952 tests with no change to the set of pre-existing failures.npx eslinton every changed file — no errors.pnpm run type-check— no new errors.Note for the maintainer
CI on
mainis currently red before any of this, and these changes do not fix or worsen it:components/mobile/MobileFooter.tsxhas lost every quote character in the file (line 1 reads`use clientand line 3import React from react). This is a hard parse error that failspnpm run lint,pnpm run type-checkandpnpm run buildonmaintoday.main, largely around the wallet/Freighter mocks (useWallet,useTheme,WalletConnect,MultiSigApprovalsand related).Both look like they need a maintainer decision rather than a drive-by fix from a test PR, so I have deliberately left them untouched to keep this diff scoped to the issue.