Public source validation / validate (push) Failing after 3m8s
30 lines
1.8 KiB
TypeScript
30 lines
1.8 KiB
TypeScript
import AxeBuilder from '@axe-core/playwright';
|
|
import { expect, test } from '@playwright/test';
|
|
import path from 'node:path';
|
|
|
|
const enabled = Boolean(process.env.PULSE_E2E_REAL_BASE_URL);
|
|
const coreRoutes = ['/', '/host', '/containers', '/storage', '/services', '/alerts', '/incidents', '/inventory'];
|
|
|
|
test('core routes remain accessible, bounded and visually stable', async ({ page }, testInfo) => {
|
|
test.skip(!enabled, 'Requires the isolated server-built Pulse stack.');
|
|
const errors: string[] = [];
|
|
page.on('console', (message) => { if (message.type() === 'error') errors.push(message.text()); });
|
|
page.on('pageerror', (error) => errors.push(error.message));
|
|
expect((await page.request.get('/auth/test-login')).ok()).toBeTruthy();
|
|
|
|
const routes = testInfo.project.name === 'wallboard-chromium' ? ['/wallboard'] : coreRoutes;
|
|
for (const route of routes) {
|
|
await page.goto(route);
|
|
await expect(page.getByRole('heading', { level: 1 }).first()).toBeVisible();
|
|
expect(await page.evaluate(() => document.documentElement.scrollWidth <= window.innerWidth + 1), `${route} has document overflow`).toBe(true);
|
|
if (route === '/wallboard') expect(await page.evaluate(() => document.documentElement.scrollHeight <= window.innerHeight + 1), `${route} has vertical overflow`).toBe(true);
|
|
const axe = await new AxeBuilder({ page }).analyze();
|
|
expect(axe.violations.filter((item) => item.impact === 'critical' || item.impact === 'serious'), `${route} axe findings`).toEqual([]);
|
|
if (process.env.PULSE_CAPTURE_VISUALS && (route === '/' || route === '/services' || route === '/wallboard')) {
|
|
const name = route === '/' ? 'overview' : route.slice(1);
|
|
await page.screenshot({ path: path.resolve('../../artifacts/evidence/M11-10', `${name}-${testInfo.project.name}.png`), fullPage: true });
|
|
}
|
|
}
|
|
expect(errors, errors.join('\n')).toEqual([]);
|
|
});
|