소스 검색

test(e2e): SC-A-04 关系类型字典 CRUD 三流用例(R558 三流证据档)

- 新增 family-relation-types-sc-a04.spec.js:正常4/异常5/权限2 = 11 用例
- 契约经 _probe_a04 线上实跑锁定(4/4),源码+探针双基线,零臆造
- 探针为未追踪临时件已删除,未入提交
- 报告 R558-1301:本档 B 类只补用例,不代判跑通
E2E Test Bot 58 분 전
부모
커밋
6338d89661
2개의 변경된 파일과 158개의 추가작업 그리고 0개의 파일을 삭제
  1. 55 0
      docs/tdd/orchestration/report-test-2026-11-28-R558-1301.md
  2. 103 0
      tests/e2e/api/family-relation-types-sc-a04.spec.js

+ 55 - 0
docs/tdd/orchestration/report-test-2026-11-28-R558-1301.md

@@ -0,0 +1,55 @@
+# 测试收割报告 · R558(三流证据档 / B 类 40 分档)
+
+- 时间:2026-11-28 13:01(北京时间)
+- 档位:三流证据档(minute=40,B 类 = 编写用户场景三流测试用例)
+- 主工作树:d:/cfc · 分支 cfclub · data_ref=origin/cfclub
+- 角色:测试负责人(只补用例、不代判跑通、不分派)
+
+## S0 启动前置检查(三查,60s 硬预算)
+- ① 分支:`cfclub` ✓
+- ② `HEAD...origin/cfclub = 0 0`(无差距)✓
+- ③ tracked 脏清单:空(`git status --porcelain | grep -v '^?? '` 无匹配行)✓
+- 结论:PASS,全程只读收口可用。
+
+## S1 互斥门
+- `{"verdict":"PASS","reason":"无他轮在产信号","mutex_minutes":10,"worklog_active":null,"locks":{}}` ✓
+
+## S2 失败补跑
+- 本档为 B 类写用例档,**跳过**(由 0 分标准轮承担),报告注明。
+
+## S3 精简盘点(标准轮承接)
+- 跳过 `--changes / --clean-check`(标准轮承接),仅核对目录结构:`tests/e2e/{api,roles,helpers,generated}` 完整 ✓。
+
+## 主职责:为「未跑通」SC 补齐三流 e2e spec
+
+### 本轮新增(1 个 SC,三流断言齐全,实跑全绿)
+| SC | 角色 | 业务域 | 新增 spec | 三流实跑 | 断言基线 |
+|----|------|--------|-----------|----------|----------|
+| SC-A-04 | 平台运营 | 关系类型 CRUD | `tests/e2e/api/family-relation-types-sc-a04.spec.js` | 11/11 全绿(正常4/异常5/权限2) | 源码+探针双锁定 |
+
+- 契约基线:`AdminFamilyRelationController /api/admin/family-relation/types/{list,save,update,disable}`;
+  服务层 `FamilyRelationTypeService`;码值 success=200 / badRequest=400 / forbidden=403。
+- **探针先行**(B 类禁臆造断言):`_probe_a04_family_relation.spec.js` 于本档线上实跑 4/4 锁定契约
+  (save=200、list=200、缺 typeKey=400、家长越权=403),实测契约与源码完全一致后**才写严格断言**;
+  探针为未追踪临时件,**已删除**,不入提交。
+- 三流构成:正常流 N1-N4(新增/列表检索/编辑/停用 confirm);异常流 E1-E5(缺键/重复/更新不存在/停用未确认/停用不存在);
+  权限流 P1-P2(家长、规划师越权一律 403)。
+- 台账侧同步:SC-A-04 由「未跑通」→「已跑通(2026-11-28 R558 复验收口)」建议标准轮在 sc-key-map.md 落行(本档只补用例,不代判,交由标准轮核验三流实测+推送+工作区干净三条后转正)。
+
+### 已覆盖·本轮无新增(既有 e2e spec 三流齐全,不重复造用例)
+- SC-P-03 / SC-P-10 / SC-P-12 / SC-P-77 / SC-P-86 / SC-P-94 / SC-P-95、SC-C-04 / C-05 / C-07 / C-09 / C-22 / C-24 / C-26、
+  SC-T-06 / T-18、SC-X-02 / X-05 / X-13、SC-B-07、SC-A-05、SC-P-13 / P-14 / P-87 / P-88、SC-C-10 / C-14 —— 均有对应 spec 且台账侧已跑通或已登记,本轮无新增。
+
+### 承袭·真实缺陷未修(blocker,不为缺陷造绿、不写放水断言)
+- G-304-1 跨家庭越权拒绝缺失(P0);B-275-1 任务打卡 500(影响 C-05/C-14);心愿兑换 500(P-13/P-14/C-04);
+  C-24 异常分数;C-26 睡眠标签契约缺口;B-260-1 法务页生产未部署;N-R373-1 生产网关 502;N-R373-2 lg 上游 AI ConnectError;
+  G9 SRS 场景锚点覆盖率;B-325-1 lg pytest 未干净退出;S1-1/R203 cfc-web 契约 —— 以上与 R557 一致,承袭标注,本轮未触碰。
+
+## B 类交付纪律核验
+- 只 add/commit 自有产物:`tests/e2e/api/family-relation-types-sc-a04.spec.js` + 本报告,**未使用 `git add .`**。
+- `.r*` 未追踪产物、既有 `_probe_*.spec.js`(6 个未追踪)均**未进入**本次提交(只 add 精确路径)。
+- 提交后核验:tracked 区干净 + `origin/cfclub` 已含本提交。
+
+## 结论
+- 本轮 B 类新增 1 个三流齐全 e2e spec(SC-A-04,11/11 全绿),探针锁定真实契约后写断言,零臆造;
+  其余已覆盖 SC 标「已覆盖·本轮无新增」;blocker 承袭标注。全程 ≤20 分钟,无人值守,未提问。

+ 103 - 0
tests/e2e/api/family-relation-types-sc-a04.spec.js

@@ -0,0 +1,103 @@
+// SC-A-04 家庭关系类型字典 CRUD 三流 e2e(管理端)
+// 契约基线:AdminFamilyRelationController /api/admin/family-relation/types/{list,save,update,disable}
+//           服务层 FamilyRelationTypeService;码值 success=200 / badRequest=400 / forbidden=403
+//           探针 _probe_a04_family_relation 已于 2026-11-28 线上实跑锁定(4/4,契约=源码)
+const { test, expect } = require('@playwright/test');
+const { registerRole, apiPost, uniqueSuffix } = require('../helpers/api');
+
+const BASE = '/api/admin/family-relation/types';
+
+test.describe('SC-A-04 关系类型字典 CRUD 三流', () => {
+  let admin, parent, teacher, created;
+
+  test.beforeAll(async ({ request }) => {
+    admin = await registerRole(request, 'admin', 'QA-A04-ADMIN');
+    parent = await registerRole(request, 'parent', 'QA-A04-PARENT');
+    teacher = await registerRole(request, 'teacher', 'QA-A04-TEACHER');
+  });
+
+  // ===== 正常流 =====
+  test('N1: admin 新增关系类型并入库', async ({ request }) => {
+    const key = 'sc_a04_' + uniqueSuffix();
+    const r = await apiPost(request, BASE + '/save', {
+      typeKey: key, typeName: '关系类型' + key, label: '标签', description: 'e2e三流', sortOrder: 9, enabled: true,
+    }, admin.token);
+    expect(r.code).toBe(200);
+    expect(r.data.typeKey).toBe(key);
+    expect(r.data.typeName).toBe('关系类型' + key);
+    expect(r.data.enabled).toBe(1);
+    created = r.data;
+  });
+
+  test('N2: admin 列表检索到新建项', async ({ request }) => {
+    const r = await apiPost(request, BASE + '/list', { typeKey: created.typeKey }, admin.token);
+    expect(r.code).toBe(200);
+    const hit = (r.data || []).find((x) => x.typeKey === created.typeKey);
+    expect(hit).toBeTruthy();
+    expect(hit.typeName).toBe(created.typeName);
+    expect(typeof hit.referenceCount).toBe('number');
+  });
+
+  test('N3: admin 编辑关系类型', async ({ request }) => {
+    const newName = '改名' + uniqueSuffix();
+    const r = await apiPost(request, BASE + '/update', {
+      id: created.id, typeName: newName, sortOrder: 7,
+    }, admin.token);
+    expect(r.code).toBe(200);
+    expect(r.data.id).toBe(created.id);
+    expect(r.data.typeName).toBe(newName);
+    expect(r.data.sortOrder).toBe(7);
+  });
+
+  test('N4: admin 停用关系类型(confirm)', async ({ request }) => {
+    const r = await apiPost(request, BASE + '/disable', { id: created.id, confirm: true }, admin.token);
+    expect(r.code).toBe(200);
+    expect(r.data.id).toBe(created.id);
+    expect(r.data.enabled).toBe(0);
+  });
+
+  // ===== 异常流 =====
+  test('E1: 缺 typeKey/typeName 被拒(400)', async ({ request }) => {
+    const r1 = await apiPost(request, BASE + '/save', { typeName: '无键' }, admin.token);
+    expect(r1.code).toBe(400);
+    expect(r1.message).toContain('不能为空');
+    const r2 = await apiPost(request, BASE + '/save', { typeKey: 'sc_a04_nk_' + uniqueSuffix() }, admin.token);
+    expect(r2.code).toBe(400);
+  });
+
+  test('E2: 重复 typeKey 被拒(400)', async ({ request }) => {
+    const r = await apiPost(request, BASE + '/save', { typeKey: created.typeKey, typeName: '重复' }, admin.token);
+    expect(r.code).toBe(400);
+    expect(r.message).toContain('已存在');
+  });
+
+  test('E3: 更新不存在 id 被拒(400)', async ({ request }) => {
+    const r = await apiPost(request, BASE + '/update', { id: 999999999, typeName: 'x' }, admin.token);
+    expect(r.code).toBe(400);
+    expect(r.message).toContain('不存在');
+  });
+
+  test('E4: 停用未确认被拒(400)', async ({ request }) => {
+    const r = await apiPost(request, BASE + '/disable', { id: created.id }, admin.token);
+    expect(r.code).toBe(400);
+    expect(r.message).toContain('解绑或确认停用');
+  });
+
+  test('E5: 停用不存在 id 被拒(400)', async ({ request }) => {
+    const r = await apiPost(request, BASE + '/disable', { id: 999999999, confirm: true }, admin.token);
+    expect(r.code).toBe(400);
+  });
+
+  // ===== 权限流 =====
+  test('P1: 家长越权 save/update/disable/list 一律 403', async ({ request }) => {
+    for (const path of ['/save', '/update', '/disable', '/list']) {
+      const r = await apiPost(request, BASE + path, { typeKey: 'x', typeName: 'y', id: 1 }, parent.token);
+      expect(r.code, '家长调用 ' + path + ' 应 403').toBe(403);
+    }
+  });
+
+  test('P2: 规划师越权 save 被拒 403', async ({ request }) => {
+    const r = await apiPost(request, BASE + '/save', { typeKey: 'sc_a04_t_' + uniqueSuffix(), typeName: 't' }, teacher.token);
+    expect(r.code).toBe(403);
+  });
+});