mirror of
https://github.com/kikootwo/ReadMeABook.git
synced 2026-06-03 04:40:09 +00:00
a97979358f
Adds file hash-based matching for Audiobookshelf library items to ensure 100% accurate ASIN assignment for RMAB-organized content. Removes fuzzy matching from library availability checks, making all matching ASIN-only to eliminate false positives and race conditions. Updates database schema, processors, and matcher utilities; adds new tests and documentation for the new matching strategy. Removes obsolete scripts, Dockerfile, and related tests; updates docker-compose for test environments.
56 lines
1.4 KiB
TypeScript
56 lines
1.4 KiB
TypeScript
/**
|
|
* Component: Confirm Dialog Tests
|
|
* Documentation: documentation/frontend/components.md
|
|
*/
|
|
|
|
// @vitest-environment jsdom
|
|
|
|
import React from 'react';
|
|
import { fireEvent, render, screen } from '@testing-library/react';
|
|
import { describe, expect, it, vi } from 'vitest';
|
|
import { ConfirmDialog } from '@/app/admin/components/ConfirmDialog';
|
|
|
|
describe('ConfirmDialog', () => {
|
|
it('renders nothing when closed', () => {
|
|
render(
|
|
<ConfirmDialog
|
|
isOpen={false}
|
|
title="Delete"
|
|
message="Confirm?"
|
|
onConfirm={vi.fn()}
|
|
onCancel={vi.fn()}
|
|
/>
|
|
);
|
|
|
|
expect(screen.queryByText('Delete')).not.toBeInTheDocument();
|
|
});
|
|
|
|
it('invokes confirm and cancel actions', () => {
|
|
const onConfirm = vi.fn();
|
|
const onCancel = vi.fn();
|
|
|
|
const { container } = render(
|
|
<ConfirmDialog
|
|
isOpen
|
|
title="Delete"
|
|
message="Confirm?"
|
|
onConfirm={onConfirm}
|
|
onCancel={onCancel}
|
|
/>
|
|
);
|
|
|
|
fireEvent.click(screen.getByRole('button', { name: 'Confirm' }));
|
|
expect(onConfirm).toHaveBeenCalledTimes(1);
|
|
|
|
fireEvent.click(screen.getByRole('button', { name: 'Cancel' }));
|
|
expect(onCancel).toHaveBeenCalledTimes(1);
|
|
|
|
const backdrop = container.querySelector('[aria-hidden="true"]');
|
|
expect(backdrop).not.toBeNull();
|
|
if (backdrop) {
|
|
fireEvent.click(backdrop);
|
|
}
|
|
expect(onCancel).toHaveBeenCalledTimes(2);
|
|
});
|
|
});
|