-
Notifications
You must be signed in to change notification settings - Fork 236
feat(testing): add Playwright accessibility testing POC for Badge and Status Light #5835
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
📚 Branch Preview🔍 Visual Regression Test ResultsWhen a visual regression test fails (or has previously failed while working on this branch), its results can be found in the following URLs:
Deployed to Azure Blob Storage: If the changes are expected, update the |
Tachometer resultsCurrently, no packages are changed by this PR... |
0c06161 to
1e47ff4
Compare
3ff495e to
fd099fd
Compare
bd182cc to
c86b099
Compare
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.
@cdransf This looks great—I'm so excited to see it happening!
I haven't had time for a thorough review yet, but wanted to leave some high-level feedback based on an initial look:
- Can we move the shared bits of config and functionality so that they live in 2nd-gen, not 1st-gen? In general, it's fine to add component-specific stuff to 1st-gen during this transition period, but any new, non-component-specific code that we want to carry forward into the future should find a place in 2nd-gen to live.
- Can you take the content of ACCESSIBILITY_TESTING.md and find a place for it in the new top-level CONTRIBUTOR-DOCS hierarchy?
- [Minor, but a bit concerning] - Do you understand the significance of the changed files where the changes are simply the addition / removal of the license header? Are these linter-prompted changes?
3e59ffd to
019281e
Compare
This was an interesting one and I believe it may be an interaction between our linting and our pre-commit hook. So it matches |
I moved it below the section on patching dependencies as it's fairly thorough and can stand as its own section in the documentation. It's also linked to from the Testing section of |
Absolutely (and this makes more sense than where I had it). I've gone ahead and moved things over, verified the commands and updated the PR description. |
Thanks for looking into it! Based on the latest commits to the barebones branch, it looks like these changes are as intended (i.e., represent actual linting fixes), but the fixed versions of these particular files hadn't been committed yet. It looks like this later commit to barebones takes care of it... ...so I think rebasing your branch on the latest barebones would clean up the file diff on this PR. |
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.
LGTM!
As I mentioned in a reply, I think rebasing on the latest barebones should clean up the diff for this PR (related to those confusing linting changes).
507fe7f to
74a79e5
Compare
94064dc to
fdf30c7
Compare
…ight Implements automated accessibility testing using two complementary approaches: 1. ARIA Snapshot Testing - Captures and validates accessibility tree structure - Detects unintended changes to component semantics - Serves as living documentation of expected a11y structure 2. aXe Rule Validation - Automated WCAG 2.0/2.1 Level A/AA compliance checking - Excludes best-practice rules (focused on component testing) - Validates color contrast, ARIA attributes, and more Test Coverage (14/14 passing, ~6s runtime): - Badge: default, icons, semantic variants, color contrast - Status Light: sizes (s/m/l), disabled state, color contrast Key Implementation Details: - Integrated with existing Storybook stories (no duplication) - Element visibility waits (reliable, fast) - WCAG-only scanning (appropriate for isolated components) - HTML report generation for debugging Files Added: - 1st-gen/playwright.config.ts - Playwright configuration - 1st-gen/test/playwright-a11y/aria-snapshots.spec.ts - ARIA tests - 1st-gen/test/playwright-a11y/axe-validation.spec.ts - aXe tests - 1st-gen/test/playwright-a11y/README.md - Documentation - RFC_A11Y_TESTING.md - Comprehensive RFC with scaling plan - README.A11Y.md - Quick start guide Usage: yarn test:a11y # Run all accessibility tests yarn test:a11y:ui # Open Playwright UI for debugging yarn test:a11y:1st # Run only 1st gen yarn test:a11y:2nd # Run only 2nd gen
fdf30c7 to
1005da2
Compare
43de61f to
1651e27
Compare
Description
SWC-1263Proof of concept implementing automated accessibility testing using Playwright with two complementary approaches:
1. ARIA Snapshot Testing
2. aXe-core WCAG Validation
Test Coverage
25 tests passing across both generations (~30s runtime):
1st Generation (13 tests):
2nd Generation (12 tests):
Key Features
test/*.a11y.spec.ts1st-gen/test/a11y-helpers.tswork for both gensACCESSIBILITY_TESTING.mdUsage
Files Added/Modified
Test Files:
1st-gen/packages/badge/test/badge.a11y.spec.ts1st-gen/packages/status-light/test/status-light.a11y.spec.ts2nd-gen/packages/swc/components/badge/test/badge.a11y.spec.ts2nd-gen/packages/swc/components/status-light/test/status-light.a11y.spec.tsShared Utilities:
1st-gen/test/a11y-helpers.ts- Deterministic helpers for both generationsConfiguration:
1st-gen/playwright.config.ts- Dual-Storybook Playwright setup with projects1st-gen/package.json- Test scripts (test:a11y,test:a11y:1st,test:a11y:2nd,test:a11y:ui)package.json- Root-level convenience commandsDocumentation:
ACCESSIBILITY_TESTING.md- Comprehensive guide covering quick start, how-to, and best practicesARIA Snapshots (auto-generated baselines):
1st-gen/packages/badge/test/badge.a11y.spec.ts-snapshots/*.aria.yml1st-gen/packages/status-light/test/status-light.a11y.spec.ts-snapshots/*.aria.yml2nd-gen/packages/swc/components/badge/test/badge.a11y.spec.ts-snapshots/*.aria.yml2nd-gen/packages/swc/components/status-light/test/status-light.a11y.spec.ts-snapshots/*.aria.ymlMotivation and Context
Problem: Manual accessibility testing is time-consuming and inconsistent. Regressions can slip through unnoticed.
Solution: Automated testing catches accessibility issues early in development and serves as executable documentation of expected behavior.
Approach: This POC demonstrates the pattern on Badge and Status Light components across both 1st and 2nd generation. If approved, the pattern can be applied to all components.
Technical Decisions
1. WCAG-only scanning
2. Deterministic waits
gotoStory()helper waits for specific conditionswaitForLoadState('networkidle')3. Playwright projects for dual-generation support
4. Collocated tests
test/directory5. Shared, generation-agnostic helpers
1st-gen/test/a11y-helpers.tssp-*) and 2nd gen (swc-*) componentsRelated Issue(s)
Author's Checklist
Reviewer's Checklist
Questions for Discussion
Manual Testing
Verify tests run successfully:
pkill -f "storybook"cd 1st-gen && yarn test:a11yReview test outputs:
yarn test:a11y:report**/test/*-snapshots/directoriesTry individual commands:
yarn test:a11y:1st- Should run 14 1st gen testsyarn test:a11y:2nd- Should run 11 2nd gen testsyarn test:a11y:ui- Should open Playwright UIyarn test:a11y badge --update-snapshots- Update baselinesReview documentation:
ACCESSIBILITY_TESTING.mdfor comprehensive guideNote: This is a POC for discussion. Not intended for immediate merge - seeking feedback on approach and implementation before broader rollout.