hide delete button for non-admin users after edit period expires
This commit is contained in:
committed by
Umputun
parent
e5743185b0
commit
5a781693aa
@@ -89,12 +89,20 @@ describe('<CommentActions/>', () => {
|
||||
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(<CommentActions {...props} />);
|
||||
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(<CommentActions {...props} />);
|
||||
expect(screen.queryByText('Delete')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should not render "Delete" for other users comments', () => {
|
||||
render(<CommentActions {...props} />);
|
||||
expect(screen.queryByText('Delete')).not.toBeInTheDocument();
|
||||
|
||||
@@ -113,7 +113,7 @@ export function CommentActions({
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
{(currentUser || admin) && deleteJSX}
|
||||
{((currentUser && editDeadline !== undefined) || admin) && deleteJSX}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user