Skip to content

Show WCAG conformance level in axe document report (#14604)#14606

Merged
cderv merged 2 commits into
mainfrom
worktree-axe-wcag-tags
Jun 22, 2026
Merged

Show WCAG conformance level in axe document report (#14604)#14606
cderv merged 2 commits into
mainfrom
worktree-axe-wcag-tags

Conversation

@cwickham

@cwickham cwickham commented Jun 18, 2026

Copy link
Copy Markdown
Member

Fixes #14604.

What

The axe: output: document report showed each violation's impact, description, and selectors, but never the WCAG conformance category. A best-practice finding (axe's own recommendation, not tied to any WCAG success criterion) was rendered identically to a genuine WCAG Level A failure, which matters for triage.

This derives a human-readable conformance label from the violation's axe-core tags (already present in the result and exposed by output: json, just not surfaced in output: document) and shows it inline in the description:

Critical · WCAG 2.0 AA (1.4.3): Ensure the contrast between foreground and background colors meets WCAG 2 AA contrast ratio thresholds

E.g. in format: html:
Screenshot 2026-06-18 at 3 53 50 PM

The label covers:

  • WCAG version + level + criteriawcag2aa + wcag143WCAG 2.0 AA (1.4.3); multiple criteria are numerically sorted and comma-joined (WCAG 2.0 A (2.4.4, 4.1.2)).
  • Best practicebest-practiceBest Practice.
  • Obsolete criteria — the -obsolete tag suffix (e.g. wcag2a-obsolete on the deprecated duplicate-id rule, for WCAG SC 4.1.1 withdrawn in 2.2) → Obsolete WCAG 2.0 A (4.1.1), so a withdrawn criterion isn't mistaken for a current failure. (These rules are disabled by default in axe-core, so this path is defensive.)
  • No conformance tags → falls back to the impact alone.

Verification

  • Ran the label function over all 104 rules in axe-core 4.10.3 (the pinned version): every rule produced a well-formed label — no malformed output, no mis-attribution, no bare level-less criteria, obsolete correctly flagged.
  • Added expectedConformance assertions to the Playwright axe matrix across all document-mode formats (HTML, dashboard, dashboard-dark, dashboard-pages, revealjs, revealjs-dark), checked against the real axe-core tags.

Notes

  • Per the issue author's preference, only the conformance level is surfaced (not the axe category, which is largely redundant with the description text).
  • Investigation was AI-assisted and grounded in a local clone of quarto-cli (per CONTRIBUTING.md, "Using AI tools to investigate").

Draft for now — opening for early review.

The `axe: output: document` report showed each violation's impact,
description, and selectors but never the WCAG conformance category, so a
`best-practice` finding was indistinguishable from a genuine WCAG failure.

Derive a human-readable label from the violation's axe-core `tags`:
the WCAG version+level and success criteria (e.g. `WCAG 2.0 AA (1.4.3)`),
`Best Practice` for axe's own recommendations, or `Obsolete WCAG 2.0 A
(4.1.1)` for withdrawn criteria (the `-obsolete` tag suffix). Falls back
to the impact alone when no conformance tags are present.

Verified against all 104 rules in axe-core 4.10.3.

Add expectedConformance assertions to the Playwright axe matrix.
@posit-snyk-bot

posit-snyk-bot commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@cwickham cwickham marked this pull request as ready for review June 19, 2026 15:30
@cwickham cwickham requested a review from cscheid June 19, 2026 15:31
@cderv cderv self-requested a review June 22, 2026 13:50

@cderv cderv left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks !

This looks good. I'll add more unit test for regression and merge

The Playwright matrix only exercises the two ordinary WCAG paths through
the document reporter, leaving the best-practice, obsolete, empty-fallback,
and numeric-sort branches of the label derivation untested. The numeric
sort in particular can only be reached deterministically with a crafted
multi-criteria input, not via whichever rules axe-core happens to flag.

Export axeConformanceLevel so it can be tested in isolation and guard the
module's self-init on typeof document so importing it outside a browser is
side-effect-free. The tests feed synthetic tags arrays (the contract axe
hands us) and assert only our formatting, so an axe-core upgrade that
re-tags a rule cannot break them.
@cderv cderv merged commit 38ef483 into main Jun 22, 2026
51 checks passed
@cderv cderv deleted the worktree-axe-wcag-tags branch June 22, 2026 14:59
cderv added a commit to quarto-dev/quarto-web that referenced this pull request Jun 22, 2026
…2081)

* docs: document WCAG conformance level in axe output: document report

Companion to quarto-dev/quarto-cli#14606, which adds a WCAG conformance
level prefix to each violation in the output:document axe report (e.g.,
"Serious · WCAG 2.0 AA (1.4.3)"), distinguishing genuine WCAG failures
from best-practice findings.

The document output bullet now mentions this. The axe-violation.png
screenshot, which predated the feature, is regenerated to show the new
prefix.

* fix screenshot: use cropBottom instead of trim to preserve full width

* fix screenshot: 1000x360 viewport so content fills width and text wraps
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

axe: output: document report omits WCAG conformance level

3 participants