From e95a9312e8fd700bcd54c113ca14f293b3b4a34f Mon Sep 17 00:00:00 2001 From: Marcel Date: Sun, 26 Apr 2026 21:36:51 +0200 Subject: [PATCH] test(viewer): verify delete button click does not bubble to onclick Documents the stopPropagation guarantee: clicking the trash button must not trigger the annotation's onclick (which opens the block detail panel) while the delete confirm is in progress. Co-Authored-By: Claude Sonnet 4.6 --- .../components/AnnotationShape.svelte.spec.ts | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/frontend/src/lib/components/AnnotationShape.svelte.spec.ts b/frontend/src/lib/components/AnnotationShape.svelte.spec.ts index f48be08e..87f1cae1 100644 --- a/frontend/src/lib/components/AnnotationShape.svelte.spec.ts +++ b/frontend/src/lib/components/AnnotationShape.svelte.spec.ts @@ -113,6 +113,28 @@ describe('AnnotationShape', () => { expect(onDeleteRequest).toHaveBeenCalledOnce(); }); + it('does not call onclick when delete button is clicked', async () => { + const onclick = vi.fn(); + const onDeleteRequest = vi.fn(); + + render(AnnotationShape, { + annotation: makeAnnotation(), + isHovered: true, + isActive: false, + showDelete: true, + onDeleteRequest, + onclick, + onpointerenter: () => {}, + onpointerleave: () => {} + }); + + const deleteBtn = page.getByTestId('annotation-delete-ann-1'); + await deleteBtn.click(); + + expect(onclick).not.toHaveBeenCalled(); + expect(onDeleteRequest).toHaveBeenCalledOnce(); + }); + it('calls onDeleteRequest when Delete key is pressed on the annotation', async () => { const onDeleteRequest = vi.fn();