diff --git a/nextjs-app/__tests__/components/SecondarySchoolRow.test.tsx b/nextjs-app/__tests__/components/SecondarySchoolRow.test.tsx new file mode 100644 index 0000000..affaecb --- /dev/null +++ b/nextjs-app/__tests__/components/SecondarySchoolRow.test.tsx @@ -0,0 +1,46 @@ +/** + * SecondarySchoolRow — sixth-form tag must come from the GIAS + * has_sixth_form flag, not the age_range-contains-"18" heuristic. + */ + +import '@testing-library/jest-dom'; +import { render, screen } from '@testing-library/react'; +import { SecondarySchoolRow } from '@/components/SecondarySchoolRow'; +import type { School } from '@/lib/types'; + +const base = { + urn: 100002, + school_name: 'Beta Sixth Form College', + local_authority: 'Testshire', + school_type: 'Academy', + phase: 'Secondary', + gender: 'Mixed', + attainment_8_score: 50.0, +} as unknown as School; + +describe('SecondarySchoolRow sixth-form tag', () => { + it('shows the tag for a 16-19 college with the GIAS flag set', () => { + render( + , + ); + expect(screen.getByText('Sixth form')).toBeInTheDocument(); + }); + + it('hides the tag for an 11-18 school without a registered sixth form', () => { + render( + , + ); + expect(screen.queryByText('Sixth form')).not.toBeInTheDocument(); + }); + + it('hides the tag when the flag is missing (pipeline not yet re-run)', () => { + render( + , + ); + expect(screen.queryByText('Sixth form')).not.toBeInTheDocument(); + }); +}); diff --git a/nextjs-app/components/FilterBar.tsx b/nextjs-app/components/FilterBar.tsx index 51ee0eb..91abf00 100644 --- a/nextjs-app/components/FilterBar.tsx +++ b/nextjs-app/components/FilterBar.tsx @@ -368,8 +368,8 @@ export function FilterBar({ disabled={isPending} > - - + + {admissionsPolicyOptions.length > 0 && ( diff --git a/nextjs-app/components/SecondarySchoolDetailView.tsx b/nextjs-app/components/SecondarySchoolDetailView.tsx index a8e8b2c..8210313 100644 --- a/nextjs-app/components/SecondarySchoolDetailView.tsx +++ b/nextjs-app/components/SecondarySchoolDetailView.tsx @@ -98,7 +98,8 @@ export function SecondarySchoolDetailView({ const secondaryAvg = nationalAvg?.secondary ?? {}; - const hasSixthForm = schoolInfo.age_range?.includes('18') ?? false; + // GIAS OfficialSixthForm flag; missing (pipeline not yet re-run) => false. + const hasSixthForm = schoolInfo.has_sixth_form ?? false; const hasFinance = finance != null && finance.per_pupil_spend != null; const hasDeprivation = deprivation != null && deprivation.idaci_decile != null; const hasLocation = schoolInfo.latitude != null && schoolInfo.longitude != null; diff --git a/nextjs-app/components/SecondarySchoolRow.tsx b/nextjs-app/components/SecondarySchoolRow.tsx index 61097ae..c32dab4 100644 --- a/nextjs-app/components/SecondarySchoolRow.tsx +++ b/nextjs-app/components/SecondarySchoolRow.tsx @@ -23,7 +23,8 @@ function detectAdmissionsTag(school: School): string | null { } function hasSixthForm(school: School): boolean { - return school.age_range?.includes('18') ?? false; + // GIAS OfficialSixthForm flag; missing (pipeline not yet re-run) => false. + return school.has_sixth_form ?? false; } interface SecondarySchoolRowProps { diff --git a/nextjs-app/lib/types.ts b/nextjs-app/lib/types.ts index 816516e..dc1cd2a 100644 --- a/nextjs-app/lib/types.ts +++ b/nextjs-app/lib/types.ts @@ -17,6 +17,7 @@ export interface School { school_type_code: string | null; religious_denomination: string | null; age_range: string | null; + has_sixth_form?: boolean | null; // Address address1: string | null;