2026-06-01-FE-03-verify.md
6.83 KB
FE-03 用户列表与查询 — 证据验证报告(round=0)
阶段:前端(frontend)。验证对象:
FE-03(关联REQ-USR-003,scope=usr)。 上游 spec:docs/superpowers/specs/2026-06-01-FE-03.md;上游 plan:docs/superpowers/plans/2026-06-01-FE-03.md。 验证时间:2026-06-01。本报告由 fe-feature-verify 渲染,主会话不自由编写测试,仅按测试命令的结构化结果落盘。
一、验证结论
全部通过(PASS)。单测与 E2E 两个门禁目标 exit_code 均为 0,failed=0,可进入 review。
| 目标 | 命令 | exit_code | passed | failed | 结论 |
|---|---|---|---|---|---|
| 单元测试(jsdom / Vitest) |
npm run test:unit(= vitest run) |
0 | 138(32 文件) | 0 | ✅ PASS |
| 端到端(Playwright) |
npm run test:e2e(= playwright test) |
0 | 15 | 0 | ✅ PASS |
命令来源:
docs/04-技术规范.md § 零 命令清单(前端 unit=npm run test:unit、e2e=npm run test:e2e)。本验证执行全量套件(覆盖 plan T1–T9 全部新增 jsdom 单测 +userlist.spec.tsE2E,并校验 FE-01/FE-02 既有 unit/E2E 不回归,对齐 plan T9「全量验证」门禁)。
二、单元测试(jsdom / Vitest)
- 命令:
cd frontend && npm run test:unit - exit_code:
0 - 结果:
Test Files 32 passed (32)/Tests 138 passed (138) - failed_list:(空)
- 覆盖 FE-03 新增的 7 个单测文件均通过:
-
tests/unit/usrApi.userlist.test.ts(listUsers 透传 query → GET /usr/users,返回 PageResult;3 用例) -
tests/unit/exportUtils.test.ts(CSV/常量/默认值断言) -
tests/unit/useUserList.test.tsx(状态机 6 态:initialLoading/loading/success/empty/error/exporting) -
tests/unit/UserFilterBar.test.tsx(BR2/BR3/BR4/BR7/BR10 默认值/枚举/回车搜索/清空) -
tests/unit/UserTable.test.tsx(BR1/BR6/BR11/BR12/BR14 序号/作废只读/行双击导航/受控分页/空态) -
tests/unit/UserToolbar.test.tsx(BR8/BR9/BR13/D7 刷新/新增导航/导出中禁用/齿轮占位) -
tests/unit/UserListPage.test.tsx(8 用例:挂载默认查询/搜索/翻页 BR8/错误重试/空态/BR15 pageNum 回显)
-
- FE-01/FE-02 既有单测(authSlice / request / LoginPage* / AppLayout* / router / RequireAuth / RedirectIfAuthed / Home / Kpi / Nav 等)一并绿,无回归。
stdout 摘录(≤30 行)
✓ tests/unit/UserListPage.test.tsx (8 tests) 1509ms
✓ UserListPage 集成 > initial load renders rows from listUsers (default query) (BR2) 393ms
✓ tests/unit/usrApi.userlist.test.ts (3 tests) 2ms
✓ tests/unit/usrApi.test.ts (2 tests) 2ms
✓ tests/unit/RequireAuth.test.tsx (3 tests) 71ms
✓ tests/unit/RedirectIfAuthed.test.tsx (3 tests) 57ms
✓ tests/unit/AppLayout.unauthorized.test.tsx (1 test) 81ms
✓ tests/unit/LoginPage.error.test.tsx (6 tests) 1752ms
Test Files 32 passed (32)
Tests 138 passed (138)
Start at 17:48:22
Duration 4.43s (transform 532ms, setup 2.36s, collect 37.88s, tests 13.58s, environment 8.09s, prepare 1.44s)
说明:日志中
window.getComputedStyle(elt, pseudoElt) Not implemented(来自 rc-table measureScrollbarSize)与 React Router v7 future flag /localStorage --localstorage-file等为 jsdom/依赖侧的非致命 stderr 警告,不影响断言,全部用例仍判定通过(exit_code=0,138 passed)。
三、端到端测试(Playwright)
- 命令:
cd frontend && npm run test:e2e - exit_code:
0 - 结果:
Running 15 tests using 9 workers→15 passed (2.5s) - failed_list:(空)
- FE-03
tests/e2e/userlist.spec.ts6 用例全过:进入用户列表渲染行 / 空结果显示「暂无匹配的用户」/ 按值搜索触发查询 / 翻页 pageNum=2 重取 / 行双击进用户单据 / 错误响应重试后恢复。 - FE-01
login.spec.ts(4 用例)+ FE-02shell.spec.ts(5 用例)一并绿,无回归。
stdout 摘录(≤30 行)
Running 15 tests using 9 workers
✓ 7 [chromium] › tests/e2e/login.spec.ts:22:3 › loads /login and shows version options (501ms)
✓ 3 [chromium] › tests/e2e/login.spec.ts:32:3 › blocks submit with validation when empty (582ms)
✓ 6 [chromium] › tests/e2e/shell.spec.ts:95:3 › visiting / unauthenticated redirects to /login (625ms)
✓ 4 [chromium] › tests/e2e/shell.spec.ts:61:3 › open and close 全部导航 overlay (677ms)
✓ 9 [chromium] › tests/e2e/shell.spec.ts:53:3 › login then lands on home with topbar and KPI title (674ms)
✓ 1 [chromium] › tests/e2e/shell.spec.ts:73:3 › open 用户列表 tab from common ops then close back to home (764ms)
✓ 2 [chromium] › tests/e2e/login.spec.ts:50:3 › successful login navigates away from /login (1.0s)
✓ 10 [chromium] › tests/e2e/userlist.spec.ts:73:3 › enter user list renders rows (486ms)
✓ 8 [chromium] › tests/e2e/login.spec.ts:77:3 › failed login stays on /login with error (1.0s)
✓ 11 [chromium] › tests/e2e/userlist.spec.ts:88:3 › empty result shows 暂无匹配的用户 (471ms)
✓ 5 [chromium] › tests/e2e/shell.spec.ts:86:3 › logout returns to /login (1.1s)
✓ 12 [chromium] › tests/e2e/userlist.spec.ts:102:3 › search by value triggers query (523ms)
✓ 14 [chromium] › tests/e2e/userlist.spec.ts:146:3 › double click row navigates to user detail (492ms)
✓ 13 [chromium] › tests/e2e/userlist.spec.ts:124:3 › pagination next page refetches with pageNum=2 (528ms)
✓ 15 [chromium] › tests/e2e/userlist.spec.ts:161:3 › error response shows retry then recovers (478ms)
15 passed (2.5s)
四、作用域校验
- 验证仅运行
frontend/下的测试套件;未触碰backend//sql//scripts/,作用域校验通过。 - 本报告落盘于
docs/superpowers/reviews/(与 review 报告同目录),round=0 → 文件名后缀-verify.md,符合命名约定。
五、自主决策记录(decisions)
| # | 问题 | 选择 | 依据 | 置信度 |
|---|---|---|---|---|
| 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 |
| 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 |