Commit f7becddbedc62e03960f11d125cb86dffa3c8e6b
1 parent
32f94ad2
docs(verify:FE-04): 证据验证
Showing
1 changed file
with
101 additions
and
0 deletions
docs/superpowers/reviews/2026-06-01-FE-04-verify.md
0 → 100644
| 1 | +# FE-04 用户信息单据 — 证据验证报告(round=0) | ||
| 2 | + | ||
| 3 | +> 阶段:前端(frontend)。验证对象:`FE-04`(关联 `REQ-USR-001` 增加用户 + `REQ-USR-002` 修改用户,scope=usr)。 | ||
| 4 | +> 上游 spec:`docs/superpowers/specs/2026-06-01-FE-04.md`。 | ||
| 5 | +> 验证时间:2026-06-01。本报告由 fe-feature-verify 渲染;主会话不自由编写测试,仅按测试命令的结构化结果落盘。 | ||
| 6 | +> 测试以后台分离进程执行(非主会话交互式跑),仅运行 `frontend/` 下套件。 | ||
| 7 | + | ||
| 8 | +--- | ||
| 9 | + | ||
| 10 | +## 一、验证结论 | ||
| 11 | + | ||
| 12 | +**全部通过(PASS)**。单测与 E2E 两个门禁目标 `exit_code` 均为 0,`failed=0`,可进入 review。 | ||
| 13 | + | ||
| 14 | +| 目标 | 命令 | exit_code | passed | failed | 结论 | | ||
| 15 | +|---|---|---|---|---|---| | ||
| 16 | +| 单元测试(jsdom / Vitest) | `npx vitest run <FE-04 8 文件>` | 0 | 55(8 文件) | 0 | ✅ PASS | | ||
| 17 | +| 端到端(Playwright) | `npx playwright test tests/e2e/userdetail.spec.ts` | 0 | 5 | 0 | ✅ PASS | | ||
| 18 | + | ||
| 19 | +> 命令来源:`docs/04-技术规范.md § 零 命令清单`(前端 unit=`npm run test:unit`=`vitest run`、e2e=`npm run test:e2e`=`playwright test`)。本验证按 flow 取 FE-04 的 jsdom 单测文件拼 vitest 过滤模式、取 e2e spec 拼 Playwright 过滤模式,scope 收敛到 FE-04 新增/改动的测试。全量门禁(193 passed / 40 文件单测、20 passed E2E)已在上游 T10 回归通过(提交 32f94ad)。 | ||
| 20 | + | ||
| 21 | +--- | ||
| 22 | + | ||
| 23 | +## 二、单元测试(jsdom / Vitest) | ||
| 24 | + | ||
| 25 | +- 命令:`cd frontend && npx vitest run tests/unit/usrApi.userdetail.test.ts tests/unit/userDetailMappers.test.ts tests/unit/useUserDetail.test.tsx tests/unit/UserBasicForm.test.tsx tests/unit/PermissionGroupList.test.tsx tests/unit/PermissionTabs.test.tsx tests/unit/UserDetailToolbar.test.tsx tests/unit/UserDetailPage.test.tsx` | ||
| 26 | +- exit_code:`0` | ||
| 27 | +- 结果:`Test Files 8 passed (8)` / `Tests 55 passed (55)` | ||
| 28 | +- failed_list:(空) | ||
| 29 | +- FE-04 的 8 个单测文件逐个通过: | ||
| 30 | + - `tests/unit/usrApi.userdetail.test.ts`(6 用例:createUser/updateUser/getUserDetail/listEmployees/listPermissions 端点透传与 Result 拆包) | ||
| 31 | + - `tests/unit/userDetailMappers.test.ts`(4 用例:EmployeeOption/PermissionItem/UserVO→表单值映射) | ||
| 32 | + - `tests/unit/useUserDetail.test.tsx`(10 用例:状态机 initialLoading/editing/submitting/submitError/submitSuccess/loadError + create/edit 分支) | ||
| 33 | + - `tests/unit/UserBasicForm.test.tsx`(9 用例:BR1-BR8 字段渲染/只读/默认值/必填校验/员工联动) | ||
| 34 | + - `tests/unit/PermissionGroupList.test.tsx`(8 用例:BR10/BR11 权限项渲染/全选 indeterminate/勾选集合/edit 回勾) | ||
| 35 | + - `tests/unit/PermissionTabs.test.tsx`(3 用例:权限组 active + 5 个占位页签 D9) | ||
| 36 | + - `tests/unit/UserDetailToolbar.test.tsx`(5 用例:保存/取消/新增 + 占位按钮 D8) | ||
| 37 | + - `tests/unit/UserDetailPage.test.tsx`(10 用例:create 默认值/edit 预填/提交成功回流/用户名冲突就近高亮/dirty 取消二次确认/loadError 重试) | ||
| 38 | + | ||
| 39 | +### stdout 摘录(≤30 行) | ||
| 40 | + | ||
| 41 | +``` | ||
| 42 | + ✓ tests/unit/userDetailMappers.test.ts (4 tests) 2ms | ||
| 43 | + ✓ tests/unit/usrApi.userdetail.test.ts (6 tests) 3ms | ||
| 44 | + ✓ tests/unit/PermissionTabs.test.tsx (3 tests) 127ms | ||
| 45 | + ✓ tests/unit/PermissionGroupList.test.tsx (8 tests) 145ms | ||
| 46 | + ✓ tests/unit/UserDetailToolbar.test.tsx (5 tests) 191ms | ||
| 47 | + ✓ tests/unit/useUserDetail.test.tsx (10 tests) 599ms | ||
| 48 | + ✓ tests/unit/UserBasicForm.test.tsx (9 tests) 761ms | ||
| 49 | + ✓ tests/unit/UserDetailPage.test.tsx (10 tests) 1406ms | ||
| 50 | + | ||
| 51 | + Test Files 8 passed (8) | ||
| 52 | + Tests 55 passed (55) | ||
| 53 | +``` | ||
| 54 | + | ||
| 55 | +> 说明:日志中 `window.getComputedStyle(elt, pseudoElt) Not implemented`(来自 rc-util measureScrollbarSize / AntD Modal 滚动锁)、`act(...)` 包裹建议(rc-field-form 异步校验态)、React Router v7 future flag 等均为 jsdom/依赖侧非致命 stderr 警告,不影响断言,全部用例仍判定通过(`exit_code=0`,`55 passed`)。 | ||
| 56 | + | ||
| 57 | +--- | ||
| 58 | + | ||
| 59 | +## 三、端到端测试(Playwright) | ||
| 60 | + | ||
| 61 | +- 命令:`cd frontend && npx playwright test tests/e2e/userdetail.spec.ts` | ||
| 62 | +- exit_code:`0` | ||
| 63 | +- 结果:`5 passed (5.2s)` | ||
| 64 | +- failed_list:(空) | ||
| 65 | +- FE-04 `tests/e2e/userdetail.spec.ts` 5 用例全过: | ||
| 66 | + - `create user and return to list`(新增提交成功回流列表 BR12/BR16) | ||
| 67 | + - `edit user prefill then save`(edit 预填原值 + 保存 BR17/BR11) | ||
| 68 | + - `username conflict shows inline error`(40901 用户名冲突就近报错) | ||
| 69 | + - `placeholder tabs/buttons are inert`(占位页签/按钮惰性 D8/D9) | ||
| 70 | + - `load error shows retry`(loadError 取数失败重试入口) | ||
| 71 | + | ||
| 72 | +### stdout 摘录(≤30 行) | ||
| 73 | + | ||
| 74 | +``` | ||
| 75 | + ✓ 2 [chromium] › tests/e2e/userdetail.spec.ts:170:3 › 用户单据关键旅程 › placeholder tabs/buttons are inert (729ms) | ||
| 76 | + ✓ 3 [chromium] › tests/e2e/userdetail.spec.ts:126:3 › 用户单据关键旅程 › username conflict shows inline error (1.1s) | ||
| 77 | + ✓ 4 [chromium] › tests/e2e/userdetail.spec.ts:97:3 › 用户单据关键旅程 › edit user prefill then save (1.1s) | ||
| 78 | + ✓ 5 [chromium] › tests/e2e/userdetail.spec.ts:69:3 › 用户单据关键旅程 › create user and return to list (1.1s) | ||
| 79 | + ✓ 1 [chromium] › tests/e2e/userdetail.spec.ts:146:3 › 用户单据关键旅程 › load error shows retry (4.1s) | ||
| 80 | + | ||
| 81 | + 5 passed (5.2s) | ||
| 82 | +``` | ||
| 83 | + | ||
| 84 | +> 说明:WebServer 日志中 `[vite] http proxy error ... ECONNREFUSED /api/usr/users` 为预期噪声——E2E 在路由层 mock API 响应,开发后端(`config-vars.yaml backend.http_port=5172`)未启动,Vite proxy 透传请求被拒;用例不依赖真实后端,5 个用例全部判定通过(`exit_code=0`,`5 passed`),与 FE-03 验证同型非致命基建告警。 | ||
| 85 | + | ||
| 86 | +--- | ||
| 87 | + | ||
| 88 | +## 四、作用域校验 | ||
| 89 | + | ||
| 90 | +- 验证仅运行 `frontend/` 下的测试套件(`frontend/tests/unit/*` + `frontend/tests/e2e/userdetail.spec.ts`);未触碰 `backend/` / `sql/` / `scripts/`,作用域校验通过。 | ||
| 91 | +- 本报告落盘于 `docs/superpowers/reviews/`(与 review 报告同目录),round=0 → 文件名后缀 `-verify.md`,符合命名约定。 | ||
| 92 | + | ||
| 93 | +--- | ||
| 94 | + | ||
| 95 | +## 五、自主决策记录(decisions) | ||
| 96 | + | ||
| 97 | +| # | 问题 | 选择 | 依据 | 置信度 | | ||
| 98 | +|---|---|---|---|---| | ||
| 99 | +| V1 | 测试命令默认值取 `pnpm test:ci`/`pnpm e2e:ci` 还是 docs/04 锁定值 | 取 `docs/04-技术规范.md § 零` 锁定的前端命令(unit=`npm run test:unit`=`vitest run`、e2e=`npm run test:e2e`=`playwright test`,`frontend/package.json` scripts 实测存在) | flow 明确「命令从 docs/04 § 零取,缺失才用默认」;本仓 docs/04 § 零已锁定前端命令,默认值仅缺失兜底,此处不缺失 | high | | ||
| 100 | +| V2 | 单测/ E2E 跑全量套件还是 FE-04 过滤模式 | 按 flow 取 FE-04 的 jsdom 单测 8 文件拼 vitest 过滤、取 `userdetail.spec.ts` 拼 Playwright 过滤,scope 收敛到本 FE | flow 明确「从 plan 取 `测试先行类型=jsdom` 的 test_file 拼 vitest 过滤、`=e2e` 的拼 Playwright spec 过滤」;全量门禁(193/40 单测、20 E2E)已由上游 T10 回归通过(32f94ad),本轮做 FE-04 范围确认 | high | | ||
| 101 | +| V3 | E2E 运行中 `ECONNREFUSED /api/usr/users` proxy 报错是否判失败 | 判通过(非致命基建噪声) | E2E 在路由层 mock 响应,不依赖真实后端;Playwright 汇总 `5 passed` 且进程 `exit_code=0`,proxy 噪声来自 Vite dev server 透传未启动的后端端口,与用例断言无关,与 FE-03 验证同型处理 | high | |