新增 e2e-live 真 API 一致性全路径,并为 admin-h5 增加 mock 浏览器冒烟。 Co-authored-by: Cursor <cursoragent@cursor.com>
2.0 KiB
2.0 KiB
Testing — Golden Rules
对照完成闸门:.ai/definition-of-done.md §4。
Priority
先测:计分、权益(深度版/会员)、归属、支付 mock。
Levels
| Level | Command / artifact | When |
|---|---|---|
| L0 Build | go test ./... · npm run build:h5 |
每次声称可合并 |
| L1 Unit | Go engine _test.go;H5 Vitest |
核心逻辑必有 |
| L2 Integration | npm run test:api:integration(需 Postgres) |
P1 关键流必有 |
| L3 E2E | npm run test:e2e(Playwright,可用系统 Chrome) |
P1 收口至少 1 条 |
| L3 Live | npm run test:e2e:live(真 API + 用户 H5 + 运营后台) |
前后台数据一致性 |
Go
npm run deps:up
cd apps/api && go test ./...
# 仅 L2:
npm run test:api:integration
- Pure engines(portrait / relation)必须有 unit tests。
- L2 在 DB 不可用时
Skip;有 DB 时必须绿。 go test ./...失败 → 不得称 Backend Done。
L2 覆盖的流
- Profile → Portrait → deep_access pay-mock → detail
- Two profiles → Relation insight → deep_access → tips
- Membership pay-mock →
/membership/meactive → report detail - Profile → Ask thread → message → assistant reply + quota
H5 Vitest:PortraitPage / RelationPage / MembershipPage / AskPage
H5
npm run test:h5 # Vitest
npm run build:h5 && npm run test:e2e # Playwright(默认 channel=chrome)
- 关键页:
PortraitPage/RelationPage/MembershipPage有 Vitest。 - Playwright 画像主路径使用 network mock,不依赖 Go。
- Admin:
npm run test:e2e:admin(登录→用户→授予→审计,network mock)。 - 若无系统 Chrome:
npx playwright install chromium后设PW_CHANNEL=空或删 channel。 - 仅 build 通过 ≠ Frontend Done。
AI
不得在下列情况标记 Done:
- 可计分逻辑零测试
- Build 红
- 无 L2 却宣称 P1 Complete
- 前端无 Loading/Empty/Error 却宣称页面 Done