test: increase coverage
This commit is contained in:
@@ -159,3 +159,59 @@ describe('TranscriptionBlock — reorder controls', () => {
|
||||
expect(onMoveDown).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
// ─── Delete confirmation ──────────────────────────────────────────────────────
|
||||
|
||||
describe('TranscriptionBlock — delete confirmation', () => {
|
||||
it('does not call onDeleteClick when user cancels confirm dialog', async () => {
|
||||
const onDeleteClick = vi.fn();
|
||||
vi.spyOn(window, 'confirm').mockReturnValue(false);
|
||||
renderBlock({ onDeleteClick });
|
||||
|
||||
const deleteBtn = page.getByRole('button', { name: 'Löschen' });
|
||||
await deleteBtn.click();
|
||||
|
||||
expect(onDeleteClick).not.toHaveBeenCalled();
|
||||
vi.restoreAllMocks();
|
||||
});
|
||||
|
||||
it('calls onDeleteClick when user confirms deletion', async () => {
|
||||
const onDeleteClick = vi.fn();
|
||||
vi.spyOn(window, 'confirm').mockReturnValue(true);
|
||||
renderBlock({ onDeleteClick });
|
||||
|
||||
const deleteBtn = page.getByRole('button', { name: 'Löschen' });
|
||||
await deleteBtn.click();
|
||||
|
||||
expect(onDeleteClick).toHaveBeenCalledOnce();
|
||||
vi.restoreAllMocks();
|
||||
});
|
||||
});
|
||||
|
||||
// ─── Quote selection ─────────────────────────────────────────────────────────
|
||||
|
||||
describe('TranscriptionBlock — quote selection', () => {
|
||||
it('shows quote hint after text is selected in textarea', async () => {
|
||||
renderBlock({ text: 'Breslau, den 12. August' });
|
||||
const textarea = page.getByRole('textbox');
|
||||
// Select all text via keyboard shortcut to trigger mouseup with selection
|
||||
await textarea.click();
|
||||
await textarea.selectText();
|
||||
// Fire mouseup to trigger the selection handler
|
||||
await textarea.dispatchEvent('mouseup');
|
||||
await expect.element(page.getByText(/Zitat/)).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
// ─── Fading state ────────────────────────────────────────────────────────────
|
||||
|
||||
describe('TranscriptionBlock — fading save state', () => {
|
||||
it('shows Gespeichert text in fading state (opacity-0 fade-out)', async () => {
|
||||
renderBlock({ saveState: 'fading' });
|
||||
const indicator = page.getByText(/Gespeichert/);
|
||||
await expect.element(indicator).toBeInTheDocument();
|
||||
// The fading class sets opacity-0
|
||||
const el = document.querySelector('.opacity-0');
|
||||
expect(el).not.toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user