From b2b2cad5acf534ae7a667d3fb2be15efff37c4a7 Mon Sep 17 00:00:00 2001 From: Tudor Date: Sat, 18 Jul 2026 21:24:09 +0100 Subject: [PATCH] test/docs: harden report-card list e2e + correct badge docstring Review fixes on the list/map report-card PR: - e2e precondition now hard-asserts ofsted_rc_date instead of test.skip, so the backend dropping the field fails loudly (that's the regression under test), not silently skips. - Use page_size=5 (the real backend param); per_page was ignored and fell back to the default page size. - Update buildOfstedListBadge docstring to describe the ofsted_rc_date-based, report-card-wins-first detection instead of the removed framework check. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_0146VHeLAWjDVE2B5uU67jCB --- e2e/tests/journeys.spec.ts | 11 +++++++++-- nextjs-app/lib/utils.ts | 7 +++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/e2e/tests/journeys.spec.ts b/e2e/tests/journeys.spec.ts index ce2ae08..548a060 100644 --- a/e2e/tests/journeys.spec.ts +++ b/e2e/tests/journeys.spec.ts @@ -86,12 +86,19 @@ test('a report-card school shows a Report Card badge in search results, not its // labelled by their old grade (e.g. "Outstanding · 2021"). The list now // carries ofsted_rc_date and the badge treats a report card as winning. const RC_URN = 138690; // Barclay Primary — has a Nov-2025+ report card - const res = await page.request.get(`/api/schools?search=Barclay%20Primary&per_page=5`); + const res = await page.request.get(`/api/schools?search=Barclay%20Primary&page_size=5`); expect(res.ok()).toBeTruthy(); const barclay = ((await res.json()).schools ?? []).find( (s: { urn: number }) => s.urn === RC_URN, ); - test.skip(!barclay?.ofsted_rc_date, 'precondition: the list must expose ofsted_rc_date for a report-card school'); + // Hard assertions, not test.skip: if the backend stops exposing + // ofsted_rc_date for this report-card school, that IS the regression this + // test exists to catch, so it must fail loudly rather than skip. + expect(barclay, 'Barclay must appear in the search results').toBeTruthy(); + expect( + barclay.ofsted_rc_date, + 'the list must expose ofsted_rc_date for a report-card school', + ).toBeTruthy(); await searchByName(page, 'Barclay Primary'); // The Barclay row must be present… diff --git a/nextjs-app/lib/utils.ts b/nextjs-app/lib/utils.ts index f62a8ca..febe5d1 100644 --- a/nextjs-app/lib/utils.ts +++ b/nextjs-app/lib/utils.ts @@ -691,9 +691,12 @@ export interface OfstedListBadge { /** * Build the Ofsted badge for a school card in the list/map view. - * Three states: + * States, in priority order: + * - Report Card school (ofsted_rc_date set): "Report Card · YYYY" in purple. + * Checked FIRST so it wins over any carried-forward legacy grade — the + * list has no full report_card object, and ofsted_framework is the raw + * event grouping ("Schools - S5"), never "ReportCard". * - OEIF school (ofsted_grade set): grade word + year, colour-keyed - * - ReportCard school (ofsted_framework === 'ReportCard'): "Report Card · YYYY" in purple * - Inspected without an overall grade (OEIF post-Sept-2024, where Ofsted no * longer issues an overall judgement): "Inspected · YYYY" — mirrors the * detail page's hero chip so a school never reads as both inspected and