Commit 8a266615eb17c1aef6c522aac7f00324976f9351
1 parent
9b60bf72
docs(verify:FE-03): 证据验证
Showing
1 changed file
with
106 additions
and
0 deletions
docs/superpowers/reviews/2026-06-01-FE-03-verify.md
0 → 100644
| 1 | +# FE-03 用户列表与查询 — 证据验证报告(round=0) | |
| 2 | + | |
| 3 | +> 阶段:前端(frontend)。验证对象:`FE-03`(关联 `REQ-USR-003`,scope=usr)。 | |
| 4 | +> 上游 spec:`docs/superpowers/specs/2026-06-01-FE-03.md`;上游 plan:`docs/superpowers/plans/2026-06-01-FE-03.md`。 | |
| 5 | +> 验证时间:2026-06-01。本报告由 fe-feature-verify 渲染,主会话不自由编写测试,仅按测试命令的结构化结果落盘。 | |
| 6 | + | |
| 7 | +--- | |
| 8 | + | |
| 9 | +## 一、验证结论 | |
| 10 | + | |
| 11 | +**全部通过(PASS)**。单测与 E2E 两个门禁目标 `exit_code` 均为 0,`failed=0`,可进入 review。 | |
| 12 | + | |
| 13 | +| 目标 | 命令 | exit_code | passed | failed | 结论 | | |
| 14 | +|---|---|---|---|---|---| | |
| 15 | +| 单元测试(jsdom / Vitest) | `npm run test:unit`(= `vitest run`) | 0 | 138(32 文件) | 0 | ✅ PASS | | |
| 16 | +| 端到端(Playwright) | `npm run test:e2e`(= `playwright test`) | 0 | 15 | 0 | ✅ PASS | | |
| 17 | + | |
| 18 | +> 命令来源:`docs/04-技术规范.md § 零 命令清单`(前端 unit=`npm run test:unit`、e2e=`npm run test:e2e`)。本验证执行全量套件(覆盖 plan T1–T9 全部新增 jsdom 单测 + `userlist.spec.ts` E2E,并校验 FE-01/FE-02 既有 unit/E2E 不回归,对齐 plan T9「全量验证」门禁)。 | |
| 19 | + | |
| 20 | +--- | |
| 21 | + | |
| 22 | +## 二、单元测试(jsdom / Vitest) | |
| 23 | + | |
| 24 | +- 命令:`cd frontend && npm run test:unit` | |
| 25 | +- exit_code:`0` | |
| 26 | +- 结果:`Test Files 32 passed (32)` / `Tests 138 passed (138)` | |
| 27 | +- failed_list:(空) | |
| 28 | +- 覆盖 FE-03 新增的 7 个单测文件均通过: | |
| 29 | + - `tests/unit/usrApi.userlist.test.ts`(listUsers 透传 query → GET /usr/users,返回 PageResult;3 用例) | |
| 30 | + - `tests/unit/exportUtils.test.ts`(CSV/常量/默认值断言) | |
| 31 | + - `tests/unit/useUserList.test.tsx`(状态机 6 态:initialLoading/loading/success/empty/error/exporting) | |
| 32 | + - `tests/unit/UserFilterBar.test.tsx`(BR2/BR3/BR4/BR7/BR10 默认值/枚举/回车搜索/清空) | |
| 33 | + - `tests/unit/UserTable.test.tsx`(BR1/BR6/BR11/BR12/BR14 序号/作废只读/行双击导航/受控分页/空态) | |
| 34 | + - `tests/unit/UserToolbar.test.tsx`(BR8/BR9/BR13/D7 刷新/新增导航/导出中禁用/齿轮占位) | |
| 35 | + - `tests/unit/UserListPage.test.tsx`(8 用例:挂载默认查询/搜索/翻页 BR8/错误重试/空态/BR15 pageNum 回显) | |
| 36 | +- FE-01/FE-02 既有单测(authSlice / request / LoginPage* / AppLayout* / router / RequireAuth / RedirectIfAuthed / Home / Kpi / Nav 等)一并绿,无回归。 | |
| 37 | + | |
| 38 | +### stdout 摘录(≤30 行) | |
| 39 | + | |
| 40 | +``` | |
| 41 | + ✓ tests/unit/UserListPage.test.tsx (8 tests) 1509ms | |
| 42 | + ✓ UserListPage 集成 > initial load renders rows from listUsers (default query) (BR2) 393ms | |
| 43 | + ✓ tests/unit/usrApi.userlist.test.ts (3 tests) 2ms | |
| 44 | + ✓ tests/unit/usrApi.test.ts (2 tests) 2ms | |
| 45 | + ✓ tests/unit/RequireAuth.test.tsx (3 tests) 71ms | |
| 46 | + ✓ tests/unit/RedirectIfAuthed.test.tsx (3 tests) 57ms | |
| 47 | + ✓ tests/unit/AppLayout.unauthorized.test.tsx (1 test) 81ms | |
| 48 | + ✓ tests/unit/LoginPage.error.test.tsx (6 tests) 1752ms | |
| 49 | + | |
| 50 | + Test Files 32 passed (32) | |
| 51 | + Tests 138 passed (138) | |
| 52 | + Start at 17:48:22 | |
| 53 | + Duration 4.43s (transform 532ms, setup 2.36s, collect 37.88s, tests 13.58s, environment 8.09s, prepare 1.44s) | |
| 54 | +``` | |
| 55 | + | |
| 56 | +> 说明:日志中 `window.getComputedStyle(elt, pseudoElt) Not implemented`(来自 rc-table measureScrollbarSize)与 React Router v7 future flag / `localStorage --localstorage-file` 等为 jsdom/依赖侧的非致命 stderr 警告,不影响断言,全部用例仍判定通过(`exit_code=0`,`138 passed`)。 | |
| 57 | + | |
| 58 | +--- | |
| 59 | + | |
| 60 | +## 三、端到端测试(Playwright) | |
| 61 | + | |
| 62 | +- 命令:`cd frontend && npm run test:e2e` | |
| 63 | +- exit_code:`0` | |
| 64 | +- 结果:`Running 15 tests using 9 workers` → `15 passed (2.5s)` | |
| 65 | +- failed_list:(空) | |
| 66 | +- FE-03 `tests/e2e/userlist.spec.ts` 6 用例全过:进入用户列表渲染行 / 空结果显示「暂无匹配的用户」/ 按值搜索触发查询 / 翻页 pageNum=2 重取 / 行双击进用户单据 / 错误响应重试后恢复。 | |
| 67 | +- FE-01 `login.spec.ts`(4 用例)+ FE-02 `shell.spec.ts`(5 用例)一并绿,无回归。 | |
| 68 | + | |
| 69 | +### stdout 摘录(≤30 行) | |
| 70 | + | |
| 71 | +``` | |
| 72 | +Running 15 tests using 9 workers | |
| 73 | + ✓ 7 [chromium] › tests/e2e/login.spec.ts:22:3 › loads /login and shows version options (501ms) | |
| 74 | + ✓ 3 [chromium] › tests/e2e/login.spec.ts:32:3 › blocks submit with validation when empty (582ms) | |
| 75 | + ✓ 6 [chromium] › tests/e2e/shell.spec.ts:95:3 › visiting / unauthenticated redirects to /login (625ms) | |
| 76 | + ✓ 4 [chromium] › tests/e2e/shell.spec.ts:61:3 › open and close 全部导航 overlay (677ms) | |
| 77 | + ✓ 9 [chromium] › tests/e2e/shell.spec.ts:53:3 › login then lands on home with topbar and KPI title (674ms) | |
| 78 | + ✓ 1 [chromium] › tests/e2e/shell.spec.ts:73:3 › open 用户列表 tab from common ops then close back to home (764ms) | |
| 79 | + ✓ 2 [chromium] › tests/e2e/login.spec.ts:50:3 › successful login navigates away from /login (1.0s) | |
| 80 | + ✓ 10 [chromium] › tests/e2e/userlist.spec.ts:73:3 › enter user list renders rows (486ms) | |
| 81 | + ✓ 8 [chromium] › tests/e2e/login.spec.ts:77:3 › failed login stays on /login with error (1.0s) | |
| 82 | + ✓ 11 [chromium] › tests/e2e/userlist.spec.ts:88:3 › empty result shows 暂无匹配的用户 (471ms) | |
| 83 | + ✓ 5 [chromium] › tests/e2e/shell.spec.ts:86:3 › logout returns to /login (1.1s) | |
| 84 | + ✓ 12 [chromium] › tests/e2e/userlist.spec.ts:102:3 › search by value triggers query (523ms) | |
| 85 | + ✓ 14 [chromium] › tests/e2e/userlist.spec.ts:146:3 › double click row navigates to user detail (492ms) | |
| 86 | + ✓ 13 [chromium] › tests/e2e/userlist.spec.ts:124:3 › pagination next page refetches with pageNum=2 (528ms) | |
| 87 | + ✓ 15 [chromium] › tests/e2e/userlist.spec.ts:161:3 › error response shows retry then recovers (478ms) | |
| 88 | + | |
| 89 | + 15 passed (2.5s) | |
| 90 | +``` | |
| 91 | + | |
| 92 | +--- | |
| 93 | + | |
| 94 | +## 四、作用域校验 | |
| 95 | + | |
| 96 | +- 验证仅运行 `frontend/` 下的测试套件;未触碰 `backend/` / `sql/` / `scripts/`,作用域校验通过。 | |
| 97 | +- 本报告落盘于 `docs/superpowers/reviews/`(与 review 报告同目录),round=0 → 文件名后缀 `-verify.md`,符合命名约定。 | |
| 98 | + | |
| 99 | +--- | |
| 100 | + | |
| 101 | +## 五、自主决策记录(decisions) | |
| 102 | + | |
| 103 | +| # | 问题 | 选择 | 依据 | 置信度 | | |
| 104 | +|---|---|---|---|---| | |
| 105 | +| V1 | 测试命令默认值取 `pnpm test:ci`/`pnpm e2e:ci` 还是 docs/04 锁定值 | 取 `docs/04-技术规范.md § 零` 锁定的 `npm run test:unit` / `npm run test:e2e`(package.json scripts 实测存在且对应 `vitest run` / `playwright test`) | flow 明确「命令从 docs/04 § 零取,缺失才用默认」;本仓 docs/04 § 零命令清单已锁定前端命令,且 `frontend/package.json` 中两脚本均存在;默认值仅在缺失时兜底,此处不缺失 | high | | |
| 106 | +| V2 | 仅跑 plan 列出的 FE-03 新增测试文件,还是跑全量套件 | 跑全量 `test:unit` + `test:e2e` | plan T9 门禁要求「`npm run test:unit && npm run test:e2e` 全绿」且需校验 FE-01/FE-02 不回归(router.test/shell.spec);全量执行同时覆盖 FE-03 新增用例与回归面,过滤模式仅为子任务级验证手段 | high | | ... | ... |