Skip to content

Commit

Permalink
Merge branch 'master' into feature/wallets_with_traders_hub
Browse files Browse the repository at this point in the history
  • Loading branch information
nijil-deriv committed Aug 7, 2023
2 parents 69b284d + fc55e5b commit e9d9323
Show file tree
Hide file tree
Showing 72 changed files with 1,145 additions and 475 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
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 @@ -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 @@ -103,7 +103,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
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import React from 'react';
import { Router } from 'react-router';
import { screen, render } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import MultiActionButtonGroup from '../multi-action-button-group';
import { createBrowserHistory } from 'history';
import { routes } from '@deriv/shared';

const mock_props = {
link_to: routes.trader,
onAction: jest.fn(),
is_buttons_disabled: false,
is_real: true,
};

type TMockProps = {
link_to: string;
onAction: jest.Mock;
is_buttons_disabled: boolean;
is_real: boolean;
};

jest.mock('Components/trade-button', () => {
const TradeButton = ({ link_to, onAction, is_buttons_disabled }: TMockProps) => (
<a href={link_to}>
<button onClick={onAction} disabled={is_buttons_disabled}>
Open
</button>
</a>
);
return TradeButton;
});

describe('Test Cases for Multi Action Button Group:', () => {
it('should display "Open" and "Transfer" button within component', () => {
render(<MultiActionButtonGroup {...mock_props} />);

expect(screen.getByText('Open')).toBeInTheDocument();
expect(screen.getByText('Transfer')).toBeInTheDocument();
});

it('should display "Top up" button instead of "Transfer" if it is not real', () => {
render(<MultiActionButtonGroup {...mock_props} is_real={false} />);

expect(screen.getByText('Open')).toBeInTheDocument();
expect(screen.getByText('Top up')).toBeInTheDocument();
expect(screen.queryByText('Transfer')).not.toBeInTheDocument();
});

it('should disable "Open" button if "is_buttons_disabled" is true', () => {
render(<MultiActionButtonGroup {...mock_props} is_buttons_disabled />);

const open_btn = screen.getByText('Open');
expect(open_btn).toBeDisabled();
});

it('should execute function when clicking on "Open"', () => {
render(<MultiActionButtonGroup {...mock_props} />);

const open_btn = screen.getByText('Open');
userEvent.click(open_btn);
expect(mock_props.onAction).toHaveBeenCalled();
});

it('should redirect to Trade page after "Open" button is clicked', () => {
const history = createBrowserHistory();
render(
<Router history={history}>
<MultiActionButtonGroup {...mock_props} is_real />
</Router>
);

const open_btn = screen.getByText('Open');
userEvent.click(open_btn);

expect(history.location.pathname).toBe(routes.trade);
});
});
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import React from 'react';
import { Button, Text } from '@deriv/components';
import { formatMoney, CFD_PLATFORMS } from '@deriv/shared';
import { useStore } from '@deriv/stores';
import { Localize, localize } from '@deriv/translations';
import TradigPlatformIconProps from 'Assets/svgs/trading-platform';
import TradingPlatformIconProps from 'Assets/svgs/trading-platform';
import { TPlatform } from 'Types';

import './static-cfd-account-manager.scss';
Expand Down Expand Up @@ -68,8 +67,6 @@ const StaticCFDAccountManager = ({
}: TStaticCFDAccountManager) => {
const icon_size = 48;
const platform_color = platform === 'options' ? 'prominent' : 'general';
const { traders_hub } = useStore();
const { is_demo } = traders_hub;
return (
<div
className={classNames('static-cfd-account-manager', {
Expand All @@ -81,7 +78,7 @@ const StaticCFDAccountManager = ({
{platform === CFD_PLATFORMS.MT5 &&
!is_eu_user &&
(type === 'financial' ? (
<TradigPlatformIconProps
<TradingPlatformIconProps
icon='Financial'
size={icon_size}
className={classNames('static-cfd-account-manager--cfds', {
Expand All @@ -90,7 +87,7 @@ const StaticCFDAccountManager = ({
})}
/>
) : (
<TradigPlatformIconProps
<TradingPlatformIconProps
icon={type === 'swap_free' ? 'SwapFree' : 'Derived'}
size={icon_size}
className={classNames('static-cfd-account-manager--cfds', {
Expand All @@ -102,7 +99,7 @@ const StaticCFDAccountManager = ({
{platform === CFD_PLATFORMS.MT5 &&
is_eu_user &&
(type === 'financial' ? (
<TradigPlatformIconProps
<TradingPlatformIconProps
icon='CFDs'
size={icon_size}
className={classNames('static-cfd-account-manager--cfds', {
Expand All @@ -111,7 +108,7 @@ const StaticCFDAccountManager = ({
})}
/>
) : (
<TradigPlatformIconProps
<TradingPlatformIconProps
icon='Derived'
size={icon_size}
className={classNames('static-cfd-account-manager--cfds', {
Expand All @@ -121,7 +118,7 @@ const StaticCFDAccountManager = ({
))}

{platform === CFD_PLATFORMS.DERIVEZ && (
<TradigPlatformIconProps
<TradingPlatformIconProps
icon='DerivEz'
size={icon_size}
className={classNames('static-cfd-account-manager--cfds', {
Expand All @@ -132,7 +129,7 @@ const StaticCFDAccountManager = ({
)}

{platform === CFD_PLATFORMS.DXTRADE && (
<TradigPlatformIconProps
<TradingPlatformIconProps
icon='DerivX'
size={icon_size}
className={classNames('static-cfd-account-manager--cfds', {
Expand All @@ -142,7 +139,7 @@ const StaticCFDAccountManager = ({
/>
)}
{platform === 'options' && (
<TradigPlatformIconProps
<TradingPlatformIconProps
icon='Options'
size={icon_size}
className={is_blurry.icon || is_last_step ? 'static-cfd-account-manager__icon--blurry' : ''}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
.static-dashboard {
background-color: var(--general-main-1);
border-radius: 1.6rem;
padding: 3rem;
padding: 1.2rem;
height: inherit;
@include desktop {
display: flex;
gap: 2.4rem;
flex-direction: column;
min-width: 132rem;
}
@include mobile {
position: relative;
bottom: 2rem;
padding: 3rem;
}
&--deposit-button {
cursor: not-allowed;
Expand All @@ -26,21 +24,31 @@
}
&--eu {
@include desktop {
padding-bottom: 7rem;
flex-direction: column-reverse;
}
padding-bottom: 7rem;
@include mobile {
height: 100%;
}
@media screen and (max-width: 320px) {
height: unset;
}
}

@include mobile {
width: 90%;
margin: 0 5%;
padding: 0;
margin-inline: 5%;
}

&-wrapper {
border-radius: $BORDER_RADIUS;
border: 2rem solid var(--general-section-1);
padding: 3rem;
@include mobile {
height: 100%;
border: none;
padding: 1.2rem;
}

&__header-and-description {
display: flex;
Expand All @@ -66,19 +74,11 @@
&__bordered,
&__bordered--with-margin {
@include mobile {
padding: 3rem 3rem 15rem;
height: 36.5rem;
padding: 1.2rem;
border: none;
overflow-y: scroll;
overflow-x: hidden;
}
}

@include mobile {
border: none;
padding: 0;
}

&__description {
margin-bottom: 1rem;

Expand Down
Loading

0 comments on commit e9d9323

Please sign in to comment.