2026-08-01 21:09:18 +01:00
|
|
|
/**
|
|
|
|
|
* The single seam between the characterization tests and the component tree.
|
|
|
|
|
*
|
2026-08-02 21:39:21 +01:00
|
|
|
* 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.
|
2026-08-01 21:09:18 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import { render } from '@testing-library/react';
|
|
|
|
|
import type { ReactNode } from 'react';
|
|
|
|
|
import { ComparisonProvider } from '@/context/ComparisonProvider';
|
2026-08-02 21:39:21 +01:00
|
|
|
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';
|
2026-08-01 21:09:18 +01:00
|
|
|
import { nationalAveragesFixture } from './schoolFixtures';
|
|
|
|
|
|
2026-08-02 21:39:21 +01:00
|
|
|
// The shell calls useComparison(), which throws outside the provider. In the
|
2026-08-01 21:09:18 +01:00
|
|
|
// app this wrapper comes from app/layout.tsx.
|
|
|
|
|
function withProviders(ui: ReactNode) {
|
|
|
|
|
return <ComparisonProvider>{ui}</ComparisonProvider>;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function renderSchoolDetail(fixture: any) {
|
2026-08-02 21:39:21 +01:00
|
|
|
const flags = computeSchoolFlags(fixture);
|
|
|
|
|
const navItems = buildNavItems(flags, {
|
|
|
|
|
ofsted: fixture.ofsted,
|
|
|
|
|
admissions: fixture.admissions,
|
|
|
|
|
yearlyDataLength: fixture.yearlyData.length,
|
|
|
|
|
});
|
|
|
|
|
|
2026-08-01 21:11:08 +01:00
|
|
|
return render(
|
2026-08-02 21:39:21 +01:00
|
|
|
withProviders(
|
|
|
|
|
<SchoolDetailShell
|
2026-08-02 21:54:59 +01:00
|
|
|
schoolInfo={fixture.schoolInfo}
|
|
|
|
|
yearlyData={fixture.yearlyData}
|
|
|
|
|
census={fixture.census}
|
2026-08-02 21:39:21 +01:00
|
|
|
navItems={navItems}
|
|
|
|
|
>
|
|
|
|
|
<PrimarySchoolSections
|
|
|
|
|
{...fixture}
|
|
|
|
|
nationalAvg={nationalAveragesFixture}
|
|
|
|
|
flags={flags}
|
|
|
|
|
/>
|
|
|
|
|
</SchoolDetailShell>,
|
|
|
|
|
),
|
2026-08-01 21:11:08 +01:00
|
|
|
);
|
2026-08-01 21:09:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function renderSecondarySchoolDetail(fixture: any) {
|
2026-08-02 21:39:21 +01:00
|
|
|
const flags = computeSecondaryFlags(fixture);
|
|
|
|
|
const navItems = buildSecondaryNavItems(flags, {
|
|
|
|
|
ofsted: fixture.ofsted,
|
|
|
|
|
admissions: fixture.admissions,
|
|
|
|
|
yearlyDataLength: fixture.yearlyData.length,
|
|
|
|
|
});
|
|
|
|
|
|
2026-08-01 21:11:08 +01:00
|
|
|
return render(
|
|
|
|
|
withProviders(
|
2026-08-02 21:39:21 +01:00
|
|
|
<SchoolDetailShell
|
2026-08-02 21:54:59 +01:00
|
|
|
schoolInfo={fixture.schoolInfo}
|
|
|
|
|
yearlyData={fixture.yearlyData}
|
|
|
|
|
census={fixture.census}
|
2026-08-02 21:39:21 +01:00
|
|
|
navItems={navItems}
|
|
|
|
|
>
|
|
|
|
|
<SecondarySchoolSections
|
|
|
|
|
{...fixture}
|
|
|
|
|
nationalAvg={nationalAveragesFixture}
|
|
|
|
|
flags={flags}
|
|
|
|
|
/>
|
|
|
|
|
</SchoolDetailShell>,
|
2026-08-01 21:11:08 +01:00
|
|
|
),
|
|
|
|
|
);
|
2026-08-01 21:09:18 +01:00
|
|
|
}
|