fix(search): badge inspected-but-ungraded schools as "Inspected", not "Not yet inspected"
Build and Push Docker Images / Build Backend (FastAPI) (push) Successful in 13s
Build and Push Docker Images / Build Frontend (Next.js) (push) Successful in 54s
Build and Push Docker Images / Build Pipeline (Meltano + dbt + Airflow) (push) Successful in 12s
Build and Push Docker Images / Trigger Portainer Update (push) Successful in 1s
Build and Push Docker Images / Build Backend (FastAPI) (push) Successful in 13s
Build and Push Docker Images / Build Frontend (Next.js) (push) Successful in 54s
Build and Push Docker Images / Build Pipeline (Meltano + dbt + Airflow) (push) Successful in 12s
Build and Push Docker Images / Trigger Portainer Update (push) Successful in 1s
A school inspected under the OEIF framework after September 2024 has an inspection on record (ofsted_date set) but no overall_effectiveness grade, since Ofsted no longer issues an overall judgement. buildOfstedListBadge had no branch for this and fell through to "Not yet inspected", while the detail page's hero chip correctly reported it as inspected — so the same school read two contradictory ways. Add an "Inspected · YYYY" branch that fires when an inspection is on record (date or framework present) but no grade and not a Report Card, mirroring the hero chip's fallback. Genuinely un-inspected schools (all Ofsted fields null) still show "Not yet inspected". Add an .ofstedInspected badge style (neutral slate) distinct from the grey pending state, and cover both cases with tests. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -129,7 +129,21 @@ describe('buildOfstedListBadge', () => {
|
|||||||
expect(badge.cssClass).toBe('ofstedRc');
|
expect(badge.cssClass).toBe('ofstedRc');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns pending badge when no grade and no ReportCard framework', () => {
|
it('returns an "Inspected" badge for an OEIF inspection with no overall grade (post-Sept-2024)', () => {
|
||||||
|
// Inspected after Sept 2024: inspection on record (date + framework) but
|
||||||
|
// Ofsted no longer issues an overall grade. Must NOT read as "Not yet inspected".
|
||||||
|
const badge = buildOfstedListBadge({ ofsted_grade: null, ofsted_date: '2024-11-01', ofsted_framework: 'OEIF' });
|
||||||
|
expect(badge.label).toBe('Inspected · 2024');
|
||||||
|
expect(badge.cssClass).toBe('ofstedInspected');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns an "Inspected" badge without a year when the grade is missing and date is absent but a record exists', () => {
|
||||||
|
const badge = buildOfstedListBadge({ ofsted_grade: null, ofsted_date: null, ofsted_framework: 'OEIF' });
|
||||||
|
expect(badge.label).toBe('Inspected');
|
||||||
|
expect(badge.cssClass).toBe('ofstedInspected');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns pending badge when no grade and no inspection on record', () => {
|
||||||
const badge = buildOfstedListBadge({ ofsted_grade: null, ofsted_date: null, ofsted_framework: null });
|
const badge = buildOfstedListBadge({ ofsted_grade: null, ofsted_date: null, ofsted_framework: null });
|
||||||
expect(badge.label).toBe('Not yet inspected');
|
expect(badge.label).toBe('Not yet inspected');
|
||||||
expect(badge.cssClass).toBe('ofstedPending');
|
expect(badge.cssClass).toBe('ofstedPending');
|
||||||
|
|||||||
@@ -202,6 +202,9 @@
|
|||||||
/* ── Ofsted badge variants ──────────────────────────────────────────────── */
|
/* ── Ofsted badge variants ──────────────────────────────────────────────── */
|
||||||
/* ofsted1–4 already defined above; these cover the two new framework states */
|
/* ofsted1–4 already defined above; these cover the two new framework states */
|
||||||
.ofstedRc { background: #5a3a6e; color: #fff; }
|
.ofstedRc { background: #5a3a6e; color: #fff; }
|
||||||
|
/* Inspected but with no overall grade (OEIF post-Sept-2024) — neutral slate,
|
||||||
|
distinct from the grey "Not yet inspected" pending state. */
|
||||||
|
.ofstedInspected { background: #e6ecf2; color: #45586b; }
|
||||||
.ofstedPending { background: #e0e0e0; color: #666; }
|
.ofstedPending { background: #e0e0e0; color: #666; }
|
||||||
|
|
||||||
/* ── vs-national delta line (under RWM metric) ──────────────────────────── */
|
/* ── vs-national delta line (under RWM metric) ──────────────────────────── */
|
||||||
|
|||||||
@@ -203,6 +203,9 @@
|
|||||||
|
|
||||||
/* ── Ofsted badge variants ──────────────────────────────────────────────── */
|
/* ── Ofsted badge variants ──────────────────────────────────────────────── */
|
||||||
.ofstedRc { background: #5a3a6e; color: #fff; }
|
.ofstedRc { background: #5a3a6e; color: #fff; }
|
||||||
|
/* Inspected but with no overall grade (OEIF post-Sept-2024) — neutral slate,
|
||||||
|
distinct from the grey "Not yet inspected" pending state. */
|
||||||
|
.ofstedInspected { background: #e6ecf2; color: #45586b; }
|
||||||
.ofstedPending { background: #e0e0e0; color: #666; }
|
.ofstedPending { background: #e0e0e0; color: #666; }
|
||||||
|
|
||||||
/* ── Right actions column ────────────────────────────── */
|
/* ── Right actions column ────────────────────────────── */
|
||||||
|
|||||||
+12
-1
@@ -592,7 +592,11 @@ export interface OfstedListBadge {
|
|||||||
* Three states:
|
* Three states:
|
||||||
* - OEIF school (ofsted_grade set): grade word + year, colour-keyed
|
* - OEIF school (ofsted_grade set): grade word + year, colour-keyed
|
||||||
* - ReportCard school (ofsted_framework === 'ReportCard'): "Report Card · YYYY" in purple
|
* - ReportCard school (ofsted_framework === 'ReportCard'): "Report Card · YYYY" in purple
|
||||||
* - No inspection: "Not yet inspected" in grey
|
* - 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
|
||||||
|
* "Not yet inspected"
|
||||||
|
* - No inspection on record: "Not yet inspected" in grey
|
||||||
*/
|
*/
|
||||||
export function buildOfstedListBadge(school: {
|
export function buildOfstedListBadge(school: {
|
||||||
ofsted_grade?: 1 | 2 | 3 | 4 | null;
|
ofsted_grade?: 1 | 2 | 3 | 4 | null;
|
||||||
@@ -621,5 +625,12 @@ export function buildOfstedListBadge(school: {
|
|||||||
return { label: `Report Card${yearStr}`, cssClass: 'ofstedRc' };
|
return { label: `Report Card${yearStr}`, cssClass: 'ofstedRc' };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// An inspection is on record (date or framework present) but carries no
|
||||||
|
// overall grade — a post-Sept-2024 OEIF inspection. Distinct from a school
|
||||||
|
// that has genuinely never been inspected.
|
||||||
|
if (school.ofsted_date != null || school.ofsted_framework != null) {
|
||||||
|
return { label: `Inspected${yearStr}`, cssClass: 'ofstedInspected' };
|
||||||
|
}
|
||||||
|
|
||||||
return { label: 'Not yet inspected', cssClass: 'ofstedPending' };
|
return { label: 'Not yet inspected', cssClass: 'ofstedPending' };
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user