openreader/tests/api.spec.ts
Richard Roberson 7a29f73d07 refactor(api): move audiobook endpoints to new path
- Relocated all audiobook-related API routes from `/api/audio/convert/*` to `/api/audiobook/*`.
- This change affects endpoints for chapter conversion, retrieval, deletion, and overall audiobook status.
- Updated client-side calls in `AudiobookExportModal.tsx`, `EPUBContext.tsx`, and `PDFContext.tsx` to reflect the new API paths.
- Modified API tests (`api.spec.ts`, `export.spec.ts`) to target the restructured endpoints.
- The new API structure provides better organization and a clearer, more consistent interface for audiobook functionality.
2025-11-21 19:29:49 -07:00

20 lines
No EOL
835 B
TypeScript

import { test, expect } from '@playwright/test';
test.describe('API health checks', () => {
test('GET /api/tts/voices returns 200 and a non-empty voices array', async ({ request }) => {
const res = await request.get('/api/tts/voices');
expect(res.ok()).toBeTruthy();
const json = await res.json();
expect(Array.isArray(json.voices)).toBeTruthy();
expect(json.voices.length).toBeGreaterThan(0);
});
test('GET /api/audiobook/status returns 200 with exists flag and chapters array', async ({ request }) => {
const bookId = `healthcheck-${Date.now()}`;
const res = await request.get(`/api/audiobook/status?bookId=${bookId}`);
expect(res.ok()).toBeTruthy();
const json = await res.json();
expect(json).toHaveProperty('exists');
expect(Array.isArray(json.chapters)).toBeTruthy();
});
});