FE-01 登录页 — 功能测试证据(verify, round=0)
阶段:前端(frontend)。作用域:
frontend/**(无backend//sql//scripts/越界)。 上游 spec:docs/superpowers/specs/2026-06-01-FE-01.md;上游 plan:docs/superpowers/plans/2026-06-01-FE-01.md。 关联 REQ:REQ-USR-004(登录用户)。提交标签REQ-USR-004,T0~T11 共 12 个提交。 测试命令来源:docs/04-技术规范.md § 零(unit=npm run test:unit/ e2e=npm run test:e2e),在frontend/子项目执行。
1. 结论
| 目标 | 命令 | exit_code | passed | failed | 结论 |
|---|---|---|---|---|---|
| 单测(jsdom / Vitest + RTL) |
npm run test:unit(cd frontend) |
0 |
32 |
0 |
全绿 |
| E2E(Playwright chromium) |
npm run test:e2e(cd frontend) |
0 |
4 |
0 |
全绿 |
总判定:通过(两目标 exit_code=0 且 failed=0)。 failed_list 均为空。可进入 review 阶段。
2. 单测证据(unit)
-
command:
cd /Users/reporkey/Desktop/mvp/test6/frontend && npm run test:unit(即vitest run) -
exit_code:
0 -
passed:
32 -
failed:
0 - failed_list:(空)
-
test files:
10 passed (10)
测试文件清单(10 个,覆盖 spec § 3 状态机六态 + § 5 BR1~BR11):
| 文件 | 用例数 | 覆盖点 |
|---|---|---|
tests/unit/smoke.test.tsx |
1 | 工程骨架冒烟(T0) |
tests/unit/request.test.ts |
— | Axios 实例 baseURL /api、Result 拆包、ApiError 业务码/网络码、Authorization 注入(T1) |
tests/unit/usrApi.test.ts |
— |
login POST /usr/login、fetchCompanies GET /usr/companies(T2) |
tests/unit/authSlice.test.ts |
— |
setCredentials/clearCredentials + token 持久化 + initialState 读取(T3) |
tests/unit/LoginPage.layout.test.tsx |
3 | 品牌头/主视觉/页脚/卡片标题/三字段+按钮(T4,BR3 掩码) |
tests/unit/LoginPage.companies.test.tsx |
5 | 版本下拉 loading/idle(D8 label)/单项自动选中/空态/取数失败重试(T5,BR5) |
tests/unit/LoginPage.validation.test.tsx |
2 | 必填校验拦截 + 全填提交 payload(T6,BR1/BR2/BR4) |
tests/unit/LoginPage.submitting.test.tsx |
2 | 提交中 loading+禁用 + 防重复提交(T7,BR10) |
tests/unit/LoginPage.success.test.tsx |
2 | 写 authSlice+持久化+navigate('/',{replace})(T8,BR9) |
tests/unit/LoginPage.error.test.tsx |
6 | 40101/40302/42901/40001/网络异常文案分流 + 失败后清空聚焦+保留(T9,BR6/7/8+D5) |
注:
tests/unit/renderLogin.tsx为共享渲染工具,非测试文件,不计入 10 个 test files。
stdout_excerpt(≤30 行,去 act 警告噪声):
✓ tests/unit/LoginPage.layout.test.tsx (3 tests) 291ms
✓ tests/unit/LoginPage.companies.test.tsx (5 tests) 491ms
✓ tests/unit/LoginPage.success.test.tsx (2 tests) 519ms
✓ LoginPage 登录成功 > dispatches setCredentials and persists token on success 358ms
✓ tests/unit/LoginPage.validation.test.tsx (2 tests) 584ms
✓ tests/unit/LoginPage.submitting.test.tsx (2 tests) 598ms
✓ LoginPage 提交中态 > button loading and fields disabled while submitting 362ms
✓ tests/unit/LoginPage.error.test.tsx (6 tests) 999ms
✓ LoginPage 登录失败错误码分流 > 40101 shows 用户名或密码错误 and clears+focuses password 370ms
Test Files 10 passed (10)
Tests 32 passed (32)
Duration 2.46s
运行期 React
act(...)警告为 AntD + 异步useEffect(版本预取)触发的 stderr 提示,非断言失败,不影响 exit_code=0 / 32 passed;登记为已知噪声(见 decisions)。
3. E2E 证据(e2e)
-
command:
cd /Users/reporkey/Desktop/mvp/test6/frontend && npm run test:e2e(即playwright test,chromium) -
exit_code:
0 -
passed:
4 -
failed:
0 - failed_list:(空)
用例清单(tests/e2e/login.spec.ts,page.route 桩 **/api/usr/companies 与 **/api/usr/login,不依赖真实后端):
-
loads /login and shows version options— 访问/login渲染桩版本项。 -
blocks submit with validation when empty— 空提交必填拦截、未发起 login。 -
successful login navigates away from /login— 填全+桩成功 → 离开/login到/、见「登录成功」。 -
failed login stays on /login with error— 桩 40101 → 停留/login、见「用户名或密码错误」。
stdout_excerpt(≤30 行,去 DeprecationWarning 噪声):
Running 4 tests using 4 workers
✓ 4 [chromium] › tests/e2e/login.spec.ts:22:3 › 登录页关键旅程 › loads /login and shows version options (360ms)
✓ 1 [chromium] › tests/e2e/login.spec.ts:32:3 › 登录页关键旅程 › blocks submit with validation when empty (414ms)
✓ 3 [chromium] › tests/e2e/login.spec.ts:77:3 › 登录页关键旅程 › failed login stays on /login with error (699ms)
✓ 2 [chromium] › tests/e2e/login.spec.ts:50:3 › 登录页关键旅程 › successful login navigates away from /login (712ms)
4 passed (1.8s)
Node
DEP0205 module.register()为 Playwright/Node 内部弃用提示,非测试失败,不影响 exit_code=0 / 4 passed。
4. 作用域与命令合规核对
- 所有实现/测试文件均在
frontend/**;未触backend//sql//scripts/,无越界。 - 测试命令取自
docs/04-技术规范.md § 零:unit=npm run test:unit、e2e=npm run test:e2e,与frontend/package.jsonscripts 一致。 - 本轮为 round=0,证据落盘固定路径
docs/superpowers/reviews/2026-06-01-FE-01-verify.md(-verify.md后缀)。
5. 自主决策记录(decisions)
| # | 问题 | 选择 | 依据 | 置信度 |
|---|---|---|---|---|
| V1 | 本环境未暴露独立的「子会话/Agent 派发」工具,如何执行 plan「派子会话依次跑 unit + e2e」 | 由本(fe-feature-verify 非交互子代理)会话经唯一可用执行原语 Bash 直接运行 npm run test:unit / npm run test:e2e 并采集结构化结果(command/exit_code/passed/failed/failed_list/stdout_excerpt),按结构化 JSON 渲染本证据 |
当前工具集只暴露 Bash 作为执行原语,无 sub-session spawn 工具;结果仍按 plan 约定的结构化 JSON 字段采集与渲染,语义等价、不污染源码 | high |
| V2 | 单测运行期大量 React act(...) 警告是否构成失败 |
视为非阻断噪声,不计入 failed | 警告打印到 stderr,由 AntD + 异步 useEffect 版本预取触发;Vitest 报告 exit_code=0 / 32 passed / 0 failed,断言全过 |
high |
6. 摘要(供 review stage 引用)
- unit:
exit_code=0/passed=32/failed=0/failed_list=[](10 test files)。 - e2e:
exit_code=0/passed=4/failed=0/failed_list=[](chromium)。 - 总判定:全绿通过,可进入 review。