Files
coredns-web-ui/e2e/harness/global-setup.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

34 lines
1.8 KiB
TypeScript

// SPDX-License-Identifier: GPL-2.0-or-later
// Copyright (C) 2026 Bryan Joshua Pedini
import fs from 'node:fs';
import path from 'node:path';
import { project, REPORTS_DIR, runDir, runSeed, SCREENSHOTS_DIR, secretsDir, SEEDS_DIR } from './env';
import { HarnessError } from './errors';
import { stackDown, stackUp } from './stack';
import { run } from './proc';
export default async function globalSetup(): Promise<void> {
const p = project();
const docker = await run('docker', ['version', '--format', '{{.Server.Version}}'], { timeoutMs: 30_000 }).catch(() => null);
if (!docker || docker.code !== 0) throw new HarnessError('prerequisite', 'the Docker socket is not reachable from the runner');
const compose = await run('docker', ['compose', 'version'], { timeoutMs: 30_000 }).catch(() => null);
if (!compose || compose.code !== 0) throw new HarnessError('prerequisite', 'docker compose is not available in the runner');
const dig = await run('dig', ['-v'], { timeoutMs: 30_000 }).catch(() => null);
if (!dig || dig.code !== 0) throw new HarnessError('prerequisite', 'dig is not available in the runner');
fs.rmSync(runDir(), { recursive: true, force: true });
fs.mkdirSync(secretsDir(), { recursive: true, mode: 0o700 });
for (const dir of [REPORTS_DIR, SCREENSHOTS_DIR, SEEDS_DIR]) fs.mkdirSync(dir, { recursive: true });
fs.writeFileSync(
path.join(REPORTS_DIR, 'run.json'),
JSON.stringify({ project: p, seed: runSeed(), appImage: process.env.E2E_APP_IMAGE ?? null, startedAt: new Date().toISOString() }, null, 2),
);
console.log(`[cdwu-e2e] run ${p} seed ${JSON.stringify(runSeed())} (reproduce with E2E_SEED)`);
try {
await stackUp((line) => console.log(`[cdwu-e2e] ${line}`));
} catch (e) {
await stackDown().catch(() => undefined);
throw e;
}
}