fix(search): no "Not yet inspected" without Ofsted's word; ISI badge (H4)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
69da9d84db
commit
ab25d83b9d
9 files changed
+92
-38
No files matched your search
@@ -1,4 +1,4 @@
|
||||
import { gradeSourceLine, latestVisitLine, showLatestVisitLine } from '@/lib/ofstedStatus';
|
||||
import { gradeSourceLine, hasReportCard, latestVisitLine, showLatestVisitLine } from '@/lib/ofstedStatus';
|
||||
import type { OfstedInspection } from '@/lib/types';
|
||||
|
||||
const base = { report_card: {} } as unknown as OfstedInspection;
|
||||
@@ -45,3 +45,12 @@ describe('showLatestVisitLine', () => {
|
||||
latest_visit: { date: '2025-06-17', kind: 'graded', outcome: null } })).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
it('names a short inspection as Ofsted does', () => {
|
||||
expect(latestVisitLine({ date: '2023-02-01', kind: 'short', outcome: null })).toBe('Short inspection, 1 February 2023');
|
||||
});
|
||||
|
||||
it('treats a report card with only a safeguarding result as a report card (FE)', () => {
|
||||
expect(hasReportCard({ rc_inspection_date: '2026-05-12', report_card: {} })).toBe(true);
|
||||
expect(hasReportCard({ rc_inspection_date: null, report_card: {} })).toBe(false);
|
||||
});
|
||||
@@ -148,40 +148,40 @@ describe('ofstedLegacyAreas', () => {
|
||||
describe('buildOfstedListBadge', () => {
|
||||
it('returns grade word + year for OEIF Outstanding', () => {
|
||||
const badge = buildOfstedListBadge({ ofsted_grade: 1, ofsted_grade_date: '2023-11-15', ofsted_date: '2023-11-15', ofsted_framework: 'OEIF' });
|
||||
expect(badge.label).toBe('Outstanding · 2023');
|
||||
expect(badge.cssClass).toBe('ofsted1');
|
||||
expect(badge!.label).toBe('Outstanding · 2023');
|
||||
expect(badge!.cssClass).toBe('ofsted1');
|
||||
});
|
||||
|
||||
it('returns grade word for each OEIF grade', () => {
|
||||
expect(buildOfstedListBadge({ ofsted_grade: 2, ofsted_grade_date: '2022-05-01' }).label).toBe('Good · 2022');
|
||||
expect(buildOfstedListBadge({ ofsted_grade: 3, ofsted_grade_date: '2021-01-01' }).label).toBe('Req. Improvement · 2021');
|
||||
expect(buildOfstedListBadge({ ofsted_grade: 4, ofsted_grade_date: '2020-03-01' }).label).toBe('Inadequate · 2020');
|
||||
expect(buildOfstedListBadge({ ofsted_grade: 2, ofsted_grade_date: '2022-05-01' })!.label).toBe('Good · 2022');
|
||||
expect(buildOfstedListBadge({ ofsted_grade: 3, ofsted_grade_date: '2021-01-01' })!.label).toBe('Req. Improvement · 2021');
|
||||
expect(buildOfstedListBadge({ ofsted_grade: 4, ofsted_grade_date: '2020-03-01' })!.label).toBe('Inadequate · 2020');
|
||||
});
|
||||
|
||||
it('prints a grade without a year when its date is missing', () => {
|
||||
const badge = buildOfstedListBadge({ ofsted_grade: 2, ofsted_grade_date: null, ofsted_date: '2025-01-01' });
|
||||
expect(badge.label).toBe('Good');
|
||||
expect(badge.cssClass).toBe('ofsted2');
|
||||
expect(badge!.label).toBe('Good');
|
||||
expect(badge!.cssClass).toBe('ofsted2');
|
||||
});
|
||||
|
||||
it('dates a grade by the inspection that awarded it, not the latest visit', () => {
|
||||
// Washwood Heath: Good from a March 2020 graded inspection; latest visit
|
||||
// an ungraded one in May 2025 (audit M1).
|
||||
const badge = buildOfstedListBadge({ ofsted_grade: 2, ofsted_grade_date: '2020-03-03', ofsted_date: '2025-05-21' });
|
||||
expect(badge.label).toBe('Good · 2020');
|
||||
expect(badge!.label).toBe('Good · 2020');
|
||||
});
|
||||
|
||||
it('shows Inspected for a latest inspection that gave no grade (Rabbsfarm)', () => {
|
||||
// Audit C1: this used to read "Good · 2025", from a 2020 ungraded visit.
|
||||
const badge = buildOfstedListBadge({ ofsted_grade: null, ofsted_grade_date: null, ofsted_date: '2025-06-17' });
|
||||
expect(badge.label).toBe('Inspected · 2025');
|
||||
expect(badge.cssClass).toBe('ofstedInspected');
|
||||
expect(badge!.label).toBe('Inspected · 2025');
|
||||
expect(badge!.cssClass).toBe('ofstedInspected');
|
||||
});
|
||||
|
||||
it('returns a Report Card badge when ofsted_rc_date is present', () => {
|
||||
const badge = buildOfstedListBadge({ ofsted_grade: null, ofsted_rc_date: '2026-02-03' });
|
||||
expect(badge.label).toBe('Report Card · 2026');
|
||||
expect(badge.cssClass).toBe('ofstedRc');
|
||||
expect(badge!.label).toBe('Report Card · 2026');
|
||||
expect(badge!.cssClass).toBe('ofstedRc');
|
||||
});
|
||||
|
||||
it('a report card wins over a carried-forward legacy grade', () => {
|
||||
@@ -194,34 +194,46 @@ describe('buildOfstedListBadge', () => {
|
||||
ofsted_framework: 'Schools - S5',
|
||||
ofsted_rc_date: '2026-02-03',
|
||||
});
|
||||
expect(badge.label).toBe('Report Card · 2026');
|
||||
expect(badge.cssClass).toBe('ofstedRc');
|
||||
expect(badge!.label).toBe('Report Card · 2026');
|
||||
expect(badge!.cssClass).toBe('ofstedRc');
|
||||
});
|
||||
|
||||
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');
|
||||
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');
|
||||
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 });
|
||||
expect(badge.label).toBe('Not yet inspected');
|
||||
expect(badge.cssClass).toBe('ofstedPending');
|
||||
it('says "Not yet inspected" only when Ofsted lists the school uninspected (audit H4)', () => {
|
||||
const badge = buildOfstedListBadge({ ofsted_grade: null, ofsted_date: null, ofsted_listed: true });
|
||||
expect(badge).toEqual({ label: 'Not yet inspected', cssClass: 'ofstedPending' });
|
||||
});
|
||||
|
||||
it('returns pending badge when all fields are undefined', () => {
|
||||
const badge = buildOfstedListBadge({});
|
||||
expect(badge.label).toBe('Not yet inspected');
|
||||
expect(badge.cssClass).toBe('ofstedPending');
|
||||
it('names ISI for a school GIAS says ISI inspects', () => {
|
||||
expect(buildOfstedListBadge({ ofsted_date: null, inspectorate: 'ISI', ofsted_listed: false }))
|
||||
.toEqual({ label: 'Inspected by ISI', cssClass: 'ofstedPending' });
|
||||
});
|
||||
|
||||
it('an Ofsted record wins over ISI', () => {
|
||||
expect(buildOfstedListBadge({ ofsted_grade: 2, ofsted_grade_date: '2022-03-01', inspectorate: 'ISI' })!.label)
|
||||
.toBe('Good · 2022');
|
||||
});
|
||||
|
||||
it('gives no badge without any inspection data', () => {
|
||||
expect(buildOfstedListBadge({ ofsted_grade: null, ofsted_date: null, ofsted_framework: null })).toBeNull();
|
||||
expect(buildOfstedListBadge({ ofsted_listed: null, inspectorate: 'Not applicable' })).toBeNull();
|
||||
});
|
||||
|
||||
it('gives no badge when all fields are undefined (audit H4)', () => {
|
||||
expect(buildOfstedListBadge({})).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user