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
+68
View File
@@ -0,0 +1,68 @@
/**
* Component: Frontend Test Render Helpers
* Documentation: documentation/frontend/components.md
*/
import React from 'react';
import { render, RenderOptions } from '@testing-library/react';
import { SWRConfig, type SWRConfiguration } from 'swr';
import { resetMockAuthState, setMockAuthState, type MockUser } from './mock-auth';
import { resetMockRouter, setMockPathname, setMockSearchParams } from './mock-next-navigation';
type RenderWithProvidersOptions = Omit<RenderOptions, 'wrapper'> & {
auth?: Partial<{
user: MockUser | null;
accessToken: string | null;
isLoading: boolean;
login: (pinId: number) => Promise<void>;
logout: () => void;
refreshToken: () => Promise<void>;
setAuthData: (user: MockUser, accessToken: string) => void;
}>;
pathname?: string;
searchParams?: string | URLSearchParams;
swr?: SWRConfiguration;
wrapper?: React.ComponentType<{ children: React.ReactNode }>;
};
const createWrapper = (
swr: SWRConfiguration | undefined,
Wrapper: RenderWithProvidersOptions['wrapper']
) => {
return function WrapperComponent({ children }: { children: React.ReactNode }) {
const content = Wrapper ? <Wrapper>{children}</Wrapper> : children;
return (
<SWRConfig value={{ provider: () => new Map(), dedupingInterval: 0, ...swr }}>
{content}
</SWRConfig>
);
};
};
export const renderWithProviders = (
ui: React.ReactElement,
options: RenderWithProvidersOptions = {}
) => {
resetMockAuthState();
resetMockRouter();
if (options.auth) {
setMockAuthState(options.auth);
}
if (options.pathname) {
setMockPathname(options.pathname);
}
if (options.searchParams) {
setMockSearchParams(options.searchParams);
}
const { wrapper, swr, ...renderOptions } = options;
return render(ui, {
wrapper: createWrapper(swr, wrapper),
...renderOptions,
});
};