04-favorites.spec.ts 865 B

12345678910111213141516171819202122232425
  1. /**
  2. * L2 回归测试:收藏功能
  3. */
  4. import { test, expect } from '@playwright/test';
  5. import { apiGet, apiPost, apiDelete, initApiClient, disposeApiClient } from '../helpers/api-client';
  6. test.describe('收藏功能 (Favorites)', () => {
  7. test.beforeAll(async () => { await initApiClient(); });
  8. test.afterAll(async () => { await disposeApiClient(); });
  9. test('F01: 获取收藏列表 GET /api/favorites', async () => {
  10. const res = await apiGet('/api/favorites');
  11. expect(res.code).toBe(0);
  12. });
  13. test('F02: 添加收藏 POST /api/favorites', async () => {
  14. const res = await apiPost('/api/favorites', { audioId: '1' });
  15. expect([0, 400]).toContain(res.code);
  16. });
  17. test('F03: 取消收藏 DELETE /api/favorites/:id', async () => {
  18. const res = await apiDelete('/api/favorites/1');
  19. expect([0, 404]).toContain(res.code);
  20. });
  21. });