exifcleaner-web/playwright.config.ts
forgejo_admin 92278e5174
Some checks failed
CI / Lint, Typecheck & Unit Tests (push) Failing after 34s
CI / E2E (Web) (push) Has been skipped
CI / E2E (Standalone single-file) (push) Has been skipped
feat(diff): detailed before/after metadata diff — surface + JPEG (#22) (#119)
2026-05-15 15:52:14 +04:00

86 lines
2.9 KiB
TypeScript

import path from "node:path";
import { fileURLToPath } from "node:url";
import { defineConfig, devices } from "@playwright/test";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
// Absolute file:// URL of the inlined single-file build. Used as `baseURL` for
// the standalone-* projects so `page.goto("")` resolves to the index.html and
// `launchPage()` works without per-spec branching. The build itself is chained
// via `yarn test:e2e:standalone`.
const standaloneIndexUrl = `file://${path.resolve(__dirname, "dist/web-standalone/index.html")}`;
export default defineConfig({
testMatch: "*.spec.ts",
timeout: 15000,
retries: process.env.CI ? 1 : 0,
workers: 1,
reporter: [["html", { open: "never" }]],
use: {
trace: "retain-on-failure",
},
webServer: {
command: "yarn build:web && yarn preview:web --port 4173 --strictPort",
url: "http://localhost:4173",
reuseExistingServer: !process.env.CI,
timeout: 120_000,
},
projects: [
{
name: "web-desktop",
testDir: "./tests/e2e/web",
use: { ...devices["Desktop Chrome"], baseURL: "http://localhost:4173", locale: "en-US" },
},
{
name: "web-mobile-ios",
testDir: "./tests/e2e/web",
use: { ...devices["iPhone 14"], baseURL: "http://localhost:4173", locale: "en-US" },
},
{
name: "web-mobile-android",
testDir: "./tests/e2e/web",
use: { ...devices["Pixel 7"], baseURL: "http://localhost:4173", locale: "en-US" },
},
// Standalone projects: load `dist/web-standalone/index.html` via file://.
// Two viewports because the standalone HTML is the *primary* distribution
// channel — it must work for the same desktop + mobile audiences as the
// hosted web build. The smoke specs in `tests/e2e/standalone/` exercise
// the inlined-bundle guarantees (single file, zero outbound requests);
// `metadata_diff.spec.ts` from tests/e2e/web/ is matched in via
// testMatch so the diff UX is verified against the inlined bundle too.
// The webServer above still launches when these projects run alone —
// harmless waste since file:// navigation never hits it.
{
name: "standalone-desktop",
testDir: "./tests/e2e",
testMatch: [
"standalone/**/*.spec.ts",
"web/metadata_diff.spec.ts",
],
use: {
...devices["Desktop Chrome"],
baseURL: standaloneIndexUrl,
locale: "en-US",
},
},
{
// Pixel 7 (Chromium-based Android emulation), not iPhone 14 (WebKit).
// The CI's `e2e-standalone` job installs Chromium only to stay cheap;
// WebKit coverage of the diff feature lives on `web-mobile-ios` against
// the hosted build. Standalone HTML renders identically in both engines
// (no service worker / PWA differences), so the narrow-viewport CSS
// guard is engine-agnostic.
name: "standalone-mobile",
testDir: "./tests/e2e",
testMatch: ["web/metadata_diff.spec.ts"],
use: {
...devices["Pixel 7"],
baseURL: standaloneIndexUrl,
locale: "en-US",
},
},
],
});