Fixes #14803: ignore capitalization when confirming deletes (#14804)

* ignore case when confirming deletes

* Test confirmation of deletes works when case differs 

Added test case for 'delete' as the confirmation text.
This commit is contained in:
Carlo Q 2024-01-23 04:32:23 -08:00 committed by GitHub
parent c11fb01805
commit 0abd7d9c28
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 19 additions and 1 deletions

View File

@ -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} />);

View File

@ -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)
);