-
Notifications
You must be signed in to change notification settings - Fork 235
feat(testing): add playwright setup #5860
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
|
0ecadf3 to
cf5ba2d
Compare
|
|
||
| import { expect, test } from '@playwright/test'; | ||
| import AxeBuilder from '@axe-core/playwright'; | ||
| import { gotoStory } from '../../../../2nd-gen/test/a11y-helpers.js'; |
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.
I think we still don’t have a definitive place for cases like this, but this kind of inter-workspace import isn’t ideal (it could cause issues with CI or other configurations). For this specific case, though, gotoStory seems small enough that we could just include it in each generation?
Ideally, though, we would conceptually land on something like @spectrum-web-components/core/toolkit
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.
Totally makes sense! I've addressed that here 580727a.
| import AxeBuilder from '@axe-core/playwright'; | ||
| import { expect, test } from '@playwright/test'; | ||
|
|
||
| import { gotoStory } from '../../../../../test/a11y-helpers.js'; |
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.
Given that this is @adobe/swc (the actual components implementation) related-only, it feels like this helper could be moved 2nd-gen/packages/swc/utils
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.
Done! ✨
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.
nit: I don't have the full context, but couldn't this be on the root level? From what I've seen, it's only getting called from root?
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.
It can! I moved it there and updated the commands in package.json. ✨
|
I didn’t re-add the |
05339c6 to
1b9ea79
Compare
9cb06e7 to
0545b8d
Compare
📚 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 |
7134b97 to
0545b8d
Compare
0545b8d to
cf00510
Compare
Description
Trying to get this #5835 in - now rebased!
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.