- Add shared accessibility test helper (tests/accessibility/helper.js/ts) - scanAccessibility(): runs axe-core scans with WCAG 2.1 AA tags - formatViolations(): formats violation details for error reporting - expectNoAccessibilityViolations(): asserts no violations - Add smoke tests demonstrating helper usage (tests/accessibility/smoke.spec.js/ts) - Refactor existing accessibility tests to use shared helper - Simplified a11y.spec.js to use expectNoAccessibilityViolations() - Maintains all existing test coverage Co-Authored-By: Claude <noreply@anthropic.com>
21 lines
900 B
JavaScript
21 lines
900 B
JavaScript
const { test, expect } = require('@playwright/test');
|
|
const { scanAccessibility, expectNoAccessibilityViolations } = require('./helper');
|
|
|
|
test.describe('Accessibility Helper Smoke Test', () => {
|
|
test('helper functions are available', async ({ page }) => {
|
|
// Basic smoke test to verify the helper is working
|
|
await page.goto('/index.html', { waitUntil: 'load' });
|
|
|
|
// Test the scanAccessibility function
|
|
const results = await scanAccessibility(page);
|
|
expect(results).toHaveProperty('violations');
|
|
expect(results).toHaveProperty('passes');
|
|
expect(Array.isArray(results.violations)).toBe(true);
|
|
expect(Array.isArray(results.passes)).toBe(true);
|
|
});
|
|
|
|
test('index page has no WCAG AA violations (using helper)', async ({ page }) => {
|
|
await page.goto('/index.html', { waitUntil: 'load' });
|
|
await expectNoAccessibilityViolations(page, 'index page');
|
|
});
|
|
});
|