| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- const { test, expect } = require('@playwright/test');
- const { loginAs, BASE_URL } = require('../../helpers/auth');
- const { assertApiSuccess, assertApiError, authHeaders } = require('../../helpers/utils');
- test.describe('【家长】心愿管理', () => {
- var auth;
- test.beforeAll(async ({ browser }) => {
- auth = await loginAs(browser, 'parent');
- });
- test('[场景1] 查看孩子心愿列表 — 期望返回心愿数据', async ({ page }) => {
- var resp = await page.request.post(BASE_URL + '/api/wishes/list?childId=1003&familyId=2001', {
- headers: authHeaders(auth),
- data: {}
- });
- var data = await assertApiSuccess(resp);
- expect(data).toBeDefined();
- });
- test('[场景2] 查看待处理心愿列表 — 期望返回待处理数据', async ({ page }) => {
- var resp = await page.request.post(BASE_URL + '/api/wishes/pending', {
- headers: authHeaders(auth),
- data: {
- familyId: 2001
- }
- });
- var data = await assertApiSuccess(resp);
- expect(data).toBeDefined();
- });
- // Scene 3 & 4 both verify the wish detail endpoint handles missing data correctly
- test('[场景3] 查看不存在的心愿详情 — 期望返回业务错误', async ({ page }) => {
- var resp = await page.request.post(BASE_URL + '/api/wishes/999999', {
- headers: authHeaders(auth),
- data: {}
- });
- await assertApiError(resp);
- });
- test('[场景4] 另一无效ID的心愿详情 — 同样期望返回业务错误', async ({ page }) => {
- var resp = await page.request.post(BASE_URL + '/api/wishes/1', {
- headers: authHeaders(auth),
- data: {}
- });
- await assertApiError(resp);
- });
- });
|