| 123456789101112131415161718192021222324252627 |
- /**
- * L2 回归测试:收藏功能
- */
- import { test, expect } from '@playwright/test';
- import { apiGet, apiPost, apiDelete, initApiClient, disposeApiClient } from '../helpers/api-client';
- test.describe('收藏功能 (Favorites)', () => {
- test.beforeAll(async () => { await initApiClient(); });
- test.afterAll(async () => { await disposeApiClient(); });
- test('F01: 获取收藏列表 GET /api/favorites', async () => {
- const res = await apiGet('/api/favorites');
- expect(res.code).toBe(0);
- });
- test('F02: 添加收藏 POST /api/favorites', async () => {
- const res = await apiPost('/api/favorites', { audioId: '1' });
- // 可能成功(0)、重复(400)或需要认证(401)
- expect([0, 400, 401]).toContain(res.code);
- });
- test('F03: 取消收藏 DELETE /api/favorites/:id', async () => {
- const res = await apiDelete('/api/favorites/99999');
- // 可能成功(0)、未找到(404)或需要认证(401)
- expect([0, 401, 404]).toContain(res.code);
- });
- });
|