feat(chronik-row): deep-link COMMENT_ADDED and MENTION_CREATED to comment
Some checks failed
CI / Unit & Component Tests (push) Failing after 2m55s
CI / OCR Service Tests (push) Successful in 37s
CI / Backend Unit Tests (push) Failing after 2m50s
CI / Unit & Component Tests (pull_request) Failing after 2m38s
CI / OCR Service Tests (pull_request) Successful in 34s
CI / Backend Unit Tests (pull_request) Failing after 2m51s

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Marcel
2026-04-21 17:38:50 +02:00
parent 95c11b9b46
commit e175e050f9
2 changed files with 49 additions and 1 deletions

View File

@@ -1,6 +1,7 @@
<script lang="ts">
import * as m from '$lib/paraglide/messages.js';
import { relativeTime } from '$lib/utils/time';
import { buildCommentHref } from '$lib/utils/commentDeepLink';
import type { components } from '$lib/generated/api';
type ActivityFeedItemDTO = components['schemas']['ActivityFeedItemDTO'];
@@ -96,10 +97,16 @@ const verbParts: { before: string; after: string } = $derived.by(() => {
after: verbText.slice(idx + SENTINEL.length)
};
});
const rowHref: string = $derived(
item.commentId
? buildCommentHref(item.documentId, item.commentId, item.annotationId ?? null)
: `/documents/${item.documentId}`
);
</script>
<a
href="/documents/{item.documentId}"
href={rowHref}
data-variant={variant}
class="group flex items-start gap-3 rounded-sm p-3 transition-colors hover:bg-canvas focus-visible:ring-2 focus-visible:ring-focus-ring focus-visible:outline-none
{variant === 'for-you' ? 'border-l-[3px] border-accent bg-accent-bg/10' : ''}"

View File

@@ -133,6 +133,47 @@ describe('ChronikRow', () => {
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