test(e2e): add global setup, sign-in helpers and authenticated page tests
All checks were successful
Build and Push Container Image / build-and-push (push) Successful in 8m45s

This commit is contained in:
2026-06-24 16:23:20 +02:00
committed by Milas Holsting
parent 9141fe4f09
commit 7701ec5a7e
4 changed files with 212 additions and 1 deletions

24
tests/e2e/global-setup.ts Normal file
View File

@@ -0,0 +1,24 @@
import { spawnSync } from "node:child_process";
const port = process.env.PORT ?? "3100";
export default function globalSetup() {
if (process.env.PLAYWRIGHT_BASE_URL !== undefined) {
return;
}
const username = process.env.E2E_USERNAME ?? "e2e@example.com";
const password = process.env.E2E_PASSWORD ?? "e2e-password";
const databaseFile = process.env.DATABASE_FILE ?? `/tmp/mal-e2e-${port}.db`;
const result = spawnSync("go", ["run", "./cmd/user", username, password], {
env: { ...process.env, DATABASE_FILE: databaseFile, GIN_MODE: "test" },
input: "y\n",
stdio: ["pipe", "pipe", "pipe"],
encoding: "utf8",
});
if (result.status !== 0) {
throw new Error(`Failed to seed e2e user:\n${result.stderr || result.stdout}`);
}
}