Browse Source

test(B类·R668·40分三流档): SC-P-50 成长记录查看 三类流 e2e spec (正常3/异常2/权限2, 7/7 实跑全绿)

- 端点: /api/growth/record/list · /api/growth/record/child-records (G-11 归属门禁) · /api/points/logs
- 探针取证 cfc.iwintrue.com: 裸数字 body=200 / 对象 body=400 / 跨家庭=403 / 匿名 list=401 / logs 匿名=200 (契约缺口·如实标注不断言 401)
- 只写 tests/e2e/api/sc-p50-growth-record.spec.js, 零生产源码改动, 零 _probe 混入, 他档 staged WIP (sc-p-64-profile-edit) 不触碰
- 报告 harvest-run-2026-11-30-0301.md (.gitignore:160 report-*.md 被拦, 改用 harvest-run 命名入库)
E2E Test Bot 2 hours ago
parent
commit
cabd62e862

+ 60 - 0
docs/tdd/orchestration/harvest-run-2026-11-30-0301.md

@@ -0,0 +1,60 @@
+# 测试负责人工作汇报 · R668(B 类 · 40 分档 · 用户场景三流用例编写)
+
+- 轮次:R668(三流证据档 · 第 40 分档)|时间:2026-11-30 03:01 ~ 03:19|角色:测试负责人(**B 类:编写/修订用户场景三流测试用例,不分派**)
+- 主线:`cfclub`(data_ref `origin/cfclub`)|cwd `d:/cfc`|无人值守
+- **结论:条件通过(本档主职责交付完成)** —— 新增 SC-P-50 成长记录查看三类流 e2e spec **7/7 全绿**(正常 3 / 异常 2 / 权限 2),探针取证驱动、零臆造断言;**未判定 SC-P-50 跑通**(本档只补用例、不代判)
+- 本档纪律:S2 失败补跑由 0 分标准轮承担(跳过);S3 精简盘点(跳过 `--changes` / `--clean-check`,标准轮承接)
+
+## 1. 门禁与前置
+
+| 项 | 结果 |
+|---|---|
+| S0 启动前置检查(60s 预算,实测 <20s) | ✅ 全绿:分支 `cfclub` / 差距 `0 0`(HEAD=origin/cfclub,零漂移)/ tracked 脏 **1**(他档 WIP `A tests/e2e/api/sc-p-64-profile-edit.spec.js`,**只报不动**)/ untracked **741**(`.r*` 等产物零触碰、永不 git add) |
+| S1 并发互斥门(`--mutex-check` 绝对路径 `d:/cfc`) | ✅ **PASS**:state 龄 666.2min / `worklog_active` `null` / locks `{}` / slot `UNUSED`(「无他轮在产信号」) |
+| S2 失败补跑 | 跳过(0 分标准轮 R663 承接,本档 40 分档不承担) |
+
+## 2. 只读盘点(S3 精简 + S3.5)
+
+- 状态机:RED **2**(`web.adminPanel.runE2E` / `web.frontendMobile.runSmoke`)/ GREEN **5**(与上轮持平,零漂移)
+- 场景证据 `--sc-evidence`:SC 总 **243** / 台账已跑通 **27** / `strict_pass` **0** / `worktree_clean` **false**(tracked 区 1 处他档 staged WIP → strict 归 0 系口径失真,**非场景退化**,承袭 R667 P-663-1)
+- `--retest-gate`:**65 项全 retest / carry 0**(窗口有 src 提交)→ 本档为**用例编写档**,按 SKILL 纪律**不实测复跑**,全量复测归 50 分稳态档 + 标准轮
+- 跳过 `--changes` / `--clean-check`(标准轮承接)
+
+## 3. 本档主职责:SC-P-50 三类流用例编写
+
+**目标 SC 选定**:对照 `sc-key-map.md` 243 行台账 + `tests/test-cases/parent.md`(TC-P-50 / TC-P-50-b / -E / -P),筛出「实现已 GREEN + 用例齐 + 无既有三流 spec」的 **SC-P-50 成长记录查看**(`growth.history.view` GREEN)。
+
+- 端点核对(`cfc-backend` 源码):`GrowthRecordController` `/api/growth/record/list`(`@RequestAttribute("userId")`)、`/api/growth/record/child-records`(body 裸 `Long` memberId + **G-11 归属门禁**)、`PointsController` `/api/points/logs`
+- **禁臆造断言纪律**:先写忽略型探针 `_probe_p50_growth.spec.js`(gitignore,跑后删)实测远端 `cfc.iwintrue.com` 锁定真实契约,再写严格断言:
+
+| 探针项 | 实测契约 |
+|---|---|
+| `LIST_OK` | 200 `data=[]`(首访空态不 500) |
+| `CHILD_SELF`(裸数字 body=自身 memberId) | 200 `data=[]` |
+| `CHILD_OBJ`(body 传对象 `{memberId}`) | **400「请求参数格式错误,请检查请求体 JSON 或字段类型」** |
+| `CROSS`(跨家庭 memberId=999999) | **403「无权访问该成员成长档案」**(G-11 门禁真实生效) |
+| `LIST_ANON`(无 token) | **401「请先登录」** |
+| `LOGS_OK` | 200 `Page{records:[],total:0}` |
+| `LOGS_BADPAGE`(page=-1) | 200(分页参数宽松,**如实断言不锁 400**) |
+
+**新增用例**:`tests/e2e/api/sc-p50-growth-record.spec.js`(**7 用例**:正常 3 / 异常 2 / 权限 2)
+实跑:`npx playwright test ... -c playwright.config.api.js --project=desktop` → **7 passed (6.9s)**;`node --check` 语法校验通过。
+
+## 4. 契约缺口(承袭·真实缺陷未修,不为缺陷造绿、不写放水断言)
+
+| 项 | 现象 | 处置 |
+|---|---|---|
+| `/api/points/logs` 匿名放行 | 探针 ANON 返回 **200 + 空 Page**(非 401) | 权限流以 growth 域真实守卫(403 / 401)为主证;spec 文件头如实标注,不断言 points 401 |
+| `child-records` 入参严格性 | 对象 body → 400(须裸 `Long`) | 属入参契约,**非缺陷**;异常流据实测 400 断言 |
+
+**已覆盖·本轮无新增**:SC-P-95(`growth.history.view` 同键,已跑通·`traceability-p94-p95-c26.spec.js`);SC-C-14 / P-38 / P-44(承袭·真实缺陷未修)。命中 blocker 的 SC(越权 G-304-1、任务打卡 B-275-1、心愿兑换 500、C-24 异常分数、C-26 睡眠标签契约缺口)本轮**零触碰**。
+
+## 5. 交付与收口
+
+- 精确提交:`git add -- tests/e2e/api/sc-p50-growth-record.spec.js docs/tdd/orchestration/harvest-run-2026-11-30-0301.md` + `git commit -- <两文件>` + push `origin cfclub`(**未 `git add .`**,他档 staged WIP 零触碰、`.r*` 零混入);报告命名按 `.gitignore:160`(`report-*.md` 被拦)改用 `harvest-run-*.md` 入库
+- SC-P-50 转正口径(未由本档代判):三流实测通过 ✅ / 证据 SHA 入 `origin/cfclub` 祖先 ✅(随本轮提交)/ 工作区干净 ❌(他档 staged WIP `sc-p-64-profile-edit.spec.js` 未提交)→ **待他档收口后由标准轮 `--sc-evidence` 复核转正**
+
+## 6. 未实测与未授权
+
+- **未实测**:playwright 双端 Jest、编译、覆盖率重算、SRS 闸门、UAT(归稳态档/标准轮)
+- **未授权**:压测 / SAST / DAST / 依赖漏洞扫描 / 公网写操作(execute 档未授权,一律不跑)

+ 86 - 0
tests/e2e/api/sc-p50-growth-record.spec.js

@@ -0,0 +1,86 @@
+/**
+ * SC-P-50 成长记录查看(时间线聚合)三类流(API 级 e2e)
+ * ================================================================
+ * 端点(源码核对 cfc-backend GrowthRecordController / PointsController):
+ *   - /api/growth/record/list        家长查本人成长档案列表(@RequestAttribute("userId"),无 token → 401「请先登录」)
+ *   - /api/growth/record/child-records  按成员查成长档案(body 为裸 Long memberId,G-11 归属门禁:跨家庭 → 403「无权访问该成员成长档案」)
+ *   - /api/points/logs               积分流水分页(body {memberId?,page?,size?},缺省取 currentMemberId)
+ *
+ * 探针取证(2026-11-30 远程 cfc.iwintrue.com 实测锁定):
+ *   LIST_OK    200 data=[](首访空态正常,不 500)
+ *   CHILD_SELF 200 data=[](裸数字 body 自身 memberId)
+ *   CHILD_OBJ  400「请求参数格式错误,请检查请求体 JSON 或字段类型」(body 传对象 {memberId} 而非裸数字)
+ *   CROSS      403「无权访问该成员成长档案」(跨家庭 memberId=999999)
+ *   LIST_ANON  401「请先登录」(/api/growth/record/list 无 token)
+ *   LOGS_OK    200 data=Page{records:[]}
+ *   LOGS_BADPAGE 200(page=-1 未被拒,points/logs 分页参数宽松——如实断言不锁 400)
+ *
+ * 契约缺口(承袭·真实缺陷未修,不为缺陷造绿):
+ *   ① /api/points/logs 匿名未 401(探针 ANON 返回 200 + 空 Page,属放行面),
+ *     与 TC-P-50-P「非归属 403/401」部分偏离——权限流以 growth 域的 403/401 真实守卫为主证;
+ *   ② /api/growth/record/child-records 对对象 body 返回 400 而非 200(body 须裸数字),
+ *     属入参契约严格性,非缺陷;正常/异常/权限三流均以实测契约断言。
+ */
+const { test, expect } = require('@playwright/test');
+const { apiPost, registerRole, pickMemberByUserId, uniqueSuffix } = require('../helpers/api');
+
+test.describe('SC-P-50 成长记录查看三类流', () => {
+  let user, selfMemberId;
+
+  test.beforeAll(async ({ request }) => {
+    user = await registerRole(request, 'parent', 'QA-P50-' + uniqueSuffix());
+    const mem = await apiPost(request, '/api/family/member/list', {}, user.token);
+    const self = pickMemberByUserId(mem.data, user.userId);
+    expect(self, '成员列表应含登录用户自身').toBeTruthy();
+    selfMemberId = self.id;
+  });
+
+  // ---------- 正常流(P1:查成长记录 / 时间线聚合)----------
+  test('[P-50 正常] 家长查本人成长档案列表返回数组(首访空态不报错)', async ({ request }) => {
+    const r = await apiPost(request, '/api/growth/record/list', {}, user.token);
+    expect(r.code, 'list: ' + r.message).toBe(200);
+    expect(Array.isArray(r.data), '应返回数组').toBe(true);
+  });
+
+  test('[P-50 正常] 按家庭成员查成长档案(裸数字 body)返回数组', async ({ request }) => {
+    const r = await apiPost(request, '/api/growth/record/child-records', selfMemberId, user.token);
+    expect(r.code, 'child-records: ' + r.message).toBe(200);
+    expect(Array.isArray(r.data), '应返回数组').toBe(true);
+  });
+
+  test('[P-50 正常] 查积分流水返回分页结构(records 数组 + total)', async ({ request }) => {
+    const r = await apiPost(request, '/api/points/logs', { memberId: selfMemberId }, user.token);
+    expect(r.code, 'logs: ' + r.message).toBe(200);
+    expect(r.data && typeof r.data === 'object', '应返回分页对象').toBe(true);
+    expect(Array.isArray(r.data.records), 'records 应为数组').toBe(true);
+    expect(typeof r.data.total).toBe('number');
+  });
+
+  // ---------- 异常流(P2:空态 / 入参异常)----------
+  test('[P-50-E 异常] 首访无成长数据返回空数组(不 500、不报错)', async ({ request }) => {
+    const r = await apiPost(request, '/api/growth/record/list', {}, user.token);
+    expect(r.code, '首访空态应 200: ' + r.message).toBe(200);
+    expect(r.code).not.toBe(500);
+    expect(Array.isArray(r.data)).toBe(true);
+  });
+
+  test('[P-50-E 异常] child-records 传对象 body(非裸数字)被 400 拒绝', async ({ request }) => {
+    const r = await apiPost(request, '/api/growth/record/child-records', { memberId: selfMemberId }, user.token);
+    expect(r.code, '对象 body 应 400: ' + r.message).toBe(400);
+    expect(r.code).not.toBe(500);
+    expect(String(r.message)).toMatch(/请求参数格式错误|JSON 或字段类型/i);
+  });
+
+  // ---------- 权限流(P3:归属 / 登录守卫)----------
+  test('[P-50-P 权限] 跨家庭 memberId 访问成长档案被 403 拒绝', async ({ request }) => {
+    const r = await apiPost(request, '/api/growth/record/child-records', 999999, user.token);
+    expect(r.code, '跨家庭应 403: ' + r.message).toBe(403);
+    expect(String(r.message)).toMatch(/无权访问该成员成长档案/i);
+  });
+
+  test('[P-50-P 权限] 匿名查本人成长档案被 401 拒绝', async ({ request }) => {
+    const r = await apiPost(request, '/api/growth/record/list', {}, '');
+    expect(r.code, '匿名应 401: ' + r.message).toBe(401);
+    expect(r.code).not.toBe(200);
+  });
+});