Files
familienarchiv/frontend/src/lib/components/ReadyColumn.svelte.spec.ts
Marcel 6c2da648db
Some checks failed
CI / Unit & Component Tests (push) Failing after 2m32s
CI / Backend Unit Tests (push) Failing after 2m45s
CI / Unit & Component Tests (pull_request) Failing after 2m27s
CI / Backend Unit Tests (pull_request) Failing after 2m46s
fix(#240): remove weekly pulse badge from ReadyColumn
The weekly count in Lesefertig counted any document with a reviewed
block in the past 7 days, not documents that crossed the ≥90% ready
threshold — a misleading stat given the column shows a different set.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-16 13:12:46 +02:00

77 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,
...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');
});
});