-
Notifications
You must be signed in to change notification settings - Fork 4
feat: accessibility audit — axe-core E2E tests, Lighthouse CI gate, and summary reporting #82
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
Open
Copilot
wants to merge
8
commits into
main
Choose a base branch
from
copilot/accessibility-improvements-cicd
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
e094798
feat: add accessibility audit — axe-core E2E tests, Lighthouse CI job…
Copilot 005b5e0
fix: use '90%' formatting (no space before %) in lighthouserc.yml and…
Copilot 58ceedf
Potential fix for pull request finding
dsanchezcr 342f5ec
Potential fix for pull request finding
dsanchezcr da86c74
Potential fix for pull request finding
dsanchezcr 27ae1df
Potential fix for pull request finding
dsanchezcr eae5bc9
Potential fix for pull request finding
dsanchezcr a14fde3
fix: resolve accessibility violations — remove opacity animation and …
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| import { test } from '@playwright/test' | ||
| import AxeBuilder from '@axe-core/playwright' | ||
| import * as fs from 'fs' | ||
| import * as path from 'path' | ||
|
|
||
| /** | ||
| * Accessibility tests using axe-core / WCAG 2.x rules. | ||
| * | ||
| * Each test scans a key page and writes all violations to | ||
| * playwright-report/a11y/<page>.json so the CI summary script can | ||
| * aggregate and report counts by severity. | ||
| * | ||
| * Tests fail only on critical / serious violations so that moderate / | ||
| * minor issues are visible in the report without blocking PRs outright. | ||
| */ | ||
|
|
||
| const WCAG_TAGS = ['wcag2a', 'wcag2aa', 'wcag21a', 'wcag21aa'] | ||
| const A11Y_REPORT_DIR = path.join('playwright-report', 'a11y') | ||
|
|
||
| function saveViolations(pageName: string, violations: object[]): void { | ||
| fs.mkdirSync(A11Y_REPORT_DIR, { recursive: true }) | ||
| fs.writeFileSync( | ||
| path.join(A11Y_REPORT_DIR, `${pageName}.json`), | ||
| JSON.stringify(violations, null, 2), | ||
| ) | ||
| } | ||
|
|
||
| test.describe('Accessibility (axe-core)', () => { | ||
| test('home page has no critical or serious violations', async ({ page }) => { | ||
| await page.goto('/') | ||
| await page.waitForLoadState('domcontentloaded') | ||
|
|
||
| const { violations } = await new AxeBuilder({ page }).withTags(WCAG_TAGS).analyze() | ||
| saveViolations('home', violations) | ||
|
|
||
| const blocking = violations.filter( | ||
| (v) => v.impact === 'critical' || v.impact === 'serious', | ||
| ) | ||
| if (blocking.length > 0) { | ||
| const details = blocking | ||
| .map((v) => ` [${v.impact}] ${v.id}: ${v.description} (${v.nodes.length} node(s))`) | ||
| .join('\n') | ||
| throw new Error( | ||
| `${blocking.length} critical/serious violation(s) on home page:\n${details}`, | ||
| ) | ||
| } | ||
| }) | ||
|
|
||
| test('create game page has no critical or serious violations', async ({ page }) => { | ||
| await page.goto('/') | ||
| await page.getByRole('button', { name: /crear nuevo juego|create new game/i }).click() | ||
| await page.waitForLoadState('domcontentloaded') | ||
|
|
||
| const { violations } = await new AxeBuilder({ page }).withTags(WCAG_TAGS).analyze() | ||
| saveViolations('create-game', violations) | ||
|
|
||
| const blocking = violations.filter( | ||
| (v) => v.impact === 'critical' || v.impact === 'serious', | ||
| ) | ||
| if (blocking.length > 0) { | ||
| const details = blocking | ||
| .map((v) => ` [${v.impact}] ${v.id}: ${v.description} (${v.nodes.length} node(s))`) | ||
| .join('\n') | ||
| throw new Error( | ||
| `${blocking.length} critical/serious violation(s) on create-game page:\n${details}`, | ||
| ) | ||
| } | ||
| }) | ||
|
|
||
| test('privacy page has no critical or serious violations', async ({ page }) => { | ||
| await page.goto('/?view=privacy') | ||
| await page.waitForLoadState('domcontentloaded') | ||
|
|
||
| const { violations } = await new AxeBuilder({ page }).withTags(WCAG_TAGS).analyze() | ||
| saveViolations('privacy', violations) | ||
|
|
||
| const blocking = violations.filter( | ||
| (v) => v.impact === 'critical' || v.impact === 'serious', | ||
| ) | ||
| if (blocking.length > 0) { | ||
| const details = blocking | ||
| .map((v) => ` [${v.impact}] ${v.id}: ${v.description} (${v.nodes.length} node(s))`) | ||
| .join('\n') | ||
| throw new Error( | ||
| `${blocking.length} critical/serious violation(s) on privacy page:\n${details}`, | ||
| ) | ||
| } | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| ci: | ||
| collect: | ||
| # Serve the pre-built frontend from dist/ via a local static server | ||
| staticDistDir: ./dist | ||
| numberOfRuns: 1 | ||
| settings: | ||
| # Only run the accessibility category for speed; other categories are | ||
| # covered separately by axe-core in Playwright. | ||
| onlyCategories: | ||
| - accessibility | ||
| # Required flags for running headless Chrome in CI (no sandbox / display) | ||
| chromeFlags: '--no-sandbox --headless' | ||
|
|
||
| assert: | ||
| assertions: | ||
| # Fail the job when the accessibility score drops below 90% | ||
| 'categories:accessibility': | ||
| - error | ||
| - minScore: 0.9 | ||
| aggregationMethod: pessimistic | ||
|
|
||
| upload: | ||
| # Upload to Google's temporary public storage so the report URL can be | ||
| # shared in the PR comment. Reports expire automatically after 7 days. | ||
| target: temporary-public-storage |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.