Files
nginx-ui/e2e/playwright.config.ts
0xJacky c00aa9513a test(demo): add an end-to-end suite for the public demo
The demo now fabricates most of what it shows — geo lookups, upstream and site
probes, connection counters, DNS records, a synthetic access log — and refuses
a set of routes outright. Nothing verified that any of it actually reaches the
screen, so a provider could silently stop being installed and every page would
still look plausible.

Eleven Playwright specs, split into per-module data assertions and the
cross-cutting guardrails: /api/pty returns the typed demo refusal rather than a
404 or a successful upgrade, the simulated shell answers `help` and `nginx -t`
without opening a WebSocket, and the destructive routes return code 40300.

Kept as its own top-level package rather than joining the app/ Bun workspace,
so the frontend build is untouched. Not wired into CI yet: it needs a running
container, and the job shape is worth deciding separately.

Also hides the Preference > Terminal tab in demo mode, which the terminal work
had specified but never implemented — the tab was still reachable and led to a
panel with nothing behind it. The tab renders only once the demo flag has
resolved, so a normal installation is unaffected.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-02 11:18:25 +08:00

43 lines
955 B
TypeScript

import { defineConfig, devices } from '@playwright/test'
import { fileURLToPath } from 'node:url'
const authState = fileURLToPath(new URL('./playwright/.auth/admin.json', import.meta.url))
export default defineConfig({
testDir: './tests',
fullyParallel: false,
timeout: 90_000,
expect: {
timeout: 20_000,
},
forbidOnly: Boolean(process.env.CI),
retries: process.env.CI ? 1 : 0,
workers: 1,
reporter: [
['line'],
['html', { open: 'never' }],
],
use: {
baseURL: process.env.E2E_BASE_URL ?? 'http://127.0.0.1:18110',
screenshot: 'only-on-failure',
trace: 'retain-on-failure',
video: 'retain-on-failure',
viewport: { width: 1440, height: 1000 },
},
projects: [
{
name: 'setup',
testMatch: /.*\.setup\.ts/,
},
{
name: 'chromium',
use: {
...devices['Desktop Chrome'],
storageState: authState,
},
dependencies: ['setup'],
},
],
})