新增 e2e/global-setup.ts:用 pg 直连真实 PG(凭据从 infra.env 环境变量读,不入库)幂等复位 graph/confirm-draft/accept(block3→rev1)/security-ack(事件→未确认+清 ack)/appeal(→supplementing)等每轮被消费的 fixture;playwright.config 接 globalSetup + workers:1(共享活体 DB 串行避竞态)。 证:消费态下 source infra.env 后 pnpm 直跑整套→globalSetup 复位→20/20 单次全绿,零手工种子(反假绿可复现)。E2E_SKIP_SEED=1 可跳过;缺 MUSE_POSTGRES_* 报清晰错。tsc -b 干净。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
35 lines
1.6 KiB
TypeScript
35 lines
1.6 KiB
TypeScript
import { defineConfig, devices } from '@playwright/test';
|
||
|
||
export default defineConfig({
|
||
testDir: './e2e',
|
||
fullyParallel: true,
|
||
// 活体 e2e 每轮经 globalSetup 直连真实 PG 复位 fixture(替代一次性 /tmp 种子脚本);需先 source infra.env(凭据不入库)。
|
||
globalSetup: './e2e/global-setup.ts',
|
||
// 共享同一真实后端 DB(muse_slice_live)、旅程间有状态消费/流转 → 串行跑避免跨用例竞态,保证可复现绿。
|
||
workers: 1,
|
||
retries: process.env.CI ? 2 : 0,
|
||
reporter: 'list',
|
||
use: {
|
||
baseURL: 'http://127.0.0.1:5173',
|
||
trace: 'on-first-retry',
|
||
},
|
||
webServer: {
|
||
// 直接用本地 vite 二进制:playwright 经 /bin/sh 派生 webServer,该 shell 无 pnpm(corepack/mise 不在其 PATH,
|
||
// 实测 `pnpm dev` → "pnpm: command not found" exit 127),故不用 `pnpm dev`,改用等价的 ./node_modules/.bin/vite。
|
||
command: './node_modules/.bin/vite --host 127.0.0.1',
|
||
url: 'http://127.0.0.1:5173',
|
||
reuseExistingServer: !process.env.CI,
|
||
timeout: 120_000,
|
||
// 活体 e2e 必须关 MSW(main.tsx 的 VITE_API_MOCK!=='false' 门控),令前端直连真实单体(vite 代理 /app-api→48080),
|
||
// 否则读路径被 mock 截获 → 假绿(见 .agents/skills/golden-journey-vertical-slice.md)。
|
||
// 此 env 在 playwright 自起 vite 时生效(CI / 无预跑 vite);本地亦可用 muse-studio/.env.local(gitignored)。
|
||
env: { ...process.env, VITE_API_MOCK: 'false' },
|
||
},
|
||
projects: [
|
||
{
|
||
name: 'chromium',
|
||
use: { ...devices['Desktop Chrome'] },
|
||
},
|
||
],
|
||
});
|