| 12345678910111213141516171819202122232425262728293031323334353637 |
- const { test, expect } = require('@playwright/test');
- const { loginAs, BASE_URL } = require('../../helpers/auth');
- const { assertApiSuccess, authHeaders } = require('../../helpers/utils');
- test.describe('【孩子】健康打卡', function() {
- var auth;
- test.beforeAll(async function({ browser }) {
- auth = await loginAs(browser, 'child');
- });
- test('[场景1] 完成每日打卡 — 打卡成功', async function({ page }) {
- var resp = await page.request.post(BASE_URL + '/api/health/checkin/create', {
- headers: authHeaders(auth),
- data: { childId: 1003, dietScore: 85, exerciseScore: 70, sleepScore: 90, moodScore: 80 },
- });
- await assertApiSuccess(resp);
- });
- test('[场景1b] 打卡数据为空 — 期望错误', async function({ page }) {
- var resp = await page.request.post(BASE_URL + '/api/health/checkin/create', {
- headers: authHeaders(auth),
- data: {},
- });
- var body = await resp.json();
- expect(body.code).not.toBe(200);
- });
- test('[场景2] 查看连续签到 — 返回天数', async function({ page }) {
- var resp = await page.request.post(BASE_URL + '/api/health/checkin/streak', {
- headers: authHeaders(auth),
- data: { childId: 1003 },
- });
- var data = await assertApiSuccess(resp);
- expect(data).toBeTruthy();
- });
- });
|