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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user