/** * 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 {ui}; } 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( , ), ); } 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( , ), ); }