fix(admissions): move the cut-off detail into its own section
PR Checks / Frontend Typecheck + Tests (pull_request) Successful in 1m5s
PR Checks / Backend Smoke (pull_request) Successful in 8s
PR Checks / Build Backend (no push) (pull_request) Successful in 13s
PR Checks / Build Frontend (no push) (pull_request) Successful in 45s
PR Checks / Build Pipeline (no push) (pull_request) Successful in 11s
PR Checks / AI Code Review (Claude) (pull_request) Successful in 1m59s
PR Checks / Frontend Typecheck + Tests (pull_request) Successful in 1m5s
PR Checks / Backend Smoke (pull_request) Successful in 8s
PR Checks / Build Backend (no push) (pull_request) Successful in 13s
PR Checks / Build Frontend (no push) (pull_request) Successful in 45s
PR Checks / Build Pipeline (no push) (pull_request) Successful in 11s
PR Checks / AI Code Review (Claude) (pull_request) Successful in 1m59s
The admissions card measured 1503px on a live school page — half the height of every section put together, and nearly three times the next largest — with its default view rendering as four tiles adrift in about 1080px of blank card. The cause was a layout trick meeting content it was never sized for. The admissions views are stacked in one grid cell so switching them never shifts layout, and the hidden ones keep their box: only visibility is dropped. That works while the views are comparable. The distance view added in #102 carries a chart, a table and a map, came to 1402px against the tile grid's 316px, and pinned every other view to its height — including the one that renders by default, which nobody had clicked. Rather than only unpinning it, the detail moves out. Every other topic on the page is a section with a nav entry, and "how close did we need to live, and would we have got in?" is a topic, not a variant reading of the intake figures. The headline number stays on the Admissions tile where the intake story is; the record behind it now lives in a Distance section directly below. admissions 1503px -> 554px distance new -> 743px (median section on the page is ~528px) Three further changes, each of which also makes the content better rather than only shorter: * The map renders on request. Before a postcode is entered it is a circle drawn round a school, and it costs a Leaflet bundle and 240px to say so; a successful check opens it automatically, which is the point at which it starts answering something. Map height 320px -> 240px. * The chart appears only at the four published years that let the summary state a direction. Below that we already refuse to call the series a trend, and a line through three points asserts one regardless of what the sentence beneath it admits. The table carries those years anyway, with the reasons a line cannot show. * Three caveat paragraphs become one. They said walking-route twice and made the same point about priorities in two voices. It now sits in CutoffDistanceDetail rather than inside the check, so it still renders for a school with coordinates missing, where there is a table but no map and no check. The new e2e guard asserts no section exceeds 2.5x the median section height. Measuring the card's internals cannot catch this: the tile grid is flex: 1, so it absorbs the stretch and every box still looks full. The first version of this test targeted an arbitrary primary, passed against the live bug, and proved nothing; pointed at a school that actually holds cut-off history it fails on staging with "#admissions is 1459px against a 526px median". Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WDvkyqqHABm4bmth2kjAxE
This commit is contained in:
1 parent
8bf6145a73
commit
94151c58ea
14 files changed
+403
-185
No files matched your search
@@ -132,13 +132,30 @@ describe('CutoffMapPanel', () => {
|
||||
expect(screen.getByRole('alert')).toHaveTextContent(/Something went wrong/);
|
||||
});
|
||||
|
||||
it('always states the limits of the check', async () => {
|
||||
it('does not carry the caveat itself', () => {
|
||||
// It moved to CutoffDistanceDetail so it renders once per section, and so
|
||||
// it still appears for a school with no coordinates (no map, no check).
|
||||
// Asserting its absence here is what stops the old three-paragraph stutter
|
||||
// creeping back.
|
||||
renderPanel([d(2024, 800)]);
|
||||
// Present before any postcode is entered, not revealed with the answer.
|
||||
expect(screen.getByText(/An indication only/)).toBeInTheDocument();
|
||||
// The two caveats divide the work: the map says the rings are not a
|
||||
// boundary, the check says the measurement may not be a straight line.
|
||||
expect(screen.getByText(/not a catchment boundary/)).toBeInTheDocument();
|
||||
expect(screen.getByText(/walking route rather than a straight line/)).toBeInTheDocument();
|
||||
expect(screen.queryByText(/Distance is the last criterion/)).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('keeps the map behind a request until there is a reason to show it', async () => {
|
||||
renderPanel([d(2024, 800)]);
|
||||
expect(screen.queryByTestId('cutoff-map')).not.toBeInTheDocument();
|
||||
|
||||
// A successful check is that reason: the rings only answer a question once
|
||||
// there is a home to sit beside them.
|
||||
mockGeocode.mockResolvedValue(northOf(200));
|
||||
await check('SE23 3NA');
|
||||
await screen.findByRole('status');
|
||||
expect(screen.getByTestId('cutoff-map')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('can also show the map without a postcode, on request', () => {
|
||||
renderPanel([d(2024, 800)]);
|
||||
fireEvent.click(screen.getByRole('button', { name: /Show these distances on a map/ }));
|
||||
expect(screen.getByTestId('cutoff-map')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
@@ -96,27 +96,33 @@ const history = (pts: [number, number][]): SchoolAdmissionDistance[] =>
|
||||
year, distance_m, route_count: 1, la_name: 'Camden', distance_unit_raw: 'miles',
|
||||
}));
|
||||
|
||||
describe('primary Distance view', () => {
|
||||
it('appears once there are two or more published years', () => {
|
||||
renderSchoolDetail({
|
||||
describe('primary Distance section', () => {
|
||||
it('appears as its own section once there are two or more published years', () => {
|
||||
// Not a third tab inside Admissions: stacking a 1402px view in the
|
||||
// admissions viewport sized the whole card to it and left the default view
|
||||
// as four tiles in ~1080px of blank card.
|
||||
const { container } = renderSchoolDetail({
|
||||
...primaryFixture,
|
||||
admissionDistance: cutoff({ distance_m: 700, year: 2024 }),
|
||||
admissionDistanceHistory: history([[2021, 1000], [2022, 900], [2023, 800], [2024, 700]]),
|
||||
});
|
||||
|
||||
expect(screen.getByRole('button', { name: 'Distance' })).toBeInTheDocument();
|
||||
expect(container.querySelector('#distance')).toBeInTheDocument();
|
||||
expect(screen.getByText('How far the last place went')).toBeInTheDocument();
|
||||
// And it did not come back as a tab.
|
||||
expect(screen.queryByRole('button', { name: 'Distance' })).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('stays hidden on a single published year', () => {
|
||||
it('stays away on a single published year', () => {
|
||||
// One point is a fact, not a history; a chart of it invites a trend reading
|
||||
// that is not there.
|
||||
renderSchoolDetail({
|
||||
const { container } = renderSchoolDetail({
|
||||
...primaryFixture,
|
||||
admissionDistance: cutoff({ distance_m: 700, year: 2024 }),
|
||||
admissionDistanceHistory: history([[2024, 700]]),
|
||||
});
|
||||
|
||||
expect(screen.queryByRole('button', { name: 'Distance' })).not.toBeInTheDocument();
|
||||
expect(container.querySelector('#distance')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('lists every year in the span, including the ones with no figure', () => {
|
||||
@@ -126,10 +132,6 @@ describe('primary Distance view', () => {
|
||||
admissionDistanceHistory: history([[2021, 1000], [2024, 700]]),
|
||||
});
|
||||
|
||||
// The view is server-rendered but starts hidden behind its tab, and role
|
||||
// queries skip hidden subtrees — so open it the way a reader would.
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Distance' }));
|
||||
|
||||
// 2022 and 2023 were never published but must still appear as rows, or the
|
||||
// gap in the chart has nothing explaining it.
|
||||
for (const year of ['2021', '2022', '2023', '2024']) {
|
||||
@@ -156,6 +158,34 @@ describe('primary Distance view', () => {
|
||||
expect(screen.queryByText(/all offered/i)).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('draws the chart only once it will also state a direction', () => {
|
||||
const four = renderSchoolDetail({
|
||||
...primaryFixture,
|
||||
admissionDistance: cutoff({ distance_m: 700, year: 2024 }),
|
||||
admissionDistanceHistory: history([[2021, 1000], [2022, 900], [2023, 800], [2024, 700]]),
|
||||
});
|
||||
expect(screen.getByText(/Last distance offered, by year/)).toBeInTheDocument();
|
||||
four.unmount();
|
||||
|
||||
renderSchoolDetail({
|
||||
...primaryFixture,
|
||||
admissionDistance: cutoff({ distance_m: 700, year: 2024 }),
|
||||
admissionDistanceHistory: history([[2023, 800], [2024, 700]]),
|
||||
});
|
||||
expect(screen.queryByText(/Last distance offered, by year/)).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('states the caveat exactly once, even though the check also renders', () => {
|
||||
renderSchoolDetail({
|
||||
...primaryFixture,
|
||||
schoolInfo: { ...primaryFixture.schoolInfo, latitude: 51.5, longitude: -0.12 },
|
||||
admissionDistance: cutoff({ distance_m: 700, year: 2024 }),
|
||||
admissionDistanceHistory: history([[2021, 1000], [2024, 700]]),
|
||||
});
|
||||
|
||||
expect(screen.getAllByText(/Distance is the last criterion/)).toHaveLength(1);
|
||||
});
|
||||
|
||||
it('withholds a trend reading while the record is thin', () => {
|
||||
renderSchoolDetail({
|
||||
...primaryFixture,
|
||||
@@ -168,16 +198,19 @@ describe('primary Distance view', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('secondary Distance detail', () => {
|
||||
it('renders inline, with no extra tab, once there are two published years', () => {
|
||||
describe('secondary Distance section', () => {
|
||||
it('renders as its own section once there are two published years', () => {
|
||||
renderSecondarySchoolDetail({
|
||||
...secondaryFixture,
|
||||
admissionDistance: cutoff({ distance_m: 3472.96 }),
|
||||
admissionDistanceHistory: history([[2023, 3800], [2024, 3472.96]]),
|
||||
});
|
||||
|
||||
expect(screen.getByText(/Last distance offered, by year/)).toBeInTheDocument();
|
||||
expect(screen.getByRole('rowheader', { name: '2023' })).toBeInTheDocument();
|
||||
// Two points is below the threshold that lets us state a direction, so no
|
||||
// chart is drawn — a line through three points asserts a trend the
|
||||
// summary underneath would refuse to.
|
||||
expect(screen.queryByText(/Last distance offered, by year/)).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('explains a selective school by how it admits rather than as missing data', () => {
|
||||
|
||||
Reference in new issue
Block a user