diff --git a/e2e/tests/journeys.spec.ts b/e2e/tests/journeys.spec.ts index cbe4360..fafc79c 100644 --- a/e2e/tests/journeys.spec.ts +++ b/e2e/tests/journeys.spec.ts @@ -487,9 +487,10 @@ test('school detail page shows GIAS identity/contact details and drops the unwir if (info.telephone) { await expect(page.locator('a[href^="tel:"]').first()).toBeVisible(); } - if (info.parliamentary_constituency) { - await expect(page.getByText('Constituency:').first()).toBeVisible(); - } + // Constituency and county left the header in the facts-and-flags redesign: + // neither helps a parent decide. The place pages keep both. + await expect(page.getByText('Constituency:')).toHaveCount(0); + await expect(page.getByText('County:')).toHaveCount(0); }); test('header details collapse behind a "Show all details" toggle on mobile', async ({ page }) => { @@ -3361,6 +3362,37 @@ test('a girls\' secondary header names it properly and shows Nursery only when i const header = page.locator('header', { has: page.getByRole('heading', { level: 1 }) }); await expect(header.getByText("Girls' school", { exact: true })).toBeVisible({ timeout: 15_000 }); await expect(header.getByText(/'s school/)).toHaveCount(0); - await expect(header.getByText('Nursery', { exact: true })) + await expect(header.getByText('Nursery class', { exact: true })) .toHaveCount(detail.school_info.nursery_provision === 'Has Nursery Classes' ? 1 : 0); }); + +/* + * The header states facts in fixed slots and flags only what applies: a + * selective school is flagged Selective, and its type reads in the search + * filter's words, not as a GIAS establishment type. The search row carries + * the same flag. Data-invariant: the school comes from the API. + */ +const TYPE_GROUP_LABELS: Record = { + state: 'State school', independent: 'Independent school', special: 'Special school (SEND)', + post16: 'Sixth form or college', alternative: 'Alternative provision', +}; + +test('a selective school is flagged Selective, on its page and in search', async ({ page }) => { + const res = await page.request.get( + '/api/schools?search=school&phase=secondary&admissions_policy=selective&page_size=1'); + expect(res.ok()).toBeTruthy(); + const [school] = (await res.json()).schools ?? []; + test.skip(!school, 'no selective secondary in this environment'); + expect(school.admissions_policy, 'the admissions filter was ignored').toBe('Selective'); + expect(school, 'the list must name the type group').toHaveProperty('type_group'); + + await page.goto(`/school/${school.urn}`); + const header = page.locator('header', { has: page.getByRole('heading', { level: 1 }) }); + const flags = header.getByRole('list', { name: 'Admission and provision' }); + await expect(flags.getByText('Selective', { exact: true })).toBeVisible({ timeout: 15_000 }); + const typeLabel = TYPE_GROUP_LABELS[school.type_group] ?? school.school_type; + await expect(header.getByText(typeLabel, { exact: true })).toBeVisible(); + + const tags = await rowTags(page, school); + await expect(tags.getByText('Selective', { exact: true })).toBeVisible(); +});