Skip to content

test(a11y): add Link contract bound to Link and its router seams - #7378

Merged
cixzhang merged 5 commits into
mainfrom
test/a11y-link-contract
Oct 13, 2026
Merged

cixzhang merged 5 commits into
mainfrom
test/a11y-link-contract

Conversation

@cixzhang

@cixzhang cixzhang commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Maintainer impact

Keyboard, speech-input, and screen-reader users depend on every Astryx link being announced as a link, carrying the name its caller gave it, joining the tab sequence, and following its destination exactly once from Enter or a completed press — whether a native anchor or an app's router component renders it. Link's local tests assert props and destination handling, but no reusable contract proved those outcomes in a real engine, and later adopters (breadcrumbs, side and top navigation, citations, clickable cards) had nothing shared to bind to.

Intended invariant

AST-020 governs contract authoring, AST-021 governs binding, and AST-009 bounds tree and browser evidence away from real-AT claims. family:navigation-destinations keeps destination safety and FR7 member-owned disabled semantics out of this contract.

This PR preserves Link runtime behavior and public API. Every gate is a WCAG 2.2 Level A outcome; the APG Link pattern supplies the exact role and Enter mechanics those outcomes rest on. No APG-only detail gates.

Change

Link contract

Expectation Authority Evidence Enforcement
link.role.exposed WCAG 2.2 4.1.2 + APG Link role accessibility tree required
link.name.exposed WCAG 2.2 4.1.2 + 2.4.4 accessibility tree required
link.name.matches-visible-label WCAG 2.2 2.5.3 accessibility tree + real browser required when visible words render
link.focus.reachable-and-escapable WCAG 2.2 2.1.1 + 2.1.2 real browser required
link.navigation.runs-on-enter WCAG 2.2 2.1.1 + APG Enter real browser required (exactly one navigation)
link.navigation.completes-on-release WCAG 2.2 2.5.2 real browser required (none on an aborted press, one on release)
link.current.exposed WCAG 2.2 1.3.1 + 4.1.2 DOM required (present only when current)

Every expectation has deliberately violating fixtures: a navigating span and button (role), an unnamed icon and a replaced name (name), a name that drops the visible words (label in name), tabindex="-1" (Tab), a click-only role="link" and a double navigation on Enter (Enter), navigation on pointer-down and a cancelled pointer click (release), and a missing or unearned aria-current (current). Every other AST-020 dimension names its owner.

Navigation is observed, not inferred: the browser half counts navigation requests through the Navigation API and cancels them so the page stays mounted; router states count their own navigations; new tabs are counted as opened pages.

First binding: Link

State Rendering Declared name Other axis
text-native native anchor Documentation —
icon-labelled native anchor, icon only Close dialog no visible words
current-page native anchor Overview aria-current="page"
external-new-tab native anchor, new tab GitHub (opens in new tab) opens a new tab
provider-router router component via LinkProvider Projects router owns navigation
as-router router component via as Settings router owns navigation

Disabled and href-less Links, destination safety, navigation aggregates, and visual treatment are recorded exclusions with owners. A scoped pr-a11y step runs the contract and binding in Chromium when Link, its a11y stories, or the contract change, and uploads the JSON report.

Evidence

  • Failure before the change: no LINK_PATTERN existed; the contract suite failed on the missing module. The first browser run also showed fixture links on about:blank never navigate and the new-tab state needs time for the opened page to arrive; both are fixed at head.
  • Success after the change: 11 contract self-tests, 12 binding tests, and 117 Link tests pass; both package typechecks pass. At exact head eb7600ea8e3edc8007f88a7b04372d633f51d02e, the pr-a11y link step ran 22 Chromium tests with 22 passing: three conforming fixtures, twelve deliberate mutations each failing for its own reason, the exercise check, and all six Link states (run 38264669425, artifact link-contract-evidence-eb7600e, report SHA-256 4f14ffd737ae757bd35121fe4cc2ee1afe542b4eb15e1167bb084a9246382127).
  • Product/runtime behavior verified unchanged: the diff touches only tests, checked-in test fixtures and stories, internal contract docs/exports, and one CI evidence step.
  • Local Link tests stay: they assert the public label, isExternalLink, newTabLabel, disabled, and router-substitution props (AST-021 FR5).
  • Known failures: none recorded.

Scope

  • No intended public API, product behavior, visual direction, or policy change.
  • Product changes discovered during the work were removed or split.
  • Public text and artifacts contain no internal Meta context.

Not adopted here: BreadcrumbItem, SideNavItem, TopNavItem, Citation, and ClickableCard link bindings; disabled-link semantics; speech or AT activation claims.

Testing

  • pnpm vitest run --project node internal/a11y-spec/src/patterns/link.jsdom.test.ts
  • pnpm vitest run --project ui packages/core/src/Link
  • pnpm -F @astryxdesign/a11y-spec typecheck and pnpm -F @astryxdesign/core typecheck
  • Chromium contract and binding specs: exact-head pr-a11y link step, 22/22 passing.

@vercel

vercel Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Oct 12, 2026 3:02pm UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 12, 2026
@astracat-bot

astracat-bot Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Oct 12, 2026, 3:34 PM UTC

@github-actions

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR

🧪 Sandbox Preview

View Sandbox for this PR

No new or modified components detected.

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@astryxdesign/core N/A 4.9KB 1.2KB

Accessibility Audit

Status: No accessibility violations detected.

Visual Regression

44 of 448 shot(s) changed.

A change here is a question, not a failure: check whether the after is the
picture you intended. Record that review on the PR. Baseline maintenance is an
explicit dispatch of CI; this report never rewrites the baseline or adds a release gate.

component story theme mode pixels
Selector Indicator Space Bottom Sheet Narrow End RTL neutral light 754,077
Selector Indicator Space Bottom Sheet Wide Start neutral light 740,188
Chat Full AI Chat probe light 238,081
Chat Full AI Chat probe dark 237,048
Markdown Default probe light 159,625
Markdown Default probe dark 158,986
Collapsible Dividers probe dark 66,445
Collapsible Dividers probe light 66,445
Chat Default neutral dark 33,205
Chat Default neutral light 32,876
Chat Empty State probe light 23,531
Chat Empty State probe dark 22,622
ChatAutoScroll Scroll Behavior Comparison neutral dark 15,378
ChatAutoScroll Scroll Behavior Comparison neutral light 14,107
Chat With Attachments probe light 13,406
Chat With Attachments probe dark 11,232
ProgressBar With Target Mark probe dark 7,895
ProgressBar With Target Mark probe light 7,895
TableRowExpansion Detail Panel neutral dark 5,129
TableRowExpansion Detail Panel neutral light 4,050

and 24 more.


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommending approval: the new link contract and Link binding follow the repository's accessibility spec-test authoring and migration rules, leave Link's runtime behavior and public API unchanged, and the contract's fixture proof plus all six Link states pass in Chromium for this revision. No changes are needed from you before maintainer review.

[Automated review]

@cixzhang
cixzhang merged commit 6613d81 into main Oct 13, 2026
49 checks passed
cixzhang added a commit that referenced this pull request Oct 13, 2026
* ci(a11y): scope PR evidence steps by the merge-base diff

The Link, Landmark, ToggleButton and RichText parity evidence steps
decided PR scope with a two-dot diff from the base branch's tip. On a
branch cut before the base gained a file, that diff lists the file as
deleted by the PR: since the Link contract landed (#7378), every older
PR ran the Link step against spec files missing at its head and failed
pr-a11y with 'No tests found' until rebased. pr-scope-touches.sh diffs
from the PR's merge base instead (fetching 200 commits of history), and
an unknown merge base still runs the evidence, as an unfetchable base
did before.

* ci(a11y): load the PR scope helper from the base

A pull_request run takes its step bodies from the merge commit while
pr-a11y checks out the PR head, so a branch cut before the helper landed
would not have it: bash would exit 127, read as unknown, and run every
gated suite (still failing older-than-Link branches). The four steps now
load pr-scope-touches.sh from BASE_SHA, as check-scope loads its policy
scripts. The helper also exits 2 (unknown) rather than 1 for unusable
arguments or an invalid pattern.

* ci(a11y): find the PR merge base at any branch age; count renames

A fixed 200-commit fetch left branches further behind main without a
merge base, so every gated suite ran (and pre-Link branches still
failed). The helper now deepens in 200-commit steps until git
merge-base succeeds, and exits 2 only when history is complete and
still unrelated. --no-renames lists both sides of a move, so moving a
matching file out of a pattern still counts as touching it.
@github-actions
github-actions Bot deleted the test/a11y-link-contract branch October 14, 2026 06:22

This branch was successfully deployed

1 active deployment
Preview — eb7600ea Deployed Oct 12, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant