fix(ofsted): badge and compare read the grade still in force
Search badges date a grade by the inspection that awarded or confirmed it (ofsted_grade_date) and say 'Inspected · year' when the latest inspection gave no grade. ofstedDisplay's kinds become graded / confirmed / no_overall_grade, read from current_grade rather than a carried-forward overall_effectiveness. lib/ofstedStatus.ts holds the two sentences the school and compare pages share. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a9e3a6a700
commit
a42c586cc8
7 files changed
+179
-52
No files matched your search
@@ -147,23 +147,37 @@ describe('ofstedLegacyAreas', () => {
|
||||
|
||||
describe('buildOfstedListBadge', () => {
|
||||
it('returns grade word + year for OEIF Outstanding', () => {
|
||||
const badge = buildOfstedListBadge({ ofsted_grade: 1, ofsted_date: '2023-11-15', ofsted_framework: 'OEIF' });
|
||||
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');
|
||||
});
|
||||
|
||||
it('returns grade word for each OEIF grade', () => {
|
||||
expect(buildOfstedListBadge({ ofsted_grade: 2, ofsted_date: '2022-05-01' }).label).toBe('Good · 2022');
|
||||
expect(buildOfstedListBadge({ ofsted_grade: 3, ofsted_date: '2021-01-01' }).label).toBe('Req. Improvement · 2021');
|
||||
expect(buildOfstedListBadge({ ofsted_grade: 4, ofsted_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('returns grade word without year when date is missing', () => {
|
||||
const badge = buildOfstedListBadge({ ofsted_grade: 2, ofsted_date: null });
|
||||
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');
|
||||
});
|
||||
|
||||
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');
|
||||
});
|
||||
|
||||
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');
|
||||
});
|
||||
|
||||
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');
|
||||
|
||||
Reference in new issue
Block a user