Files
romm/frontend/playwright.config.ts
Georges-Antoine Assi 229da1ce6b ci(e2e): copy frontend/assets into the preview build (#5056)
* ci(e2e): copy frontend/assets into the preview build

The CI e2e run serves `vite build` output through `vite preview`, but the
build leaves out frontend/assets, which only the Docker image copies on top
of dist. Platform icons, logos, fonts and default covers came back as the
SPA fallback HTML. Copy the folder into dist the same way the image does.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* Address Greptile review: shorten the asset-copy comment

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-02 19:08:34 -04:00

80 lines
3.3 KiB
TypeScript

import { defineConfig, devices } from "@playwright/test";
// End-to-end suite.
// uv run python .github/scripts/seed_e2e_users.py # once, from the repo root
// npm run test:e2e
export default defineConfig({
testDir: "./e2e",
// Permission gating is global state on the server (the fixture users' grants),
// so the specs read it rather than mutate it and are safe to parallelise.
fullyParallel: true,
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 1,
// Every worker logs in and hammers ONE dev server, whose on-demand Vite
// transforms are the bottleneck. Too many workers turns real passes into
// timeouts, so keep the pool small.
workers: Number(process.env.E2E_WORKERS ?? 2),
reporter: process.env.CI ? "github" : "list",
timeout: 45_000,
expect: { timeout: 10_000 },
use: {
baseURL: process.env.E2E_BASE_URL ?? "http://localhost:3000",
trace: "retain-on-failure",
screenshot: "only-on-failure",
actionTimeout: 15_000,
navigationTimeout: 30_000,
// The production build ships a PWA service worker that precaches ~9MB on
// first load. Every test gets a fresh context, so that install would run
// over and over, competing with the app for the first navigation, and its
// cache makes runs non-deterministic. Nothing here tests offline support.
serviceWorkers: "block",
},
projects: [
// Logs each fixture user in once and saves the session; every spec then
// starts authenticated via `test.use({ storageState })` instead of driving
// the login form again. login.spec.ts is the one place the form itself is
// exercised, and it opts out by using a fresh page.
{
name: "setup",
testMatch: /.*\.setup\.ts/,
use: { ...devices["Desktop Chrome"] },
},
{
name: "chromium",
testIgnore: /.*\.setup\.ts/,
use: { ...devices["Desktop Chrome"] },
dependencies: ["setup"],
},
],
// Serve the app unless we were pointed at an instance that is already up
// (E2E_BASE_URL).
//
// CI builds and serves the STATIC bundle. The dev server compiles on demand,
// and force-reloads the page whenever it discovers a new dependency to
// pre-bundle ("optimized dependencies changed. reloading") -- which wipes
// whatever a test was mid-way through. Serving a build removes that entire
// class of failure and is much faster: the build is ~5s and the suite drops
// from ~3.7min to ~35s. `vite preview` inherits `server.proxy`, so /api and
// /ws still reach the backend on DEV_PORT (5000) -- the same default
// `main.py` binds, so neither side needs configuring.
//
// Locally it stays on the dev server: `reuseExistingServer` attaches to the
// `npm run dev` you already have, so a code change is picked up without a
// rebuild. `login()` retries to absorb the reload described above.
...(process.env.E2E_BASE_URL
? {}
: {
webServer: {
// Vite skips `assets/`; the Docker image copies it over `dist`, so do the same.
command: process.env.CI
? "npm run build && cp -R assets/. dist/assets/ && npm run preview -- --port 3000 --strictPort --host 127.0.0.1"
: "npm run dev",
url: "http://127.0.0.1:3000",
reuseExistingServer: !process.env.CI,
timeout: 180_000,
stdout: "pipe" as const,
stderr: "pipe" as const,
},
}),
});