feat: drive sixth-form separation from GIAS OfficialSixthForm flag #21
@@ -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(
|
||||
<SecondarySchoolRow
|
||||
school={{ ...base, age_range: '16-19', has_sixth_form: true }}
|
||||
/>,
|
||||
);
|
||||
expect(screen.getByText('Sixth form')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('hides the tag for an 11-18 school without a registered sixth form', () => {
|
||||
render(
|
||||
<SecondarySchoolRow
|
||||
school={{ ...base, age_range: '11-18', has_sixth_form: false }}
|
||||
/>,
|
||||
);
|
||||
expect(screen.queryByText('Sixth form')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('hides the tag when the flag is missing (pipeline not yet re-run)', () => {
|
||||
render(
|
||||
<SecondarySchoolRow school={{ ...base, age_range: '11-18' }} />,
|
||||
);
|
||||
expect(screen.queryByText('Sixth form')).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
@@ -368,8 +368,8 @@ export function FilterBar({
|
||||
disabled={isPending}
|
||||
>
|
||||
<option value="">With or without sixth form</option>
|
||||
<option value="yes">With sixth form (11-18)</option>
|
||||
<option value="no">Without sixth form (11-16)</option>
|
||||
<option value="yes">With sixth form</option>
|
||||
<option value="no">Without sixth form</option>
|
||||
</select>
|
||||
|
||||
{admissionsPolicyOptions.length > 0 && (
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user