Files
familienarchiv/frontend/src/lib/document/ReadyColumn.svelte.spec.ts
Marcel e7f8aa5894 refactor: move document domain core to lib/document/
Moves ~25 components, utils (search, filename, groupDocuments,
documentStatusLabel, validateFile), bulkSelection store, and
TranscriptionSection sub-component. Fixes broken relative imports.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-05 13:56:36 +02:00

79 lines
2.6 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { describe, it, expect, afterEach } from 'vitest';
import { cleanup, render } from 'vitest-browser-svelte';
import { page } from 'vitest/browser';
import ReadyColumn from './ReadyColumn.svelte';
import type { components } from '$lib/generated/api';
type TranscriptionQueueItemDTO = components['schemas']['TranscriptionQueueItemDTO'];
afterEach(cleanup);
function makeDoc(overrides: Partial<TranscriptionQueueItemDTO> = {}): TranscriptionQueueItemDTO {
return {
id: 'doc-1',
title: 'Test Dokument',
annotationCount: 0,
textedBlockCount: 0,
reviewedBlockCount: 0,
contributors: [],
hasMoreContributors: false,
...overrides
};
}
describe('ReadyColumn', () => {
it('renders mint-themed list when docs are provided', async () => {
const doc1 = makeDoc({ id: 'doc-1', title: 'Leseферtig Brief' });
const doc2 = makeDoc({ id: 'doc-2', title: 'Archiv Dokument' });
render(ReadyColumn, { props: { docs: [doc1, doc2] } });
await expect.element(page.getByText('Leseферtig Brief')).toBeInTheDocument();
await expect.element(page.getByText('Archiv Dokument')).toBeInTheDocument();
// Mint-themed container should exist
const mintContainer = document.querySelector('.border-brand-mint');
expect(mintContainer).not.toBeNull();
});
it('renders dashed empty state with CTA link when docs array is empty', async () => {
render(ReadyColumn, { props: { docs: [] } });
await expect
.element(page.getByText('Noch keine Dokumente vollständig transkribiert.'))
.toBeInTheDocument();
const ctaLink = page.getByRole('link', { name: 'Jetzt mitmachen' });
await expect.element(ctaLink).toBeInTheDocument();
await expect
.element(ctaLink)
.toHaveAttribute('href', '/enrich?filter=NEEDS_SEGMENTATION&next=1');
});
it('shows reviewedPct using annotationCount as denominator', async () => {
// annotationCount=4, reviewedBlockCount=4, textedBlockCount=2
// reviewedPct = Math.round(4 / 4 * 100) = 100, NOT Math.round(4/2*100) = 200
const doc = makeDoc({
id: 'doc-1',
title: 'Geprüftes Dokument',
annotationCount: 4,
reviewedBlockCount: 4,
textedBlockCount: 2
});
render(ReadyColumn, { props: { docs: [doc] } });
// Should show 100% (using annotationCount=4 as denominator)
await expect.element(page.getByText('100% geprüft')).toBeInTheDocument();
});
it('links to /documents/{id}', async () => {
const doc = makeDoc({ id: 'ready-789', title: 'Fertiges Dokument' });
render(ReadyColumn, { props: { docs: [doc] } });
const link = page.getByRole('link', { name: /Fertiges Dokument/ });
await expect.element(link).toHaveAttribute('href', '/documents/ready-789');
});
});