mirror of
https://github.com/arsvendg/Stirling-PDF.git
synced 2026-07-14 18:44:05 +02:00
## Description Consolidates Playwright running under cohesive Task namespaces, isolates Playwright state from the developer's local working tree, and swaps CI's frontend webserver from `vite` dev to `vite preview` against a pre-built `dist/`. ### `e2e:*` namespace Renames `.taskfiles/testing.yml` to `.taskfiles/e2e.yml` and consolidates everything Playwright-related under one `e2e:` namespace: - `e2e:stubbed` / `e2e:live` / `e2e:enterprise` / `e2e:cross-browser`: project-specific runners - `e2e:check` (no-Docker subset) and `e2e:check:all` (full) - `e2e:oauth:up` / `:down`, `e2e:saml:up` / `:down`: symmetric lifecycle for the keycloak compose stacks - `e2e:install`: Playwright browser install - `docker:test`: full Docker integration suite The redundant `frontend:test:e2e:*` project shortcuts are removed. CI workflows (`e2e-stubbed.yml`, `e2e-live.yml`, `build-enterprise.yml`, `nightly.yml`) are updated to call the new task names. ### Isolated Playwright state New `STIRLING_BASE_PATH` (and `-Dstirling.base-path=`) override in `InstallationPathConfig` redirects the entire state tree (configs, backups, customFiles, pipeline, logs) at startup. `task e2e:live` points it at `.test-state/playwright/` (purged on every invocation) so the suite never touches the developer's local DB, settings.yml or backups. `task e2e:live` auto-spawns gradle, waits for `/api/v1/info/status` to come up, runs Playwright, then tears down the whole backend process tree. ### CI runs Playwright against `vite preview` Builds the frontend up-front with `VITE_BUILD_FOR_PREVIEW=1` (forces absolute base so deep SPA routes resolve `/assets/...`) and the playwright `webServer` now uses `vite preview --port 5173 --strictPort` in CI. Avoids the per-page on-demand transform cost that was blowing the 30s navigation timeout under `--workers=3` on `all-tool-pages-load.spec.ts`. Local dev keeps `vite` dev for HMR. ### OAuth/SAML compose helpers `start-oauth-test.sh` and `start-saml-test.sh` gain a `--license-key <KEY>` (`-k`) flag so CI and scripted runs can skip the interactive license prompt. `start-oauth-test.sh` also moves from `for arg in "$@"` to a `while`-with-`shift` arg loop to support multi-arg flags consistently with the SAML script. ### Backend gradlew unification Drops the per-platform `cmd /c gradlew.bat` branches from `backend.yml` and routes every gradle invocation through `bash gradlew`. Works uniformly on Linux/macOS and Windows-with-Git-Bash. ### Compare.tsx flake fix (re-land of [#6316](https://github.com/Stirling-Tools/Stirling-PDF/pull/6316)) Piggybacks Anthony's never-merged fix from #6316. Without it, `e2e:stubbed` continues to flake under `--workers=3` on `compare.spec.ts`'s second-upload case via a React "Maximum update depth exceeded" infinite loop in the Compare auto-fill effect. CI traces from recent failed runs match exactly; 10 local runs of `compare.spec.ts` with `CI=1 --workers=3` pass cleanly with the fix applied. --------- Co-authored-by: James Brunton <[email protected]>
111 lines
3.3 KiB
TypeScript
111 lines
3.3 KiB
TypeScript
import { defineConfig, devices } from "@playwright/test";
|
|
|
|
/**
|
|
* Stirling-PDF E2E Test Configuration
|
|
*
|
|
* The suite is split into two projects:
|
|
* - `stubbed` — backend-free specs that mock `/api/v1/*` via `page.route()`.
|
|
* Safe to run in CI without the Spring Boot server. Lives in
|
|
* `src/core/tests/stubbed/**`.
|
|
* - `live` — specs that require a real backend on `localhost:8080`
|
|
* (auth, admin mutation, real tool round-trips). Lives in
|
|
* `src/core/tests/live/**`.
|
|
*
|
|
* Run one:
|
|
* npx playwright test --project=stubbed
|
|
* npx playwright test --project=live
|
|
*
|
|
* @see https://playwright.dev/docs/test-configuration
|
|
*/
|
|
const chromiumViewport = {
|
|
...devices["Desktop Chrome"],
|
|
viewport: { width: 1920, height: 1080 },
|
|
};
|
|
|
|
export default defineConfig({
|
|
testDir: "./src/core/tests",
|
|
testMatch: "**/*.spec.ts",
|
|
|
|
fullyParallel: true,
|
|
forbidOnly: !!process.env.CI,
|
|
retries: process.env.CI ? 2 : 0,
|
|
workers: process.env.CI ? 1 : "50%",
|
|
reporter: [["html", { open: "never" }], ["list"]],
|
|
timeout: 60_000,
|
|
expect: { timeout: 10_000 },
|
|
|
|
use: {
|
|
baseURL: "http://localhost:5173",
|
|
trace: "on-first-retry",
|
|
screenshot: "only-on-failure",
|
|
video: "on-first-retry",
|
|
actionTimeout: 10_000,
|
|
navigationTimeout: 30_000,
|
|
},
|
|
|
|
projects: [
|
|
// Stubbed — no backend required, chromium-only for CI speed
|
|
{
|
|
name: "stubbed",
|
|
testDir: "./src/core/tests/stubbed",
|
|
use: chromiumViewport,
|
|
},
|
|
|
|
// Live setup — runs once before the live suite to perform the real
|
|
// forced-password-change first-login flow against a freshly-booted
|
|
// backend. The live project depends on it.
|
|
{
|
|
name: "live-setup",
|
|
testDir: "./src/core/tests/live-setup",
|
|
testMatch: /.*\.setup\.ts$/,
|
|
use: chromiumViewport,
|
|
},
|
|
|
|
// Live backend — auth + admin-mutation + real-tool smoke
|
|
{
|
|
name: "live",
|
|
testDir: "./src/core/tests/live",
|
|
use: chromiumViewport,
|
|
dependencies: ["live-setup"],
|
|
},
|
|
|
|
// Enterprise — license-gated SSO/SAML/audit/teams against keycloak compose
|
|
// Uses port 8080 directly (the docker compose stack publishes the
|
|
// backend's built-in frontend there); the Vite dev server is bypassed
|
|
// because the OAuth/SAML callback URLs are registered against 8080.
|
|
{
|
|
name: "enterprise",
|
|
testDir: "./src/core/tests/enterprise",
|
|
use: {
|
|
...chromiumViewport,
|
|
baseURL: "http://localhost:8080",
|
|
},
|
|
},
|
|
|
|
// Cross-browser coverage for the stubbed suite (opt-in locally)
|
|
{
|
|
name: "stubbed-firefox",
|
|
testDir: "./src/core/tests/stubbed",
|
|
use: { ...devices["Desktop Firefox"] },
|
|
},
|
|
{
|
|
name: "stubbed-webkit",
|
|
testDir: "./src/core/tests/stubbed",
|
|
use: { ...devices["Desktop Safari"] },
|
|
},
|
|
],
|
|
|
|
webServer: {
|
|
// In CI, serve a pre-built `dist/` via `vite preview` so the heavy tool
|
|
// pages don't pay vite's on-demand transform cost on first hit (which
|
|
// blew the 30s navigationTimeout under --workers=3 — see
|
|
// all-tool-pages-load.spec.ts). Locally, keep `vite` dev for HMR.
|
|
command: process.env.CI
|
|
? "npx vite preview --port 5173 --strictPort"
|
|
: "npx vite",
|
|
url: "http://localhost:5173",
|
|
reuseExistingServer: !process.env.CI,
|
|
timeout: 120_000,
|
|
},
|
|
});
|