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

Aum/prodqa 38/client redirection to correct withdrawal page using loginid #9017

Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
176246e
fix: redirect user to correct withdrawal page using loginid
aum-deriv Jun 14, 2023
265d840
fix: fixed a typo error
aum-deriv Jun 14, 2023
133e16e
chore: empty-commit
aum-deriv Jun 15, 2023
15260cc
chore: empty-commit
aum-deriv Jun 15, 2023
b34fc1a
Merge branch 'master' of github.com:binary-com/deriv-app into Aum/PRO…
aum-deriv Jun 16, 2023
66230b5
chore: empty-commit
aum-deriv Jun 17, 2023
6a8b389
chore: empty-commit
aum-deriv Jun 17, 2023
173618d
chore: empty-commit
aum-deriv Jun 17, 2023
7b8b20f
Merge branch 'master' of github.com:binary-com/deriv-app into aum/PRO…
aum-deriv Jun 19, 2023
bd8d917
chore: remove useStore usage from redirect.jsx
aum-deriv Jun 19, 2023
2f2aa64
chore: added test case for redirect.jsx
aum-deriv Jun 20, 2023
684e2d7
Merge branch 'master' of github.com:binary-com/deriv-app into aum/PRO…
aum-deriv Jun 20, 2023
611bebd
chore: fixed condition for root redirection in redirect.jsx
aum-deriv Jun 20, 2023
8967d42
Merge branch 'master' of github.com:binary-com/deriv-app into aum/PRO…
aum-deriv Jun 21, 2023
cb68b92
Merge branch 'master' of github.com:binary-com/deriv-app into aum/PRO…
aum-deriv Jun 21, 2023
e5a4d3c
chore: empty-commit
aum-deriv Jun 21, 2023
ba54bdf
chore: added suggestions from PR comments
aum-deriv Jun 21, 2023
0031dcd
Merge branch 'master' of github.com:binary-com/deriv-app into aum/PRO…
aum-deriv Jul 3, 2023
0a443f9
fix: fixed bug for DIEL accounts as well
aum-deriv Jul 3, 2023
b27f77a
Merge branch 'master' of github.com:binary-com/deriv-app into aum/PRO…
aum-deriv Jul 3, 2023
77b1eb5
chore: removed test file for redirect.spec.jsx
aum-deriv Jul 3, 2023
523f979
chore: added suggested change from comments
aum-deriv Jul 4, 2023
d124777
Merge branch 'master' of github.com:binary-com/deriv-app into aum/PRO…
aum-deriv Jul 4, 2023
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
@@ -0,0 +1,42 @@
import React from 'react';
import { createBrowserHistory } from 'history';
import { Router } from 'react-router-dom';
import { render } from '@testing-library/react';
import Redirect from '../redirect';

jest.mock('Stores/connect', () => ({
__esModule: true,
default: 'mockedDefaultExport',
connect: () => Component => Component,
}));

describe('<Redirect />', () => {
const history = createBrowserHistory();
aum-deriv marked this conversation as resolved.
Show resolved Hide resolved
let mock_props;

beforeEach(() => {
history.push('/redirect?action=payment_withdraw&lang=EN&code=FwGsJwTJ&loginid=CR456');

mock_props = {
loginid: 'CR1234',
verification_code: {
payment_withdraw: '',
},
setVerificationCode: jest.fn(),
setNewEmail: jest.fn(),
setLoginId: jest.fn(id => {
return id;
}),
};
});

it('should set login id provided to the one provided in the url before redirection', () => {
render(
<Router history={history}>
<Redirect {...mock_props} />
</Router>
);
aum-deriv marked this conversation as resolved.
Show resolved Hide resolved

expect(mock_props.setLoginId).toHaveBeenCalledWith('CR456');
});
});
7 changes: 6 additions & 1 deletion packages/core/src/App/Containers/Redirect/redirect.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { WS } from 'Services';
const Redirect = ({
history,
currency,
loginid,
setLoginId,
setVerificationCode,
verification_code,
hasAnyRealAccount,
Expand All @@ -26,6 +28,7 @@ const Redirect = ({
const { is_appstore } = React.useContext(PlatformContext);
const action_param = url_params.get('action');
const code_param = url_params.get('code') || verification_code[action_param];
const loginid_param = url_params.get('loginid') || loginid;

setVerificationCode(code_param, action_param);
setNewEmail(url_params.get('email'), action_param);
Expand Down Expand Up @@ -117,6 +120,7 @@ const Redirect = ({
break;
}
case 'payment_withdraw': {
setLoginId(loginid_param);
aum-deriv marked this conversation as resolved.
Show resolved Hide resolved
history.push(routes.cashier_withdrawal);
redirected_to_route = true;
break;
Expand Down Expand Up @@ -180,7 +184,7 @@ const Redirect = ({
break;
}

if (!redirected_to_route) {
if (!redirected_to_route && history.location.pathname !== routes.root) {
history.push({
pathname: routes.root,
search: url_query_string,
Expand Down Expand Up @@ -211,6 +215,7 @@ export default withRouter(
connect(({ client, ui }) => ({
currency: client.currency,
loginid: client.loginid,
nijil-deriv marked this conversation as resolved.
Show resolved Hide resolved
setLoginId: client.setLoginId,
is_eu: client.is_eu,
setVerificationCode: client.setVerificationCode,
verification_code: client.verification_code,
Expand Down