Problem
src/components/layout/site-search.tsx (239 lines — the Cmd/Ctrl+K / / site-wide search dialog added for #222, searching places, competitions, and docs at once) has no test file:
$ find src -name "*.test.ts" -o -name "*.test.tsx" | grep -i search
src/lib/search.test.ts
src/lib/search.ts (the pure search/ranking logic it calls into) is tested, but the component itself isn't, even though it owns real, easy-to-get-wrong logic that a pure-function test can't cover:
- Arrow-key navigation that wraps around (
(i + 1) % flatResults.length / (i - 1 + flatResults.length) % flatResults.length)
- Building a flat, cross-group
activeIndex out of grouped results (indexByKey) so keyboard nav moves correctly across the place/competition/docs group boundaries
Enter selecting the currently active row and navigating via router.push
- The "See all N results" vs. "and N more" branching (
seeAllHref returns null for docs, so it must render the plain-text fallback instead)
Every other interactive, similarly logic-heavy component in the app has a test file next to it (map-view.test.tsx, results-list.test.tsx, competition-filters.test.tsx, competitions-browser.test.tsx, suggest-place-dialog.test.tsx, onboarding-flow.test.tsx) — site-search.tsx is the newest major interactive component and the one exception.
Fix
Add src/components/layout/site-search.test.tsx using the existing Testing Library setup (see results-list.test.tsx or competition-filters.test.tsx for the project's conventions), covering at minimum: rendering grouped results, arrow-key wraparound, Enter navigating to the active result, and the "see all" / "and N more" branching for a group whose results exceed the per-group cap.
Acceptance criteria
Problem
src/components/layout/site-search.tsx(239 lines — theCmd/Ctrl+K//site-wide search dialog added for #222, searching places, competitions, and docs at once) has no test file:src/lib/search.ts(the pure search/ranking logic it calls into) is tested, but the component itself isn't, even though it owns real, easy-to-get-wrong logic that a pure-function test can't cover:(i + 1) % flatResults.length/(i - 1 + flatResults.length) % flatResults.length)activeIndexout of grouped results (indexByKey) so keyboard nav moves correctly across the place/competition/docs group boundariesEnterselecting the currently active row and navigating viarouter.pushseeAllHrefreturnsnullfor docs, so it must render the plain-text fallback instead)Every other interactive, similarly logic-heavy component in the app has a test file next to it (
map-view.test.tsx,results-list.test.tsx,competition-filters.test.tsx,competitions-browser.test.tsx,suggest-place-dialog.test.tsx,onboarding-flow.test.tsx) —site-search.tsxis the newest major interactive component and the one exception.Fix
Add
src/components/layout/site-search.test.tsxusing the existing Testing Library setup (seeresults-list.test.tsxorcompetition-filters.test.tsxfor the project's conventions), covering at minimum: rendering grouped results, arrow-key wraparound,Enternavigating to the active result, and the "see all" / "and N more" branching for a group whose results exceed the per-group cap.Acceptance criteria
src/components/layout/site-search.test.tsxexists and passes undernpm run test:unit