fix(compare): anchor grade-5 & EBacc rows; restore secondary-button outline
PR Checks / Frontend Typecheck + Tests (pull_request) Successful in 1m4s
PR Checks / Backend Smoke (pull_request) Successful in 7s
PR Checks / Build Backend (no push) (pull_request) Successful in 11s
PR Checks / Build Frontend (no push) (pull_request) Successful in 48s
PR Checks / Build Pipeline (no push) (pull_request) Successful in 10s
PR Checks / AI Code Review (Claude) (pull_request) Successful in 8s
PR Checks / Frontend Typecheck + Tests (pull_request) Successful in 1m4s
PR Checks / Backend Smoke (pull_request) Successful in 7s
PR Checks / Build Backend (no push) (pull_request) Successful in 11s
PR Checks / Build Frontend (no push) (pull_request) Successful in 48s
PR Checks / Build Pipeline (no push) (pull_request) Successful in 10s
PR Checks / AI Code Review (Claude) (pull_request) Successful in 8s
SF1 (expert sign-off): the secondary academics 'Grade 5+ in English & maths' and 'EBacc entry' rows rendered as bare numbers — the one place the 'every number anchored against the England average' promise broke. Both now show the official England anchor (already in the payload) + an Above/Close/Below verdict chip, matching Attainment 8 (which also gains a chip for consistency). Button affordance: globals.css has a duplicate .btn block whose 'border: none' overrode the base '1px solid transparent', so .btn-secondary/.btn-active's 'border-color' had no width — every outline button (the modal's '+ Compare', search-result '+ Compare', 'Comparing') rendered as borderless teal text. Give the outline variants the full 'border' shorthand so the outline renders regardless of the clobbered base. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0146VHeLAWjDVE2B5uU67jCB
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
/**
|
||||
* Secondary academics: every headline number carries its England anchor and a
|
||||
* verdict chip (expert sign-off SF1 — the grade-5 and EBacc rows previously
|
||||
* rendered as bare numbers, breaking the "anchored against England" promise).
|
||||
*/
|
||||
|
||||
import { render, screen, within } from '@testing-library/react';
|
||||
|
||||
import { CompareAcademics } from '@/components/compare/CompareAcademics';
|
||||
import type { ComparisonData, NationalAverages, School } from '@/lib/types';
|
||||
|
||||
function school(urn: number, name: string): School {
|
||||
return { urn, school_name: name, attainment_8_score: 58.7 } as School;
|
||||
}
|
||||
|
||||
function data(urn: number): ComparisonData {
|
||||
return {
|
||||
school_info: school(urn, 'Test High'),
|
||||
yearly_data: [
|
||||
{
|
||||
year: 202425,
|
||||
attainment_8_score: 58.7,
|
||||
english_maths_strong_pass_pct: 30,
|
||||
ebacc_entry_pct: 10,
|
||||
},
|
||||
] as ComparisonData['yearly_data'],
|
||||
ofsted: null,
|
||||
census: null,
|
||||
admissions: null,
|
||||
admissions_history: [],
|
||||
deprivation: null,
|
||||
};
|
||||
}
|
||||
|
||||
const NATIONAL: NationalAverages = {
|
||||
year: 202425,
|
||||
primary: {},
|
||||
secondary: {
|
||||
attainment_8_score: 46.0,
|
||||
english_maths_strong_pass_pct: 45.4,
|
||||
ebacc_entry_pct: 40.5,
|
||||
},
|
||||
by_year: [],
|
||||
};
|
||||
|
||||
test('grade-5 and EBacc rows show the England anchor and a Below chip when under it', () => {
|
||||
const s = school(137086, 'Bishop Stopford School');
|
||||
render(
|
||||
<CompareAcademics
|
||||
schools={[s]}
|
||||
data={{ '137086': data(137086) }}
|
||||
nationalAverages={NATIONAL}
|
||||
isSecondary
|
||||
/>,
|
||||
);
|
||||
|
||||
// The official anchors appear (45.4% and 40.5%), not just the school numbers.
|
||||
expect(screen.getByText(/England average 45%/)).toBeInTheDocument();
|
||||
expect(screen.getByText(/England average 41%/)).toBeInTheDocument();
|
||||
|
||||
// 30% grade-5 and 10% EBacc are both well below their anchors → Below chips.
|
||||
// Attainment 8 (58.7 vs 46.0) is above → at least one "Above" chip too.
|
||||
expect(screen.getAllByText(/Below England average/).length).toBeGreaterThanOrEqual(2);
|
||||
expect(screen.getAllByText(/Above England average/).length).toBeGreaterThanOrEqual(1);
|
||||
});
|
||||
@@ -183,10 +183,15 @@ body {
|
||||
}
|
||||
|
||||
/* Secondary: teal outline — supporting actions (+ Compare) */
|
||||
/* NOTE: a duplicate `.btn` block further down this file sets `border: none`,
|
||||
which wins over the base `.btn`'s `1px solid transparent`. The outline
|
||||
variants below therefore declare the full `border` shorthand explicitly so
|
||||
they don't depend on the base border-width — otherwise `border-color` alone
|
||||
has no width and the outline never renders (buttons read as plain text). */
|
||||
.btn-secondary {
|
||||
background: transparent;
|
||||
color: var(--accent-teal);
|
||||
border-color: var(--accent-teal);
|
||||
border: 1px solid var(--accent-teal);
|
||||
}
|
||||
.btn-secondary:hover:not(:disabled) {
|
||||
background: var(--accent-teal-bg);
|
||||
@@ -196,7 +201,7 @@ body {
|
||||
.btn-tertiary {
|
||||
background: var(--bg-secondary);
|
||||
color: var(--text-secondary);
|
||||
border-color: var(--border-color);
|
||||
border: 1px solid var(--border-color);
|
||||
}
|
||||
.btn-tertiary:hover:not(:disabled) {
|
||||
background: var(--border-color);
|
||||
@@ -207,7 +212,7 @@ body {
|
||||
.btn-active {
|
||||
background: var(--accent-teal-bg);
|
||||
color: var(--accent-teal);
|
||||
border-color: var(--accent-teal);
|
||||
border: 1px solid var(--accent-teal);
|
||||
}
|
||||
.btn-active:hover:not(:disabled) {
|
||||
background: transparent;
|
||||
|
||||
@@ -162,6 +162,21 @@ export function CompareAcademics({
|
||||
const grade5 = latestValues(data, urns, 'english_maths_strong_pass_pct');
|
||||
const ebacc = latestValues(data, urns, 'ebacc_entry_pct');
|
||||
const att8Anchor = nationalAverages?.secondary?.attainment_8_score;
|
||||
const grade5Anchor = nationalAverages?.secondary?.english_maths_strong_pass_pct;
|
||||
const ebaccAnchor = nationalAverages?.secondary?.ebacc_entry_pct;
|
||||
|
||||
// Every headline number gets its England anchor + verdict chip, so the
|
||||
// "anchored against the England average" promise holds for the grade-5
|
||||
// and EBacc rows too, not just Attainment 8.
|
||||
const anchorChip = (value: number | null, anchor: number | null | undefined, tol: number) => {
|
||||
if (value == null || anchor == null) return null;
|
||||
const v = verdict(value, anchor, tol);
|
||||
return (
|
||||
<Chip tone={v === 'above' ? 'good' : v === 'below' ? 'warn' : 'neutral'}>
|
||||
{v === 'above' ? 'Above' : v === 'below' ? 'Below' : 'Close to'} England average
|
||||
</Chip>
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<Section
|
||||
@@ -174,7 +189,8 @@ export function CompareAcademics({
|
||||
<Cell key={school.urn} school={school} index={i}>
|
||||
{att8[i] != null ? (
|
||||
<>
|
||||
<span className={s.big}>{(att8[i] as number).toFixed(1)}</span>
|
||||
<span className={s.big}>{(att8[i] as number).toFixed(1)}</span>{' '}
|
||||
{anchorChip(att8[i], att8Anchor, 2)}
|
||||
{att8Anchor != null && (
|
||||
<span className={s.small}>England average {att8Anchor.toFixed(1)}</span>
|
||||
)}
|
||||
@@ -216,14 +232,38 @@ export function CompareAcademics({
|
||||
</RowLabel>
|
||||
{schools.map((school, i) => (
|
||||
<Cell key={school.urn} school={school} index={i}>
|
||||
{grade5[i] != null ? `${Math.round(grade5[i] as number)}%` : <span className={s.small}>No data</span>}
|
||||
{grade5[i] != null ? (
|
||||
<>
|
||||
<span className={s.big} style={{ fontSize: '1.1rem' }}>
|
||||
{Math.round(grade5[i] as number)}%
|
||||
</span>{' '}
|
||||
{anchorChip(grade5[i], grade5Anchor, 3)}
|
||||
{grade5Anchor != null && (
|
||||
<span className={s.small}>England average {Math.round(grade5Anchor)}%</span>
|
||||
)}
|
||||
</>
|
||||
) : (
|
||||
<span className={s.small}>No data</span>
|
||||
)}
|
||||
</Cell>
|
||||
))}
|
||||
|
||||
<RowLabel tip="% entering the English Baccalaureate subject combination.">EBacc entry</RowLabel>
|
||||
{schools.map((school, i) => (
|
||||
<Cell key={school.urn} school={school} index={i}>
|
||||
{ebacc[i] != null ? `${Math.round(ebacc[i] as number)}%` : <span className={s.small}>No data</span>}
|
||||
{ebacc[i] != null ? (
|
||||
<>
|
||||
<span className={s.big} style={{ fontSize: '1.1rem' }}>
|
||||
{Math.round(ebacc[i] as number)}%
|
||||
</span>{' '}
|
||||
{anchorChip(ebacc[i], ebaccAnchor, 3)}
|
||||
{ebaccAnchor != null && (
|
||||
<span className={s.small}>England average {Math.round(ebaccAnchor)}%</span>
|
||||
)}
|
||||
</>
|
||||
) : (
|
||||
<span className={s.small}>No data</span>
|
||||
)}
|
||||
</Cell>
|
||||
))}
|
||||
</SectionGrid>
|
||||
|
||||
Reference in New Issue
Block a user