Files
jackyu66gitandCursor 7e9023f0a8
ci / h5 (push) Canceled after 0s
ci / api (push) Canceled after 0s
ci / ess-docs (push) Canceled after 0s
test(e2e): 前后台联调 Playwright 与 admin 冒烟
新增 e2e-live 真 API 一致性全路径,并为 admin-h5 增加 mock 浏览器冒烟。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-06 22:41:43 +08:00

62 lines
2.0 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 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
```bash
npm run deps:up
cd apps/api && go test ./...
# 仅 L2
npm run test:api:integration
```
- Pure enginesportrait / relation)必须有 unit tests。
- L2 在 DB 不可用时 `Skip`;有 DB 时必须绿。
- `go test ./...` 失败 → 不得称 Backend Done。
### L2 覆盖的流
1. Profile → Portrait → deep_access pay-mock → detail
2. Two profiles → Relation insight → deep_access → tips
3. Membership pay-mock → `/membership/me` active → report detail
4. Profile → Ask thread → message → assistant reply + quota
H5 Vitest`PortraitPage` / `RelationPage` / `MembershipPage` / `AskPage`
## H5
```bash
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