07-comments.spec.ts 928 B

12345678910111213141516171819202122232425262728
  1. /**
  2. * L2 回归测试:评论系统
  3. */
  4. import { test, expect } from '@playwright/test';
  5. import { apiGet, apiPost, apiDelete, initApiClient, disposeApiClient } from '../helpers/api-client';
  6. test.describe('评论系统 (Comments)', () => {
  7. test.beforeAll(async () => { await initApiClient(); });
  8. test.afterAll(async () => { await disposeApiClient(); });
  9. test('C01: 获取评论列表 GET /api/comments', async () => {
  10. const res = await apiGet('/api/comments');
  11. expect(res.code).toBe(0);
  12. });
  13. test('C02: 创建评论 POST /api/comments', async () => {
  14. const res = await apiPost('/api/comments', {
  15. audioId: '1',
  16. content: '[自动化测试] 测试评论内容',
  17. });
  18. expect([0, 400]).toContain(res.code);
  19. });
  20. test('C03: 删除评论 DELETE /api/comments/:id', async () => {
  21. const res = await apiDelete('/api/comments/99999');
  22. expect([0, 404]).toContain(res.code);
  23. });
  24. });