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

[DTRA]/Ahmad/Update Dtrader Url #14558

Merged
Merged
Show file tree
Hide file tree
Changes from 14 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 @@ -23,6 +23,6 @@ describe('<ContinueTradingButton/>', () => {
renderWithRouter(<ContinueTradingButton />);
const continue_btn_text = screen.getByTestId('continue_btn_text');
fireEvent.click(continue_btn_text);
expect(history.location.pathname).toBe(routes.root);
expect(history.location.pathname).toBe(routes.trade);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react';
import classNames from 'classnames';
import { ButtonLink, Text } from '@deriv/components';
import { Localize } from '@deriv/translations';
import { routes } from '@deriv/shared/src/utils/routes/routes';

type TContinueTradingButtonProps = { className?: string };

Expand All @@ -12,7 +13,7 @@ type TContinueTradingButtonProps = { className?: string };
* @returns React Element
*/
export const ContinueTradingButton = ({ className }: TContinueTradingButtonProps) => (
<ButtonLink className={classNames('account-management__button', className)} to='/'>
<ButtonLink className={classNames('account-management__button', className)} to={routes.trade}>
<Text className='dc-btn__text' as='p' weight='bold' data-testid='continue_btn_text'>
<Localize i18n_default_text='Continue trading' />
</Text>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { createBrowserHistory } from 'history';
import { routes } from '@deriv/shared';

const mock_props = {
link_to: routes.trader,
link_to: routes.trade,
onAction: jest.fn(),
is_buttons_disabled: false,
is_real: true,
Expand Down Expand Up @@ -69,10 +69,6 @@ describe('Test Cases for Multi Action Button Group:', () => {
<MultiActionButtonGroup {...mock_props} is_real />
</Router>
);

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

expect(history.location.pathname).toBe(routes.trade);
expect(screen.getByRole('link')).toHaveAttribute('href', '/dtrader');
});
});
2 changes: 1 addition & 1 deletion packages/core/src/Stores/client-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -2196,7 +2196,7 @@ export default class ClientStore extends BaseStore {
const target_url = is_next_wallet_enabled ? routes.wallets : routes.traders_hub;

if (
(redirect_url?.endsWith('/') ||
(redirect_url?.endsWith(routes.trade) ||
redirect_url?.endsWith(routes.bot) ||
/chart_type|interval|symbol|trade_type/.test(redirect_url)) &&
(isTestLink() || isProduction() || isLocal() || isStaging() || isTestDerivApp())
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/src/utils/routes/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const routes = {
settings: '/settings',
statement: '/reports/statement',
token: '/settings/token',
trade: '/',
trade: '/dtrader',
bot: '/bot',
cashier: '/cashier',
cashier_deposit: '/cashier/deposit',
Expand Down
1 change: 1 addition & 0 deletions packages/stores/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ type TRoutes =
| '/reports/profit'
| '/reports'
| '/'
| '/dtrader'
ahmadtaimoor-deriv marked this conversation as resolved.
Show resolved Hide resolved
| '/redirect'
| '/settings'
| '/reports/statement'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react';
import { render, screen } from '@testing-library/react';
import { BrowserRouter } from 'react-router-dom';
import { BinaryLink } from '../index';
import userEvent from '@testing-library/user-event';

type TMockBinaryLink = {
to?: string;
Expand All @@ -17,22 +18,24 @@ const MockBinaryLink = ({ to }: TMockBinaryLink) => (

describe('BinaryLink component', () => {
it('should render "children" when passed in', () => {
render(<MockBinaryLink />);
render(<MockBinaryLink to='/dtrader' />);
expect(screen.getByTestId('dt_child')).toBeInTheDocument();
});

it('should have "active_class" when passed in', () => {
render(<MockBinaryLink to='/' />);
expect(screen.getByTestId('dt_binary_link')).toHaveClass('active_class');
render(<MockBinaryLink to='/dtrader' />);
userEvent.click(screen.getByTestId('dt_binary_link'));
const link = screen.getByTestId('dt_binary_link');
expect(link).toHaveClass('active_class');
});

it('should render "NavLink" when "to" property is passed', () => {
render(<MockBinaryLink to='/' />);
it('should render "NavLink" when valid "to" property is passed', () => {
render(<MockBinaryLink to='/dtrader' />);
expect(screen.getByTestId('dt_binary_link')).toBeInTheDocument();
});

it('should render "a" element whe property "to" is not passed', () => {
render(<MockBinaryLink />);
expect(screen.getByTestId('dt_binary_link')).toBeInTheDocument();
it('throws an error for an invalid route', () => {
const viewComponent = () => render(<MockBinaryLink to='/invalid' />);
expect(viewComponent).toThrowError('Route not found: /invalid');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ describe('Routes Config', () => {

it('should return routes with trade route', async () => {
const routes = getRoutesConfig();
expect(routes?.[1]?.path).toBe('/');
expect(routes?.[1]?.path).toBe('/dtrader');
expect(routes?.[1]?.getTitle?.()).toBe('Trader');
expect(routes?.[1]?.exact).toBe(true);
const history = createMemoryHistory();
history.push('/');
history.push('/dtrader');
render(<MockBinaryRoutes store={mockStore({})} history={history} is_logged_in is_logging_in />);
await waitFor(() => {
expect(screen.getByText('Trader')).toBeInTheDocument();
Expand Down
2 changes: 1 addition & 1 deletion packages/trader/src/App/Containers/Routes/routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type TTradePageMountingMiddlewareParams = {
path_to: string;
};

export const checkRoutingMatch = (route_list: Array<string | undefined>, path = '') => {
export const checkRoutingMatch = (route_list: Array<string | undefined>, path = '/dtrader') => {
return route_list.some(route => !!matchPath(path, { path: route, exact: true }));
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe('<TradeFooterExtensions>', () => {
mock_store.client.is_logged_in = true;
router_prop = {
location: {
pathname: '/',
pathname: '/dtrader',
},
};
renderTraderFooterExtensions(router_prop);
Expand Down
2 changes: 1 addition & 1 deletion packages/tradershub/src/constants/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const optionsAndMultipliersContent = (isEU: boolean) => [
{
description: isEU ? 'Multipliers trading platform.' : 'Options and multipliers trading platform.',
icon: <IconComponent icon='DTrader' />,
redirect: '/',
redirect: '/dtrader',
smallIcon: <IconComponent height={32} icon='DTrader' width={32} />,
title: 'Deriv Trader',
},
Expand Down
2 changes: 1 addition & 1 deletion packages/wallets/src/constants/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const optionsAndMultipliersContent = [
{
description: i18n.t('Options and multipliers trading platform.'),
icon: <DerivProductDerivTraderBrandLightLogoHorizontalIcon height='48' width='48' />,
redirect: '/',
redirect: '/dtrader',
smallIcon: <DerivProductDerivTraderBrandLightLogoHorizontalIcon height='32' width='32' />,
title: i18n.t('Deriv Trader'),
},
Expand Down
Loading