Skip to content

Commit

Permalink
Merge branch master into kate/OPT-306/accum_chore_text_changes
Browse files Browse the repository at this point in the history
  • Loading branch information
kate-deriv committed Aug 9, 2023
2 parents 7d6157e + ae6293d commit 311c3bc
Show file tree
Hide file tree
Showing 190 changed files with 3,864 additions and 1,665 deletions.
8 changes: 4 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,9 @@ commands:
- run:
name: "Publish to cloudflare pages (staging)"
command: |
npm i wrangler@2.0.19
npm i wrangler@3.1.0
cd packages/core
npx wrangler pages publish dist/ --project-name=deriv-app-pages --branch=staging
npx wrangler pages deploy dist/ --project-name=deriv-app-pages --branch=staging
echo "New staging website - http://staging.cf-pages-deriv-app.deriv.com"
publish_to_pages_production:
Expand All @@ -172,9 +172,9 @@ commands:
- run:
name: "Publish to cloudflare pages (production)"
command: |
npm i wrangler@2.0.19
npm i wrangler@3.1.0
cd packages/core
npx wrangler pages publish dist/ --project-name=deriv-app-pages --branch=main
npx wrangler pages deploy dist/ --project-name=deriv-app-pages --branch=main
echo "New website - http://cf-pages-deriv-app.deriv.com"
jobs:
Expand Down
26 changes: 13 additions & 13 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
},
"dependencies": {
"@babel/preset-typescript": "^7.16.5",
"@sendbird/chat": "^4.9.5",
"@sendbird/chat": "^4.9.7",
"@types/react-transition-group": "^4.4.4",
"babel-jest": "^27.3.1",
"dotenv": "^8.2.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -741,4 +741,20 @@ describe('<PersonalDetails/>', () => {
const el_tax_residence = screen.getByTestId('selected_value');
expect(el_tax_residence).toHaveTextContent('Malta');
});

it('should disable tax_residence field if it is immutable from BE', () => {
isMobile.mockReturnValue(false);
isDesktop.mockReturnValue(true);
const new_props = {
...props,
is_mf: true,
value: {
...props.value,
tax_residence: 'France',
},
disabled_items: ['salutation', 'first_name', 'last_name', 'date_of_birth', 'tax_residence'],
};
renderwithRouter(<PersonalDetails {...new_props} />);
expect(screen.getByTestId('tax_residence')).toBeDisabled();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from 'react';
import { render, screen, waitFor } from '@testing-library/react';
import POAAddressMismatchHintBox from '../poa-address-mismatch-hint-box';

describe('<POAAddressMismatchHintBox/>', () => {
const msg =
'It appears that the address in your document doesn’t match the address in your Deriv profile. Please update your personal details now with the correct address.';

it('should render POAAddressMismatchHintBox component', async () => {
window.HTMLElement.prototype.scrollIntoView = jest.fn();

render(<POAAddressMismatchHintBox />);
await waitFor(() => {
expect(window.HTMLElement.prototype.scrollIntoView).toHaveBeenCalled();
});
expect(screen.getByText(msg)).toBeVisible();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ describe('<IdvDocumentSubmit/>', () => {
document_1: { display_name: 'Test document 1 name', format: '5436454364243' },
document_2: { display_name: 'Test document 2 name', format: 'A54321' },
},
has_visual_sample: true,
has_visual_sample: 1,
},
},
},
Expand All @@ -80,7 +80,7 @@ describe('<IdvDocumentSubmit/>', () => {
expect(screen.queryByText('Please select a document type.')).not.toBeInTheDocument();

const inputs = screen.getAllByRole<HTMLTextAreaElement>('textbox');
expect(inputs.length).toBe(5);
expect(inputs).toHaveLength(5);
expect(inputs[0].name).toBe('document_type');
expect(inputs[1].name).toBe('document_number');
});
Expand Down
109 changes: 109 additions & 0 deletions packages/account/src/Configs/__test__/personal-details-config.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
import { personal_details_config } from 'Configs/personal-details-config';

jest.mock('@deriv/shared', () => ({
...jest.requireActual('@deriv/shared'),
getErrorMessages: jest.fn().mockReturnValue({
name: jest.fn(),
password: jest.fn(),
}),
generateValidationFunction: jest.fn(),
getDefaultFields: jest.fn(),
toMoment: jest.fn(),
validLength: jest.fn(),
}));
describe('personal-details-config', () => {
const mock_props = {
residence_list: [
{
services: {
idv: {
documents_supported: {},
has_visual_sample: 0,
is_country_supported: 0,
},
onfido: {
documents_supported: {
passport: {
display_name: 'Passport',
},
},
is_country_supported: 0,
},
},
phone_idd: '93',
text: 'Afghanistan',
value: 'af',
tin_format: [],
disabled: '1',
},
{
services: {
idv: {
documents_supported: {},
has_visual_sample: 0,
is_country_supported: 0,
},
onfido: {
documents_supported: {
driving_licence: {
display_name: 'Driving Licence',
},
national_identity_card: {
display_name: 'National Identity Card',
},
passport: {
display_name: 'Passport',
},
residence_permit: {
display_name: 'Residence Permit',
},
},
is_country_supported: 1,
},
phone_idd: '93',
text: 'Indonesia',
value: 'af',
tin_format: [],
disabled: '1',
},
},
],
account_settings: {
tax_residence: 'af',
residence: 'Indonesia',
},
is_appstore: false,
real_account_signup_target: 'maltainvest',
account_status: { cashier_validation: ['system_maintenance'] },
};

it('should return account tax residence as default value if it is already set', () => {
const personal_details = personal_details_config(mock_props);
expect(personal_details[0].tax_residence.default_value).toEqual('Afghanistan');
});

it('should return residence as the default value for MF clients, If the account tax residence is not set', () => {
const new_props = {
...mock_props,
account_settings: {
...mock_props.account_settings,
tax_residence: '',
},
};
const personal_details = personal_details_config(new_props);
expect(personal_details[0].tax_residence.default_value).toEqual(new_props.account_settings.residence);
});

it('should not set default value for CR clients, If the account tax residence is not set', () => {
const new_props = {
...mock_props,
real_account_signup_target: 'svg',
account_settings: {
...mock_props.account_settings,
tax_residence: '',
},
};
const personal_details = personal_details_config(new_props);
expect(personal_details[0].tax_residence.default_value).toEqual('');
});
});
12 changes: 7 additions & 5 deletions packages/account/src/Configs/personal-details-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type TPersonalDetailsConfig = {
account_status: GetAccountStatus;
};

const personal_details_config = ({
export const personal_details_config = ({
residence_list,
account_settings,
is_appstore,
Expand All @@ -38,6 +38,8 @@ const personal_details_config = ({
const min_phone_number = 9;
const max_phone_number = 35;

const default_residence = real_account_signup_target === 'maltainvest' ? account_settings?.residence : '';

const config = {
account_opening_reason: {
supported_in: ['iom', 'malta', 'maltainvest'],
Expand Down Expand Up @@ -114,10 +116,10 @@ const personal_details_config = ({
],
},
tax_residence: {
default_value:
real_account_signup_target === 'maltainvest'
? account_settings.residence
: residence_list.find(item => item.value === account_settings.tax_residence)?.text || '',
//if tax_residence is already set, we will use it as default value else for mf clients we will use residence as default value
default_value: account_settings?.tax_residence
? residence_list.find(item => item.value === account_settings?.tax_residence)?.text ?? ''
: default_residence,
supported_in: ['maltainvest'],
rules: [['req', localize('Tax residence is required.')]],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,33 +22,6 @@ jest.mock('@deriv/shared/src/services/ws-methods', () => ({

describe('<PersonalDetailsForm />', () => {
const history = createBrowserHistory();
const mock_props = {
authentication_status: {},
is_eu: true,
is_mf: false,
is_uk: false,
is_svg: false,
is_virtual: false,
residence_list: [{}],
states_list: [],
refreshNotifications: jest.fn(),
showPOAAddressMismatchSuccessNotification: jest.fn(),
showPOAAddressMismatchFailureNotification: jest.fn(),
Notifications: '',
fetchResidenceList: jest.fn(),
fetchStatesList: jest.fn(),
has_residence: false,
account_settings: {},
getChangeableFields: jest
.fn()
.mockReturnValue(['first_name', 'last_name', 'phone', 'address_line_1', 'address_city']),
current_landing_company: {},
history: {},
is_social_signup: false,
updateAccountStatus: jest.fn(),
has_poa_address_mismatch: false,
is_language_changing: false,
};

const promise = Promise.resolve();
const fetchResidenceList = jest.fn(() => promise);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import classNames from 'classnames';
import { getStatusBadgeConfig } from '@deriv/account';
import { Text, StatusBadge } from '@deriv/components';
import TradigPlatformIconProps from 'Assets/svgs/trading-platform';
import TradingPlatformIconProps from 'Assets/svgs/trading-platform';
import {
getAppstorePlatforms,
getMFAppstorePlatforms,
Expand Down Expand Up @@ -96,7 +96,7 @@ const TradingAppCard = ({
'trading-app-card__icon--container__clickable': clickable_icon,
})}
>
<TradigPlatformIconProps icon={icon} onClick={clickable_icon ? openStaticPage : undefined} size={48} />
<TradingPlatformIconProps icon={icon} onClick={clickable_icon ? openStaticPage : undefined} size={48} />
</div>
<div className={classNames('trading-app-card__container', { 'trading-app-card--divider': has_divider })}>
<div className='trading-app-card__details'>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { localize } from '@deriv/translations';
import { observer } from 'mobx-react-lite';
import classNames from 'classnames';
import { useStores } from 'Stores/index';
import TradigPlatformIconProps from 'Assets/svgs/trading-platform';
import TradingPlatformIconProps from 'Assets/svgs/trading-platform';
import { TModalContent, TAccountCard, TTradingPlatformAvailableAccount } from './types';
import { TIconTypes } from 'Types';
import { CFD_PLATFORMS } from '@deriv/shared';
Expand All @@ -23,7 +23,7 @@ const AccountCard = ({ selectAccountTypeCard, account_type_card, title_and_type,
onClick={() => cardSelection(title_and_type)}
>
<div className='account-type-card__image'>
<TradigPlatformIconProps icon={icon as TIconTypes} size={64} />
<TradingPlatformIconProps icon={icon as TIconTypes} size={64} />
</div>
<div className='account-type-card__header'>
<Text as='h2' weight='bold'>
Expand Down
Loading

0 comments on commit 311c3bc

Please sign in to comment.