Barrierefreiheit nach WCAG 2.1 AA (0.37.0)
Some checks failed
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 5m58s
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 6m45s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 7m4s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 6m47s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 14m39s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 14m39s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 10m45s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 10m52s
CI / Bekannte Sicherheitslücken in Paketen (pull_request) Successful in 1m16s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m49s
Some checks failed
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 5m58s
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 6m45s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 7m4s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 6m47s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 14m39s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 14m39s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 10m45s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 10m52s
CI / Bekannte Sicherheitslücken in Paketen (pull_request) Successful in 1m16s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m49s
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
452d3d3303
commit
f8f6a4ba2b
151 changed files with 584 additions and 394 deletions
71
scripts/a11y.mjs
Normal file
71
scripts/a11y.mjs
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
/**
|
||||
* Barrierefreiheit prüfen (WCAG 2.1 A/AA) mit axe-core über die wichtigsten Seiten.
|
||||
*
|
||||
* A11Y_BASE=http://127.0.0.1:8765 A11Y_EMAIL=… A11Y_PASSWORD=… npm run a11y
|
||||
*
|
||||
* Optional: A11Y_DARK=1 (dunkles Design), A11Y_MOBILE=1 (Handy-Breite), A11Y_PATHS=/,/termine
|
||||
* Beendet sich mit Code 1, wenn Verstöße gefunden werden.
|
||||
*/
|
||||
import { createRequire } from 'node:module';
|
||||
import { chromium } from '@playwright/test';
|
||||
|
||||
const require = createRequire(import.meta.url);
|
||||
const base = process.env.A11Y_BASE ?? 'http://127.0.0.1:8765';
|
||||
const paths = (process.env.A11Y_PATHS ?? [
|
||||
'/login', '/', '/neuigkeiten', '/termine', '/personen', '/suche?q=a', '/seiten', '/profil', '/profil/bearbeiten',
|
||||
'/redaktion', '/umfragen', '/ideen', '/stellen', '/glossar', '/it-service', '/redaktion/neuigkeiten/neu',
|
||||
].join(',')).split(',');
|
||||
|
||||
const browser = await chromium.launch(process.env.A11Y_CHROMIUM ? { executablePath: process.env.A11Y_CHROMIUM } : {});
|
||||
const context = await browser.newContext({
|
||||
locale: 'de-DE',
|
||||
colorScheme: process.env.A11Y_DARK ? 'dark' : 'light',
|
||||
viewport: process.env.A11Y_MOBILE ? { width: 390, height: 844 } : { width: 1280, height: 900 },
|
||||
});
|
||||
const page = await context.newPage();
|
||||
|
||||
async function audit(path) {
|
||||
const response = await page.goto(base + path, { waitUntil: 'networkidle' });
|
||||
await page.addScriptTag({ path: require.resolve('axe-core/axe.min.js') });
|
||||
|
||||
const result = await page.evaluate(async () => window.axe.run(document, {
|
||||
runOnly: { type: 'tag', values: ['wcag2a', 'wcag2aa', 'wcag21a', 'wcag21aa'] },
|
||||
}));
|
||||
|
||||
return { path, status: response?.status(), violations: result.violations };
|
||||
}
|
||||
|
||||
// Anmeldeseite zuerst, dann anmelden
|
||||
const results = [await audit('/login')];
|
||||
|
||||
if (process.env.A11Y_EMAIL) {
|
||||
await page.fill('#email', process.env.A11Y_EMAIL);
|
||||
await page.fill('#password', process.env.A11Y_PASSWORD ?? '');
|
||||
await page.click('button[type=submit]');
|
||||
await page.waitForURL((url) => !url.pathname.startsWith('/login'));
|
||||
|
||||
for (const path of paths.filter((p) => p !== '/login')) {
|
||||
results.push(await audit(path));
|
||||
}
|
||||
}
|
||||
|
||||
let total = 0;
|
||||
|
||||
for (const { path, status, violations } of results) {
|
||||
total += violations.length;
|
||||
console.log(`\n${violations.length ? '✗' : '✓'} ${path} (${status})`);
|
||||
|
||||
for (const v of violations) {
|
||||
console.log(` [${v.impact}] ${v.id}: ${v.help}`);
|
||||
|
||||
for (const node of v.nodes.slice(0, 4)) {
|
||||
console.log(` ${node.target.join(' ')}${node.any?.[0]?.message ? ' – ' + node.any[0].message : ''}`);
|
||||
}
|
||||
|
||||
if (v.nodes.length > 4) console.log(` … und ${v.nodes.length - 4} weitere`);
|
||||
}
|
||||
}
|
||||
|
||||
console.log(`\n${total} Verstöße auf ${results.length} Seiten.`);
|
||||
await browser.close();
|
||||
process.exit(total ? 1 : 0);
|
||||
Loading…
Add table
Add a link
Reference in a new issue