Skip to content

Commit

Permalink
Update branch (#5680)
Browse files Browse the repository at this point in the history
* fixed translation for amount field in account transfer form cashier (#5605)

Co-authored-by: Carol Sachdeva <58209918+carol-binary@users.noreply.github.com>

* farrah/updated deposit store test coverage (#5430)

* updated deposit store test coverage

* added a check for updateAccountStatus

Co-authored-by: Carol Sachdeva <58209918+carol-binary@users.noreply.github.com>

* likhith/Fix validation message for payment methods (#5187)

* Added appropriate error message

* Fixed error messages in Edit form

* Added validation for SWIFT

* Added a hook to validate methods

* Removed commented code

* Refactored the code by moving the custom hook to hooks folder

* Minor bug fixes

* refactor: Renamed a variable

* fix: added regex to allow more characters as valid

* fix: implemented button disabled

* fix: changed the edit payment method

* fix: added payment error message overlapping issue

Co-authored-by: Likhith Kolayari <likhith@deriv.com>
Co-authored-by: Carol Sachdeva <58209918+carol-binary@users.noreply.github.com>

* Amina/poi_limited_test_case (#5642)

* poi_limited_test_case

* poi_limited_test_case

Co-authored-by: Carol Sachdeva <58209918+carol-binary@users.noreply.github.com>

* yauheni / IdvRejected test coverage (#5637)

Co-authored-by: “yauheni-kryzhyk-deriv” <“yauheni@deriv.me”>
Co-authored-by: Carol Sachdeva <58209918+carol-binary@users.noreply.github.com>

* yauheni / IdvNoSubmisssions test coverage (#5636)

* yauheni / IdvNoSubmisssions test coverage

* imports fix

* naming typo fix

* Delete poi-idv-rejected.spec.js

Co-authored-by: “yauheni-kryzhyk-deriv” <“yauheni@deriv.me”>
Co-authored-by: Carol Sachdeva <58209918+carol-binary@users.noreply.github.com>

* feat: add check if has restricted parent (#5635)

Co-authored-by: Carol Sachdeva <58209918+carol-binary@users.noreply.github.com>

* Adrienne / P2P responsive add PM full screen modal button footers are now fixed by design (#5561)

* Mobile add PM full screen modal button footers are now fixed by design specs

* Incorporated code review changes

Co-authored-by: Carol Sachdeva <58209918+carol-binary@users.noreply.github.com>

* Bala/Add bootstrap dev script (#5659)

* chore: add bootstrap dev script

* Update package.json

Co-authored-by: Yashim Wong <75345074+yashim-deriv@users.noreply.github.com>

* chore: remove build from bootstrap

Co-authored-by: Yashim Wong <75345074+yashim-deriv@users.noreply.github.com>
Co-authored-by: Carol Sachdeva <58209918+carol-binary@users.noreply.github.com>

* translations: 📚 sync translations with crowdin (#5679)

Co-authored-by: DerivFE <80095553+DerivFE@users.noreply.github.com>

* update branch

Co-authored-by: vinu-deriv <100689171+vinu-deriv@users.noreply.github.com>
Co-authored-by: Farrah Mae Ochoa <82315152+farrah-deriv@users.noreply.github.com>
Co-authored-by: Likhith Kolayari <98398322+likhith-deriv@users.noreply.github.com>
Co-authored-by: Likhith Kolayari <likhith@deriv.com>
Co-authored-by: amina-deriv <84661147+amina-deriv@users.noreply.github.com>
Co-authored-by: yauheni-kryzhyk-deriv <103182683+yauheni-kryzhyk-deriv@users.noreply.github.com>
Co-authored-by: “yauheni-kryzhyk-deriv” <“yauheni@deriv.me”>
Co-authored-by: maryiafrantsava-binary <103181650+maryiafrantsava-binary@users.noreply.github.com>
Co-authored-by: adrienne-deriv <103016120+adrienne-deriv@users.noreply.github.com>
Co-authored-by: balakrishna-binary <56330681+balakrishna-binary@users.noreply.github.com>
Co-authored-by: Yashim Wong <75345074+yashim-deriv@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: DerivFE <80095553+DerivFE@users.noreply.github.com>
  • Loading branch information
14 people authored Jun 9, 2022
1 parent 99307da commit 66ef317
Show file tree
Hide file tree
Showing 35 changed files with 511 additions and 297 deletions.
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,15 @@
"stylelint-webpack-plugin": "^2.1.1"
},
"scripts": {
"bootstrap": "f () { npm ci && lerna link && lerna bootstrap --ci --hoist --strict && lerna link && npm run build:travis ;}; f",
"bootstrap": "f () { npm ci && lerna link && lerna bootstrap --ci --hoist --strict && lerna link ;}; f",
"bootstrap:dev": "f () { npm ci && lerna link && lerna bootstrap --hoist --strict && lerna link ;}; f",
"build": "f () { lerna exec --scope=@deriv/${1:-'*'} -- npm run build $2 ;}; f",
"build:publish": "f () { lerna exec --scope=@deriv/${1:-'*'} -- npm run build:publish $2 ;}; f",
"build:local": "f () { lerna exec --scope @deriv/trader --scope @deriv/bot-web-ui --parallel -- npm run build $1 ;}; f",
"build:travis": "lerna exec --scope @deriv/shared --scope @deriv/components --scope @deriv/translations --scope @deriv/cashier --scope @deriv/account --scope @deriv/p2p -- npm run build:travis",
"build:travis": "lerna exec --scope @deriv/shared --scope @deriv/components --scope @deriv/translations --scope @deriv/cashier --scope @deriv/account --scope @deriv/p2p --scope @deriv/cfd -- npm run build:travis",
"build:prod": "export NODE_ENV=staging && npm run build && export NODE_ENV=",
"build:storybook": "cd packages/components && build-storybook --output-dir .out",
"build:gh-pages": "f () { lerna exec --scope @deriv/components --scope @deriv/p2p -- npm run build && lerna exec --scope @deriv/cashier --scope @deriv/account -- npm run build $1 && npm run build:local $1 ;}; f",
"build:gh-pages": "f () { lerna exec --scope @deriv/components --scope @deriv/p2p -- npm run build && lerna exec --scope @deriv/cashier --scope @deriv/account --scope @deriv/cfd -- npm run build $1 && npm run build:local $1 ;}; f",
"clean": "echo \"Remove $(git rev-parse --show-toplevel)/node_modules\" && lerna clean && rm -rf \"$(git rev-parse --show-toplevel)/node_modules\"",
"deploy": "f () { npm run build:travis && npm run build:local && lerna exec --scope @deriv/core -- npm run deploy $@ ;}; f",
"deploy:clean": "f () { npm run build:travis && npm run build:local && lerna exec --scope @deriv/core -- npm run deploy:clean $@ ;}; f",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React from 'react';
import { fireEvent, render, screen } from '@testing-library/react';
import IdvNoSubmissions from '../poi-idv-limited';

jest.mock('../../../Assets/ic-idv-document-rejected.svg', () => jest.fn(() => 'IdvDocumentRejected'));

describe('<IdvNoSubmissions/>', () => {
const mockHandleRequireSubmission = jest.fn();

it('should render IdvNoSubmissions component and trigger click', () => {
render(<IdvNoSubmissions handleRequireSubmission={mockHandleRequireSubmission} />);

expect(screen.getByText('IdvDocumentRejected')).toBeInTheDocument();
expect(screen.getByText(/ID verification failed/i)).toBeInTheDocument();
expect(screen.getByText(/we were unable to verify your ID with the details you provided/i)).toBeInTheDocument();
expect(screen.getByText(/please upload your identity document/i)).toBeInTheDocument();

const btn = screen.getByRole('button');
expect(btn).toHaveTextContent(/upload identity document/i);
fireEvent.click(btn);
expect(mockHandleRequireSubmission).toHaveBeenCalledTimes(1);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React from 'react';
import { fireEvent, render, screen } from '@testing-library/react';
import IdvRejected from '../poi-idv-rejected';

jest.mock('../../../Assets/ic-idv-document-rejected.svg', () => jest.fn(() => 'IdvDocumentRejected'));

describe('<IdvRejected/>', () => {
const mockHandleRequireSubmission = jest.fn();

it('should render IdvRejected component and trigger click', () => {
render(<IdvRejected handleRequireSubmission={mockHandleRequireSubmission} />);

expect(screen.getByText('IdvDocumentRejected')).toBeInTheDocument();
expect(screen.getByText(/ID verification failed/i)).toBeInTheDocument();
expect(screen.getByText(/we were unable to verify your ID with the details you provided/i)).toBeInTheDocument();

const btn = screen.getByRole('button');
expect(btn).toHaveTextContent(/try again/i);
fireEvent.click(btn);
expect(mockHandleRequireSubmission).toHaveBeenCalledTimes(1);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from 'react';
import { fireEvent, render, screen } from '@testing-library/react';
import { POILimited } from '../poi-limited';

describe('<POILimited/>', () => {
it('should render POILimited component', () => {
window.LC_API = {
open_chat_window: jest.fn(),
};
render(<POILimited />);
expect(screen.getByText(/you've reached the limit for uploading your documents\./i)).toBeInTheDocument();
expect(screen.getByText(/please contact us via/i)).toBeInTheDocument();

const live_chat_text = screen.getByText(/live chat/i);
expect(live_chat_text).toBeInTheDocument();
fireEvent.click(live_chat_text);
expect(window.LC_API.open_chat_window).toHaveBeenCalledTimes(1);
});
});
16 changes: 9 additions & 7 deletions packages/bot-skeleton/src/scratch/hooks/contextmenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,18 +245,20 @@ Blockly.ContextMenu.blockDisableOption = function (block) {
*/
Blockly.ContextMenu.blockEnableOption = function (block) {
const checkAreSomeDisabled = (block_, disabledArr = []) => {
if (block_.restricted_parents?.some(restricted_parent => block_.isDescendantOf(restricted_parent))) {
disabledArr.push(block_.disabled);
return block_.nextConnection?.targetConnection
? checkAreSomeDisabled(block_.nextConnection?.targetConnection.sourceBlock_, disabledArr)
: disabledArr.includes(true);
if (block_.restricted_parents && !block_.restricted_parents?.includes(block_.getTopParent()?.type)) {
return false;
}
return false;
disabledArr.push(block_.disabled);
return block_.nextConnection?.targetConnection
? checkAreSomeDisabled(block_.nextConnection?.targetConnection.sourceBlock_, disabledArr)
: disabledArr.includes(true);
};
const enabled = checkAreSomeDisabled(block);

const enableBlocksRecursively = block_ => {
block_.setDisabled(false);
if (!block_.restricted_parents || block_.restricted_parents.includes(block_.getTopParent()?.type)) {
block_.setDisabled(false);
}
if (block_.nextConnection?.targetConnection) {
enableBlocksRecursively(block_.nextConnection?.targetConnection.sourceBlock_);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ const AccountTransferForm = ({
<Loading className='cashier__loader' is_fullscreen={false} />
</div>
) : (
<Form>
<Form noValidate>
<div className='cashier__drop-down-wrapper account-transfer-form__drop-down-wrapper'>
<Dropdown
id='transfer_from'
Expand Down
157 changes: 157 additions & 0 deletions packages/cashier/src/Stores/__tests__/deposit-store.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
import DepositStore from '../deposit-store';

describe('DepositStore', () => {
let deposit_store;

beforeEach(() => {
const root_store = {
client: {
is_authentication_needed: false,
is_tnc_needed: false,
is_financial_account: false,
is_financial_information_incomplete: false,
is_trading_experience_incomplete: false,
account_status: {},
is_eu: false,
mt5_login_list: [],
is_deposit_lock: false,
is_virtual: false,
updateAccountStatus: jest.fn(),
},
modules: {
cashier: {
general_store: {
active_container: 'deposit',
is_crypto: false,
onMountCommon: jest.fn(),
setLoading: jest.fn(),
setOnRemount: jest.fn(),
},
iframe: {
checkIframeLoaded: jest.fn(),
clearTimeoutCashierUrl: jest.fn(),
is_session_timeout: false,
setContainerHeight: jest.fn(),
setIframeUrl: jest.fn(),
setSessionTimeout: jest.fn(),
setTimeoutCashierUrl: jest.fn(),
},
},
},
};
const WS = {
authorized: {
cashier: jest.fn(() => Promise.resolve({ cashier: 'https://cashier.deriv.com' })),
},
send: jest.fn(() => Promise.resolve({})),
};

deposit_store = new DepositStore({ root_store, WS });
});

it('should mount deposit properly', async () => {
const { checkIframeLoaded, setIframeUrl, setSessionTimeout, setTimeoutCashierUrl } =
deposit_store.root_store.modules.cashier.iframe;
const { updateAccountStatus } = deposit_store.root_store.client;

await deposit_store.onMountDeposit();
expect(checkIframeLoaded).toHaveBeenCalled();

deposit_store.root_store.modules.cashier.iframe.is_session_timeout = true;

await deposit_store.onMountDeposit();
expect(checkIframeLoaded).toHaveBeenCalled();
expect(setIframeUrl).toHaveBeenCalledWith('https://cashier.deriv.com');
expect(setSessionTimeout).toHaveBeenCalledWith(false);
expect(setTimeoutCashierUrl).toHaveBeenCalled();
expect(updateAccountStatus).toHaveBeenCalled();
});

it('should handle the error on deposit', async () => {
const { setSessionTimeout, clearTimeoutCashierUrl } = deposit_store.root_store.modules.cashier.iframe;
const error_message = 'Sorry, an error occured.';
const spyHandleCashierError = jest.spyOn(deposit_store.error, 'handleCashierError');

deposit_store.root_store.modules.cashier.iframe.is_session_timeout = true;
deposit_store.WS.authorized.cashier.mockResolvedValueOnce({ error: { message: error_message } });

await deposit_store.onMountDeposit();
expect(spyHandleCashierError).toHaveBeenCalledWith({ message: error_message });
expect(setSessionTimeout).toHaveBeenCalledWith(true);
expect(clearTimeoutCashierUrl).toHaveBeenCalled();
});

it('should not load the iframe if client is on virtual account', async () => {
const { setLoading } = deposit_store.root_store.modules.cashier.general_store;
const { checkIframeLoaded } = deposit_store.root_store.modules.cashier.iframe;

deposit_store.root_store.modules.cashier.iframe.is_session_timeout = true;
deposit_store.root_store.client.is_virtual = true;

await deposit_store.onMountDeposit();
expect(checkIframeLoaded).not.toHaveBeenCalled();
expect(setLoading).toHaveBeenCalledWith(false);
});

it('should return is_deposit_locked equal to true if the client needs authentication', () => {
expect(deposit_store.is_deposit_locked).toBeFalse();

deposit_store.root_store.client.account_status.status = ['authentication_needed'];
deposit_store.root_store.client.is_authentication_needed = true;
deposit_store.root_store.client.is_eu = true;
expect(deposit_store.is_deposit_locked).toBeTrue();
});

it('should return is_deposit_locked equal to true if the client needs financial assessment', () => {
deposit_store.root_store.client.account_status.status = [
'financial_information_not_complete',
'trading_experience_not_complete',
];
deposit_store.root_store.client.is_financial_account = true;
deposit_store.root_store.client.is_financial_information_incomplete = true;
expect(deposit_store.is_deposit_locked).toBeTrue();

deposit_store.root_store.client.is_financial_information_incomplete = false;
deposit_store.root_store.client.is_trading_experience_incomplete = true;
expect(deposit_store.is_deposit_locked).toBeTrue();
});

it('should return is_deposit_locked equal to true if the client needs terms and conditions', () => {
deposit_store.root_store.client.account_status.status = ['cashier_locked'];
deposit_store.root_store.client.is_eu = true;
deposit_store.root_store.client.is_tnc_needed = true;
expect(deposit_store.is_deposit_locked).toBeTrue();

deposit_store.root_store.client.is_eu = false;
deposit_store.root_store.client.mt5_login_list = [{ account_type: 'real', sub_account_type: 'financial_stp' }];
expect(deposit_store.is_deposit_locked).toBeTrue();
});

it('should return is_deposit_locked equal to true if the client needs financial risk approval', () => {
deposit_store.root_store.client.account_status.status = ['financial_assessment_not_complete'];
deposit_store.error.is_ask_financial_risk_approval = true;
expect(deposit_store.is_deposit_locked).toBeTrue();
});

it('should submit funds protection', async () => {
Object.defineProperty(window, 'location', {
configurable: true,
value: { reload: jest.fn() },
});

await deposit_store.submitFundsProtection();
expect(location.reload).toHaveBeenCalled();

window.location.reload.mockRestore();
});

it('should handle the error upon submitting funds protection', async () => {
const spySetMessage = jest.spyOn(deposit_store.error, 'setMessage');
const error_message = 'Sorry, an error occurred.';

deposit_store.WS.send.mockResolvedValueOnce({ error: { message: error_message } });

await deposit_store.submitFundsProtection();
expect(spySetMessage).toHaveBeenCalledWith(error_message);
});
});
Loading

0 comments on commit 66ef317

Please sign in to comment.