mirror of
https://github.com/kikootwo/ReadMeABook.git
synced 2026-06-03 04:40:09 +00:00
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:
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
* Component: Registration Settings Step Tests
|
||||
* Documentation: documentation/setup-wizard.md
|
||||
*/
|
||||
|
||||
// @vitest-environment jsdom
|
||||
|
||||
import React, { useState } from 'react';
|
||||
import { fireEvent, render, screen } from '@testing-library/react';
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
import { RegistrationSettingsStep } from '@/app/setup/steps/RegistrationSettingsStep';
|
||||
|
||||
const RegistrationHarness = ({
|
||||
onNext,
|
||||
onBack,
|
||||
initialValue = false,
|
||||
}: {
|
||||
onNext: () => void;
|
||||
onBack: () => void;
|
||||
initialValue?: boolean;
|
||||
}) => {
|
||||
const [requireAdminApproval, setRequireAdminApproval] = useState(initialValue);
|
||||
|
||||
return (
|
||||
<RegistrationSettingsStep
|
||||
requireAdminApproval={requireAdminApproval}
|
||||
onUpdate={(_, value) => setRequireAdminApproval(value)}
|
||||
onNext={onNext}
|
||||
onBack={onBack}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
describe('RegistrationSettingsStep', () => {
|
||||
it('toggles admin approval and navigates', async () => {
|
||||
const onNext = vi.fn();
|
||||
const onBack = vi.fn();
|
||||
|
||||
render(<RegistrationHarness onNext={onNext} onBack={onBack} />);
|
||||
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Back' }));
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Next' }));
|
||||
|
||||
expect(onBack).toHaveBeenCalled();
|
||||
expect(onNext).toHaveBeenCalled();
|
||||
|
||||
expect(screen.getByText('Auto-Approval Enabled')).toBeInTheDocument();
|
||||
const buttons = screen.getAllByRole('button');
|
||||
const toggleButton = buttons.find((button) => !['Back', 'Next'].includes(button.textContent || ''));
|
||||
expect(toggleButton).toBeDefined();
|
||||
fireEvent.click(toggleButton as HTMLButtonElement);
|
||||
expect(screen.getByText('Admin Approval Workflow')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user