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,55 @@
/**
* Component: Audiobook Grid Tests
* Documentation: documentation/frontend/components.md
*/
// @vitest-environment jsdom
import React from 'react';
import path from 'path';
import { render, screen } from '@testing-library/react';
import { beforeEach, describe, expect, it, vi } from 'vitest';
const mockAudiobookCard = () => {
vi.doMock(path.resolve('src/components/audiobooks/AudiobookCard.tsx'), () => ({
AudiobookCard: ({ audiobook }: { audiobook: any }) => (
<div data-testid="audiobook-card">{audiobook.asin}</div>
),
}));
};
describe('AudiobookGrid', () => {
beforeEach(() => {
vi.resetModules();
mockAudiobookCard();
});
it('renders skeleton cards when loading', async () => {
const { AudiobookGrid } = await import('@/components/audiobooks/AudiobookGrid');
const { container } = render(<AudiobookGrid audiobooks={[]} isLoading={true} />);
expect(container.querySelectorAll('.animate-pulse')).toHaveLength(8);
});
it('shows the empty message when there are no results', async () => {
const { AudiobookGrid } = await import('@/components/audiobooks/AudiobookGrid');
render(<AudiobookGrid audiobooks={[]} isLoading={false} emptyMessage="Nothing found" />);
expect(screen.getByText('Nothing found')).toBeInTheDocument();
});
it('applies grid classes based on card size', async () => {
const { AudiobookGrid } = await import('@/components/audiobooks/AudiobookGrid');
const { container } = render(
<AudiobookGrid
audiobooks={[{ asin: 'a1', title: 'Book', author: 'Author' }]}
cardSize={9}
/>
);
expect(container.querySelector('div')?.className).toContain('grid-cols-1');
});
});