PR Checks / Frontend Typecheck + Tests (pull_request) Successful in 1m13s
PR Checks / Backend Smoke (pull_request) Successful in 10s
PR Checks / Build Backend (no push) (pull_request) Successful in 17s
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 15s
- E2E: list with page_size (per_page was ignored), fail clearly if the gender filter is ignored, and require nursery_provision on the detail payload so the Nursery assertion cannot pass vacuously. - singleSexLabel ignores case, as hasNurseryClasses does. - Header test: type withSchool with Partial<School>, and match the single-sex labels exactly instead of any span ending in "school". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
68 lines
2.6 KiB
TypeScript
68 lines
2.6 KiB
TypeScript
/**
|
||
* The facts row under the school name.
|
||
*
|
||
* nursery_provision is GIAS text, not a boolean: "Has Nursery Classes",
|
||
* "No Nursery Classes" or "Not applicable". Tested for truthiness, every one
|
||
* of those read as a nursery, so secondaries aged 11–18 showed "Nursery".
|
||
*/
|
||
|
||
import { screen } from '@testing-library/react';
|
||
import type { School } from '@/lib/types';
|
||
import { primaryFixture, secondaryFixture } from '../support/schoolFixtures';
|
||
import { renderSchoolDetail, 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/SatsChart', () => ({
|
||
__esModule: true,
|
||
default: () => <div data-testid="sats-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 withSchool<T extends { schoolInfo: School }>(fixture: T, info: Partial<School>): T {
|
||
return { ...fixture, schoolInfo: { ...fixture.schoolInfo, ...info } };
|
||
}
|
||
|
||
describe('school header nursery chip', () => {
|
||
it('shows Nursery when GIAS says the school has nursery classes', () => {
|
||
renderSchoolDetail(withSchool(primaryFixture, { nursery_provision: 'Has Nursery Classes' }));
|
||
expect(screen.getByText('Nursery', { selector: 'span' })).toBeInTheDocument();
|
||
});
|
||
|
||
it.each(['No Nursery Classes', 'Not applicable', null])(
|
||
'hides Nursery when GIAS says %p',
|
||
(value) => {
|
||
renderSecondarySchoolDetail(withSchool(secondaryFixture, { nursery_provision: value }));
|
||
expect(screen.queryByText('Nursery', { selector: 'span' })).not.toBeInTheDocument();
|
||
},
|
||
);
|
||
});
|
||
|
||
describe('school header single-sex chip', () => {
|
||
it.each([['Girls', "Girls' school"], ['Boys', "Boys' school"]])(
|
||
'labels a %s school with a plural possessive',
|
||
(gender, label) => {
|
||
renderSecondarySchoolDetail(withSchool(secondaryFixture, { gender }));
|
||
expect(screen.getByText(label)).toBeInTheDocument();
|
||
expect(screen.queryByText(/'s school/)).not.toBeInTheDocument();
|
||
},
|
||
);
|
||
|
||
it('says nothing for a mixed school', () => {
|
||
renderSecondarySchoolDetail(withSchool(secondaryFixture, { gender: 'Mixed' }));
|
||
expect(screen.queryByText(/^(Girls|Boys|Mixed)'s? school$/)).not.toBeInTheDocument();
|
||
});
|
||
});
|