/** * L2 回归测试:跨平台发布、会员中心、用户反馈、分享、偏好、分类 * 批量覆盖模块 17-22 */ import { test, expect } from '@playwright/test'; import { apiGet, apiPost, apiPut, initApiClient, disposeApiClient } from '../helpers/api-client'; // ===== 17: 跨平台发布 ===== test.describe('跨平台发布 (Publish)', () => { test.beforeAll(async () => { await initApiClient(); }); test.afterAll(async () => { await disposeApiClient(); }); test('PU01: 获取平台账号 GET /api/publish/accounts', async () => { const res = await apiGet('/api/publish/accounts'); // 可能成功(0)或需要认证(401) expect([0, 401]).toContain(res.code); }); test('PU02: 获取发布任务列表 GET /api/publish/tasks', async () => { const res = await apiGet('/api/publish/tasks'); // 可能成功(0)或需要认证(401) expect([0, 401]).toContain(res.code); }); }); // ===== 18: 会员中心 ===== test.describe('会员中心 (Member)', () => { test.beforeAll(async () => { await initApiClient(); }); test.afterAll(async () => { await disposeApiClient(); }); test('MB01: 获取会员状态 GET /api/member/status', async () => { const res = await apiGet('/api/member/status'); expect(res.code).toBe(0); }); }); // ===== 19: 用户反馈 ===== test.describe('用户反馈 (Feedback)', () => { test.beforeAll(async () => { await initApiClient(); }); test.afterAll(async () => { await disposeApiClient(); }); test('FB01: 获取反馈列表 - 反馈仅支持 POST,跳过 GET', async () => { // /api/feedback 仅支持 POST,不支持 GET test.skip(); }); test('FB02: 提交反馈 POST /api/feedback', async () => { const res = await apiPost('/api/feedback', { content: '[自动化测试] 反馈内容', type: 'bug', title: '测试反馈', }); expect([0, 400]).toContain(res.code); }); }); // ===== 20: 分享功能 ===== test.describe('分享功能 (Share)', () => { test.beforeAll(async () => { await initApiClient(); }); test.afterAll(async () => { await disposeApiClient(); }); test('SH01: 获取分享链接 GET /api/share?audioId=xxx', async () => { const res = await apiGet('/api/share?audioId=1'); // 可能成功(0)、参数错误(400)或需要认证(401) expect([0, 400, 401]).toContain(res.code); }); }); // ===== 21: 用户偏好 ===== test.describe('用户偏好 (Preferences)', () => { test.beforeAll(async () => { await initApiClient(); }); test.afterAll(async () => { await disposeApiClient(); }); test('PR01: 获取偏好 GET /api/user/preferences', async () => { const res = await apiGet('/api/user/preferences'); expect(res.code).toBe(0); }); test('PR02: 更新偏好 PUT /api/user/preferences', async () => { const res = await apiPut('/api/user/preferences', { playSpeed: 1.5, quality: 'high', }); expect([0, 401, 400]).toContain(res.code); }); }); // ===== 22: 分类浏览 ===== test.describe('分类浏览 (Categories)', () => { test.beforeAll(async () => { await initApiClient(); }); test.afterAll(async () => { await disposeApiClient(); }); test('CT01: 获取分类列表 GET /api/categories', async () => { const res = await apiGet('/api/categories'); expect(res.code).toBe(0); }); }); // ===== 签到功能 ===== test.describe('签到功能 (Sign)', () => { test.beforeAll(async () => { await initApiClient(); }); test.afterAll(async () => { await disposeApiClient(); }); test('SG01: 获取签到状态 GET /api/sign/status', async () => { const res = await apiGet('/api/sign/status'); expect(res.code).toBe(0); }); test('SG02: 执行签到 POST /api/sign', async () => { const res = await apiPost('/api/sign'); expect([0, 400, 401]).toContain(res.code); }); });