fix(compare): Ofsted rows show the grade still in force and the latest visit

'Inspected' is the school's latest visit, so Washwood Heath reads 21 May 2025 rather than '3 Mar 2020 · 4+ years ago' (audit M1). The Result row names the inspection a grade came from, or says 'No overall grade'; 'Grade carried forward' and 'transitional framework' go.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
TudorandClaude Opus 5.5 committed 2026-10-05 16:32:19 +01:00
1 parent 9ef48da4b1
commit d37baa572b
3 files changed
+56 -37

No files matched your search

@@ -33,18 +33,26 @@ function ofsted(partial: Partial<OfstedInspection>): OfstedInspection {
};
}
const schools = [school(1, 'Graded School'), school(2, 'Carried School'), school(3, 'Card School')];
const schools = [school(1, 'Graded School'), school(2, 'Confirmed School'), school(3, 'Card School')];
const data: Record<string, ComparisonData> = {
'1': {
school_info: schools[0],
yearly_data: [],
ofsted: ofsted({ overall_effectiveness: 1, grade_source: 'graded' }),
ofsted: ofsted({
overall_effectiveness: 1,
current_grade: { grade: 1, date: '2021-10-07', basis: 'graded' },
latest_visit: { date: '2021-10-07', kind: 'graded', outcome: null },
}),
},
'2': {
school_info: schools[1],
yearly_data: [],
ofsted: ofsted({ overall_effectiveness: 2, grade_source: 'ungraded_carried_forward' }),
ofsted: ofsted({
overall_effectiveness: 2,
current_grade: { grade: 2, date: '2023-03-14', basis: 'confirmed' },
latest_visit: { date: '2023-03-14', kind: 'ungraded', outcome: 'School remains Good' },
}),
},
'3': {
school_info: schools[2],
@@ -65,9 +73,9 @@ describe('CompareOfsted', () => {
render(<CompareOfsted schools={schools} data={data} />);
expect(screen.getByText('Outstanding')).toBeInTheDocument();
// Carried-forward grade is shown but marked as such
// A grade confirmed at an ungraded visit says so, with that visit's date
expect(screen.getByText('Good')).toBeInTheDocument();
expect(screen.getByText(/carried forward/i)).toBeInTheDocument();
expect(screen.getByText('Confirmed at an ungraded inspection, 14 March 2023')).toBeInTheDocument();
// Report card: label present, no overall-grade badge for that school
expect(screen.getByText('Report card')).toBeInTheDocument();
expect(screen.getByText(/no overall grade/i)).toBeInTheDocument();
@@ -104,7 +112,7 @@ describe('CompareOfsted', () => {
yearly_data: [],
ofsted: ofsted({
overall_effectiveness: 2,
grade_source: 'graded',
current_grade: { grade: 2, date: '2021-10-07', basis: 'graded' },
quality_of_education: 1,
early_years_provision: 9,
sixth_form_provision: 2,
@@ -167,4 +175,26 @@ describe('CompareOfsted', () => {
expect(screen.getAllByText('Graded').length).toBe(4);
expect(screen.getAllByText('Card').length).toBe(4);
});
it('dates "Inspected" by the latest visit, not the graded inspection (Washwood Heath)', () => {
const s1 = school(7, 'Washwood Heath Academy');
render(<CompareOfsted schools={[s1]} data={{ '7': { school_info: s1, yearly_data: [], ofsted: ofsted({
inspection_date: '2020-03-03', overall_effectiveness: 2, quality_of_education: 2,
current_grade: { grade: 2, date: '2020-03-03', basis: 'graded' },
latest_visit: { date: '2025-05-21', kind: 'ungraded', outcome: 'Standards maintained' },
}) } }} />);
expect(screen.getByText(/21 May 2025/)).toBeInTheDocument();
expect(screen.queryByText('4+ years ago')).not.toBeInTheDocument();
expect(screen.getByText('Graded inspection, 3 March 2020')).toBeInTheDocument();
});
it('shows no overall grade after a no-grade inspection (Rabbsfarm)', () => {
const s1 = school(8, 'Rabbsfarm Primary School');
render(<CompareOfsted schools={[s1]} data={{ '8': { school_info: s1, yearly_data: [], ofsted: ofsted({
inspection_date: '2025-06-17', quality_of_education: 3,
current_grade: null, latest_visit: { date: '2025-06-17', kind: 'graded', outcome: null },
}) } }} />);
expect(screen.getAllByText('No overall grade').length).toBeGreaterThan(0);
expect(screen.queryByText('Good')).not.toBeInTheDocument();
});
});