Files
coredns-web-ui/e2e/tests/accessibility.spec.ts
T
bryanpedini 57a005c19f test(e2e): add playwright harness and test stack
- test(e2e): add playwright harness and test stack
- test(e2e): add core flow
- fix(ui): preserve same-origin browser form submissions
- fix(ui): offer reload inside stale edit dialogs
- test(e2e): add persona session and accessibility suites
- test(e2e): preserve per-run artifacts and clean pulled images
- test(e2e): verify import and audit state across navigation
- test(e2e): tighten verification helpers and persona checks
- test(e2e): bound response body reads of the browser observer
- test: recover review compatibility assertions
- test: stabilize audit and user flow assertions
2026-11-19 15:46:12 +01:00

50 lines
2.4 KiB
TypeScript

// SPDX-License-Identifier: GPL-2.0-or-later
// Copyright (C) 2026 Bryan Joshua Pedini
import path from 'node:path';
import AxeBuilder from '@axe-core/playwright';
import { test, expect } from '../harness/fixtures';
import { SCREENSHOTS_DIR } from '../harness/env';
import { up } from '../harness/api';
import { addAddress, createZone } from '../harness/personas';
test.use({ group: 'a11y' });
test('all HTML pages meet axe severity limits in both themes and viewport sizes', async ({ world }) => {
test.setTimeout(240_000);
const admin = await world.bootstrapAdmin();
const api = await world.apiAs(admin);
const user = await world.createUser(api, 'user');
const zonePath = await createZone(api, world.zoneName());
await addAddress(api, zonePath, 'www', '192.0.2.15');
const userPath = up(user.username);
const adminPages = [
['zones', '/'], ['zone', zonePath], ['import', `${zonePath}/import`],
['audit', '/audit'], ['account', '/account'], ['users', '/users'], ['user', userPath],
];
for (const colorScheme of ['light', 'dark'] as const) {
for (const width of [360, 1440]) {
const opts = { colorScheme, viewport: { width, height: 900 } };
const assess = async (ui: Awaited<ReturnType<typeof world.ui>>, name: string, target: string, status = 200) => {
expect((await ui.goto(target))?.status(), target).toBe(status);
await expect(ui.page.getByRole('heading', { level: 1 })).toBeVisible();
const { violations } = await new AxeBuilder({ page: ui.page }).analyze();
const severe = violations.filter(({ impact }) => impact === 'serious' || impact === 'critical');
await ui.page.screenshot({ path: path.join(SCREENSHOTS_DIR, `${name}-${width}-${colorScheme}.png`), fullPage: true });
expect.soft(severe.map(({ id, nodes }) => ({ id, targets: nodes.map((n) => n.target) })), `${name} at ${width}px in ${colorScheme}`).toEqual([]);
};
const anon = await world.ui(opts);
await assess(anon, 'login', '/login');
await assess(anon, 'version', '/version');
await anon.close();
const adminUi = await world.uiAs(admin, opts);
for (const [name, target] of adminPages) await assess(adminUi, name, target);
await adminUi.close();
const userUi = await world.uiAs(user, opts);
await assess(userUi, 'forbidden', '/users', 403);
await assess(userUi, 'not-found', zonePath, 404);
await userUi.close();
}
}
});