Both detail views fetched /api/national-averages in a useEffect, so the England-comparison deltas popped in after hydration and every section that uses them was pinned to the client. The page now fetches it in parallel with the school details (backend-cached 1h, degrades to null) and passes it down. Removes one client round-trip per detail page and unblocks the section extraction. Characterization tests pass unmodified; only the render helper changed. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
39 lines
1.4 KiB
TypeScript
39 lines
1.4 KiB
TypeScript
/**
|
|
* The single seam between the characterization tests and the component tree.
|
|
*
|
|
* Task 7 of the server/client split rewrites the bodies of these functions to
|
|
* render the new shell + server-sections composition. Nothing else in the test
|
|
* suite may change — the characterization assertions passing unmodified across
|
|
* that rewrite is the proof that behaviour was preserved.
|
|
*
|
|
* National averages now arrive as a server-supplied prop rather than a client
|
|
* fetch, so no fetch stub is needed.
|
|
*/
|
|
|
|
import { render } from '@testing-library/react';
|
|
import type { ReactNode } from 'react';
|
|
import { SchoolDetailView } from '@/components/SchoolDetailView';
|
|
import { SecondarySchoolDetailView } from '@/components/SecondarySchoolDetailView';
|
|
import { ComparisonProvider } from '@/context/ComparisonProvider';
|
|
import { nationalAveragesFixture } from './schoolFixtures';
|
|
|
|
// Both views call 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) {
|
|
return render(
|
|
withProviders(<SchoolDetailView {...fixture} nationalAvg={nationalAveragesFixture} />),
|
|
);
|
|
}
|
|
|
|
export function renderSecondarySchoolDetail(fixture: any) {
|
|
return render(
|
|
withProviders(
|
|
<SecondarySchoolDetailView {...fixture} nationalAvg={nationalAveragesFixture} />,
|
|
),
|
|
);
|
|
}
|