/**
 * L2 回归测试：播放历史
 */
import { test, expect } from '@playwright/test';
import { apiGet, apiDelete, initApiClient, disposeApiClient } from '../helpers/api-client';

test.describe('播放历史 (History)', () => {
  test.beforeAll(async () => { await initApiClient(); });
  test.afterAll(async () => { await disposeApiClient(); });

  test('H01: 获取历史列表 GET /api/history', async () => {
    const res = await apiGet('/api/history', { page: '1', pageSize: '5' });
    expect(res.code).toBe(0);
    expect(res.data).toBeDefined();
  });

  test('H02: 分页参数生效', async () => {
    const res = await apiGet('/api/history', { page: '1', pageSize: '2' });
    expect(res.code).toBe(0);
  });

  test('H03: 按日期筛选', async () => {
    const res = await apiGet('/api/history', { startDate: '2024-01-01' });
    expect(res.code).toBe(0);
  });

  test('H04: 批量删除历史 DELETE /api/history/batch', async () => {
    const res = await apiDelete('/api/history/batch');
    // 可能成功(0)或需要认证(401)
    expect([0, 401]).toContain(res.code);
  });
});
