Skip to content

Commit

Permalink
[COJ1414] Suisin/fix: add Continue Trading button in POI (deriv-com#1…
Browse files Browse the repository at this point in the history
…7243)

* fix: add Continue Trading button in POI

* chore: fix test case fail issue
  • Loading branch information
suisin-deriv authored Oct 21, 2024
1 parent 4462035 commit ef59d53
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { render, screen } from '@testing-library/react';
import { Button } from '@deriv/components';
import React from 'react';
import { Verified } from '../verified';
import { MemoryRouter } from 'react-router';

jest.mock('Components/poa/poa-button', () => jest.fn(() => <div data-testid='poa-button' />));

Expand All @@ -12,12 +13,20 @@ describe('<Verified/>', () => {
const needs_poa_msg = 'To continue trading, you must also submit a proof of address.';

it('should render Verified component', () => {
render(<Verified />);
render(
<MemoryRouter>
<Verified />
</MemoryRouter>
);
expect(screen.getByText(message)).toBeInTheDocument();
});

it('should show icon with message if needs_poa is false', () => {
render(<Verified />);
render(
<MemoryRouter>
<Verified />
</MemoryRouter>
);

expect(screen.getByTestId('dt_IcPoaVerified')).toBeInTheDocument();
expect(screen.getByText(message)).toBeInTheDocument();
Expand All @@ -28,13 +37,21 @@ describe('<Verified/>', () => {
expect(screen.getByRole('button')).toBeInTheDocument();
});

it('should not show redirect button if redirect_button is not passed', () => {
render(<Verified />);
expect(screen.queryByRole('button')).not.toBeInTheDocument();
it('should show continue trading button if redirect_button is not passed', () => {
render(
<MemoryRouter>
<Verified />
</MemoryRouter>
);
expect(screen.getByText('Continue trading')).toBeInTheDocument();
});

it('should show poa buttons and the message if needs_poa is true and is_from_external is false ', () => {
render(<Verified needs_poa redirect_button={redirect_button} />);
render(
<MemoryRouter>
<Verified needs_poa redirect_button={redirect_button} />
</MemoryRouter>
);
expect(screen.getByTestId('poa-button')).toBeInTheDocument();
expect(screen.getByText(needs_poa_msg)).toBeInTheDocument();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { TPOIStatus } from 'Types';
import IconMessageContent from '../../../icon-message-content';
import PoaButton from '../../../poa/poa-button';
import { service_code } from '../../../../Sections/Verification/ProofOfIdentity/proof-of-identity-utils';
import ContinueTradingButton from '../../../poa/continue-trading-button';

export const Verified = ({ needs_poa, redirect_button, is_from_external, service }: TPOIStatus) => {
const message =
Expand All @@ -19,7 +20,7 @@ export const Verified = ({ needs_poa, redirect_button, is_from_external, service
icon={<Icon icon='IcPoaVerified' size={128} data_testid='dt_IcPoaVerified' />}
className='account-management-dashboard'
>
{!is_from_external && redirect_button}
{!is_from_external && (redirect_button || <ContinueTradingButton />)}
</IconMessageContent>
);
}
Expand Down

0 comments on commit ef59d53

Please sign in to comment.