Skip to content

test(templates): axe every concept, and measure gradient plates in pixels - #394

Merged
Ducksss merged 1 commit into
devfrom
claude/templates-a11y-sweep
Jul 27, 2026
Merged

Ducksss merged 1 commit into
devfrom
claude/templates-a11y-sweep

Conversation

@Ducksss

@Ducksss Ducksss commented Jul 27, 2026 •

Copy link
Copy Markdown
Owner

Why

tests/e2e/templates.e2e.spec.ts ran its accessibility describe block against templateShowcases[0] only. With ten concepts in the gallery — each with its own scoped theme, palette, and hand-tuned contrast — nine of ten had no automated a11y coverage. Every concept was verified by its author at build time; nothing stopped a regression after that.

What

  • New tests/e2e/templates-a11y.e2e.spec.ts — 43 tests: the gallery plus every concept's detail page and full preview at 1280 and 390. Data-driven from src/lib/templates/registry, so a new concept is covered the moment it is registered.
  • Its own isolated Playwright batch (templates-a11y in tools/run-e2e.ts), the way templates-visual is isolated, and pinned in both places in tests/int/e2e-runner.int.spec.ts. ~54s in the gate.
  • New tests/e2e/support/painted-contrast.ts — the contrast check axe cannot make (below).
  • New tests/int/painted-contrast.int.spec.ts — the WCAG maths and the report contract.
  • The old one-concept block is removed from templates.e2e.spec.ts, leaving a pointer comment.
  • CONTRIBUTING.md gains a short section on the two hazards, so the next person extending this suite does not rediscover them.

The two hazards, handled

1. Un-settled reveals. Straight after goto, in-view sections driven by TemplateSectionReveal (and the per-concept reveals layered on top) are mid-fade, and axe reads ~13%-opacity ink as a serious colour-contrast violation. The suite runs under reducedMotion: 'reduce', where the CSS nets pin the final frame before hydration — and then asserts it rather than trusting it: any [data-template-section] or data-*-reveal element still mid-transition fails the run by name. A future concept that ships a reveal attribute without its @media (prefers-reduced-motion: reduce) net cannot quietly reintroduce flake. This is load-bearing: without reduced motion the same pages produce serious violations on agency-studio and nonprofit-cause, and up to 38 unsettled elements.

2. Gradient plates. axe cannot resolve a gradient or image background, so it reports text over one as incomplete, never as a violation — 13 to 72 unjudged nodes per page here, including every hero plate. A green axe run proves nothing about them. The preview sweeps hand that list to the painted-contrast helper, which repaints all ink in a sentinel colour, captures, repaints it transparent, captures again, solves per-pixel glyph coverage from the pair, then composites the authored colour at its real opacity over the background the plate capture shows underneath. What it cannot score — gradient-filled ink, cross-frame nodes, the position: fixed preview-exit pill — is counted and logged, never silently passed. Every run prints how many pairings it scored and what it could not, so "green" is never mistaken for "everything was checked".

Three things mutation testing caught

All recorded in the module comment, because each looked fine and was not:

  • A plain ink-on/ink-off diff mask thins out exactly where it matters — washed-out ink barely differs from its plate, so a real failure read as "nothing to measure". Hence the sentinel.
  • The ink override must be inline !important; an author rule like .hero-title { color: … !important } outranks any * selector and leaves the node identical in both captures.
  • Translucent ink must be composited. text-foreground/70 is not the colour the browser paints, and the templates use text-*/NN in 27 places. Taking it at face value flatters every translucent run.

Injected colour, alpha, and ancestor-opacity regressions are each caught at 1.10–1.50:1 while axe still reports zero blocking violations.

Findings worth a look (no action in this PR)

  • fintech-trust at 390 is the thinnest real pairing in the gallery: 3.11:1 against a 3:1 requirement (mint serif on the aurora field); nonprofit-cause at 390 is 4.99:1 against 4.5:1. Both pass, with almost no headroom — a future palette nudge will trip this suite.
  • portfolio-solo (both widths) and agency-studio at 390 have nothing measurable — their only axe-unjudged nodes are the excluded chrome pill, i.e. no text over gradients. Honest, and logged, but the pixel pass proves nothing for those two.
  • The floating preview-exit pill overlays hero content at 390px. That overlap is what produced a false 1.00:1 before the captures started hiding it, the way tools/templates/capture.ts already does for posters.

Verification

  • pnpm test:release on this branch: green, batches 40 / 69 / 102 / 43 / 130, int 379 passed. (One earlier run failed on ENOSPC — the dev box's disk, not the code.)
  • Widened suite run twice back to back on this base: 43/43 both, with byte-identical measurement counts. Ratios wobble by ±0.02 from gradient rasterisation, which is why the report lists the three tightest pairings rather than a single "worst" that would name a different node each run.
  • No new visual baselines, so no per-platform mint is needed.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Accessibility

    • Added comprehensive accessibility checks for template galleries, detail pages, and full previews across desktop and mobile layouts.
    • Added enhanced contrast validation for text displayed over gradients and images.
  • Documentation

    • Documented how to run and interpret the template accessibility checks.
  • Testing

    • Added coverage for contrast calculations, reporting, test discovery, and dedicated accessibility test execution.

Copilot AI review requested due to automatic review settings July 27, 2026 20:16
@vercel

vercel Bot commented Jul 27, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
payload-components Ready Ready Preview, Comment Jul 27, 2026 8:49pm
payload-components-97bf Ready Ready Preview, Comment Jul 27, 2026 8:49pm

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Jul 27, 2026 •

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@Ducksss, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 29 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: a9fba32a-d09d-4a78-b06b-4fdc30781182

📥 Commits

Reviewing files that changed from the base of the PR and between 94911c5 and b980b99.

📒 Files selected for processing (7)
  • CONTRIBUTING.md
  • tests/e2e/support/painted-contrast.ts
  • tests/e2e/templates-a11y.e2e.spec.ts
  • tests/e2e/templates.e2e.spec.ts
  • tests/int/e2e-runner.int.spec.ts
  • tests/int/painted-contrast.int.spec.ts
  • tools/run-e2e.ts
📝 Walkthrough

Walkthrough

Adds a dedicated templates-a11y Playwright suite covering template pages across desktop and mobile viewports. It introduces painted-pixel contrast analysis, moves existing axe checks into the isolated suite, updates e2e batching, and documents the coverage.

Changes

Template accessibility coverage

Layer / File(s) Summary
Painted contrast measurement and validation
tests/e2e/support/painted-contrast.ts, tests/int/painted-contrast.int.spec.ts
Adds screenshot-based glyph/background contrast scoring, report formatting, skip handling, and tests for WCAG contrast calculations and report output.
Template accessibility suite
tests/e2e/templates-a11y.e2e.spec.ts, CONTRIBUTING.md
Adds reduced-motion axe checks for gallery, detail, and full-preview pages at desktop and mobile widths, plus reveal settlement, image readiness, and painted contrast assertions. Documents the sweep.
Isolated e2e integration
tests/e2e/templates.e2e.spec.ts, tools/run-e2e.ts, tests/int/e2e-runner.int.spec.ts
Moves the existing template axe sweep into templates-a11y, registers it as an isolated batch, and updates discovery and batching expectations.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related PRs

Suggested reviewers: copilot

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately highlights the main change: broader template a11y coverage plus pixel-based contrast checking.
Description check ✅ Passed The description is detailed and covers the why, what, hazards, verification, and notes; it mostly satisfies the template even if headings differ.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/templates-a11y-sweep

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
tests/e2e/templates-a11y.e2e.spec.ts (1)

89-92: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Settled-transform check misses 3D identity matrices.

Only 'none' and the 2D identity 'matrix(1, 0, 0, 1, 0, 0)' count as settled. If a concept's @media (prefers-reduced-motion: reduce) net resolves to a 3D transform (e.g. via translate3d/transform3d shorthand, which Chromium reports as matrix3d(...)), this would misreport a genuinely settled element as unsettled and fail the suite for the wrong reason.

♻️ Broaden the identity check
       const settledTransform =
-        style.transform === 'none' || style.transform === 'matrix(1, 0, 0, 1, 0, 0)'
+        style.transform === 'none' ||
+        style.transform === 'matrix(1, 0, 0, 1, 0, 0)' ||
+        style.transform === 'matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/e2e/templates-a11y.e2e.spec.ts` around lines 89 - 92, Update the
settledTransform check in the accessibility wait logic to also recognize
Chromium’s 3D identity transform matrix as settled, alongside 'none' and the
existing 2D identity matrix. Keep the opacity requirement and current
continuation behavior unchanged.
tests/e2e/support/painted-contrast.ts (1)

88-117: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

skippedNoGlyphPixels is a bare count; skippedUnresolved gets a per-selector list.

Every other skip category that can hide a real failure (unresolvedSelectors) keeps enough detail to know which node was dropped and why. A candidate that yields zero glyph pixels (channel collision with the sentinel, or coverage below the floor) only bumps a counter — there's no way to tell which selector it was without re-instrumenting. Given the PR's explicit goal of never treating "unmeasurable" as "passed," recording the dropped selectors here too would make this failure mode as debuggable as the unresolved one.

♻️ Sketch
   /* Nodes whose box held no glyph pixels (text painted by a child element, or
      clipped away) — nothing to measure, so nothing is claimed about them. */
   skippedNoGlyphPixels: number
+  /* Selectors of nodes that fell into skippedNoGlyphPixels, for the same
+     reason unresolvedSelectors exists — a skip should never hide which node
+     it applied to. */
+  skippedNoGlyphPixelsSelectors: string[]
     const scored = scoreCandidate(candidate, glyphs, plate)
     if (!scored) {
       report.skippedNoGlyphPixels += 1
+      report.skippedNoGlyphPixelsSelectors.push(candidate.selector)
       continue
     }

Also applies to: 562-572

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/e2e/support/painted-contrast.ts` around lines 88 - 117, Extend
PaintedContrastReport and the reporting logic that increments
skippedNoGlyphPixels to retain the selectors for every node dropped because no
glyph pixels were found. Add a dedicated selector list for this category,
populate it at the same decision points as the count, and preserve the existing
skippedUnresolved selector tracking separately.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@tests/e2e/support/painted-contrast.ts`:
- Around line 88-117: Extend PaintedContrastReport and the reporting logic that
increments skippedNoGlyphPixels to retain the selectors for every node dropped
because no glyph pixels were found. Add a dedicated selector list for this
category, populate it at the same decision points as the count, and preserve the
existing skippedUnresolved selector tracking separately.

In `@tests/e2e/templates-a11y.e2e.spec.ts`:
- Around line 89-92: Update the settledTransform check in the accessibility wait
logic to also recognize Chromium’s 3D identity transform matrix as settled,
alongside 'none' and the existing 2D identity matrix. Keep the opacity
requirement and current continuation behavior unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: d6f93e60-9e40-4f6e-80c0-7ca059156b3a

📥 Commits

Reviewing files that changed from the base of the PR and between d646903 and 94911c5.

📒 Files selected for processing (7)
  • CONTRIBUTING.md
  • tests/e2e/support/painted-contrast.ts
  • tests/e2e/templates-a11y.e2e.spec.ts
  • tests/e2e/templates.e2e.spec.ts
  • tests/int/e2e-runner.int.spec.ts
  • tests/int/painted-contrast.int.spec.ts
  • tools/run-e2e.ts

@Ducksss
Ducksss enabled auto-merge (squash) July 27, 2026 20:27
…xels

The accessibility sweep in templates.e2e.spec.ts was pinned to
templateShowcases[0], so only one concept's scoped theme and hand-tuned
contrast was ever checked. Move it to its own isolated Playwright batch
covering the gallery plus every concept's detail page and full preview at
1280 and 390, data-driven from the registry so a new concept is covered on
registration.

Two hazards the widened sweep has to handle:

Un-settled reveals. Straight after goto, in-view sections are mid-fade and
axe reads ~13%-opacity ink as a serious contrast violation. Run under
reducedMotion, where the CSS nets pin the final frame before hydration, and
assert it rather than trust it: any [data-template-section] or data-*-reveal
element still mid-transition fails the run by name, so a future concept that
ships a reveal without its prefers-reduced-motion net cannot reintroduce
flake quietly.

Gradient plates. axe cannot resolve a gradient or image background, so it
reports text over one as `incomplete`, never as a violation — 13 to 72
unjudged nodes per page, including every hero plate. tests/e2e/support/
painted-contrast.ts scores exactly those pairings against painted pixels: it
repaints all ink in a sentinel colour, captures, repaints it transparent,
captures again, solves per-pixel glyph coverage from the two, then composites
the authored colour at its real opacity over the background the plate capture
shows underneath. What it cannot score — gradient-filled ink, cross-frame
nodes, the fixed preview-exit pill — is counted and logged, never silently
passed.

Three things it took mutation testing to get right, all recorded in the
module comment: a plain ink-on/ink-off diff mask thins out exactly when
contrast is low, so a real failure read as "nothing to measure"; the ink
override has to be inline !important or an author `!important` colour
outranks it and the node looks identical in both captures; and translucent
ink has to be composited, because text-foreground/70 is not the colour the
browser paints. Injected colour, alpha, and ancestor-opacity regressions are
each caught at 1.10-1.50:1 while axe still reports zero violations.

Co-Authored-By: Claude Opus 5 <[email protected]>
@Ducksss
Ducksss force-pushed the claude/templates-a11y-sweep branch from 94911c5 to b980b99 Compare July 27, 2026 20:47
@vercel

vercel Bot commented Jul 27, 2026

Copy link
Copy Markdown

Deployment failed with the following error:

Resource is limited - try again in 24 hours (more than 100, code: "api-deployments-free-per-day").

Learn More: https://vercel.com/ducksss-projects?upgradeToPro=build-rate-limit

@Ducksss
Ducksss merged commit 3c8c770 into dev Jul 27, 2026
11 of 12 checks passed
Ducksss added a commit that referenced this pull request Jul 29, 2026
…r adoption, template a11y (#409)

Brings main level with dev (137 commits). Headline items:

- the component wall no longer crops blocks: per-breakpoint zoom pins the twins'
  inner layout width at 1280px (#392), and the 640-1023px band gets a 256px frame
  plus a widened fade (#399). Production was cutting content-quote,
  content-feature-media and content-feature-split by 88/79/78px on a tablet;
  measured on the live site, not inferred. Three viewport tests now assert the fit
  so a curated-at-one-width regression cannot recur silently.
- prettier is adopted: config matched to the house style (#402), the tree
  formatted, and format:check gated in test:release and the CI lint step (#408).
- template a11y and layout fixes (#394, #398, #404), consent gate split by
  provider (#400), axe now waits for the consent banner (#405), CodeQL
  double-escaping fix (#391).

Tree is identical to dev by construction: branched from dev, reparented onto main,
so the diff is exactly the main..dev delta with no squash-divergence conflicts.
Ducksss added a commit that referenced this pull request Jul 29, 2026
…e days

Triaged every bot review on the 60 PRs merged since 2026-07-24. Copilot was
quota-limited on all of them and Codex's one finding (#340 Linux baselines) was
handled by #342, so everything actionable is CodeRabbit's. Most of its findings
were already closed by #378/#380 or superseded by later work; two were false
positives. These five were still open and worth taking.

- frontend.e2e: pin the tablet wall fade (#399). The 2.75rem override IS that
  PR, and nothing asserted it — the existing fade check runs at 390px, outside
  the 640-1023px query, so deleting the rule stayed green, and the overrun
  ceiling is deliberately loose enough (60px) to swallow the 44px residue too.
  Asserted exactly, because matching the residue is the point.

- templates-a11y: accept the 3D identity as settled (#394). A reveal written
  with translate3d, or carrying a translateZ(0) compositor hint, serialises as
  matrix3d — the check saw only the 2D identity and would have failed the gate
  for a reveal sitting exactly where it belongs.

- painted-contrast: name the no-glyph-pixel skips (#394). unresolvedSelectors
  already exists so a skip cannot hide which node it dropped; this is the other
  way an unmeasurable node leaves the run, and it was a bare count.

- ComponentWall: fix the zoom comment (#396). It claimed every card shows true
  desktop proportions at every size. zoom pins the 1280px layout width, not the
  breakpoint — frontend.e2e's own comment says as much — and that claim is
  exactly what would mislead the next person curating frame heights.

- CONTRIBUTING: document the changed-vs-all snapshot trap (#375). A bare
  --update-snapshots skips baselines whose diff lands under tolerance, which is
  the same stale-baseline half-mint the section warns about, minus the missing
  file that would have revealed it. visual-baselines.yml explains this at
  length; the local instructions did not.

Skipped, with reasons: tokenising the wall fade heights and the mask-image
black stops (#399/#396/#370) — the token rule scans component utilities, not
globals.css, which defines tokens and carries raw lengths throughout, and a
mask's black is an alpha keyword rather than a colour; fading only
confirmed-overflow cards (#396) — the valve exists for content that has not
changed yet; moving privacy copy into site.ts (#372) — real per AGENTS.md, but
about/blog/brand-guide hold local copy too, so this belongs in one deliberate
pass; subset-aware blog visual validation (#375) — outputRoot defaults to the
repo, so a --slug render is incremental against committed assets and the
full-catalog gate is the correct final check.

Verified: lint, tsc, the three affected int specs, and both e2e specs green
(frontend 44 passed, templates-a11y 43 passed) in production mode.

Co-Authored-By: Claude Opus 5 <[email protected]>
Ducksss added a commit that referenced this pull request Jul 29, 2026
…e days (#411)

Triaged every bot review on the 60 PRs merged since 2026-07-24. Copilot was
quota-limited on all of them and Codex's one finding (#340 Linux baselines) was
handled by #342, so everything actionable is CodeRabbit's. Most of its findings
were already closed by #378/#380 or superseded by later work; two were false
positives. These five were still open and worth taking.

- frontend.e2e: pin the tablet wall fade (#399). The 2.75rem override IS that
  PR, and nothing asserted it — the existing fade check runs at 390px, outside
  the 640-1023px query, so deleting the rule stayed green, and the overrun
  ceiling is deliberately loose enough (60px) to swallow the 44px residue too.
  Asserted exactly, because matching the residue is the point.

- templates-a11y: accept the 3D identity as settled (#394). A reveal written
  with translate3d, or carrying a translateZ(0) compositor hint, serialises as
  matrix3d — the check saw only the 2D identity and would have failed the gate
  for a reveal sitting exactly where it belongs.

- painted-contrast: name the no-glyph-pixel skips (#394). unresolvedSelectors
  already exists so a skip cannot hide which node it dropped; this is the other
  way an unmeasurable node leaves the run, and it was a bare count.

- ComponentWall: fix the zoom comment (#396). It claimed every card shows true
  desktop proportions at every size. zoom pins the 1280px layout width, not the
  breakpoint — frontend.e2e's own comment says as much — and that claim is
  exactly what would mislead the next person curating frame heights.

- CONTRIBUTING: document the changed-vs-all snapshot trap (#375). A bare
  --update-snapshots skips baselines whose diff lands under tolerance, which is
  the same stale-baseline half-mint the section warns about, minus the missing
  file that would have revealed it. visual-baselines.yml explains this at
  length; the local instructions did not.

Skipped, with reasons: tokenising the wall fade heights and the mask-image
black stops (#399/#396/#370) — the token rule scans component utilities, not
globals.css, which defines tokens and carries raw lengths throughout, and a
mask's black is an alpha keyword rather than a colour; fading only
confirmed-overflow cards (#396) — the valve exists for content that has not
changed yet; moving privacy copy into site.ts (#372) — real per AGENTS.md, but
about/blog/brand-guide hold local copy too, so this belongs in one deliberate
pass; subset-aware blog visual validation (#375) — outputRoot defaults to the
repo, so a --slug render is incremental against committed assets and the
full-catalog gate is the correct final check.

Verified: lint, tsc, the three affected int specs, and both e2e specs green
(frontend 44 passed, templates-a11y 43 passed) in production mode.

Co-authored-by: Claude Opus 5 <[email protected]>

This branch was successfully deployed

1 active deployment
Preview – payload-components-97bf — b980b994 Deployed Jul 27, 2026 by vercel[bot]
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.

2 participants