fix(school): send the school page its admissions policy, and read it exactly
The header's Selective flag read school_info.admissions_policy, which the detail endpoint never sent, so no school page could flag Selective while its search row did (staging E2E: The Grammar School at Leeds). The detail payload now carries it, and a contract test checks it carries every field the header's flags read. Sending it would have switched on two older copies of the tag logic #176 fixed in the rows. The Admissions section and the cut-off note both tested includes('selective'), so every non-selective secondary would have read "entry is by selective examination". The section also counted "None" as a faith: Burntwood reads "a faith-based admissions priority (None)" today. All of them now share isSelective() and hasReligiousCharacter(), which also treats "Not applicable" as no faith, as the place table already does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
392ec29fdb
commit
ef4a2ccccb
9 files changed
+144
-13
No files matched your search
@@ -0,0 +1,58 @@
|
||||
/**
|
||||
* The Admissions section's Selective and faith notes.
|
||||
*
|
||||
* It tested the policy with includes('selective'), which "Non-selective"
|
||||
* passes, and excluded only "Does not apply" from the religious character, so
|
||||
* Burntwood (no religious character, recorded as "None") read "this school
|
||||
* has a faith-based admissions priority (None)". The Selective half never
|
||||
* fired only because the school page's API did not send admissions_policy.
|
||||
*/
|
||||
|
||||
import { screen, within } from '@testing-library/react';
|
||||
import type { School } from '@/lib/types';
|
||||
import { secondaryFixture } from '../support/schoolFixtures';
|
||||
import { renderSecondarySchoolDetail } from '../support/renderSchoolDetail';
|
||||
|
||||
jest.mock('@/lib/analytics', () => ({
|
||||
track: jest.fn(),
|
||||
getNavigationSource: () => 'direct',
|
||||
}));
|
||||
jest.mock('@/components/PerformanceChart', () => ({
|
||||
PerformanceChart: () => <div data-testid="performance-chart" />,
|
||||
}));
|
||||
jest.mock('@/components/AdmissionsTrendChart', () => ({
|
||||
__esModule: true,
|
||||
default: () => <div data-testid="admissions-trend-chart" />,
|
||||
}));
|
||||
jest.mock('@/components/SchoolHeroMap', () => ({
|
||||
SchoolHeroMap: () => <div data-testid="hero-map" />,
|
||||
__esModule: true,
|
||||
}));
|
||||
|
||||
function admissionsOf(info: Partial<School>) {
|
||||
renderSecondarySchoolDetail({ ...secondaryFixture, schoolInfo: { ...secondaryFixture.schoolInfo, ...info } });
|
||||
return within(screen.getByRole('heading', { name: 'Admissions' }).closest('section')!);
|
||||
}
|
||||
|
||||
describe('Admissions section notes', () => {
|
||||
it('notes the entrance test for a selective school', () => {
|
||||
const section = admissionsOf({ admissions_policy: 'Selective', religious_denomination: 'None' });
|
||||
expect(section.getByText('Selective:')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('does not call a non-selective school selective', () => {
|
||||
const section = admissionsOf({ admissions_policy: 'Non-selective', religious_denomination: 'None' });
|
||||
expect(section.queryByText('Selective:')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it.each(['None', 'Does not apply'])('claims no faith priority when the register says %p', (religious_denomination) => {
|
||||
// Not "Non-selective": a misread Selective would win and hide this case.
|
||||
const section = admissionsOf({ admissions_policy: 'Not applicable', religious_denomination });
|
||||
expect(section.queryByText('Faith priority:')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('notes the religious character of a faith school', () => {
|
||||
const section = admissionsOf({ admissions_policy: 'Non-selective', religious_denomination: 'Church of England' });
|
||||
expect(section.getByText('Faith priority:')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user