Skip to content

Commit 3d52a34

Browse files
committed
chore: fix test case failing for poi-confirm-with-example-form-container
1 parent 1901d85 commit 3d52a34

File tree

4 files changed

+25
-13
lines changed

4 files changed

+25
-13
lines changed

packages/account/src/Components/forms/personal-details-form.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ const PersonalDetailsForm = props => {
4343
// need to put this check related to DIEL clients
4444
const is_svg_only = is_svg && !is_eu_user;
4545

46-
const is_country_code_dropdown_enabled = false;
46+
const is_country_code_dropdown_enabled = true;
4747

4848
const { errors, touched, values, setFieldValue, handleChange, handleBlur } = useFormikContext();
4949

@@ -388,6 +388,7 @@ const PersonalDetailsForm = props => {
388388
)}
389389
{!is_svg_only && 'phone' in values && (
390390
<PhoneField
391+
is_country_code_dropdown_enabled={is_country_code_dropdown_enabled}
391392
handleChange={handleChange}
392393
setFieldValue={setFieldValue}
393394
country_code_list={legacy_core_countries_list}

packages/account/src/Components/personal-details/personal-details.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ const PersonalDetails = observer(
7979
} = useStore();
8080
const { account_status, account_settings, residence, real_account_signup_target } = props;
8181

82-
const is_country_code_dropdown_enabled = false;
82+
const is_country_code_dropdown_enabled = true;
8383
const { isDesktop } = useDevice();
8484
const handleCancel = (values: TPersonalDetailsSectionForm) => {
8585
const current_step = getCurrentStep() - 1;

packages/account/src/Components/poi/poi-confirm-with-example-form-container/__tests__/poi-confirm-with-example-form-container.spec.tsx

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,18 @@ import { act, render, screen, waitFor } from '@testing-library/react';
44
import userEvent from '@testing-library/user-event';
55
import PoiConfirmWithExampleFormContainer from '../poi-confirm-with-example-form-container';
66
import { APIProvider } from '@deriv/api';
7+
import { useGetPhoneNumberList } from '@deriv/hooks';
78

89
jest.mock('@deriv/quill-icons', () => ({
910
...jest.requireActual('@deriv/quill-icons'),
1011
DerivLightNameDobPoiIcon: () => 'DerivLightNameDobPoiIcon',
1112
}));
1213

14+
jest.mock('@deriv/hooks', () => ({
15+
...jest.requireActual('@deriv/hooks'),
16+
useGetPhoneNumberList: jest.fn(),
17+
}));
18+
1319
jest.mock('@deriv/shared', () => ({
1420
...jest.requireActual('@deriv/shared'),
1521
isDesktop: jest.fn(() => true),
@@ -46,6 +52,11 @@ jest.mock('@deriv/shared', () => ({
4652
describe('<PoiConfirmWithExampleFormContainer/>', () => {
4753
beforeAll(() => {
4854
(ReactDOM.createPortal as jest.Mock) = jest.fn(element => element);
55+
(useGetPhoneNumberList as jest.Mock).mockReturnValue({
56+
legacy_core_countries_list: [
57+
{ text: 'United States (+1)', value: '+1', id: '1_US', carriers: [], disabled: false },
58+
],
59+
});
4960
});
5061
afterEach(() => {
5162
(ReactDOM.createPortal as jest.Mock).mockClear();
@@ -71,7 +82,7 @@ describe('<PoiConfirmWithExampleFormContainer/>', () => {
7182
expect(await screen.findByText('DerivLightNameDobPoiIcon')).toBeInTheDocument();
7283
expect(screen.getByText(clarification_message)).toBeInTheDocument();
7384
const checkbox_el: HTMLInputElement = screen.getByRole('checkbox');
74-
expect(checkbox_el.checked).toBeFalsy();
85+
expect(checkbox_el).not.toBeChecked();
7586

7687
const input_fields: HTMLInputElement[] = screen.getAllByRole('textbox');
7788
expect(input_fields).toHaveLength(3);
@@ -84,29 +95,29 @@ describe('<PoiConfirmWithExampleFormContainer/>', () => {
8495
renderComponent({});
8596

8697
const checkbox_el: HTMLInputElement = await screen.findByRole('checkbox');
87-
expect(checkbox_el.checked).toBeFalsy();
98+
expect(checkbox_el).not.toBeChecked();
8899

89100
const input_fields: HTMLInputElement[] = screen.getAllByRole('textbox');
90101
const first_name_input = input_fields[0];
91102
const last_name_input = input_fields[1];
92103
const dob_input = input_fields[2];
93104

94-
expect(first_name_input.value).toBe('test first name');
95-
expect(last_name_input.value).toBe('test last name');
96-
expect(dob_input.value).toBe('2003-08-02');
105+
expect(first_name_input).toHaveValue('test first name');
106+
expect(last_name_input).toHaveValue('test last name');
107+
expect(dob_input).toHaveValue('2003-08-02');
97108

98-
userEvent.clear(first_name_input);
99-
userEvent.clear(last_name_input);
100-
userEvent.type(first_name_input, 'new test first name');
101-
userEvent.type(last_name_input, 'new test last name');
109+
await userEvent.clear(first_name_input);
110+
await userEvent.clear(last_name_input);
111+
await userEvent.type(first_name_input, 'new test first name');
112+
await userEvent.type(last_name_input, 'new test last name');
102113

103114
await waitFor(() => {
104115
expect(first_name_input.value).toBe('new test first name');
105116
expect(last_name_input.value).toBe('new test last name');
106117
});
107118

108119
const button_el = screen.getByRole('button');
109-
userEvent.click(button_el);
120+
await userEvent.click(button_el);
110121
await userEvent.click(button_el);
111122
act(() => {
112123
jest.advanceTimersByTime(500);

packages/core/src/App/Containers/RealAccountSignup/account-wizard.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ const StepperHeader = ({ has_target, has_real_account, items, getCurrentStep, ge
5757
const AccountWizard = observer(props => {
5858
const { client, notifications, ui, traders_hub } = useStore();
5959

60-
const is_country_code_dropdown_enabled = false;
60+
const is_country_code_dropdown_enabled = true;
6161
const { selected_phone_code } = useGetPhoneNumberList();
6262

6363
const { is_eu_user } = traders_hub;

0 commit comments

Comments
 (0)