test(web): 补充 Web MVP 端到端测试与本地测试编排
- 新增 Playwright E2E(治理、登录、投瓶捞瓶回复与实时聊天、举报拉黑与断线恢复)共 9 条用例 - 每个用例前重置数据库、用例后关闭全部 browser context,消除跨用例污染与资源泄漏 - 前端改由 Playwright 托管构建与 preview(关闭 SW);Vite 代理注入 Origin 头以通过接口 Origin 校验 - 根级 vitest 排除 Playwright 用例与需专用配置的 web 用例,避免误收集导致的假失败 - 测试手机号按实测校验结果收敛白名单,避免用例传入会被后端拒绝的号段 验证结果: - Web E2E 9/9 连续两轮通过(含运行前后服务健康检查) - API E2E 146/146 连续两轮通过 - 单测:根级 14 文件/119 用例、web 包 8 文件/31 用例通过 - typecheck、lint、build、依赖审计(audit)均通过
This commit is contained in:
+28
-2
@@ -5,6 +5,8 @@ export default defineConfig({
|
||||
plugins: [
|
||||
vue(),
|
||||
VitePWA({
|
||||
// E2E 跑产物时关闭 Service Worker,避免缓存干扰断言
|
||||
disable: process.env.DISABLE_PWA === "1",
|
||||
registerType: "autoUpdate",
|
||||
manifest: {
|
||||
name: "漂流瓶 · 深海回声",
|
||||
@@ -28,8 +30,32 @@ export default defineConfig({
|
||||
],
|
||||
server: {
|
||||
proxy: {
|
||||
"/api": "http://localhost:3000",
|
||||
"/socket.io": { target: "http://localhost:3000", ws: true },
|
||||
"/api": {
|
||||
target: "http://127.0.0.1:3000",
|
||||
changeOrigin: true,
|
||||
headers: { Origin: "http://127.0.0.1:5173" },
|
||||
},
|
||||
"/socket.io": {
|
||||
target: "http://127.0.0.1:3000",
|
||||
ws: true,
|
||||
headers: { Origin: "http://127.0.0.1:5173" },
|
||||
},
|
||||
},
|
||||
},
|
||||
// E2E 跑产物预览时同样需要把 /api 与 /socket.io 代理到 API,
|
||||
// 并由代理注入 Origin,满足 StateChangingOriginGuard 的校验。
|
||||
preview: {
|
||||
proxy: {
|
||||
"/api": {
|
||||
target: "http://127.0.0.1:3000",
|
||||
changeOrigin: true,
|
||||
headers: { Origin: "http://127.0.0.1:5173" },
|
||||
},
|
||||
"/socket.io": {
|
||||
target: "http://127.0.0.1:3000",
|
||||
ws: true,
|
||||
headers: { Origin: "http://127.0.0.1:5173" },
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user