mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2026-09-03 05:10:16 +03:00
# Description of Changes <!-- Please provide a summary of the changes, including: - What was changed - Why the change was made - Any challenges encountered Closes #(issue_number) --> --- ## Checklist ### General - [ ] I have read the [Contribution Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md) - [ ] I have read the [Stirling-PDF Developer Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/DeveloperGuide.md) (if applicable) - [ ] I have read the [How to add new languages to Stirling-PDF](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md) (if applicable) - [ ] I have performed a self-review of my own code - [ ] My changes generate no new warnings ### Documentation - [ ] I have updated relevant docs on [Stirling-PDF's doc repo](https://github.com/Stirling-Tools/Stirling-Tools.github.io/blob/main/docs/) (if functionality has heavily changed) - [ ] I have read the section [Add New Translation Tags](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md#add-new-translation-tags) (for new translation tags only) ### Translations (if applicable) - [ ] I ran [`scripts/counter_translation.py`](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/docs/counter_translation.md) ### UI Changes (if applicable) - [ ] Screenshots or videos demonstrating the UI changes are attached (e.g., as comments or direct attachments in the PR) ### Testing (if applicable) - [ ] I have run `task check` to verify linters, typechecks, and tests pass - [ ] I have tested my changes locally. Refer to the [Testing Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/DeveloperGuide.md#7-testing) for more details.
138 lines
4.7 KiB
TypeScript
138 lines
4.7 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
|
|
*/
|
|
/** 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,
|
|
};
|
|
|
|
// Dedicated dev-server port via V2_PORT so local runs don't collide with a
|
|
// vite already on 5173 from other parallel work. Defaults to 5173.
|
|
const DEV_PORT = process.env.V2_PORT ?? "5173";
|
|
|
|
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:${DEV_PORT}`,
|
|
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",
|
|
// Desktop Safari ships deviceScaleFactor 2; the editor now renders
|
|
// bitmaps at dpr x zoom, so leaving it would 4x every page raster in
|
|
// this suite. The HiDPI spec opts into 2x deliberately where it matters.
|
|
use: {
|
|
...devices["Desktop Safari"],
|
|
viewport: STUBBED_VIEWPORT,
|
|
deviceScaleFactor: 1,
|
|
},
|
|
},
|
|
],
|
|
|
|
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 ${DEV_PORT} --strictPort`
|
|
: `npx vite --port ${DEV_PORT} --strictPort`,
|
|
url: `http://localhost:${DEV_PORT}`,
|
|
reuseExistingServer: !process.env.CI,
|
|
timeout: 120_000,
|
|
},
|
|
});
|