fix(compare): date report cards with their own inspection date, never the legacy one

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0146VHeLAWjDVE2B5uU67jCB
This commit is contained in:
Tudor
2026-07-16 14:48:17 +01:00
co-authored by Claude Fable 5
parent e00a1b38a8
commit 9773483221
6 changed files with 79 additions and 2 deletions
@@ -96,6 +96,45 @@ describe('CompareOfsted', () => {
expect(links[0]).toHaveAttribute('href', 'https://reports.ofsted.gov.uk/provider/21/1');
});
it('dates a report card with the report-card inspection date, never the legacy date', () => {
const cardSchool = school(4, 'Dated Card School');
const cardData: Record<string, ComparisonData> = {
'4': {
school_info: cardSchool,
yearly_data: [],
ofsted: ofsted({
inspection_date: '2021-10-07',
rc_inspection_date: '2026-02-03',
rc_safeguarding_met: true,
report_card: { rc_achievement: { code: 1, label: 'Exceptional' } },
}),
},
};
render(<CompareOfsted schools={[cardSchool]} data={cardData} />);
expect(screen.getByText(/3 Feb 2026/)).toBeInTheDocument();
expect(screen.queryByText(/7 Oct 2021/)).toBeNull();
expect(screen.queryByText('4+ years ago')).toBeNull();
});
it('shows an em dash when a report card has no rc_inspection_date yet', () => {
const cardSchool = school(5, 'Undated Card School');
const cardData: Record<string, ComparisonData> = {
'5': {
school_info: cardSchool,
yearly_data: [],
ofsted: ofsted({
inspection_date: '2021-10-07',
rc_inspection_date: null,
rc_safeguarding_met: true,
report_card: { rc_achievement: { code: 1, label: 'Exceptional' } },
}),
},
};
render(<CompareOfsted schools={[cardSchool]} data={cardData} />);
expect(screen.getByText('—')).toBeInTheDocument();
expect(screen.queryByText(/7 Oct 2021/)).toBeNull();
});
it('renders a per-measure mobile tag with the short school name', () => {
render(<CompareOfsted schools={schools} data={data} />);
// Each measure repeats the schools, so the short name ("Graded" from