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 <noreply@anthropic.com>
This commit is contained in:
@@ -17,10 +17,21 @@ const event = (title: string) =>
|
|||||||
documentId: undefined
|
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<typeof makeTimelineDTO>) => ({
|
||||||
|
user: undefined,
|
||||||
|
canWrite: false,
|
||||||
|
canAnnotate: false,
|
||||||
|
canBlogWrite: false,
|
||||||
|
timeline
|
||||||
|
});
|
||||||
|
|
||||||
describe('/zeitstrahl page', () => {
|
describe('/zeitstrahl page', () => {
|
||||||
it('wraps the timeline in a bordered, rounded canvas frame (REQ-001)', () => {
|
it('wraps the timeline in a bordered, rounded canvas frame (REQ-001)', () => {
|
||||||
render(Page, {
|
render(Page, {
|
||||||
data: { timeline: makeTimelineDTO({ years: [makeYear(1909, [makeEntry()])] }) }
|
data: pageData(makeTimelineDTO({ years: [makeYear(1909, [makeEntry()])] }))
|
||||||
});
|
});
|
||||||
const canvas = document.querySelector('[data-testid="timeline-canvas"]');
|
const canvas = document.querySelector('[data-testid="timeline-canvas"]');
|
||||||
expect(canvas).not.toBeNull();
|
expect(canvas).not.toBeNull();
|
||||||
@@ -41,7 +52,7 @@ describe('/zeitstrahl page', () => {
|
|||||||
makeYear(1924, [makeEntry({ documentId: 'c' }), event('Tod')])
|
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"]');
|
const sub = document.querySelector('[data-testid="timeline-meta"]');
|
||||||
expect(sub?.textContent).toContain('1909–1924');
|
expect(sub?.textContent).toContain('1909–1924');
|
||||||
expect(sub?.textContent).toContain(m.timeline_letters_count({ count: 3 }));
|
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)', () => {
|
it('omits the range segment when there are no year bands (REQ-002)', () => {
|
||||||
render(Page, {
|
render(Page, {
|
||||||
data: { timeline: makeTimelineDTO({ undated: [makeEntry({ documentId: 'u1' })] }) }
|
data: pageData(makeTimelineDTO({ undated: [makeEntry({ documentId: 'u1' })] }))
|
||||||
});
|
});
|
||||||
const sub = document.querySelector('[data-testid="timeline-meta"]');
|
const sub = document.querySelector('[data-testid="timeline-meta"]');
|
||||||
expect(sub).not.toBeNull();
|
expect(sub).not.toBeNull();
|
||||||
@@ -60,7 +71,7 @@ describe('/zeitstrahl page', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('omits the entire sub-line for an empty timeline (REQ-002)', () => {
|
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();
|
expect(document.querySelector('[data-testid="timeline-meta"]')).toBeNull();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user