diff --git a/frontend/src/lib/components/DashboardMentions.svelte b/frontend/src/lib/components/DashboardMentions.svelte index 97cd5ad7..2473e1b4 100644 --- a/frontend/src/lib/components/DashboardMentions.svelte +++ b/frontend/src/lib/components/DashboardMentions.svelte @@ -5,6 +5,8 @@ type NotificationDTO = { id: string; type: 'REPLY' | 'MENTION'; documentId?: string; + referenceId?: string; + annotationId?: string; read: boolean; createdAt: string; actorName?: string; @@ -26,7 +28,9 @@ let { mentions }: Props = $props();
{#if mention.documentId} {mention.actorName ?? ''} diff --git a/frontend/src/lib/components/DashboardMentions.svelte.spec.ts b/frontend/src/lib/components/DashboardMentions.svelte.spec.ts index 53a871c6..5192ff73 100644 --- a/frontend/src/lib/components/DashboardMentions.svelte.spec.ts +++ b/frontend/src/lib/components/DashboardMentions.svelte.spec.ts @@ -10,6 +10,8 @@ type NotificationDTO = { id: string; type: 'REPLY' | 'MENTION'; documentId?: string; + referenceId?: string; + annotationId?: string; read: boolean; createdAt: string; actorName?: string; @@ -20,6 +22,7 @@ function makeMention(overrides: Partial = {}): NotificationDTO id: 'notif-1', type: 'MENTION', documentId: 'doc-abc', + referenceId: 'comment-xyz', read: false, createdAt: '2026-01-15T10:00:00Z', actorName: 'Anna Schmidt', @@ -40,15 +43,22 @@ describe('DashboardMentions', () => { await expect.element(widget).toBeInTheDocument(); }); - it('renders one row per mention with link to document', async () => { - const mentions = [ - makeMention({ id: 'n1', documentId: 'doc-1', actorName: 'Anna' }), - makeMention({ id: 'n2', documentId: 'doc-2', actorName: 'Bob' }) - ]; - render(DashboardMentions, { mentions }); - const links = page.getByRole('link'); - await expect.element(links.nth(0)).toHaveAttribute('href', '/documents/doc-1'); - await expect.element(links.nth(1)).toHaveAttribute('href', '/documents/doc-2'); + it('builds link with commentId param when no annotationId', async () => { + render(DashboardMentions, { + mentions: [makeMention({ documentId: 'doc-1', referenceId: 'cmt-1' })] + }); + const link = page.getByRole('link'); + await expect.element(link).toHaveAttribute('href', '/documents/doc-1?commentId=cmt-1'); + }); + + it('builds link with commentId and annotationId when annotationId is present', async () => { + render(DashboardMentions, { + mentions: [makeMention({ documentId: 'doc-2', referenceId: 'cmt-2', annotationId: 'ann-9' })] + }); + const link = page.getByRole('link'); + await expect + .element(link) + .toHaveAttribute('href', '/documents/doc-2?commentId=cmt-2&annotationId=ann-9'); }); it('shows actor name in each row', async () => { diff --git a/frontend/src/lib/components/DashboardRecentDocuments.svelte b/frontend/src/lib/components/DashboardRecentDocuments.svelte index 542298ab..6639539b 100644 --- a/frontend/src/lib/components/DashboardRecentDocuments.svelte +++ b/frontend/src/lib/components/DashboardRecentDocuments.svelte @@ -5,7 +5,7 @@ import { getLocale } from '$lib/paraglide/runtime.js'; type Document = { id: string; title: string; - documentDate?: string; + createdAt?: string; sender?: { id: string; firstName: string; lastName: string }; }; @@ -20,7 +20,7 @@ function formatDate(dateStr: string): string { day: 'numeric', month: 'long', year: 'numeric' - }).format(new Date(dateStr + 'T12:00:00')); + }).format(new Date(dateStr)); } @@ -37,12 +37,12 @@ function formatDate(dateStr: string): string { > {doc.title} - {#if doc.documentDate} + {#if doc.createdAt} - {formatDate(doc.documentDate)} + {formatDate(doc.createdAt)} {/if}
diff --git a/frontend/src/lib/components/DashboardRecentDocuments.svelte.spec.ts b/frontend/src/lib/components/DashboardRecentDocuments.svelte.spec.ts index 74ecf14d..3e7af6cc 100644 --- a/frontend/src/lib/components/DashboardRecentDocuments.svelte.spec.ts +++ b/frontend/src/lib/components/DashboardRecentDocuments.svelte.spec.ts @@ -9,12 +9,12 @@ afterEach(cleanup); type Document = { id: string; title: string; - documentDate?: string; + createdAt?: string; sender?: { id: string; firstName: string; lastName: string }; }; -function makeDoc(id: string, title: string, date?: string): Document { - return { id, title, documentDate: date }; +function makeDoc(id: string, title: string, createdAt?: string): Document { + return { id, title, createdAt }; } describe('DashboardRecentDocuments', () => {