Add series fields to audiobooks and update related logic

Introduces 'series' and 'seriesPart' fields to the Audiobook model and database schema. Updates API routes, file organization, and path template utilities to support series metadata. Enhances chapter merging logic, improves notification backend testing, and expands test coverage for admin and API routes.
This commit is contained in:
kikootwo
2026-01-22 15:56:55 -05:00
parent dc7e557694
commit 31bca0052f
105 changed files with 10384 additions and 75 deletions
+45
View File
@@ -44,6 +44,40 @@ describe('Config API routes', () => {
expect(configServiceMock.setMany).toHaveBeenCalled();
});
it('returns 400 when configuration update payload is invalid', async () => {
const { PUT } = await import('@/app/api/config/route');
const response = await PUT({ json: vi.fn().mockResolvedValue({}) } as any);
const payload = await response.json();
expect(response.status).toBe(400);
expect(payload.error).toMatch(/Validation error/);
});
it('returns 500 when configuration update fails', async () => {
configServiceMock.setMany.mockRejectedValueOnce(new Error('db down'));
const { PUT } = await import('@/app/api/config/route');
const response = await PUT({
json: vi.fn().mockResolvedValue({
updates: [{ key: 'plex_url', value: 'http://plex' }],
}),
} as any);
const payload = await response.json();
expect(response.status).toBe(500);
expect(payload.error).toMatch(/Failed to update configuration/);
});
it('returns 500 when configuration lookup fails', async () => {
configServiceMock.getAll.mockRejectedValueOnce(new Error('db down'));
const { GET } = await import('@/app/api/config/route');
const response = await GET();
const payload = await response.json();
expect(response.status).toBe(500);
expect(payload.error).toMatch(/Failed to get configuration/);
});
it('returns category configuration', async () => {
configServiceMock.getCategory.mockResolvedValue({ plex_url: 'http://plex' });
const { GET } = await import('@/app/api/config/[category]/route');
@@ -54,6 +88,17 @@ describe('Config API routes', () => {
expect(payload.category).toBe('plex');
expect(payload.config.plex_url).toBe('http://plex');
});
it('returns 500 when category configuration lookup fails', async () => {
configServiceMock.getCategory.mockRejectedValueOnce(new Error('db down'));
const { GET } = await import('@/app/api/config/[category]/route');
const response = await GET({} as any, { params: Promise.resolve({ category: 'plex' }) });
const payload = await response.json();
expect(response.status).toBe(500);
expect(payload.error).toMatch(/Failed to get configuration/);
});
});