PR Checks / Frontend Typecheck + Tests (pull_request) Successful in 1m4s
PR Checks / Backend Smoke (pull_request) Successful in 7s
PR Checks / Build Backend (no push) (pull_request) Successful in 10s
PR Checks / Build Frontend (no push) (pull_request) Successful in 47s
PR Checks / Build Pipeline (no push) (pull_request) Successful in 1m12s
PR Checks / AI Code Review (Claude) (pull_request) Failing after 9m28s
Leftover from the mechanical extraction: the shell still called computeSchoolFlags() and derived isReportCard / ofstedInspectedDate / oeifAreas / oeifAllSameGrade / deprivationDesc / primaryAvg / secondaryAvg on every render, duplicating work page.tsx already does. None of those values were referenced in its JSX anymore -- that logic moved to the section composers. The chrome needs only four locally-derived values (latestResults, phase, isAllThrough, hasLocation), all one-liners over props it already owns. Removing them made seven props dead, which TypeScript caught at both call sites: absenceData, ofsted, admissions, admissionsHistory, deprivation, finance and nationalAvg now go straight to the section composers and never reach the client component. The shell's surface is down to schoolInfo, yearlyData, census, navItems and children. No behaviour change: 155 tests pass and the characterization tests remain byte-identical to the commit that introduced them. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
80 lines
2.5 KiB
TypeScript
80 lines
2.5 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/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,
|
|
yearlyDataLength: fixture.yearlyData.length,
|
|
});
|
|
|
|
return render(
|
|
withProviders(
|
|
<SchoolDetailShell
|
|
schoolInfo={fixture.schoolInfo}
|
|
yearlyData={fixture.yearlyData}
|
|
census={fixture.census}
|
|
navItems={navItems}
|
|
>
|
|
<PrimarySchoolSections
|
|
{...fixture}
|
|
nationalAvg={nationalAveragesFixture}
|
|
flags={flags}
|
|
/>
|
|
</SchoolDetailShell>,
|
|
),
|
|
);
|
|
}
|
|
|
|
export function renderSecondarySchoolDetail(fixture: any) {
|
|
const flags = computeSecondaryFlags(fixture);
|
|
const navItems = buildSecondaryNavItems(flags, {
|
|
ofsted: fixture.ofsted,
|
|
admissions: fixture.admissions,
|
|
yearlyDataLength: fixture.yearlyData.length,
|
|
});
|
|
|
|
return render(
|
|
withProviders(
|
|
<SchoolDetailShell
|
|
schoolInfo={fixture.schoolInfo}
|
|
yearlyData={fixture.yearlyData}
|
|
census={fixture.census}
|
|
navItems={navItems}
|
|
>
|
|
<SecondarySchoolSections
|
|
{...fixture}
|
|
nationalAvg={nationalAveragesFixture}
|
|
flags={flags}
|
|
/>
|
|
</SchoolDetailShell>,
|
|
),
|
|
);
|
|
}
|