- 修复 TDesign Dialog onConfirm 不自动关闭的问题 - 使用 useEffect 监听 mutation 状态自动关闭对话框 - 测试使用 waitForResponse 等待 API 响应 - 添加 clearDatabase 函数确保测试隔离 - 归档 e2e-real-backend 变更到 archive/2026-04-22 - 同步 e2e-testing spec 到主 specs
60 lines
1.6 KiB
TypeScript
60 lines
1.6 KiB
TypeScript
import { defineConfig, devices } from '@playwright/test'
|
|
import fs from 'node:fs'
|
|
import os from 'node:os'
|
|
import path from 'node:path'
|
|
import { fileURLToPath } from 'node:url'
|
|
|
|
const __filename = fileURLToPath(import.meta.url)
|
|
const __dirname = path.dirname(__filename)
|
|
|
|
const E2E_PORT = 19026
|
|
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'nex-e2e-'))
|
|
const dbPath = path.join(tempDir, 'test.db')
|
|
const logPath = path.join(tempDir, 'log')
|
|
|
|
fs.mkdirSync(logPath, { recursive: true })
|
|
|
|
process.env.NEX_BACKEND_PORT = String(E2E_PORT)
|
|
process.env.NEX_E2E_TEMP_DIR = tempDir
|
|
|
|
const backendDir = path.resolve(__dirname, '..', 'backend')
|
|
|
|
export default defineConfig({
|
|
testDir: './e2e',
|
|
fullyParallel: false,
|
|
forbidOnly: !!process.env.CI,
|
|
retries: process.env.CI ? 2 : 0,
|
|
workers: 1,
|
|
reporter: 'html',
|
|
use: {
|
|
baseURL: 'http://localhost:5173',
|
|
trace: 'on-first-retry',
|
|
storageState: undefined,
|
|
},
|
|
projects: [
|
|
{
|
|
name: 'chromium',
|
|
use: { ...devices['Desktop Chrome'] },
|
|
},
|
|
],
|
|
globalSetup: './e2e/global-setup.ts',
|
|
globalTeardown: './e2e/global-teardown.ts',
|
|
webServer: [
|
|
{
|
|
command: `go run cmd/server/main.go --server-port ${E2E_PORT} --database-path "${dbPath}" --log-path "${logPath}" --log-level warn`,
|
|
url: `http://localhost:${E2E_PORT}/health`,
|
|
timeout: 60_000,
|
|
reuseExistingServer: false,
|
|
cwd: backendDir,
|
|
},
|
|
{
|
|
command: 'bun run dev',
|
|
url: 'http://localhost:5173',
|
|
reuseExistingServer: false,
|
|
env: {
|
|
NEX_BACKEND_PORT: String(E2E_PORT),
|
|
},
|
|
},
|
|
],
|
|
})
|