Skip to content

Commit

Permalink
Merge pull request #83 from ameerul-deriv/FEQ-2264-incorrect-invalid-…
Browse files Browse the repository at this point in the history
…verification-link-modal

Ameerul / FEQ-2264 Incorrect invalid verification link modal
  • Loading branch information
farrah-deriv authored May 29, 2024
2 parents 270088b + 0cd23d1 commit 63a5189
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 36 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import clsx from 'clsx';
import { ERROR_CODES } from '@/constants';
import {
DerivLightIcEmailVerificationLinkBlockedIcon,
DerivLightIcEmailVerificationLinkInvalidIcon,
} from '@deriv/quill-icons';
import { DerivLightIcEmailVerificationLinkInvalidIcon } from '@deriv/quill-icons';
import { Localize } from '@deriv-com/translations';
import { Button, Modal, Text, useDevice } from '@deriv-com/ui';
import './InvalidVerificationLinkModal.scss';
Expand Down Expand Up @@ -36,44 +33,25 @@ const InvalidVerificationLinkModal = ({
isOpen={isModalOpen}
onRequestClose={onRequestClose}
>
<Modal.Header hideBorder onRequestClose={onRequestClose} />
<Modal.Body
className={clsx('flex flex-col items-center gap-[2.4rem] p-[2.4rem] pb-4', {
className={clsx('flex flex-col items-center gap-[2.4rem] p-[2.4rem]', {
'py-0 px-[1.4rem] gap-[1.4rem]': isExcessiveErrorMobile,
})}
>
{isInvalidVerification ? (
<DerivLightIcEmailVerificationLinkInvalidIcon height={iconSize} width={iconSize} />
) : (
<DerivLightIcEmailVerificationLinkBlockedIcon height={iconSize} width={iconSize} />
)}
{isInvalidVerification && (
<Text weight='bold'>
<Localize i18n_default_text='Invalid verification link' />
</Text>
)}
{error?.message && (
<Text align='center' weight={isInvalidVerification ? 'normal' : 'bold'}>
{error.message}
</Text>
)}
<DerivLightIcEmailVerificationLinkInvalidIcon height={iconSize} width={iconSize} />
<Text weight='bold'>
<Localize i18n_default_text='Invalid verification link' />
</Text>
{error?.message && <Text align='center'>{error.message}</Text>}
</Modal.Body>
<Modal.Footer
className={clsx('justify-center', {
'pt-2 min-h-fit': isExcessiveErrorMobile,
})}
hideBorder
>
<Button
onClick={() => (isInvalidVerification ? mutate() : onRequestClose())}
size={isMobile ? 'md' : 'lg'}
textSize='sm'
>
{isInvalidVerification ? (
<Localize i18n_default_text='Get new link' />
) : (
<Localize i18n_default_text='OK' />
)}
<Button onClick={mutate} size={isMobile ? 'md' : 'lg'} textSize='sm'>
<Localize i18n_default_text='Get new link' />
</Button>
</Modal.Footer>
</Modal>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const mockUseModalManager = {
};

jest.mock('@/hooks/custom-hooks', () => ({
useIsAdvertiserBarred: jest.fn(() => false),
useModalManager: jest.fn(() => mockUseModalManager),
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ jest.mock('@/hooks', () => ({
}));

jest.mock('@/hooks/custom-hooks', () => ({
useIsAdvertiserBarred: () => false,
useModalManager: () => mockModalManager,
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ describe('<OrderDetailsCardFooter />', () => {
expect(screen.getByText('Please wait for 59 seconds before requesting another email.')).toBeInTheDocument();
});

it('should call history.replace, hideModal and reset when clicking on OK button in InvalidVerificationLinkModal', async () => {
it('should call mutate when clicking on Get new link button in InvalidVerificationLinkModal', async () => {
modalManager.isModalOpenFor.mockImplementation(
(modalName: string) => modalName === 'InvalidVerificationLinkModal'
);
Expand All @@ -324,12 +324,10 @@ describe('<OrderDetailsCardFooter />', () => {
const paymentButton = screen.getByRole('button', { name: 'I’ve received payment' });
await userEvent.click(paymentButton);

const okButton = screen.getByRole('button', { name: 'OK' });
const okButton = screen.getByRole('button', { name: 'Get new link' });
await userEvent.click(okButton);

expect(modalManager.hideModal).toHaveBeenCalled();
expect(mockUseHistory().replace).toHaveBeenCalled();
expect(mockUseConfirm().reset).toHaveBeenCalled();
expect(mockUseConfirm().mutate).toHaveBeenCalled();
});

it('should show InvalidVerificationLinkModal if InvalidVerificationToken error is returned when code param is in the URL', async () => {
Expand Down

0 comments on commit 63a5189

Please sign in to comment.