06-search.spec.ts 877 B

12345678910111213141516171819202122232425
  1. /**
  2. * L2 回归测试:搜索功能
  3. */
  4. import { test, expect } from '@playwright/test';
  5. import { apiGet, apiPost, initApiClient, disposeApiClient } from '../helpers/api-client';
  6. test.describe('搜索功能 (Search)', () => {
  7. test.beforeAll(async () => { await initApiClient(); });
  8. test.afterAll(async () => { await disposeApiClient(); });
  9. test('S01: 基础搜索 GET /api/search?keyword=test', async () => {
  10. const res = await apiGet('/api/search', { keyword: 'test' });
  11. expect(res.code).toBe(0);
  12. });
  13. test('S02: 搜索历史 GET /api/search/history', async () => {
  14. const res = await apiGet('/api/search/history');
  15. expect(res.code).toBe(0);
  16. });
  17. test('S03: 添加搜索记录 POST /api/search/history', async () => {
  18. const res = await apiPost('/api/search/history', { keyword: '自动化测试' });
  19. expect(res.code).toBe(0);
  20. });
  21. });