Repository navigation
Expand file tree
/
Copy pathplaywright.config.js
More file actions
78 lines (75 loc) · 2.52 KB
/
Copy pathplaywright.config.js
File metadata and controls
78 lines (75 loc) · 2.52 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
// playwright.config.js
//
// Smoke-test config for the DashClaw dashboard. Runs a headless Chromium
// against a dedicated demo-mode dev server on port 3099, separate from any
// dev server the operator might be running on 3000.
//
// Usage:
// npm run test:smoke # headless, full sweep
// npm run test:smoke -- --headed # watch it navigate
// PW_BASE_URL=https://stage.example.com npm run test:smoke # against staging
import { defineConfig, devices } from '@playwright/test';
const SMOKE_PORT = Number(process.env.PW_SMOKE_PORT || 3099);
const BASE_URL = process.env.PW_BASE_URL || `http://localhost:${SMOKE_PORT}`;
// When PW_BASE_URL is set, we assume an already-deployed target (staging/prod)
// and skip the local webServer boot.
const REMOTE_TARGET = Boolean(process.env.PW_BASE_URL);
export default defineConfig({
testDir: './tests/smoke',
fullyParallel: true,
forbidOnly: Boolean(process.env.CI),
retries: process.env.CI ? 1 : 0,
workers: process.env.CI ? 2 : undefined,
reporter: [
['list'],
['html', { outputFolder: 'playwright-report', open: 'never' }],
],
use: {
baseURL: BASE_URL,
trace: 'retain-on-failure',
screenshot: 'only-on-failure',
video: 'retain-on-failure',
// Demo-mode cookie unlocks dashboard routes without requiring a real
// NextAuth session. Valid for 1 year per app/demo/route.js convention.
storageState: {
cookies: [
{
name: 'dashclaw_demo',
value: '1',
domain: 'localhost',
path: '/',
expires: Math.floor(Date.now() / 1000) + 60 * 60 * 24 * 365,
httpOnly: false,
secure: false,
sameSite: 'Lax',
},
],
origins: [],
},
},
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},
],
webServer: REMOTE_TARGET
? undefined
: {
// Demo mode — fixture data, no login required, writes return 403.
// Ensures every dashboard route has something to render even on a
// fresh clone with no DB. Uses the dedicated `dev:smoke` script on
// port 3099 so it can't collide with a regular `npm run dev` the
// operator may already have running on 3000.
command: 'npm run dev:smoke',
url: `${BASE_URL}/api/health`,
timeout: 120_000,
reuseExistingServer: !process.env.CI,
stdout: 'ignore',
stderr: 'pipe',
env: {
DASHCLAW_MODE: 'demo',
NEXT_PUBLIC_DASHCLAW_MODE: 'demo',
},
},
});