The section is dated by the latest visit and headlines the grade still in force with the inspection that awarded or confirmed it, or 'No overall grade'. A later visit that isn't the grade's source gets its own line, with an ungraded outcome such as 'Standards maintained'. The primary and secondary no-grade branches merge, so the secondary page no longer drops the sixth-form and early-years judgements (audit M2), and 'Not rated' goes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
85 lines
4.1 KiB
TypeScript
85 lines
4.1 KiB
TypeScript
import { render, screen } from '@testing-library/react';
|
|
import { OfstedSection } from '@/components/school/OfstedSection';
|
|
import { ofstedLegacyAreas } from '@/lib/utils';
|
|
import type { OfstedInspection } from '@/lib/types';
|
|
|
|
const empty = {
|
|
framework: null, inspection_date: null, inspection_type: null, overall_effectiveness: null,
|
|
quality_of_education: null, behaviour_attitudes: null, personal_development: null,
|
|
leadership_management: null, early_years_provision: null, sixth_form_provision: null,
|
|
previous_overall: null, rc_safeguarding_met: null, rc_inclusion: null, rc_curriculum_teaching: null,
|
|
rc_achievement: null, rc_attendance_behaviour: null, rc_personal_development: null,
|
|
rc_leadership_governance: null, rc_early_years: null, rc_sixth_form: null, report_url: null,
|
|
report_card: {},
|
|
} as OfstedInspection;
|
|
|
|
// `page` mimics how each school page used to mount the section; the secondary
|
|
// page's branch hard-coded four areas and dropped the sixth form (audit M2).
|
|
function renderSection(o: Partial<OfstedInspection>, page: Record<string, unknown> = {}) {
|
|
const ofsted = { ...empty, ...o } as OfstedInspection;
|
|
render(
|
|
<OfstedSection
|
|
{...page}
|
|
ofsted={ofsted}
|
|
urn={1}
|
|
isReportCard={false}
|
|
ofstedInspectedDate={ofsted.latest_visit?.date ?? null}
|
|
oeifAllSameGrade={false}
|
|
oeifAreas={ofstedLegacyAreas(ofsted)}
|
|
/>,
|
|
);
|
|
}
|
|
|
|
it('shows no overall grade, not an older one, after a no-grade inspection (Rabbsfarm)', () => {
|
|
renderSection({
|
|
inspection_date: '2025-06-17', quality_of_education: 3, behaviour_attitudes: 3,
|
|
personal_development: 2, leadership_management: 3, early_years_provision: 2,
|
|
current_grade: null, latest_visit: { date: '2025-06-17', kind: 'graded', outcome: null },
|
|
});
|
|
expect(screen.getByText(/Inspected 17 June 2025/)).toBeInTheDocument();
|
|
expect(screen.getByText('No overall grade')).toBeInTheDocument();
|
|
expect(screen.queryByText('Good', { selector: 'span' })).not.toBeInTheDocument();
|
|
expect(screen.queryByText('Not rated')).not.toBeInTheDocument();
|
|
expect(screen.getAllByText('Requires Improvement')).toHaveLength(3);
|
|
});
|
|
|
|
it('keeps the sixth-form judgement when there is no overall grade (audit M2)', () => {
|
|
renderSection({
|
|
inspection_date: '2025-04-01', quality_of_education: 1, behaviour_attitudes: 1,
|
|
personal_development: 1, leadership_management: 1, sixth_form_provision: 2,
|
|
current_grade: null, latest_visit: { date: '2025-04-01', kind: 'graded', outcome: null },
|
|
}, { variant: 'secondary' });
|
|
expect(screen.getByText(/sixth form/i)).toBeInTheDocument();
|
|
expect(screen.getByText('Good')).toBeInTheDocument();
|
|
});
|
|
|
|
it('dates a grade by its source and prints a later visit separately (Washwood Heath)', () => {
|
|
renderSection({
|
|
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(/Inspected 21 May 2025/)).toBeInTheDocument();
|
|
expect(screen.getByText('Graded inspection, 3 March 2020')).toBeInTheDocument();
|
|
expect(screen.getByText(/Latest visit: Ungraded inspection, 21 May 2025: Standards maintained/)).toBeInTheDocument();
|
|
});
|
|
|
|
it('says a grade was confirmed at an ungraded visit (Robins Lane)', () => {
|
|
renderSection({
|
|
inspection_date: '2020-01-07', overall_effectiveness: 2,
|
|
current_grade: { grade: 2, date: '2024-07-18', basis: 'confirmed' },
|
|
latest_visit: { date: '2024-07-18', kind: 'ungraded', outcome: 'School remains Good' },
|
|
});
|
|
expect(screen.getByText('Confirmed at an ungraded inspection, 18 July 2024')).toBeInTheDocument();
|
|
expect(screen.queryByText(/Latest visit/)).not.toBeInTheDocument();
|
|
});
|
|
|
|
it('prints an ungraded outcome when there is no grade (Oakgrove)', () => {
|
|
renderSection({
|
|
current_grade: null,
|
|
latest_visit: { date: '2024-11-13', kind: 'ungraded', outcome: 'Standards maintained' },
|
|
});
|
|
expect(screen.getByText('No overall grade')).toBeInTheDocument();
|
|
expect(screen.getByText(/Ungraded inspection, 13 November 2024: Standards maintained/)).toBeInTheDocument();
|
|
});
|