Skip to content

testing: no test file for site-search.tsx despite being the newest interactive component #262

Description

@yakew7

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

  • src/components/layout/site-search.test.tsx exists and passes under npm run test:unit
  • Covers keyboard navigation (arrows + Enter) and the see-all/overflow branching

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions