|
@@ -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);
|
|
|
|
|
+ });
|
|
|
|
|
+});
|