From 7abcd5e26a2db2b50165e119b9094e2bf562acfb Mon Sep 17 00:00:00 2001 From: SnapOtter Date: Mon, 27 Apr 2026 21:51:56 +0800 Subject: [PATCH] test: add Playwright configs for landing and docs e2e tests --- package.json | 2 ++ playwright.docs.config.ts | 30 ++++++++++++++++++++++++++++++ playwright.landing.config.ts | 30 ++++++++++++++++++++++++++++++ tests/e2e-docs/.gitkeep | 0 tests/e2e-landing/.gitkeep | 0 5 files changed, 62 insertions(+) create mode 100644 playwright.docs.config.ts create mode 100644 playwright.landing.config.ts create mode 100644 tests/e2e-docs/.gitkeep create mode 100644 tests/e2e-landing/.gitkeep diff --git a/package.json b/package.json index e61dd426..08b3fee1 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,8 @@ "test:all": "vitest run --coverage && playwright test", "test:e2e": "playwright test", "test:e2e:ui": "playwright test --ui", + "test:e2e:landing": "playwright test --config playwright.landing.config.ts", + "test:e2e:docs": "playwright test --config playwright.docs.config.ts", "test:docker": "docker compose -f docker/docker-compose.test.yml up --build --abort-on-container-exit", "version:sync": "./scripts/sync-version.sh", "release": "semantic-release", diff --git a/playwright.docs.config.ts b/playwright.docs.config.ts new file mode 100644 index 00000000..e69f792d --- /dev/null +++ b/playwright.docs.config.ts @@ -0,0 +1,30 @@ +import { defineConfig, devices } from "@playwright/test"; + +const DOCS_PORT = 5173; + +export default defineConfig({ + testDir: "./tests/e2e-docs", + timeout: 30_000, + expect: { timeout: 10_000 }, + fullyParallel: true, + retries: 0, + workers: 1, + reporter: "html", + use: { + baseURL: `http://localhost:${DOCS_PORT}`, + screenshot: "only-on-failure", + trace: "retain-on-failure", + }, + projects: [ + { + name: "chromium", + use: { ...devices["Desktop Chrome"] }, + }, + ], + webServer: { + command: "pnpm --filter @snapotter/docs docs:dev", + port: DOCS_PORT, + reuseExistingServer: !process.env.CI, + timeout: 60_000, + }, +}); diff --git a/playwright.landing.config.ts b/playwright.landing.config.ts new file mode 100644 index 00000000..4bbc89da --- /dev/null +++ b/playwright.landing.config.ts @@ -0,0 +1,30 @@ +import { defineConfig, devices } from "@playwright/test"; + +const LANDING_PORT = 1350; + +export default defineConfig({ + testDir: "./tests/e2e-landing", + timeout: 30_000, + expect: { timeout: 10_000 }, + fullyParallel: true, + retries: 0, + workers: 1, + reporter: "html", + use: { + baseURL: `http://localhost:${LANDING_PORT}`, + screenshot: "only-on-failure", + trace: "retain-on-failure", + }, + projects: [ + { + name: "chromium", + use: { ...devices["Desktop Chrome"] }, + }, + ], + webServer: { + command: "pnpm --filter @snapotter/landing dev", + port: LANDING_PORT, + reuseExistingServer: !process.env.CI, + timeout: 60_000, + }, +}); diff --git a/tests/e2e-docs/.gitkeep b/tests/e2e-docs/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/tests/e2e-landing/.gitkeep b/tests/e2e-landing/.gitkeep new file mode 100644 index 00000000..e69de29b