fix(timeline): drop zero-count segments from the zeitstrahl meta line

A timeline with content in only one category rendered a misleading
"0 Briefe" / "0 Ereignisse" segment. Only push a count segment when its
count is greater than zero; the grouping label and (when present) the
range are unchanged.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Marcel
2026-06-14 12:10:37 +02:00
parent f715f9ce9c
commit 9665c9c0fc
2 changed files with 26 additions and 2 deletions

View File

@@ -75,4 +75,23 @@ describe('/zeitstrahl page', () => {
render(Page, { data: pageData(makeTimelineDTO()) });
expect(document.querySelector('[data-testid="timeline-meta"]')).toBeNull();
});
it('drops the letters segment instead of showing "0 Briefe" (REQ-002)', () => {
render(Page, {
data: pageData(makeTimelineDTO({ years: [makeYear(1914, [event('Geburt')])] }))
});
const sub = document.querySelector('[data-testid="timeline-meta"]');
expect(sub).not.toBeNull();
expect(sub?.textContent).not.toContain(m.timeline_letters_count({ count: 0 }));
expect(sub?.textContent).toContain(m.timeline_grouping_date());
});
it('drops the events segment instead of showing "0 Ereignisse" (REQ-002)', () => {
render(Page, {
data: pageData(makeTimelineDTO({ undated: [makeEntry({ documentId: 'u1' })] }))
});
const sub = document.querySelector('[data-testid="timeline-meta"]');
expect(sub).not.toBeNull();
expect(sub?.textContent).not.toContain(m.timeline_events_count({ count: 0 }));
});
});