Skip to content

Commit

Permalink
Fixes #14803: ignore capitalization when confirming deletes (#14804)
Browse files Browse the repository at this point in the history
* ignore case when confirming deletes

* Test confirmation of deletes works when case differs 

Added test case for 'delete' as the confirmation text.
  • Loading branch information
luzlab authored Jan 23, 2024
1 parent c11fb01 commit 0abd7d9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,24 @@ describe('Test DeleteWidgetV1 Component', () => {
});
});

it('Delete click should work properly regardless of capitalization', async () => {
await act(async () => {
render(<DeleteWidgetModal {...mockProps} />);

const inputBox = await screen.findByTestId('confirmation-text-input');
const confirmButton = await screen.findByTestId('confirm-button');
const hardDelete = await screen.findByTestId('hard-delete');

userEvent.click(hardDelete);

userEvent.type(inputBox, 'delete');

expect(confirmButton).not.toBeDisabled();

userEvent.click(confirmButton);
});
});

it('Discard click should work properly', async () => {
await act(async () => {
render(<DeleteWidgetModal {...mockProps} />);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ const DeleteWidgetModal = ({

const isDeleteTextPresent = useMemo(() => {
return (
deleteConfirmationText === DELETE_CONFIRMATION_TEXT &&
deleteConfirmationText.toLowerCase() === DELETE_CONFIRMATION_TEXT.toLowerCase() &&
(deletionType === DeleteType.SOFT_DELETE ||
deletionType === DeleteType.HARD_DELETE)
);
Expand Down

0 comments on commit 0abd7d9

Please sign in to comment.