Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fasih/TRAH-3793/ Removed popup #16048

Merged
merged 5 commits into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -120,23 +120,6 @@ export const AdditionalKycInfoForm = observer(({ setError }: TAdditionalKycInfoF
{...fields.tax_identification_number}
data_testId='dt_tax_identification_number'
/>
fasihali-deriv marked this conversation as resolved.
Show resolved Hide resolved
<FormFieldInfo
message={
<Localize
i18n_default_text="Don't know your tax identification number? <1 />Click <0>here</0> to learn more."
components={[
<a
key={0}
className='link'
target='_blank'
rel='noopener noreferrer'
href={OECD_TIN_FORMAT_URL}
/>,
<br key={1} />,
]}
/>
}
/>
</fieldset>
<fieldset className='additional-kyc-info-modal__form-field'>
<FormSelectField
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -751,14 +751,7 @@ const TaxResidenceField = ({
);
};

const TaxIdentificationNumberField = ({
is_tin_popover_open,
setIsTinPopoverOpen,
setIsTaxResidencePopoverOpen,
disabled,
required = false,
}) => {
const { isDesktop } = useDevice();
const TaxIdentificationNumberField = ({ disabled, required = false }) => {
likhith-deriv marked this conversation as resolved.
Show resolved Hide resolved
return (
fasihali-deriv marked this conversation as resolved.
Show resolved Hide resolved
<div className='details-form__tax'>
<FormInputField
Expand All @@ -769,38 +762,6 @@ const TaxIdentificationNumberField = ({
disabled={disabled}
required={required}
/>
<div
data-testid='tax_identification_number_pop_over'
onClick={e => {
setIsTaxResidencePopoverOpen(false);
setIsTinPopoverOpen(true);
if (e.target.tagName !== 'A') e.stopPropagation();
}}
>
<Popover
alignment={isDesktop ? 'right' : 'left'}
icon='info'
is_open={is_tin_popover_open}
message={
<Localize
i18n_default_text={
"Don't know your tax identification number? Click <0>here</0> to learn more."
}
components={[
<a
key={0}
className='link link--red'
rel='noopener noreferrer'
target='_blank'
href='https://www.oecd.org/tax/automatic-exchange/crs-implementation-and-assistance/tax-identification-numbers/'
/>,
]}
/>
}
zIndex={9998}
disable_message_icon
/>
</div>
</div>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ const mock_errors: FormikErrors<TPersonalDetailsSectionForm> = {

const tax_residence_pop_over_text =
/the country in which you meet the criteria for paying taxes\. usually the country in which you physically reside\./i;
const tin_pop_over_text = /don't know your tax identification number\?/i;

const runCommonFormfieldsTests = (is_svg: boolean) => {
expect(screen.getByRole('radio', { name: /mr/i })).toBeInTheDocument();
Expand Down Expand Up @@ -99,24 +98,6 @@ const runCommonFormfieldsTests = (is_svg: boolean) => {
).toBeInTheDocument();
}

const tax_residence_pop_over = screen.queryByTestId('tax_residence_pop_over');
if (tax_residence_pop_over) {
fireEvent.click(tax_residence_pop_over);
}

expect(screen.getByText(tax_residence_pop_over_text)).toBeInTheDocument();

expect(screen.getByLabelText(/tax identification number/i)).toBeInTheDocument();
const tax_identification_number_pop_over = screen.queryByTestId('tax_identification_number_pop_over');
expect(tax_identification_number_pop_over).toBeInTheDocument();

if (tax_identification_number_pop_over) {
fireEvent.click(tax_identification_number_pop_over);
}

expect(screen.getByText(tin_pop_over_text)).toBeInTheDocument();
expect(screen.getByRole('link', { name: 'here' })).toBeInTheDocument();

if (is_svg)
expect(
screen.getByRole('heading', {
Expand Down Expand Up @@ -819,23 +800,6 @@ describe('<PersonalDetails/>', () => {
expect(screen.queryByText(tax_residence_pop_over_text)).not.toBeInTheDocument();
});

it('should close tax_identification_number_pop_over when clicked outside', () => {
const new_props = { ...mock_props, is_svg: false };
renderwithRouter({ props: new_props });

const tin_pop_over = screen.getByTestId('tax_identification_number_pop_over');
expect(tin_pop_over).toBeInTheDocument();
fireEvent.click(tin_pop_over);

expect(screen.getByText(tin_pop_over_text)).toBeInTheDocument();
expect(screen.getByRole('link', { name: 'here' })).toBeInTheDocument();

fireEvent.click(screen.getByRole('heading', { name: /account opening reason/i }));

expect(screen.queryByText(tin_pop_over_text)).not.toBeInTheDocument();
expect(screen.queryByRole('link', { name: 'here' })).not.toBeInTheDocument();
});

it('should close tax_residence pop-over when scrolled', () => {
renderwithRouter({});

Expand All @@ -852,23 +816,6 @@ describe('<PersonalDetails/>', () => {
expect(screen.queryByText(tax_residence_pop_over_text)).not.toBeInTheDocument();
});

it('should close tax_identification_number_pop_over when scrolled', () => {
renderwithRouter({});

const tax_identification_number_pop_over = screen.getByTestId('tax_identification_number_pop_over');
expect(tax_identification_number_pop_over).toBeInTheDocument();
fireEvent.click(tax_identification_number_pop_over);
expect(screen.getByText(tin_pop_over_text)).toBeInTheDocument();
expect(screen.getByRole('link', { name: 'here' })).toBeInTheDocument();

fireEvent.scroll(screen.getByTestId('dt_personal_details_container'), {
target: { scrollY: 100 },
});

expect(screen.queryByText(tax_residence_pop_over_text)).not.toBeInTheDocument();
expect(screen.queryByRole('link', { name: 'here' })).not.toBeInTheDocument();
});

it('should validate idv values when a document type is selected', async () => {
(shouldShowIdentityInformation as jest.Mock).mockReturnValue(true);
const new_props = {
Expand Down
Loading