12-album.spec.ts 1.6 KB

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