-
Notifications
You must be signed in to change notification settings - Fork 0
test: #17 axe-core over every state of the search page #60
Conversation
Adds axe-core as a client dev dependency and checks the search page in all four of its states: idle, with results, with no results, and when the search fails. Also asserts the skip link stays the first focusable element after a search has rendered. Two deliberate details in the harness: - color-contrast is disabled because jsdom does no layout or painting, so axe has nothing to measure a rendered ratio against and would report every pair as incomplete rather than passing. Contrast is verified by hand in a browser, which is where the README numbers come from. - the harness asserts axe found passing rules before asserting it found no violations. Without that an empty container would pass vacuously whatever the markup looked like. I checked this by running the harness against a deliberately broken tree and confirming it reported violations. Verified: axe reports zero violations on the search page in all four states. Audited by hand and already conforming: focus-visible outlines are never suppressed anywhere in the CSS, every form control has an accessible name, and the result count already carries role=status with aria-live=polite.
AI usage rows for 20 and 22 October, including the review finding I got wrong and corrected, and the one palette value the tool proposed that did not meet the 3:1 a form-control border needs. Three statements were out of date. architecture.md still listed URL-based search state as planned, which landed with #19. The README still listed accessibility and sustainability as planned while both are delivered here. The README milestone row still said M2 was current and the frontend description still mentioned a 300 ms debounce that #19 removed.
Rachel was right that the old assertion proved nothing about keyboard use. It checked that the first element matching a focusable selector carried the skip-link class, which passes even when the link is unreachable or points at nothing. Replaced with two tests that say what they mean. One Tab from a fresh page must land on the skip link, and the href must resolve to an element that can take focus. That needs @testing-library/user-event, since jsdom does not traverse the tab order on its own. Checked the tests fail when they should: with the link given tabIndex=-1 and href=#nope both go red. The old test passed against that same broken markup.
|
Both done - thanks for the nudge on the retarget, and you were right about the test. Retargeted#60 now targets The skip-link testYour read was exact. The old assertion checked that the first element matching Replaced with two tests that each claim one thing:
I checked the tests fail when they should rather than trusting a green suite. Gave the link The old test passed against that same broken markup, which is the gap you spotted. Full gate suite green: 54 client, 21 server. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good now! The updated tests address my previous comment. Thanks for fixing this! 😊
Closes #17
Stacked PR
This targets
feat/18-baerekraft-green-web(#59) because both changeclient/src/global.css. Review and merge #59 first, then this can be retargeted tomain.Summary
axe-coreas a client dev dependency, run over the search page in all four of its states: idle, with results, with no results, and when the search fails.What was already conforming
I audited these by hand rather than assuming, and they needed no change:
outlinedeclaration in the whole client, the:focus-visiblerule inglobal.css. Nothing suppresses it anywhere.SearchForm's input has a visually hidden<label htmlFor>; the three buttons are "Search", "Retry search" and "Clear search" with visible text. No unlabelled control exists.ResultsLayoutalready hasrole="status"witharia-live="polite", and the results region carriesaria-busy.prefers-reduced-motionwas already inglobal.css.The skip link
The link is
<a href="#main">andmainis a landmark withtabIndex={-1}, so it takes focus. #17 asked for a skip link "to the results" and the test asserts#main.#mainis right and I have left it. The requirement in universal utforming is that a keyboard user can bypass the repeated navigation block, and#maindoes exactly that. Retargeting at the results region would also skip the search form, which is a live control someone may well want to reach. So#mainis the more useful target, not merely an acceptable one.Two deliberate details in the axe harness
color-contrastis disabled. jsdom does no layout or painting, so axe has nothing to measure a rendered ratio against and would report every pair as incomplete rather than passing. Contrast is verified by hand in a browser and the ratios are in feat: #18 dark theme and measured bærekraft numbers #59.Not covered here
fieldset,legend, sharedname, each input wrapped in its ownlabel. This PR cannot test it until that lands.main.Verification
pnpm format:check,pnpm lint,pnpm typecheck,pnpm test(53 client, 21 server)