fact_performance's total_pupils is the cohort a year's results were measured on. For a secondary that is Year 11 alone, and the list API sent it as the card's "pupils": Burntwood showed 245 in search and 1,462 on its page. The list and place payloads now carry the register's whole-school count, and nothing when the register has none. Map popups and the compare basket read the same field. The header and the wellbeing section fell back to the same results figure when the census had no record. They now fall back to the register count. The shell took yearlyData only for that fallback, so the prop is gone and the results array no longer ships to the client for the chrome. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
83 lines
2.8 KiB
TypeScript
83 lines
2.8 KiB
TypeScript
/**
|
|
* The single seam between the characterization tests and the component tree.
|
|
*
|
|
* This file is the ONLY thing the server/client split was allowed to change.
|
|
* It now renders the shell + server-sections composition that
|
|
* app/school/[slug]/page.tsx builds, instead of the old monolithic views.
|
|
* Every assertion in schoolDetail.characterization.test.tsx is unchanged —
|
|
* that is the proof the refactor preserved behaviour.
|
|
*/
|
|
|
|
import { render } from '@testing-library/react';
|
|
import type { ReactNode } from 'react';
|
|
import { ComparisonProvider } from '@/context/ComparisonProvider';
|
|
import { SchoolDetailShell } from '@/components/school/SchoolDetailShell';
|
|
import { PrimarySchoolSections } from '@/components/school/PrimarySchoolSections';
|
|
import { SecondarySchoolSections } from '@/components/school/SecondarySchoolSections';
|
|
import {
|
|
computeSchoolFlags, buildNavItems,
|
|
computeSecondaryFlags, buildSecondaryNavItems,
|
|
} from '@/lib/schoolSections';
|
|
import { nationalAveragesFixture } from './schoolFixtures';
|
|
|
|
// The shell calls useComparison(), which throws outside the provider. In the
|
|
// app this wrapper comes from app/(frontend)/layout.tsx.
|
|
function withProviders(ui: ReactNode) {
|
|
return <ComparisonProvider>{ui}</ComparisonProvider>;
|
|
}
|
|
|
|
export function renderSchoolDetail(fixture: any) {
|
|
const flags = computeSchoolFlags(fixture);
|
|
const navItems = buildNavItems(flags, {
|
|
ofsted: fixture.ofsted,
|
|
admissions: fixture.admissions,
|
|
admissionDistance: fixture.admissionDistance ?? null,
|
|
yearlyDataLength: fixture.yearlyData.length,
|
|
});
|
|
|
|
return render(
|
|
withProviders(
|
|
<SchoolDetailShell
|
|
schoolInfo={fixture.schoolInfo}
|
|
census={fixture.census}
|
|
navItems={navItems}
|
|
>
|
|
<PrimarySchoolSections
|
|
{...fixture}
|
|
admissionDistanceHistory={fixture.admissionDistanceHistory ?? []}
|
|
nationalAvg={nationalAveragesFixture}
|
|
flags={flags}
|
|
/>
|
|
</SchoolDetailShell>,
|
|
),
|
|
);
|
|
}
|
|
|
|
export function renderSecondarySchoolDetail(fixture: any) {
|
|
const flags = computeSecondaryFlags(fixture);
|
|
const navItems = buildSecondaryNavItems(flags, {
|
|
ofsted: fixture.ofsted,
|
|
admissions: fixture.admissions,
|
|
admissionDistance: fixture.admissionDistance ?? null,
|
|
yearlyDataLength: fixture.yearlyData.length,
|
|
});
|
|
|
|
return render(
|
|
withProviders(
|
|
<SchoolDetailShell
|
|
schoolInfo={fixture.schoolInfo}
|
|
census={fixture.census}
|
|
navItems={navItems}
|
|
>
|
|
<SecondarySchoolSections
|
|
{...fixture}
|
|
admissionsHistory={fixture.admissionsHistory ?? []}
|
|
admissionDistanceHistory={fixture.admissionDistanceHistory ?? []}
|
|
nationalAvg={nationalAveragesFixture}
|
|
flags={flags}
|
|
/>
|
|
</SchoolDetailShell>,
|
|
),
|
|
);
|
|
}
|