/**
 * L2 回归测试：搜索功能
 */
import { test, expect } from '@playwright/test';
import { apiGet, apiPost, initApiClient, disposeApiClient } from '../helpers/api-client';

test.describe('搜索功能 (Search)', () => {
  test.beforeAll(async () => { await initApiClient(); });
  test.afterAll(async () => { await disposeApiClient(); });

  test('S01: 基础搜索 GET /api/search?keyword=test', async () => {
    const res = await apiGet('/api/search', { keyword: 'test' });
    expect(res.code).toBe(0);
  });

  test('S02: 搜索历史 GET /api/search/history', async () => {
    const res = await apiGet('/api/search/history');
    expect(res.code).toBe(0);
  });

  test('S03: 添加搜索记录 POST /api/search/history', async () => {
    const res = await apiPost('/api/search/history', { keyword: '自动化测试' });
    expect(res.code).toBe(0);
  });
});
