fix(search): show applied type and faith by label, in any case
PR Checks / Frontend Typecheck + Tests (pull_request) Successful in 1m14s
PR Checks / Backend Smoke (pull_request) Successful in 10s
PR Checks / Build Backend (no push) (pull_request) Successful in 19s
PR Checks / Build Frontend (no push) (pull_request) Successful in 1m18s
PR Checks / Build Pipeline (no push) (pull_request) Successful in 11s
PR Checks / AI Code Review (Claude) (pull_request) Successful in 22s

The results list's chip printed the school type group's key ("post16")
rather than its label. A URL value that no option spelled the same way
(an old link's raw GIAS type, or a key in another case) left the select
reading "Any school type" while the list stayed filtered, and choosing
"Any" changed nothing. Values now match options ignoring case, as the
API does, and an unlisted one is shown as an option of its own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
TudorandClaude Opus 5.5 committed 2026-10-02 12:00:54 +01:00
1 parent c992d7f3b9
commit 84caee9f72
4 files changed
+75 -5

No files matched your search

@@ -112,3 +112,27 @@ describe('Faith', () => {
expect(within(openSheet()).queryByRole('combobox', { name: 'Faith' })).not.toBeInTheDocument();
});
});
describe('a URL value the options do not spell the same way', () => {
const row = () => screen.getByRole('group', { name: 'Filters' });
it('shows an old raw-label type in the select, and lets "Any" clear it', () => {
params = new URLSearchParams('search=school&school_type=Community+school');
render(<FilterBar filters={filters} />);
const type = within(row()).getByRole('combobox', { name: 'School type' });
expect(type).toHaveValue('Community school');
expect(within(type).getByRole('option', { name: 'Community school' })).toBeInTheDocument();
fireEvent.change(type, { target: { value: '' } });
expect(pushedParams().get('school_type')).toBeNull();
});
it('matches a key in another case, in the select and the chip', () => {
params = new URLSearchParams('postcode=SW196AR&radius=1&school_type=Special&faith=Roman_Catholic');
render(<FilterBar filters={filters} />);
expect(within(row()).getByRole('combobox', { name: 'School type' })).toHaveValue('special');
expect(screen.getByRole('button', { name: 'Remove filter: Special school (SEND)' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: 'Remove filter: Roman Catholic' })).toBeInTheDocument();
expect(screen.getByRole('combobox', { name: 'Faith' })).toHaveValue('roman_catholic');
});
});
@@ -166,3 +166,14 @@ describe('the folded search', () => {
expect(screen.queryByRole('button', { name: /Edit search/ })).not.toBeInTheDocument();
});
});
describe('the results list filter chips', () => {
it('name a school type group by its label, not its key', () => {
params = new URLSearchParams('search=southmead&school_type=council');
const { container } = render(<HomeView initialSchools={results()} filters={filters} />);
const chips = container.querySelector('[class*="activeFilters"]')!;
expect(chips).toHaveTextContent('State school: council-run');
expect(chips).not.toHaveTextContent(/\bcouncil\b(?!-run)/);
});
});