fix(e2e): compare-chips test must compare schools in one phase #15

Merged
tudor merged 1 commits from fix/e2e-compare-chips-phase into main 2026-07-06 11:01:22 +00:00
Owner

Problem

The compare chart on mobile journey (added in #11) fails on the staging gate:

Expected: 2  Received: 0
getByRole('group', { name: /highlight a school/i }).getByRole('button')

It picks the first two /school/ links from a "primary" search and asserts exactly two mobile chips. But a "primary" search can return all-through schools — e.g. the first staging result is "Hessle High School and Penshurst Primary School", which has Attainment 8 data and therefore classifies as secondary. When the two picks split across phases (Primary 1 / Secondary 1), the compare view's active phase holds a single school, the chip legend is correctly gated out (it only renders for ≥2 schools in the active phase), and the canvas still shows that one line — so the canvas assertion passes but the chip assertion sees 0.

This is a test artefact, not a product bug — I reproduced the chips rendering perfectly for two same-phase schools.

Fix

Compare three schools instead of two. classifySchool always bins a school into exactly one of two phases, and the view auto-selects the strict-majority phase (ties → primary), so with three schools the active phase always holds ≥2 and the chip legend is guaranteed to render. Assert ≥2 chips (the majority may be 2 or 3) and keep the focus-toggle checks.

Verification

Ran the updated test against staging (BASE_URL=https://stx.schoolcompare.co.uk) — passes, including the aria-pressed focus toggle. This unblocks the promotion gate, which is currently red on main for every deploy because of this test.

🤖 Generated with Claude Code

## Problem The `compare chart on mobile` journey (added in #11) fails on the staging gate: ``` Expected: 2 Received: 0 getByRole('group', { name: /highlight a school/i }).getByRole('button') ``` It picks the first two `/school/` links from a "primary" search and asserts exactly two mobile chips. But a "primary" search can return **all-through** schools — e.g. the first staging result is *"Hessle High School **and** Penshurst Primary School"*, which has Attainment 8 data and therefore classifies as **secondary**. When the two picks split across phases (Primary 1 / Secondary 1), the compare view's active phase holds a single school, the chip legend is correctly gated out (it only renders for ≥2 schools in the active phase), and the canvas still shows that one line — so the canvas assertion passes but the chip assertion sees 0. This is a test artefact, not a product bug — I reproduced the chips rendering perfectly for two same-phase schools. ## Fix Compare **three** schools instead of two. `classifySchool` always bins a school into exactly one of two phases, and the view auto-selects the strict-majority phase (ties → primary), so with three schools the active phase always holds ≥2 and the chip legend is guaranteed to render. Assert ≥2 chips (the majority may be 2 or 3) and keep the focus-toggle checks. ## Verification Ran the updated test against staging (`BASE_URL=https://stx.schoolcompare.co.uk`) — passes, including the `aria-pressed` focus toggle. This unblocks the promotion gate, which is currently red on `main` for every deploy because of this test. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
tudor added 1 commit 2026-07-06 10:42:36 +00:00
fix(e2e): compare-chips test must use schools in one phase
PR Checks / Frontend Typecheck + Tests (pull_request) Successful in 9m38s
PR Checks / Backend Smoke (pull_request) Successful in 5s
PR Checks / Build Backend (no push) (pull_request) Successful in 10s
PR Checks / Build Frontend (no push) (pull_request) Successful in 50s
PR Checks / Build Pipeline (no push) (pull_request) Successful in 9s
PR Checks / AI Code Review (Claude) (pull_request) Successful in 37s
3adea73ee0
The test picked the first two /school/ links from a 'primary' search and
asserted exactly two mobile chips. But a 'primary' search can return
all-through schools (e.g. 'Hessle High School and Penshurst Primary')
that classify as secondary, so the two picks can split across phases —
the active phase then holds one school and the chips are correctly gated
out (they need ≥2 in the active phase), while the canvas still shows one
line. That's a test artefact, not a bug.

Pick three schools instead: across two phases the auto-selected majority
phase always holds ≥2, so the chip legend is guaranteed. Assert ≥2 chips
(the majority may be 2 or 3). Verified against staging.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

🤖 AI Code Review (Claude Code)

This diff only modifies an e2e test (compare-chips journey) to use three schools instead of two, and relaxes the chip-count assertion to a lower bound instead of an exact match. It's a test-only change with no production or deploy config impact.

🟡 Minor

  • e2e/tests/journeys.spec.ts: The chip count assertion was weakened from an exact toHaveCount(2) to toBeGreaterThanOrEqual(2), so the test no longer verifies that exactly one chip renders per school in the active phase — a regression that adds an extra stray chip would go undetected.
## 🤖 AI Code Review (Claude Code) This diff only modifies an e2e test (compare-chips journey) to use three schools instead of two, and relaxes the chip-count assertion to a lower bound instead of an exact match. It's a test-only change with no production or deploy config impact. ### 🟡 Minor - **e2e/tests/journeys.spec.ts**: The chip count assertion was weakened from an exact `toHaveCount(2)` to `toBeGreaterThanOrEqual(2)`, so the test no longer verifies that exactly one chip renders per school in the active phase — a regression that adds an extra stray chip would go undetected.
tudor merged commit 331ae8d89f into main 2026-07-06 11:01:22 +00:00
Sign in to join this conversation.
No Reviewers
No labels
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: tudor/school_compare#15