fix(search): offer every phase while a phase filter is applied #162

Merged
tudor merged 1 commits from fix/phase-filter-global into main 2026-10-01 11:03:20 +00:00
Owner

What

The phase filter on the search results now always lists every phase. Previously, with Secondary selected, Primary was not offered — you had to go back to "Any phase" before you could pick it.

Why

FilterBar preferred result_filters.phases, which the backend computes from the returned schools after the phase filter has been applied. That leaves only the chosen phase (plus the phases PHASE_GROUPS folds into it). The phase select now reads the global /api/filters list.

Trade-off: a postcode search now also offers phases with no nearby schools, which return an empty result.

Not changed

  • The backend still returns result_filters.phases; it is now unused by the phase select.
  • School type and local authority have the same self-narrowing behaviour (picking a type leaves only that type on offer). Left for a follow-up.

Tests

  • New unit test FilterBarPhase.test.tsx — failed before the fix, passes after. All 263 component tests pass; tsc clean.
  • New E2E journey: the phase filter switches straight from secondary to primary. Runs on the post-merge staging gate.

🤖 Generated with Claude Code

## What The phase filter on the search results now always lists every phase. Previously, with **Secondary** selected, **Primary** was not offered — you had to go back to "Any phase" before you could pick it. ## Why `FilterBar` preferred `result_filters.phases`, which the backend computes from the returned schools *after* the phase filter has been applied. That leaves only the chosen phase (plus the phases `PHASE_GROUPS` folds into it). The phase select now reads the global `/api/filters` list. Trade-off: a postcode search now also offers phases with no nearby schools, which return an empty result. ## Not changed - The backend still returns `result_filters.phases`; it is now unused by the phase select. - School type and local authority have the same self-narrowing behaviour (picking a type leaves only that type on offer). Left for a follow-up. ## Tests - New unit test `FilterBarPhase.test.tsx` — failed before the fix, passes after. All 263 component tests pass; `tsc` clean. - New E2E journey: *the phase filter switches straight from secondary to primary*. Runs on the post-merge staging gate. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
tudor added 1 commit 2026-10-01 10:06:12 +00:00
fix(search): offer every phase while a phase filter is applied
PR Checks / Frontend Typecheck + Tests (pull_request) Successful in 1m12s
PR Checks / Backend Smoke (pull_request) Successful in 10s
PR Checks / Build Backend (no push) (pull_request) Successful in 18s
PR Checks / Build Frontend (no push) (pull_request) Successful in 1m20s
PR Checks / Build Pipeline (no push) (pull_request) Successful in 11s
PR Checks / AI Code Review (Claude) (pull_request) Successful in 15s
e211e1376d
The phase select read its options from the result-scoped filters, which
the backend computes after applying the phase filter. With secondary
chosen only secondary and all-through were offered, so switching to
primary meant going back to "Any phase" first. Read the global phase
list instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

🤖 AI Code Review (Claude Code)

The PR makes the FilterBar phase dropdown always use the full phase list rather than the result-scoped list. This fixes the case where choosing 'secondary' hid 'primary'. It adds a unit test and an e2e journey test. The change is small and looks correct and healthy.

🟡 Minor

  • nextjs-app/tests/components/FilterBarPhase.test.tsx: The module-level searchParams is reassigned inside the test and never reset. It is currently the only test in the file so it is harmless, but it could leak state if more tests are added. Resetting it in a beforeEach would be more robust.
  • e2e/tests/journeys.spec.ts: The e2e test assumes the 'school' search with phase=secondary returns results, and that the Phase combobox is rendered whenever results exist. If the filter bar is hidden when there are no results, the test could be flaky on sparse seed data. Seed data dependence is not documented.
## 🤖 AI Code Review (Claude Code) The PR makes the FilterBar phase dropdown always use the full phase list rather than the result-scoped list. This fixes the case where choosing 'secondary' hid 'primary'. It adds a unit test and an e2e journey test. The change is small and looks correct and healthy. ### 🟡 Minor - **nextjs-app/__tests__/components/FilterBarPhase.test.tsx**: The module-level `searchParams` is reassigned inside the test and never reset. It is currently the only test in the file so it is harmless, but it could leak state if more tests are added. Resetting it in a beforeEach would be more robust. - **e2e/tests/journeys.spec.ts**: The e2e test assumes the 'school' search with phase=secondary returns results, and that the Phase combobox is rendered whenever results exist. If the filter bar is hidden when there are no results, the test could be flaky on sparse seed data. Seed data dependence is not documented.
tudor merged commit 0c414680fd into main 2026-10-01 11:03:20 +00:00
Sign in to join this conversation.
No Reviewers
No labels
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: tudor/school_compare#162