Skip to content

fix(a11y-gate): audit a story only once it has finished rendering #515

Description

@Ardnived

Summary

The accessibility gate (pnpm test:a11y) sometimes audits a story before the story has finished rendering. settled() in scripts/check-a11y.mjs waits for the first DOM mutation and then 250 ms of quiet. A story that renders a shell first and its content after a longer pause looks settled too early. axe, the tap probe and the keyboard walk then measure a partial page. The gate fails at random on a required check, or passes having read less of the page.

Approach

  • Evidence: on PR feat(dates): every date and time through one Intl formatter, in the visitor's own format #509, views--event-·-sticky-register was audited with 2 tab stops in one full run and 12 in the next, on the same build. The walk then landed on "Copy address", a button the audit never stamped. Across back-to-back runs the gate also measured 696 and then 706 controls on an unchanged tree.
  • Masked, not fixed: before PR feat(dates): every date and time through one Intl formatter, in the visitor's own format #509, an unstamped stop read as order 0 (Number(null)) and failed tab-order ("Tab went backwards to …"). That PR makes an unstamped stop abstain. The CI failure no longer shows, but the audit still reads a partial page.
  • Fix options: have settled() wait for a readiness signal the story gives, rather than a quiet period alone. For example, wait until no [aria-busy="true"] element or skeleton is left and no lazy chunk is still loading. Or lengthen the quiet window for the stories that need it, and record the measured render times beside QUIET_MS.
  • A tripwire: report a story whose stamped stop count changes between two audits of the same page (audit, settle again, audit). That makes a partial read visible instead of silent.

Acceptance criteria

  • views--event-·-sticky-register reports its full set of tab stops on every run.
  • Across repeated full runs on one unchanged build, the gate measures the same number of controls each time.
  • A story audited before it finished rendering is reported, not passed or failed silently.

Verification checklist

Notes

Found while getting PR #509 green. That PR also fixed a second bug in the walk: a roving-tabindex group made the walk wrap round to the first stop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Fields

    Priority

    Medium

    Hold Until

    None yet

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions