Skip to content

Commit

Permalink
chore: Merge branch 'master' into likhith/79242/fix-broken-manual-upl…
Browse files Browse the repository at this point in the history
…oad-flow
  • Loading branch information
likhith-deriv committed Jan 17, 2023
2 parents f8c11a1 + 5a902f7 commit 4325ecc
Show file tree
Hide file tree
Showing 1,056 changed files with 33,469 additions and 26,582 deletions.
3 changes: 3 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,20 @@ commands:
# VERIFY_CACHE_FOLDERS_START (DO NOT REMOVE)
- "node_modules"
- "packages/account/node_modules"
- "packages/api/node_modules"
- "packages/appstore/node_modules"
- "packages/bot-skeleton/node_modules"
- "packages/bot-web-ui/node_modules"
- "packages/cashier/node_modules"
- "packages/components/node_modules"
- "packages/core/node_modules"
- "packages/hooks/node_modules"
- "packages/cfd/node_modules"
- "packages/indicators/node_modules"
- "packages/p2p/node_modules"
- "packages/reports/node_modules"
- "packages/shared/node_modules"
- "packages/stores/node_modules"
- "packages/trader/node_modules"
- "packages/translations/node_modules"
# VERIFY_CACHE_FOLDERS_END (DO NOT REMOVE)
Expand Down
1 change: 1 addition & 0 deletions .commitlintrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"extends": ["@commitlint/config-conventional", "@commitlint/config-nx-scopes"],
"rules": {
"subject-case": [0, "always"],
"type-enum": [
2,
"always",
Expand Down
1 change: 0 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ module.exports = {
es6: true,
browser: true,
amd: true,
mocha: true,
jest: true,
jquery: true,
jasmine: true,
Expand Down
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx lint-staged --allow-empty
npx lint-staged --allow-empty
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ All packages must contain the following scripts to perform the stated actions:
|| `serve` | Runs build suite and starts the dev server. When serving `core`, takes optional `open` value as argument to open specific page. (e.g: `npm run serve core --open=bot`) |
|| `build` | Runs build suite and outputs the result into `dist`. Takes optional `base` value as argument. |
|| `test` | Runs the test suite with eslint, stylelint and jest. |
|| `test:mocha` | Runs only the test suite. |
|| `test:jest` | Runs only the jest test suite. |
|| `test:qa` | Runs the e2e test suite. |
|| `test:performance` | Runs the performance test suite. |
Expand Down
2 changes: 1 addition & 1 deletion default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ server {

charset UTF-8;

error_page 404 /404.html;
error_page 404 /custom404.html;

location @custom_error_503 {
return 503;
Expand Down
2 changes: 1 addition & 1 deletion hooks/pre-push.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function main() {
npm run test:stylelint $package
fi

npm run test:mocha $package
npm run test:jest $package
done
}

Expand Down
18,015 changes: 8,447 additions & 9,568 deletions package-lock.json

Large diffs are not rendered by default.

10 changes: 4 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@
"@types/node": "^17.0.27",
"@types/react": "^18.0.7",
"@types/react-dom": "^18.0.0",
"@testing-library/user-event": "^13.5.0",
"@types/react-router-dom": "^5.1.6",
"@types/react-virtualized": "^9.21.21",
"@typescript-eslint/eslint-plugin": "^5.8.0",
"@typescript-eslint/parser": "^5.8.0",
"babel-polyfill": "^6.26.0",
"chai": "^4.2.0",
"eslint": "^7.18.0",
"eslint-config-airbnb-base": "^14.2.1",
"eslint-config-binary": "^1.0.2",
Expand All @@ -51,7 +51,6 @@
"jest": "^26.4.2",
"lerna": "^5.5.1",
"lint-staged": "^10.4.0",
"mocha": "^7.1.1",
"nx": "^14.5.10",
"postcss": "^8.3.6",
"prettier": "^2.1.2",
Expand All @@ -62,6 +61,9 @@
"stylelint-no-unsupported-browser-features": "^4.0.0",
"stylelint-selector-bem-pattern": "^2.1.0",
"stylelint-webpack-plugin": "^2.1.1",
"@testing-library/jest-dom": "^5.12.0",
"jest-chain": "^1.1.5",
"jest-extended": "^1.2.0",
"ts-jest": "^26.4.2"
},
"scripts": {
Expand Down Expand Up @@ -89,7 +91,6 @@
"serve": "f () { lerna exec --scope=@deriv/${1:-'*'} -- npm run serve $npm_config_open;}; f",
"start": "f () { lerna exec --scope=@deriv/${1:-'*'} -- npm run start ;}; f",
"test": "f () { bash ./scripts/circleci-config.test.sh && npm run test:stylelint && npm run test:eslint-all && npm run test:jest ;}; f",
"test:mocha": "f () { lerna exec --scope=@deriv/${1:-'*'} -- npm run test:mocha ;}; f",
"test:stylelint": "stylelint \"./packages/*/src/**/*.s(a|c)ss\"",
"test:jest": "jest --all --maxWorkers=2",
"test:qa": "cd e2e_tests && jest -c ./jest.config.js --maxWorkers=2 --detectOpenHandles",
Expand All @@ -101,12 +102,9 @@
},
"dependencies": {
"@babel/preset-typescript": "^7.16.5",
"@testing-library/jest-dom": "^5.12.0",
"@types/react-transition-group": "^4.4.4",
"babel-jest": "^27.3.1",
"dotenv": "^8.2.0",
"jest-chain": "^1.1.5",
"jest-extended": "^1.2.0",
"react": "^16.14.0",
"react-dom": "^16.14.0",
"typescript": "^4.6.3"
Expand Down
10 changes: 4 additions & 6 deletions packages/account/build/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,10 @@ const IS_RELEASE = process.env.NODE_ENV === 'production' || process.env.NODE_ENV
const ALIASES = {
Assets: path.resolve(__dirname, '../src/Assets'),
Components: path.resolve(__dirname, '../src/Components'),
Containers: path.resolve(__dirname, '../src/Containers'),
Constants: path.resolve(__dirname, '../src/Constants'),
Configs: path.resolve(__dirname, '../src/Configs'),
Duplicated: path.resolve(__dirname, '../src/Duplicated'),
Constants: path.resolve(__dirname, '../src/Constants'),
Containers: path.resolve(__dirname, '../src/Containers'),
Helpers: path.resolve(__dirname, '../src/Helpers'),
Layout: path.resolve(__dirname, '../src/Layout'),
Modules: path.resolve(__dirname, '../src/Modules'),
Sections: path.resolve(__dirname, '../src/Sections'),
Services: path.resolve(__dirname, '../src/Services'),
Expand All @@ -34,8 +32,8 @@ const ALIASES = {
Types: path.resolve(__dirname, '../src/Types'),
};

const rules = (is_test_env = false, is_mocha_only = false) => [
...(is_test_env && !is_mocha_only
const rules = (is_test_env = false) => [
...(is_test_env
? [
{
test: /\.(js|jsx|ts|tsx)$/,
Expand Down
29 changes: 17 additions & 12 deletions packages/account/build/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ module.exports = function (env) {
'currency-selector': 'Components/currency-selector',
'currency-selector-config': 'Configs/currency-selector-config',
'currency-selector-schema': 'Configs/currency-selector-schema',
'currency-radio-button-group': 'Components/currency-selector/radio-button-group.jsx',
'currency-radio-button': 'Components/currency-selector/radio-button.jsx',
'currency-radio-button-group': 'Components/currency-selector/radio-button-group.tsx',
'currency-radio-button': 'Components/currency-selector/radio-button.tsx',
'demo-message': 'Components/demo-message',
'error-component': 'Components/error-component',
'file-uploader-container': 'Components/file-uploader-container',
'financial-assessment': 'Sections/Profile/FinancialAssessment',
'financial-assessment': 'Sections/Assessment/FinancialAssessment',
'financial-details': 'Components/financial-details',
'financial-details-config': 'Configs/financial-details-config',
'form-body': 'Components/form-body',
Expand All @@ -31,34 +31,39 @@ module.exports = function (env) {
'icon-message-content': 'Components/icon-message-content',
'leave-confirm': 'Components/leave-confirm',
'load-error-message': 'Components/load-error-message',
'personal-details': 'Components/personal-details',
'personal-details-config': 'Configs/personal-details-config',
'poa-expired': 'Components/poa/status/expired',
'poa-needs-review': 'Components/poa/status/needs-review',
'poa-status-codes': 'Components/poa/status/status-codes',
'poa-submitted': 'Components/poa/status/submitted',
'poa-unverified': 'Components/poa/status/unverified',
'poa-verified': 'Components/poa/status/verified',
'personal-details': 'Components/personal-details',
'personal-details-config': 'Configs/personal-details-config',
'poi-expired': 'Components/poi/status/expired',
'poi-missing-personal-details': 'Components/poi/missing-personal-details',
'poi-unsupported': 'Components/poi/status/unsupported',
'poi-unverified': 'Components/poi/status/unverified',
'poi-upload-complete': 'Components/poi/status/upload-complete',
'poi-verified': 'Components/poi/status/verified',
'proof-of-address-container': 'Sections/Verification/ProofOfAddress/proof-of-address-container.jsx',
'proof-of-identity': 'Sections/Verification/ProofOfIdentity/proof-of-identity.jsx',
'proof-of-identity-container': 'Sections/Verification/ProofOfIdentity/proof-of-identity-container.jsx',
'proof-of-address-container': 'Sections/Verification/ProofOfAddress/proof-of-address-container.jsx',
'proof-of-identity-config': 'Configs/proof-of-identity-config',
'proof-of-identity-form-on-signup': 'Components/poi/poi-form-on-signup',
'proof-of-identity-container-for-mt5':
'Sections/Verification/ProofOfIdentity/proof-of-identity-container-for-mt5',
'poi-poa-docs-submitted': 'Components/poi-poa-docs-submitted/poi-poa-docs-submitted.jsx',
'reset-trading-password-modal': 'Components/reset-trading-password-modal',
'risk-tolerance-warning-modal': 'Components/trading-assessment/risk-tolerance-warning-modal.jsx',
'self-exclusion': 'Components/self-exclusion',
'scrollbars-container': 'Components/scrollbars-container',
'sent-email-modal': 'Components/sent-email-modal',
'terms-of-use': 'Components/terms-of-use',
'terms-of-use-config': 'Configs/terms-of-use-config',
'proof-of-identity-config': 'Configs/proof-of-identity-config',
'proof-of-identity-form-on-signup': 'Components/poi/poi-form-on-signup',
'proof-of-identity-container-for-mt5':
'Sections/Verification/ProofOfIdentity/proof-of-identity-container-for-mt5',
'poi-poa-docs-submitted': 'Components/poi-poa-docs-submitted/poi-poa-docs-submitted.jsx',
'trading-assessment': 'Sections/Assessment/TradingAssessment',
'trading-assessment-config': 'Configs/trading-assessment-config',
'trading-assessment-new-user': 'Components/trading-assessment/trading-assessment-new-user.jsx',
'test-warning-modal': 'Components/trading-assessment/test-warning-modal.jsx',
'trading-assessment-form': 'Components/trading-assessment/trading-assessment-form.jsx',
},
mode: IS_RELEASE ? 'production' : 'development',
module: {
Expand Down
1 change: 1 addition & 0 deletions packages/account/global.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare module '@binary-com/binary-document-uploader';
2 changes: 2 additions & 0 deletions packages/account/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@
"@babel/preset-react": "^7.16.7",
"@jest/globals": "^26.5.3",
"@testing-library/react": "^12.0.0",
"@testing-library/user-event": "^13.5.0",
"babel-eslint": "^10.1.0",
"@types/react": "^18.0.7",
"@types/react-dom": "^18.0.0",
"babel-loader": "^8.1.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@ import { createBrowserHistory } from 'history';
import { fireEvent, render, screen } from '@testing-library/react';
import { PlatformContext } from '@deriv/shared';
import { findRouteByPath } from '../helpers';
import BinaryLink from '../binary-link.jsx';
import BinaryLink from '../binary-link';

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

jest.mock('../helpers.js', () => ({
jest.mock('../helpers', () => ({
findRouteByPath: jest.fn(() => '/test/path'),
normalizePath: jest.fn(() => '/test/path'),
}));

jest.mock('Constants/routes-config.js', () => () => ({
jest.mock('Constants/routes-config', () => () => ({
getRoutesConfig: jest.fn(() => []),
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jest.mock('Stores/connect', () => ({
connect: () => Component => Component,
}));

jest.mock('../route-with-sub-routes.jsx', () => jest.fn(() => <div>RouteWithSubRoutes</div>));
jest.mock('../route-with-sub-routes', () => jest.fn(() => <div>RouteWithSubRoutes</div>));

jest.mock('Constants/routes-config', () => () => [{}]);

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,32 +1,42 @@
import React from 'react';
import { expect } from 'chai';
import { configure, shallow } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import { render, screen } from '@testing-library/react';
import { RouteWithSubRoutesRender } from '../route-with-sub-routes';
import { Redirect } from 'react-router-dom';
import { PlatformContext } from '@deriv/shared';

configure({ adapter: new Adapter() });
jest.mock('react-router-dom', () => ({
...jest.requireActual('react-router-dom'),
Route: jest.fn(({ exact, path }) => (
<div>
<span>
Route loaded {String(exact)} {path}`
</span>
</div>
)),
}));

afterEach(() => {
jest.clearAllMocks();
});

describe('<RouteWithSubRoutes />', () => {
it('should render one <RouteWithSubRoutesRender /> component', () => {
const comp = (
render(
<PlatformContext.Provider>
<RouteWithSubRoutesRender />
</PlatformContext.Provider>
);
const wrapper = shallow(comp);
expect(wrapper).to.have.length(1);

expect(screen.getByText(/Route loaded/)).toBeInTheDocument();
});

it('should have props as passed as route', () => {
const route = { path: '/', component: Redirect, title: '', exact: true, to: '/root' };
const comp = (
const route = { path: '/test', component: Redirect, title: '', exact: true, to: '/root' };
render(
<PlatformContext.Provider>
<RouteWithSubRoutesRender {...route} />
</PlatformContext.Provider>
);
const wrapper = shallow(comp);
expect(wrapper.prop('exact')).to.equal(true);
expect(wrapper.prop('path')).to.equal('/');
expect(screen.getByText(/route loaded true \/test/i)).toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import PropTypes from 'prop-types';
import React from 'react';
import { NavLink } from 'react-router-dom';
import { PlatformContext } from '@deriv/shared';
import getRoutesConfig from 'Constants/routes-config';
import { findRouteByPath, normalizePath } from './helpers';
import { TPlatformContext } from 'Types';

const BinaryLink = ({ active_class, to, children, ...props }) => {
const { is_appstore } = React.useContext(PlatformContext);
const path = normalizePath(to);
type TBinaryLink = {
active_class: string;
to: string;
};

const BinaryLink = ({ active_class, to, children, ...props }: React.PropsWithChildren<Partial<TBinaryLink>>) => {
const { is_appstore } = React.useContext<TPlatformContext>(PlatformContext);
const path = normalizePath(to as string);
const route = findRouteByPath(path, getRoutesConfig({ is_appstore }));

if (!route) {
Expand All @@ -23,11 +28,4 @@ const BinaryLink = ({ active_class, to, children, ...props }) => {
);
};

BinaryLink.propTypes = {
active_class: PropTypes.string,
children: PropTypes.oneOfType([PropTypes.object, PropTypes.array, PropTypes.string]),
is_social_signup: PropTypes.bool,
to: PropTypes.string,
};

export default BinaryLink;
Loading

0 comments on commit 4325ecc

Please sign in to comment.