2026-10-02 22:50:44 +01:00
|
|
|
/**
|
|
|
|
|
* "Pupils" on a school page is the size of the school.
|
|
|
|
|
*
|
|
|
|
|
* A year's results row carries the cohort its figures were measured on. For a
|
|
|
|
|
* secondary that is the GCSE year group alone (Burntwood: 245, against 1,462
|
|
|
|
|
* on roll), so it must never stand in for the whole-school count.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import { screen } from '@testing-library/react';
|
|
|
|
|
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/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 withoutCensus(schoolTotal: number | null) {
|
|
|
|
|
const yearlyData = secondaryFixture.yearlyData.map((r) => ({ ...r, total_pupils: 245 }));
|
|
|
|
|
return {
|
|
|
|
|
...secondaryFixture,
|
|
|
|
|
census: null,
|
|
|
|
|
yearlyData,
|
|
|
|
|
schoolInfo: { ...secondaryFixture.schoolInfo, total_pupils: schoolTotal },
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
describe('pupil count without a census record', () => {
|
|
|
|
|
it('uses the register count in the header, not the results cohort', () => {
|
|
|
|
|
renderSecondarySchoolDetail(withoutCensus(1462));
|
2026-10-02 22:59:45 +01:00
|
|
|
expect(screen.getByText('1,462 pupils')).toBeInTheDocument();
|
|
|
|
|
expect(screen.queryByText('245 pupils')).not.toBeInTheDocument();
|
2026-10-02 22:50:44 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('shows no count rather than the results cohort when the register has none', () => {
|
|
|
|
|
renderSecondarySchoolDetail(withoutCensus(null));
|
2026-10-02 22:59:45 +01:00
|
|
|
expect(screen.queryByText(/^[\d,]+ pupils$/)).not.toBeInTheDocument();
|
2026-10-02 22:50:44 +01:00
|
|
|
expect(screen.queryByText('Total pupils')).not.toBeInTheDocument();
|
|
|
|
|
});
|
|
|
|
|
});
|