ktg-plugin-marketplace/plugins/voyage/tests/e2e/voyage-playground-network.spec.mjs
Kjell Tore Guttormsen 067d9ab245 test(voyage): add e2e Playwright + axe-core specs (a11y + network) [skip-docs]
Step 30 of v4.3 plan — Wave 7 Group D:
- voyage-playground-a11y.spec.mjs (3 tests): light + dark theme axe-core
  scans (compared against baseline JSON, fails only on NEW or GROWN
  violations) + pixel-diff smoke for SC1 (light + dark, 1280x900,
  maxDiffPixelRatio=0.02).
- voyage-playground-network.spec.mjs (1 test): SC7 authoritative gate via
  page.on('request') instrument — verifies zero external (http/https/ws)
  requests during page load.
- playwright.config.mjs: snapshotPathTemplate routes to tests/e2e/snapshots/
  (matches Step 31 expected_paths).

Baseline policy: HTML is FROZEN in Sesjon 6 (Wave 7 = verification, not
fix). Existing critical/serious WCAG violations (aria-hidden-focus +
color-contrast) recorded in tests/e2e/snapshots/a11y-baseline.json as
delta-baseline. Actual a11y fix deferred to v4.4.

Verify: npm run test:e2e -> 4 passed (3 a11y + 1 network).
2026-05-10 18:22:52 +02:00

33 lines
1.4 KiB
JavaScript

// tests/e2e/voyage-playground-network.spec.mjs
// v4.3 Step 30 — Group D SC7 authoritative network-intercept gate.
//
// Instruments page.on('request', ...) to capture every outbound request
// during playground load. Allowlist: nothing (zero external requests).
// All assets MUST be bundled locally (./lib/, ./vendor/, file://...).
//
// Why authoritative: voyage-playground.test.mjs already greps the static
// HTML for http/https URLs (Step 28 SC7), but a runtime intercept also
// catches fetch()/XHR/import calls that are constructed dynamically.
import { test, expect } from '@playwright/test';
test.describe('voyage-playground network — SC7 zero external requests', () => {
test('no http/https requests during page load', async ({ page }) => {
const externalRequests = [];
page.on('request', (request) => {
const url = request.url();
// file:// URLs are local — playground is loaded via file:// baseURL
if (url.startsWith('file://') || url.startsWith('data:') || url.startsWith('blob:')) {
return;
}
// Anything else is external (http://, https://, ws://, ftp://, etc.)
externalRequests.push({ url, method: request.method(), resourceType: request.resourceType() });
});
await page.goto('voyage-playground.html');
await page.waitForLoadState('networkidle');
expect(externalRequests, JSON.stringify(externalRequests, null, 2)).toEqual([]);
});
});