Test: Component: Global Unified Search Categorization - #529
Open
Deb-Auth wants to merge 1 commit into
Open
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 #499
Summary
Adds automated tests verifying that global search results group correctly into Deliveries, Drivers and Transactions, together with the unified search implementation those tests exercise.
The existing
components/ui/CommandPalette.tsxonly groups into "Quick actions" and "Deliveries" and has no notion of drivers or transactions, so there was no categorisation to verify. This PR adds a unified search across all three categories following the project's Component -> Hook -> Service layering, and tests every layer. The command palette is deliberately left untouched to avoid colliding with the design work currently landing on it.What was added
services/globalSearchService.ts— the transport for the unified search endpoint.SearchCategory, a canonicalSEARCH_CATEGORIESorder andSEARCH_CATEGORY_LABELS.{ results: [...] }envelope from the API.hrefper category when the API does not supply one.AbortSignal.hooks/useGlobalSearch.ts— runs the search and groups the results.isEmptyis only true once a search has actually run, so an untouched search box never reads as "no results".components/search/GlobalSearch.tsx— the search input plus grouped results, with a heading per non-empty category, loading, error and empty states, an accessible live count and a clear action.Test coverage
hooks/__tests__/useGlobalSearch.test.ts(13 tests)Errorrejection falls back to a generic message; a later successful query clears the error.clear()both restore the idle state.components/search/__tests__/GlobalSearch.test.tsx(14 tests)onSelecthandler.services/__tests__/globalSearchService.test.ts(11 tests)Canonical category order, request shape with a trimmed query, empty-query short-circuit, normalisation of wrapped and bare-array responses, explicit
hrefpreservation, title fallback, malformed-record rejection, missing and non-arrayresults, error propagation and abort-signal forwarding.Mocking of external dependencies
@/lib/api(the shared axios instance) is mocked in the service tests, andglobalSearchServiceitself is mocked in the hook and component tests. No real HTTP, wallet or WebSocket call is made anywhere in the suite. The race-condition tests drive the timing explicitly with deferred promises rather than timers, so they are deterministic rather than timing-dependent.Verification
npx jest services/__tests__/globalSearchService.test.ts hooks/__tests__/useGlobalSearch.test.ts components/search/__tests__/GlobalSearch.test.tsx— 38 tests pass.pnpm test— the full suite goes from 921 to 959 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.