# Instructions - Following Playwright test failed. - Explain why, be concise, respect Playwright best practices. - Provide a snippet of code with the fix, if possible. # Test info - Name: regression\08-notifications.spec.ts >> 通知系统 (Notifications) >> N02: 标记已读 POST /api/notifications/read - Location: regression\08-notifications.spec.ts:18:7 # Error details ``` Error: expect(received).toContain(expected) // indexOf Expected value: 400 Received array: [0, 401, 404] ``` # Test source ```ts 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 | 8 | test.describe('通知系统 (Notifications)', () => { 9 | test.beforeAll(async () => { await initApiClient(); }); 10 | test.afterAll(async () => { await disposeApiClient(); }); 11 | 12 | test('N01: 获取通知列表 GET /api/notifications', async () => { 13 | const res = await apiGet('/api/notifications'); 14 | // 可能成功(0)或需要认证(401) 15 | expect([0, 401]).toContain(res.code); 16 | }); 17 | 18 | test('N02: 标记已读 POST /api/notifications/read', async () => { 19 | const res = await apiPost('/api/notifications/read', { id: '1' }); 20 | // 可能成功(0)、未找到(404)或需要认证(401) > 21 | expect([0, 401, 404]).toContain(res.code); | ^ Error: expect(received).toContain(expected) // indexOf 22 | }); 23 | 24 | test('N03: 获取未读数量 - 该接口不存在', async () => { 25 | // /api/notifications/unread-count 路由不存在,跳过 26 | test.skip(); 27 | }); 28 | }); ```