-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Expand file tree
/
Copy pathplaywright.config.ts
More file actions
126 lines (115 loc) · 4.16 KB
/
Copy pathplaywright.config.ts
File metadata and controls
126 lines (115 loc) · 4.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
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
*/
/** Shared by every stubbed project so a spec sees one layout on all engines. */
const STUBBED_VIEWPORT = { width: 1920, height: 1080 };
const chromiumViewport = {
...devices["Desktop Chrome"],
viewport: STUBBED_VIEWPORT,
};
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%",
// In CI, add a JSON report alongside the HTML/list output so the workflow
// can flag flaky tests (passed only on retry) as warnings without failing
// the job. Path is pinned via PLAYWRIGHT_JSON_OUTPUT_FILE in the workflow;
// the outputFile here is just a sane default. Omitted locally to keep dev
// runs' terminal output clean.
reporter: process.env.CI
? [
["html", { open: "never" }],
["list"],
["json", { outputFile: "playwright-report/results.json" }],
]
: [["html", { open: "never" }], ["list"]],
timeout: 60_000,
expect: { timeout: 10_000 },
use: {
baseURL: process.env.PLAYWRIGHT_BASE_URL ?? "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. The chromium arm of the cross-browser
// set below; CI fans all three out, one job per engine.
{
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. Same viewport as `stubbed`,
// or a layout difference here reads as an engine outage.
{
name: "stubbed-firefox",
testDir: "./src/core/tests/stubbed",
use: { ...devices["Desktop Firefox"], viewport: STUBBED_VIEWPORT },
},
{
name: "stubbed-webkit",
testDir: "./src/core/tests/stubbed",
use: { ...devices["Desktop Safari"], viewport: STUBBED_VIEWPORT },
},
],
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,
},
});