1
0

fix(e2e): 修复对话框关闭问题,完善 E2E 测试

- 修复 TDesign Dialog onConfirm 不自动关闭的问题
- 使用 useEffect 监听 mutation 状态自动关闭对话框
- 测试使用 waitForResponse 等待 API 响应
- 添加 clearDatabase 函数确保测试隔离
- 归档 e2e-real-backend 变更到 archive/2026-04-22
- 同步 e2e-testing spec 到主 specs
This commit is contained in:
2026-04-22 10:32:57 +08:00
parent 59179094ed
commit f488b9cc15
13 changed files with 112 additions and 206 deletions

View File

@@ -26,6 +26,18 @@ export interface SeedStatsInput {
date: string
}
export async function clearDatabase(
request: import('@playwright/test').APIRequestContext,
) {
const providers = await request.get(`${API_BASE}/api/providers`)
if (providers.ok()) {
const data = await providers.json()
for (const p of data) {
await request.delete(`${API_BASE}/api/providers/${p.id}`)
}
}
}
export async function seedProvider(
request: import('@playwright/test').APIRequestContext,
data: SeedProviderInput,
@@ -66,10 +78,15 @@ export async function seedModel(
export async function seedUsageStats(statsData: SeedStatsInput[]) {
const tempDir = process.env.NEX_E2E_TEMP_DIR
if (!tempDir) {
throw new Error('NEX_E2E_TEMP_DIR not set')
throw new Error('NEX_E2E_TEMP_DIR not set - ensure playwright.config.ts is loaded')
}
const dbPath = path.join(tempDir, 'test.db')
if (!fs.existsSync(dbPath)) {
throw new Error(`Database file not found at ${dbPath}. Backend may not have created it yet.`)
}
const SQL = await initSqlite()
const buf = fs.readFileSync(dbPath)
const db = new SQL.Database(buf)