08-notifications.spec.ts 1.0 KB

12345678910111213141516171819202122232425262728
  1. /**
  2. * L2 回归测试:通知系统
  3. * 注意:通知 API 标记已读是 POST /api/notifications/read,不是 PUT
  4. */
  5. import { test, expect } from '@playwright/test';
  6. import { apiGet, apiPost, initApiClient, disposeApiClient } from '../helpers/api-client';
  7. test.describe('通知系统 (Notifications)', () => {
  8. test.beforeAll(async () => { await initApiClient(); });
  9. test.afterAll(async () => { await disposeApiClient(); });
  10. test('N01: 获取通知列表 GET /api/notifications', async () => {
  11. const res = await apiGet('/api/notifications');
  12. // 可能成功(0)或需要认证(401)
  13. expect([0, 401]).toContain(res.code);
  14. });
  15. test('N02: 标记已读 POST /api/notifications/read', async () => {
  16. const res = await apiPost('/api/notifications/read', { id: '1' });
  17. // 可能成功(0)、未找到(404)或需要认证(401)
  18. expect([0, 401, 404]).toContain(res.code);
  19. });
  20. test('N03: 获取未读数量 - 该接口不存在', async () => {
  21. // /api/notifications/unread-count 路由不存在,跳过
  22. test.skip();
  23. });
  24. });