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
All checks were successful
Build and Push Container Image / build-and-push (push) Successful in 8m45s
This commit is contained in:
24
tests/e2e/global-setup.ts
Normal file
24
tests/e2e/global-setup.ts
Normal 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}`);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user