2026-07-27 15:37:30 +08:00
|
|
|
import { randomBytes } from "node:crypto";
|
2026-04-23 10:58:56 +08:00
|
|
|
import path from "node:path";
|
|
|
|
|
import { defineConfig, devices } from "@playwright/test";
|
|
|
|
|
|
2026-07-27 15:37:30 +08:00
|
|
|
function resolveRunId(): string {
|
|
|
|
|
const runId = process.env.PLAYWRIGHT_RUN_ID ?? `${process.pid}_${randomBytes(4).toString("hex")}`;
|
|
|
|
|
if (!/^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/.test(runId)) {
|
|
|
|
|
throw new Error(
|
|
|
|
|
`PLAYWRIGHT_RUN_ID must be 1-64 letters, digits, underscores, or hyphens and start with a letter or digit, received ${JSON.stringify(runId)}`,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
process.env.PLAYWRIGHT_RUN_ID = runId;
|
|
|
|
|
return runId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const runId = resolveRunId();
|
|
|
|
|
const runRoot = path.join(__dirname, "test-results", "e2e-docker-runs", runId);
|
|
|
|
|
const authFile = path.join(runRoot, "auth", "analytics-user.json");
|
|
|
|
|
process.env.PLAYWRIGHT_RUN_ROOT = runRoot;
|
|
|
|
|
process.env.PLAYWRIGHT_AUTH_FILE = authFile;
|
2026-04-23 10:58:56 +08:00
|
|
|
|
|
|
|
|
const baseURL = process.env.BASE_URL ?? "http://localhost:1349";
|
2026-07-27 15:37:30 +08:00
|
|
|
process.env.API_URL = baseURL;
|
2026-04-23 10:58:56 +08:00
|
|
|
|
|
|
|
|
export default defineConfig({
|
|
|
|
|
testDir: "./tests/e2e-docker",
|
|
|
|
|
timeout: 120_000,
|
|
|
|
|
expect: {
|
|
|
|
|
timeout: 30_000,
|
|
|
|
|
},
|
|
|
|
|
fullyParallel: false,
|
|
|
|
|
retries: 0,
|
|
|
|
|
workers: 1,
|
2026-07-27 15:37:30 +08:00
|
|
|
outputDir: path.join(runRoot, "playwright-output"),
|
|
|
|
|
reporter: [
|
|
|
|
|
["html", { open: "never", outputFolder: path.join(runRoot, "playwright-report") }],
|
|
|
|
|
["list"],
|
|
|
|
|
],
|
2026-04-23 10:58:56 +08:00
|
|
|
use: {
|
|
|
|
|
baseURL,
|
|
|
|
|
screenshot: "only-on-failure",
|
|
|
|
|
trace: "retain-on-failure",
|
|
|
|
|
},
|
|
|
|
|
projects: [
|
|
|
|
|
{
|
|
|
|
|
name: "setup",
|
2026-07-27 15:37:30 +08:00
|
|
|
testMatch: /(?:^|[/\\])auth\.setup\.ts$/,
|
2026-04-23 10:58:56 +08:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "chromium",
|
|
|
|
|
use: {
|
|
|
|
|
...devices["Desktop Chrome"],
|
|
|
|
|
storageState: authFile,
|
|
|
|
|
},
|
|
|
|
|
dependencies: ["setup"],
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
export { authFile };
|