/** * L2 回归测试:音频播放器 * 覆盖:播放列表、播放进度CRUD、最近播放、章节音频详情、公开状态 */ import { test, expect } from '@playwright/test'; import { apiGet, apiPost, apiPut, apiDelete, initApiClient, disposeApiClient } from '../helpers/api-client'; test.describe('音频播放器 (Player)', () => { test.beforeAll(async () => { await initApiClient(); }); test.afterAll(async () => { await disposeApiClient(); }); test('P01: 获取音频播放列表 GET /api/player/audio/list', async () => { const res = await apiGet('/api/player/audio/list'); expect(res.code).toBe(0); expect(res.data).toBeDefined(); }); test('P02: 获取播放进度 GET /api/player/progress', async () => { const res = await apiGet('/api/player/progress'); expect(res.code).toBe(0); }); test('P03: 保存播放进度 POST /api/player/progress', async () => { const res = await apiPost('/api/player/progress', { audioId: 1, progress: 30.5, duration: 120, }); // 可能成功(0)或需要认证(401) expect([0, 401]).toContain(res.code); }); test('P04: 更新播放进度 PUT /api/player/progress/1', async () => { const res = await apiPut('/api/player/progress/1', { progress: 60.0 }); // 可能成功(0)、未找到(404)或需要认证(401) expect([0, 401, 404]).toContain(res.code); }); test('P05: 获取最近播放 GET /api/player/recent', async () => { const res = await apiGet('/api/player/recent'); expect(res.code).toBe(0); }); test('P06: 获取章节音频详情 GET /api/player/audio/:id', async () => { const res = await apiGet('/api/player/audio/1'); expect([0, 404]).toContain(res.code); }); test('P07: 更新公开状态 PUT /api/player/audio/:id/public', async () => { const res = await apiPut('/api/player/audio/1/public', { isPublic: true }); expect([0, 403, 404]).toContain(res.code); }); });