| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- /**
- * SC-C-05 方案任务打卡三类流(task.child.checkin)
- * ================================================================
- * 正常流:每日打卡创建/列表/详情;
- * 异常流:无效打卡参数被拒;重复打卡幂等处理;
- * 权限流:跨家庭成员打卡被拒。
- */
- const { test, expect } = require('@playwright/test');
- const { registerRole, apiPost, uniqueSuffix } = require('../helpers/api');
- test.describe('SC-C-05 方案任务打卡三类流', () => {
- let parent;
- let childA;
- test.beforeAll(async ({ request }) => {
- parent = await registerRole(request, 'parent', 'QA-CHKIN');
- const mem = await apiPost(request, '/api/family/member/list', {}, parent.token);
- const self = (mem.data || []).find((m) => String(m.userId) === String(parent.userId));
- const addA = await apiPost(request, '/api/family/member/add', {
- relativeMemberId: self.id, generationLevel: 'child',
- nickname: 'A-Chkin' + uniqueSuffix(), gender: 'female', birthday: '2016-04-01',
- }, parent.token);
- expect(addA.code, 'addA: ' + addA.message).toBe(200);
- childA = addA.data.id;
- });
- test('[C-05 正常] 每日打卡创建', async ({ request }) => {
- const r = await apiPost(request, '/api/daily/checkin/create', {
- memberId: childA, content: '完成阅读' + uniqueSuffix(), type: 'daily', moodLevel: 4,
- }, parent.token);
- expect(r.code, r.message).toBe(200);
- });
- test('[C-05 正常] 打卡列表与详情', async ({ request }) => {
- const list = await apiPost(request, '/api/daily/checkin/list', { memberId: childA }, parent.token);
- expect(list.code, list.message).toBe(200);
- const items = list.data && (Array.isArray(list.data) ? list.data : list.data.records);
- if (items && items.length) {
- const detail = await apiPost(request, '/api/daily/checkin/detail', {
- memberId: childA, checkinId: items[0].id,
- }, parent.token);
- expect(detail.code, detail.message).toBe(200);
- }
- });
- test('[C-05-E 异常] 无效打卡参数被拒', async ({ request }) => {
- const r = await apiPost(request, '/api/daily/checkin/create', {
- memberId: childA, content: '', type: 'UNKNOWN_TYPE',
- }, parent.token);
- expect(r.code).not.toBe(200);
- });
- test('[C-05-P 权限] 跨家庭成员打卡被拒', async ({ request }) => {
- const r = await apiPost(request, '/api/daily/checkin/create', {
- memberId: 999999999, content: '越权打卡', type: 'daily',
- }, parent.token);
- expect(r.code).not.toBe(200);
- });
- });
|