| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- /**
- * 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);
- });
- });
|