From 2ac4aa8f9cd8d143dff0235c882ec098af36fd19 Mon Sep 17 00:00:00 2001 From: Marcel Date: Sun, 14 Jun 2026 11:16:07 +0200 Subject: [PATCH] test(timeline): type-clean the zeitstrahl page spec data (REQ-001/002) Pass the full PageData shape (layout auth fields + timeline) through a pageData() helper so the route spec is svelte-check-clean; the component still only reads data.timeline. Refs #833 Co-Authored-By: Claude Opus 4.8 --- .../src/routes/zeitstrahl/page.svelte.spec.ts | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/frontend/src/routes/zeitstrahl/page.svelte.spec.ts b/frontend/src/routes/zeitstrahl/page.svelte.spec.ts index 50782a41..af31f0c9 100644 --- a/frontend/src/routes/zeitstrahl/page.svelte.spec.ts +++ b/frontend/src/routes/zeitstrahl/page.svelte.spec.ts @@ -17,10 +17,21 @@ const event = (title: string) => documentId: undefined }); +// The route's PageData merges the layout's auth fields with the page load's +// timeline; the component only reads `timeline`, but the full shape keeps the +// test type-clean. +const pageData = (timeline: ReturnType) => ({ + user: undefined, + canWrite: false, + canAnnotate: false, + canBlogWrite: false, + timeline +}); + describe('/zeitstrahl page', () => { it('wraps the timeline in a bordered, rounded canvas frame (REQ-001)', () => { render(Page, { - data: { timeline: makeTimelineDTO({ years: [makeYear(1909, [makeEntry()])] }) } + data: pageData(makeTimelineDTO({ years: [makeYear(1909, [makeEntry()])] })) }); const canvas = document.querySelector('[data-testid="timeline-canvas"]'); expect(canvas).not.toBeNull(); @@ -41,7 +52,7 @@ describe('/zeitstrahl page', () => { makeYear(1924, [makeEntry({ documentId: 'c' }), event('Tod')]) ] }); - render(Page, { data: { timeline: dto } }); + render(Page, { data: pageData(dto) }); const sub = document.querySelector('[data-testid="timeline-meta"]'); expect(sub?.textContent).toContain('1909–1924'); expect(sub?.textContent).toContain(m.timeline_letters_count({ count: 3 })); @@ -51,7 +62,7 @@ describe('/zeitstrahl page', () => { it('omits the range segment when there are no year bands (REQ-002)', () => { render(Page, { - data: { timeline: makeTimelineDTO({ undated: [makeEntry({ documentId: 'u1' })] }) } + data: pageData(makeTimelineDTO({ undated: [makeEntry({ documentId: 'u1' })] })) }); const sub = document.querySelector('[data-testid="timeline-meta"]'); expect(sub).not.toBeNull(); @@ -60,7 +71,7 @@ describe('/zeitstrahl page', () => { }); it('omits the entire sub-line for an empty timeline (REQ-002)', () => { - render(Page, { data: { timeline: makeTimelineDTO() } }); + render(Page, { data: pageData(makeTimelineDTO()) }); expect(document.querySelector('[data-testid="timeline-meta"]')).toBeNull(); }); });