- 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
121 lines
3.8 KiB
TypeScript
121 lines
3.8 KiB
TypeScript
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
// Copyright (C) 2026 Bryan Joshua Pedini
|
|
|
|
import os from 'node:os';
|
|
import path from 'node:path';
|
|
import { HarnessError } from './errors';
|
|
|
|
export const RESOURCE_PREFIX = 'cdwu-e2e-';
|
|
export const RUN_LABEL = 'cdwu.e2e.run';
|
|
export const COMPOSE_FILE = path.resolve(process.cwd(), 'compose.yaml');
|
|
export const REPORTS_DIR = path.resolve(process.cwd(), 'reports');
|
|
export const SCREENSHOTS_DIR = path.join(REPORTS_DIR, 'screenshots');
|
|
export const SEEDS_DIR = path.join(REPORTS_DIR, 'failing-seeds');
|
|
export const DEFAULT_SEED = 'cdwu-e2e-default-seed-1';
|
|
export const MYSQL_HOST = 'mysql';
|
|
export const COREDNS_HOST = 'coredns';
|
|
export const ORIGIN2_URL = 'http://origin2:8081';
|
|
export const SESSION_COOKIE = 'coredns_webui_session';
|
|
|
|
export type GroupName = 'harness' | 'core' | 'session' | 'power' | 'stupid' | 'malicious' | 'fuzzer' | 'operator' | 'a11y';
|
|
|
|
export interface GroupConfig {
|
|
name: GroupName;
|
|
service: string;
|
|
database: string;
|
|
prefix: string;
|
|
appUser: string;
|
|
appPassword: string;
|
|
dnsUser: string;
|
|
dnsPassword: string;
|
|
dnsPort: number;
|
|
baseURL: string;
|
|
idleTimeoutMs: number;
|
|
maxAgeMs: number;
|
|
trustedProxies: string;
|
|
logLevel: string;
|
|
}
|
|
|
|
function group(name: GroupName, dnsPort: number, extra: Partial<GroupConfig> = {}): GroupConfig {
|
|
return {
|
|
name,
|
|
service: `app-${name}`,
|
|
database: `e2e_${name}`,
|
|
prefix: 'coredns_',
|
|
appUser: `webui_${name}`,
|
|
appPassword: `webui-${name}-e2e-pass`,
|
|
dnsUser: `dns_${name}`,
|
|
dnsPassword: `dns-${name}-e2e-pass`,
|
|
dnsPort,
|
|
baseURL: `http://app-${name}:8080`,
|
|
idleTimeoutMs: 3600_000,
|
|
maxAgeMs: 12 * 3600_000,
|
|
trustedProxies: '',
|
|
logLevel: 'DEBUG',
|
|
...extra,
|
|
};
|
|
}
|
|
|
|
export const GROUPS: Readonly<Record<GroupName, GroupConfig>> = {
|
|
harness: group('harness', 5300),
|
|
core: group('core', 5301),
|
|
session: group('session', 5302, { idleTimeoutMs: 60_000, maxAgeMs: 180_000 }),
|
|
power: group('power', 5303),
|
|
stupid: group('stupid', 5304),
|
|
malicious: group('malicious', 5305, { prefix: 'e2e_', logLevel: 'TRACE', trustedProxies: '192.0.2.0/24' }),
|
|
fuzzer: group('fuzzer', 5306, { logLevel: 'TRACE' }),
|
|
operator: group('operator', 5307),
|
|
a11y: group('a11y', 5308),
|
|
};
|
|
|
|
export const GROUP_NAMES = Object.keys(GROUPS) as GroupName[];
|
|
|
|
export function requireEnv(name: string): string {
|
|
const value = process.env[name];
|
|
if (!value) throw new HarnessError('prerequisite', `environment variable ${name} is required (run the suite through scripts/test-e2e.sh)`);
|
|
return value;
|
|
}
|
|
|
|
export function project(): string {
|
|
const p = requireEnv('E2E_PROJECT');
|
|
if (!p.startsWith(RESOURCE_PREFIX) || !/^[a-z0-9][a-z0-9_-]*$/.test(p)) {
|
|
throw new HarnessError('prerequisite', `E2E_PROJECT must start with ${RESOURCE_PREFIX} and be a valid compose project name`);
|
|
}
|
|
return p;
|
|
}
|
|
|
|
export function containerName(service: string): string {
|
|
return `${project()}-${service}`;
|
|
}
|
|
|
|
export function runSeed(): string {
|
|
return process.env.E2E_SEED || DEFAULT_SEED;
|
|
}
|
|
|
|
export function runDir(): string {
|
|
return path.join(os.tmpdir(), `${project()}-run`);
|
|
}
|
|
|
|
export function secretsDir(): string {
|
|
return path.join(runDir(), 'secrets');
|
|
}
|
|
|
|
export function intEnv(name: string, fallback: number): number {
|
|
const v = process.env[name];
|
|
if (!v) return fallback;
|
|
const n = Number(v);
|
|
if (!Number.isInteger(n) || n < 1) throw new HarnessError('prerequisite', `${name} must be a positive integer`);
|
|
return n;
|
|
}
|
|
|
|
export function runnerAddress(): string {
|
|
const fromEnv = process.env.E2E_RUNNER_IP;
|
|
if (fromEnv) return fromEnv;
|
|
for (const list of Object.values(os.networkInterfaces())) {
|
|
for (const addr of list ?? []) {
|
|
if (addr.family === 'IPv4' && !addr.internal) return addr.address;
|
|
}
|
|
}
|
|
throw new HarnessError('prerequisite', 'cannot determine the runner address on the stack network');
|
|
}
|