mirror of
https://github.com/kikootwo/ReadMeABook.git
synced 2026-06-02 20:30:10 +00:00
31bca0052f
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.
55 lines
1.7 KiB
TypeScript
55 lines
1.7 KiB
TypeScript
/**
|
|
* 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();
|
|
});
|
|
});
|