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\12-album.spec.ts >> 专辑管理 (Album) >> AL01: 获取专辑列表 GET /api/book-generator/albums
- Location: regression\12-album.spec.ts:11:7
Error details
Error: expect(received).toBe(expected) // Object.is equality
Expected: 0
Received: 404
Test source
1 | /**
2 | * L2 回归测试:专辑管理
3 | */
4 | import { test, expect } from '@playwright/test';
5 | import { apiGet, apiPost, apiPut, apiDelete, initApiClient, disposeApiClient } from '../helpers/api-client';
6 |
7 | test.describe('专辑管理 (Album)', () => {
8 | test.beforeAll(async () => { await initApiClient(); });
9 | test.afterAll(async () => { await disposeApiClient(); });
10 |
11 | test('AL01: 获取专辑列表 GET /api/book-generator/albums', async () => {
12 | const res = await apiGet('/api/book-generator/albums');
> 13 | expect(res.code).toBe(0);
| ^ Error: expect(received).toBe(expected) // Object.is equality
14 | });
15 |
16 | test('AL02: 获取专辑章节 GET /api/book-generator/albums/:id/chapters', async () => {
17 | const res = await apiGet('/api/book-generator/albums/1/chapters');
18 | expect([0, 404]).toContain(res.code);
19 | });
20 |
21 | test('AL03: 重命名专辑 PUT /api/book-generator/album/:id/rename', async () => {
22 | const res = await apiPut('/api/book-generator/album/1/rename', { title: '新名称' });
23 | expect([0, 404, 403]).toContain(res.code);
24 | });
25 |
26 | test('AL04: 重命名章节 PUT /api/book-generator/album/:bookId/chapters/:chapterId/rename', async () => {
27 | const res = await apiPut('/api/book-generator/album/1/chapters/1/rename', { title: '新章节' });
28 | // 可能成功(0)、未找到(404)、禁止(403)或需要认证(401)
29 | expect([0, 401, 403, 404]).toContain(res.code);
30 | });
31 |
32 | test('AL05: 移动章节 PUT /api/book-generator/album/:bookId/chapters/:chapterId/move', async () => {
33 | const res = await apiPut('/api/book-generator/album/1/chapters/1/move', { newNumber: 2 });
34 | // 可能成功(0)、未找到(404)、禁止(403)或需要认证(401)
35 | expect([0, 401, 403, 404]).toContain(res.code);
36 | });
37 | });
38 |