diff --git a/frontend/src/lib/components/chronik/ChronikRow.svelte b/frontend/src/lib/components/chronik/ChronikRow.svelte index 1df3c75e..d15268a6 100644 --- a/frontend/src/lib/components/chronik/ChronikRow.svelte +++ b/frontend/src/lib/components/chronik/ChronikRow.svelte @@ -1,6 +1,7 @@ { expect(preview?.textContent).not.toContain('Brief vom 12. Juli 1920'); }); + // --- deep-link href for comment events --- + it('links to /documents/:id?commentId=…&annotationId=… for COMMENT_ADDED', async () => { + const item: ActivityFeedItemDTO = { + ...baseItem, + kind: 'COMMENT_ADDED', + commentId: 'comment-7', + annotationId: 'annot-9' + }; + render(ChronikRow, { item }); + const link = document.querySelector( + 'a[href="/documents/doc-1?commentId=comment-7&annotationId=annot-9"]' + ); + expect(link).not.toBeNull(); + }); + + it('links to /documents/:id?commentId=…&annotationId=… for MENTION_CREATED', async () => { + const item: ActivityFeedItemDTO = { + ...baseItem, + kind: 'MENTION_CREATED', + youMentioned: true, + commentId: 'comment-8', + annotationId: 'annot-11' + }; + render(ChronikRow, { item }); + const link = document.querySelector( + 'a[href="/documents/doc-1?commentId=comment-8&annotationId=annot-11"]' + ); + expect(link).not.toBeNull(); + }); + + it('falls back to bare document href when commentId is absent on a comment row', async () => { + // Back-compat for old/missing backend payloads. Still navigates sensibly. + const item: ActivityFeedItemDTO = { + ...baseItem, + kind: 'COMMENT_ADDED' + }; + render(ChronikRow, { item }); + const link = document.querySelector('a[href="/documents/doc-1"]'); + expect(link).not.toBeNull(); + }); + // --- robustness: title rendering for edge cases --- it('still renders the row link when documentTitle is an empty string', async () => { // Felix: verbText.indexOf(docTitle) returned 0 for empty titles — the span