diff --git a/frontend/apps/remark42/app/components/comment/comment-actions.spec.tsx b/frontend/apps/remark42/app/components/comment/comment-actions.spec.tsx index 48b1e5c5c5..648dd85326 100644 --- a/frontend/apps/remark42/app/components/comment/comment-actions.spec.tsx +++ b/frontend/apps/remark42/app/components/comment/comment-actions.spec.tsx @@ -89,12 +89,20 @@ describe('', () => { expect(screen.getByText('Hide')).toBeInTheDocument(); }); - it('should render "Delete" for current user comments', () => { + it('should render "Delete" for current user comments when editing is available', () => { props.currentUser = true; + props.editDeadline = Date.now() + 300 * 1000; // set editDeadline to a future timestamp render(); expect(screen.getByText('Delete')).toBeInTheDocument(); }); + it('should not render "Delete" for current user comments when editDeadline is undefined', () => { + props.currentUser = true; + props.editDeadline = undefined; // set editDeadline to undefined + render(); + expect(screen.queryByText('Delete')).not.toBeInTheDocument(); + }); + it('should not render "Delete" for other users comments', () => { render(); expect(screen.queryByText('Delete')).not.toBeInTheDocument(); diff --git a/frontend/apps/remark42/app/components/comment/comment-actions.tsx b/frontend/apps/remark42/app/components/comment/comment-actions.tsx index fdfa7f0158..d3fca73e41 100644 --- a/frontend/apps/remark42/app/components/comment/comment-actions.tsx +++ b/frontend/apps/remark42/app/components/comment/comment-actions.tsx @@ -113,7 +113,7 @@ export function CommentActions({ )} )} - {(currentUser || admin) && deleteJSX} + {((currentUser && editDeadline !== undefined) || admin) && deleteJSX} );