From bca3f34ceca265b8e7633789f197b437e23b1d25 Mon Sep 17 00:00:00 2001 From: Marcel Date: Wed, 27 May 2026 18:48:45 +0200 Subject: [PATCH] feat(documents): badge undated rows instead of a bare em-dash MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit DocumentRow rendered a bare em-dash for null-dated letters — a glyph a screen reader announces as nothing. Both breakpoints now render the single DocumentDate component unconditionally (no {#if}/—/{:else}), so the cue cannot drift; its unknown state is a neutral metadata chip ("Datum unbekannt", text-ink-3, ≥4.5:1 both themes) with a non-color calendar glyph, never red/amber. Present dates render at honest precision via formatDocumentDate ("Juni 1916", not a fabricated day). Refs #668 --- frontend/src/lib/document/DocumentDate.svelte | 30 +++++++++++++------ frontend/src/lib/document/DocumentRow.svelte | 16 ++++------ .../lib/document/DocumentRow.svelte.spec.ts | 29 ++++++++++++++++++ 3 files changed, 56 insertions(+), 19 deletions(-) diff --git a/frontend/src/lib/document/DocumentDate.svelte b/frontend/src/lib/document/DocumentDate.svelte index a3539c31..937b5f7c 100644 --- a/frontend/src/lib/document/DocumentDate.svelte +++ b/frontend/src/lib/document/DocumentDate.svelte @@ -28,13 +28,21 @@ const showRawLine = $derived( - - {#if isUnknown} - + {#if isUnknown} + + - {/if} - {label} - + {label} + + {:else} + + {label} + + {/if} {#if showRawLine} - {#if doc.documentDate} - - {:else} - — - {/if} +
diff --git a/frontend/src/lib/document/DocumentRow.svelte.spec.ts b/frontend/src/lib/document/DocumentRow.svelte.spec.ts index 9511edc0..bb9609c2 100644 --- a/frontend/src/lib/document/DocumentRow.svelte.spec.ts +++ b/frontend/src/lib/document/DocumentRow.svelte.spec.ts @@ -73,6 +73,35 @@ describe('DocumentRow – title', () => { }); }); +// ─── Date rendering (#668) ────────────────────────────────────────────────── + +describe('DocumentRow – date rendering', () => { + it('renders a "Datum unbekannt" badge for an undated document', async () => { + const item = makeItem({ documentDate: undefined, metaDatePrecision: 'UNKNOWN' }); + render(DocumentRow, { item }); + // The badge text appears (once per breakpoint block). + await expect.element(page.getByText('Datum unbekannt').first()).toBeInTheDocument(); + }); + + it('does not render a bare em-dash for an undated document', async () => { + const item = makeItem({ documentDate: undefined, metaDatePrecision: 'UNKNOWN' }); + render(DocumentRow, { item }); + await expect.element(page.getByText('—', { exact: true }).first()).not.toBeInTheDocument(); + }); + + it('renders the full date for a day-precision document', async () => { + const item = makeItem({ documentDate: '1943-12-24', metaDatePrecision: 'DAY' }); + render(DocumentRow, { item }); + await expect.element(page.getByText(/24\. Dezember 1943/).first()).toBeInTheDocument(); + }); + + it('renders month precision honestly without fabricating a day', async () => { + const item = makeItem({ documentDate: '1916-06-01', metaDatePrecision: 'MONTH' }); + render(DocumentRow, { item }); + await expect.element(page.getByText(/Juni 1916/).first()).toBeInTheDocument(); + }); +}); + // ─── Snippet ────────────────────────────────────────────────────────────────── describe('DocumentRow – snippet', () => {