Compare commits
4 Commits
b13c10936b
...
251b5503a2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
251b5503a2 | ||
|
|
007ec65dbd | ||
|
|
e95a9312e8 | ||
|
|
f22596a29d |
@@ -154,6 +154,13 @@ class AnnotationControllerTest {
|
|||||||
.andExpect(status().isForbidden());
|
.andExpect(status().isForbidden());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@WithMockUser(authorities = "READ_ALL")
|
||||||
|
void deleteAnnotation_returns403_whenUserHasOnlyReadAllPermission() throws Exception {
|
||||||
|
mockMvc.perform(delete("/api/documents/" + UUID.randomUUID() + "/annotations/" + UUID.randomUUID()))
|
||||||
|
.andExpect(status().isForbidden());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@WithMockUser(authorities = "ANNOTATE_ALL")
|
@WithMockUser(authorities = "ANNOTATE_ALL")
|
||||||
void deleteAnnotation_returns204_whenHasAnnotatePermission() throws Exception {
|
void deleteAnnotation_returns204_whenHasAnnotatePermission() throws Exception {
|
||||||
|
|||||||
@@ -130,8 +130,8 @@ let shapeStyle = $derived(
|
|||||||
}}
|
}}
|
||||||
style="
|
style="
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: -8px;
|
top: 4px;
|
||||||
right: -8px;
|
right: 4px;
|
||||||
min-width: 44px;
|
min-width: 44px;
|
||||||
min-height: 44px;
|
min-height: 44px;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|||||||
@@ -113,6 +113,28 @@ describe('AnnotationShape', () => {
|
|||||||
expect(onDeleteRequest).toHaveBeenCalledOnce();
|
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 () => {
|
it('calls onDeleteRequest when Delete key is pressed on the annotation', async () => {
|
||||||
const onDeleteRequest = vi.fn();
|
const onDeleteRequest = vi.fn();
|
||||||
|
|
||||||
|
|||||||
@@ -120,7 +120,10 @@ async function handleAnnotationDeleteRequest(annotationId: string) {
|
|||||||
await deleteBlock(block.id);
|
await deleteBlock(block.id);
|
||||||
} else {
|
} else {
|
||||||
// Annotation has no linked block — delete the annotation directly
|
// Annotation has no linked block — delete the annotation directly
|
||||||
await fetch(`/api/documents/${doc.id}/annotations/${annotationId}`, { method: 'DELETE' });
|
const res = await fetch(`/api/documents/${doc.id}/annotations/${annotationId}`, {
|
||||||
|
method: 'DELETE'
|
||||||
|
});
|
||||||
|
if (!res.ok) throw new Error('Delete annotation failed');
|
||||||
annotationReloadKey++;
|
annotationReloadKey++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user