Files
KantSites/scripts/browser-check.mjs
T
kantarciandClaude Opus 5 82b07820bc Kant CMS: Grundgerüst, visueller Editor, Mediathek
Symfony 7.4 / Twig / Doctrine DBAL auf herkömmlichem PHP-Webhosting.
Versionierte Blockdokumente (v1-v3) mit unveränderlichen Revisionen,
getrennten Entwürfen/Veröffentlichungen und optimistischer
Konflikterkennung. Visueller Editor mit Strukturbaum, Live-Vorschau,
responsiven Gerätewerten, Abschnittsvorlagen, Bildmediathek,
Galerien und Effekten. Öffentliche Ausgabe ohne Editor-JavaScript.

Geprüft: 41 PHP-Tests / 155 Assertions, 10 JavaScript-Modelltests.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-12 10:19:05 +02:00

49 lines
2.6 KiB
JavaScript

import { chromium } from 'playwright';
import AxeBuilder from '@axe-core/playwright';
import assert from 'node:assert/strict';
import { mkdir, writeFile } from 'node:fs/promises';
const origin = process.env.CMS_URL || 'http://127.0.0.1:8080';
const browser = await chromium.launch();
await mkdir('reports', { recursive: true });
const results = [];
try {
for (const width of [1440, 390]) {
const context = await browser.newContext({ viewport: { width, height: 1000 } });
const page = await context.newPage();
const errors = [];
page.on('pageerror', error => errors.push(error.message));
for (const path of ['/', '/grundlagen', '/projektstand']) {
const response = await page.goto(origin + path);
assert.equal(response.status(), 200);
assert.equal(await page.locator('h1').count(), 1);
assert.equal(await page.locator('script').count(), 0);
assert(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth), 'Horizontal overflow');
const axe = await new AxeBuilder({ page }).withTags(['wcag2a', 'wcag2aa', 'wcag21aa', 'best-practice']).analyze();
assert.deepEqual(axe.violations.map(v => ({ id: v.id, nodes: v.nodes.map(n => n.target) })), []);
results.push({ width, path, violations: axe.violations.length, checks: axe.passes.length });
await page.screenshot({ path: `reports/${width}-${path === '/' ? 'home' : path.slice(1)}.png`, fullPage: true });
}
await page.goto(origin);
await page.keyboard.press('Tab');
assert.equal(await page.locator(':focus').innerText(), 'Zum Inhalt springen');
await page.keyboard.press('Enter');
assert.equal(await page.locator(':focus').getAttribute('id'), 'main');
await page.getByRole('link', { name: 'Die Grundlage entdecken' }).click();
assert.equal(new URL(page.url()).pathname, '/grundlagen');
await page.getByRole('link', { name: 'Projektstand' }).click();
assert.equal(new URL(page.url()).pathname, '/projektstand');
assert.deepEqual(errors, []);
await context.close();
}
const noJs = await browser.newPage({ javaScriptEnabled: false });
await noJs.goto(origin);
assert.match(await noJs.locator('h1').innerText(), /Deine Inhalte/);
await noJs.getByRole('link', { name: 'Die Grundlage entdecken' }).click();
assert.equal(new URL(noJs.url()).pathname, '/grundlagen');
await writeFile('reports/browser.json', JSON.stringify({ origin, results, keyboard: 'passed', noJavaScript: 'passed' }, null, 2));
console.log('Passed: 6 page/viewport accessibility checks, keyboard navigation, no-JS navigation.');
} finally {
await browser.close();
}