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
@@ -0,0 +1,83 @@
/**
* Component: Setup Audiobookshelf Step Tests
* Documentation: documentation/setup-wizard.md
*/
// @vitest-environment jsdom
import React, { useState } from 'react';
import { fireEvent, render, screen, waitFor } from '@testing-library/react';
import { afterEach, describe, expect, it, vi } from 'vitest';
import { AudiobookshelfStep } from '@/app/setup/steps/AudiobookshelfStep';
const AudiobookshelfHarness = ({
onNext,
onBack,
initialState,
}: {
onNext: () => void;
onBack: () => void;
initialState?: Partial<React.ComponentProps<typeof AudiobookshelfStep>>;
}) => {
const [state, setState] = useState({
absUrl: 'http://abs.local',
absApiToken: 'token',
absLibraryId: '',
absTriggerScanAfterImport: false,
...initialState,
});
return (
<AudiobookshelfStep
{...state}
onUpdate={(field, value) => setState((prev) => ({ ...prev, [field]: value }))}
onNext={onNext}
onBack={onBack}
/>
);
};
describe('AudiobookshelfStep', () => {
afterEach(() => {
vi.unstubAllGlobals();
});
it('requires library selection after successful test', async () => {
const fetchMock = vi.fn().mockResolvedValue({
ok: true,
json: async () => ({
success: true,
libraries: [{ id: 'lib-1', name: 'Main', itemCount: 10 }],
}),
});
vi.stubGlobal('fetch', fetchMock);
const onNext = vi.fn();
render(<AudiobookshelfHarness onNext={onNext} onBack={vi.fn()} />);
fireEvent.click(screen.getByRole('button', { name: 'Test Connection' }));
await waitFor(() => {
expect(fetchMock).toHaveBeenCalledWith('/api/setup/test-abs', expect.any(Object));
});
await screen.findByText('Connection successful!');
fireEvent.click(screen.getByRole('button', { name: 'Next' }));
expect(screen.getByText('Please select an audiobook library')).toBeInTheDocument();
expect(onNext).not.toHaveBeenCalled();
fireEvent.click(screen.getByRole('button', { name: 'Test Connection' }));
await screen.findByText('Connection successful!');
const librarySelect = await screen.findByRole('combobox');
fireEvent.change(librarySelect, { target: { value: 'lib-1' } });
await waitFor(() => {
expect(librarySelect).toHaveValue('lib-1');
});
fireEvent.click(screen.getByRole('button', { name: 'Next' }));
expect(onNext).toHaveBeenCalled();
});
});