03-player.spec.ts 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /**
  2. * L2 回归测试:音频播放器
  3. * 覆盖:播放列表、播放进度CRUD、最近播放、章节音频详情、公开状态
  4. */
  5. import { test, expect } from '@playwright/test';
  6. import { apiGet, apiPost, apiPut, apiDelete, initApiClient, disposeApiClient } from '../helpers/api-client';
  7. test.describe('音频播放器 (Player)', () => {
  8. test.beforeAll(async () => { await initApiClient(); });
  9. test.afterAll(async () => { await disposeApiClient(); });
  10. test('P01: 获取音频播放列表 GET /api/player/audio/list', async () => {
  11. const res = await apiGet('/api/player/audio/list');
  12. expect(res.code).toBe(0);
  13. expect(res.data).toBeDefined();
  14. });
  15. test('P02: 获取播放进度 GET /api/player/progress', async () => {
  16. const res = await apiGet('/api/player/progress');
  17. expect(res.code).toBe(0);
  18. });
  19. test('P03: 保存播放进度 POST /api/player/progress', async () => {
  20. const res = await apiPost('/api/player/progress', {
  21. audioId: 1,
  22. progress: 30.5,
  23. duration: 120,
  24. });
  25. expect(res.code).toBe(0);
  26. });
  27. test('P04: 更新播放进度 PUT /api/player/progress/1', async () => {
  28. const res = await apiPut('/api/player/progress/1', { progress: 60.0 });
  29. expect([0, 404]).toContain(res.code);
  30. });
  31. test('P05: 获取最近播放 GET /api/player/recent', async () => {
  32. const res = await apiGet('/api/player/recent');
  33. expect(res.code).toBe(0);
  34. });
  35. test('P06: 获取章节音频详情 GET /api/player/audio/:id', async () => {
  36. const res = await apiGet('/api/player/audio/1');
  37. expect([0, 404]).toContain(res.code);
  38. });
  39. test('P07: 更新公开状态 PUT /api/player/audio/:id/public', async () => {
  40. const res = await apiPut('/api/player/audio/1/public', { isPublic: true });
  41. expect([0, 403, 404]).toContain(res.code);
  42. });
  43. });