05-history.spec.ts 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. /**
  2. * L2 回归测试:播放历史
  3. */
  4. import { test, expect } from '@playwright/test';
  5. import { apiGet, apiDelete, initApiClient, disposeApiClient } from '../helpers/api-client';
  6. test.describe('播放历史 (History)', () => {
  7. test.beforeAll(async () => { await initApiClient(); });
  8. test.afterAll(async () => { await disposeApiClient(); });
  9. test('H01: 获取历史列表 GET /api/history', async () => {
  10. const res = await apiGet('/api/history', { page: '1', pageSize: '5' });
  11. expect(res.code).toBe(0);
  12. expect(res.data).toBeDefined();
  13. });
  14. test('H02: 分页参数生效', async () => {
  15. const res = await apiGet('/api/history', { page: '1', pageSize: '2' });
  16. expect(res.code).toBe(0);
  17. });
  18. test('H03: 按日期筛选', async () => {
  19. const res = await apiGet('/api/history', { startDate: '2024-01-01' });
  20. expect(res.code).toBe(0);
  21. });
  22. test('H04: 批量删除历史 DELETE /api/history/batch', async () => {
  23. const res = await apiDelete('/api/history/batch');
  24. // 可能成功(0)或需要认证(401)
  25. expect([0, 401]).toContain(res.code);
  26. });
  27. });