1
0
Files
nex/openspec/changes/e2e-real-backend/proposal.md
lanyuanxiaoyao 59179094ed feat: E2E 测试集成真实后端
- Playwright 双 webServer 模式自动启动 Go 后端 + Vite 前端
- 后端使用临时 SQLite 数据库隔离,固定端口 19026
- vite.config.ts proxy target 动态读取环境变量
- 新增 sql.js 依赖用于 SQLite 统计数据 seed
- 新增 e2e/fixtures.ts 共享工具模块(API seed + SQLite seed)
- 拆分测试文件 5→7(providers/models/stats/navigation/validation)
- 删除旧文件 crud.spec.ts/sidebar.spec.ts/stats-cards.spec.ts
- E2E 测试尚有部分用例需调试修复
2026-04-22 00:31:35 +08:00

30 lines
2.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
## Why
前端 E2E 测试当前只启动 Vite dev server不启动后端。所有涉及写操作创建/编辑/删除供应商、模型)的测试无法验证数据是否真正持久化,大量测试在缺少数据时直接 skip。测试实质上只是 UI 组件存在性检查,不是真正的端到端验证。后端已有完善的 CLI 参数机制(`--server-port``--database-path` 等)和 SQLite 文件数据库,具备每次测试使用干净隔离环境的天然条件。
## What Changes
- Playwright 配置改为双 `webServer` 模式,自动启动 Go 后端(隔离临时数据库)+ Vite 前端
- `vite.config.ts` 的 proxy target 改为通过环境变量动态配置E2E 时指向测试后端19026日常开发回退默认值9826
- 新增 `e2e/fixtures.ts` 共享工具模块,提供 API seed 和 SQLite seed通过 sql.js 直接操作临时数据库插入统计数据)
- 新增 `e2e/global-setup.ts``e2e/global-teardown.ts` 管理临时目录生命周期
- 重写全部 E2E 测试文件5→7 个),覆盖完整 CRUD 验证、统计数据验证、导航、表单校验
- 新增 `sql.js` + `@types/sql.js` 依赖(纯 WASM零原生编译Windows 兼容)
## Capabilities
### New Capabilities
- `e2e-testing`: 前端 E2E 测试基础设施,定义 Playwright 双 webServer 启动模式、临时文件隔离、端口策略、环境变量传递、统计数据 seed 方式、测试文件组织结构
### Modified Capabilities
(无 — 现有 `test-coverage` spec 中的 E2E 要求不变,本 change 提供实现手段使其得到真正满足)
## Impact
- **代码变更**: `frontend/vite.config.ts`1 行)、`frontend/playwright.config.ts`(重写)、`frontend/e2e/` 目录(新增 5 文件 + 重写 3 文件 + 删除 2 文件)
- **新增依赖**: `sql.js``@types/sql.js`devDependencies
- **后端无变更**: 仅通过 CLI 参数以隔离模式启动现有后端,不修改后端代码
- **开发体验零侵入**: 日常 `bun run dev` 行为不变,仅 `bun run test:e2e` 启动真实后端