test(transcription): cover TranscriptionColumn branches

Empty placeholder, heading + per-doc rendering, weekly-pulse visibility
gated on weeklyCount > 0, block-progress label vs em-dash branch,
task=transcribe link, missing-documentDate handling.

8 tests, ~20 branches.

Refs #496.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Marcel
2026-05-10 02:30:32 +02:00
parent 106fbac7db
commit 9695417f26

View File

@@ -0,0 +1,77 @@
import { describe, it, expect, afterEach } from 'vitest';
import { cleanup, render } from 'vitest-browser-svelte';
import { page } from 'vitest/browser';
import TranscriptionColumn from './TranscriptionColumn.svelte';
afterEach(cleanup);
const makeDoc = (overrides: Record<string, unknown> = {}) => ({
id: 'd1',
title: 'Brief 1923',
documentDate: '1923-04-15',
textedBlockCount: 0,
annotationCount: 10,
contributors: [],
hasMoreContributors: false,
...overrides
});
describe('TranscriptionColumn', () => {
it('renders the empty placeholder when docs is empty', async () => {
render(TranscriptionColumn, { props: { docs: [], weeklyCount: 0 } });
await expect.element(page.getByText(/Keine Dokumente warten/i)).toBeVisible();
});
it('renders the heading when docs has items', async () => {
render(TranscriptionColumn, { props: { docs: [makeDoc()], weeklyCount: 0 } });
await expect.element(page.getByRole('heading', { name: /text transkribieren/i })).toBeVisible();
});
it('renders the weekly pulse when weeklyCount > 0', async () => {
render(TranscriptionColumn, { props: { docs: [makeDoc()], weeklyCount: 5 } });
await expect.element(page.getByText(/diese Woche/i)).toBeVisible();
});
it('hides the weekly pulse when weeklyCount is 0', async () => {
render(TranscriptionColumn, { props: { docs: [makeDoc()], weeklyCount: 0 } });
await expect.element(page.getByText(/diese Woche/i)).not.toBeInTheDocument();
});
it('shows the block progress label when textedBlockCount > 0', async () => {
render(TranscriptionColumn, {
props: {
docs: [makeDoc({ textedBlockCount: 3, annotationCount: 10 })],
weeklyCount: 0
}
});
await expect.element(page.getByText('3 / 10 Blöcke')).toBeVisible();
});
it('shows the em-dash placeholder when textedBlockCount is 0', async () => {
render(TranscriptionColumn, { props: { docs: [makeDoc()], weeklyCount: 0 } });
expect(document.body.textContent).toContain('—');
});
it('renders the document title as a link with task=transcribe query', async () => {
render(TranscriptionColumn, { props: { docs: [makeDoc()], weeklyCount: 0 } });
await expect
.element(page.getByRole('link', { name: /brief 1923/i }))
.toHaveAttribute('href', '/documents/d1?task=transcribe');
});
it('omits the date when documentDate is undefined', async () => {
render(TranscriptionColumn, {
props: { docs: [makeDoc({ documentDate: undefined })], weeklyCount: 0 }
});
// formatMCDate should not be called; just verify component renders
await expect.element(page.getByRole('link', { name: /brief 1923/i })).toBeVisible();
});
});