Skip to content

Commit

Permalink
yashim/feat: add mock server integration phase1 (#9003)
Browse files Browse the repository at this point in the history
* feat: add mock server integration

* refactor: use session instead of client

* fix: persistent mock server enable state

* chore: draft

* feat: add mock server control panel UI

* feat: add clear all functionality

* feat: completed login mock

* fix: tests

* fix: code

* feat: add feature toggle

* feat: end of day commit

* fix: review comments + tests

* chore: used deriv-api

* fix: typescript error

* chore: update package lock

---------

Co-authored-by: Dev Sans <yashimwong@gmail.com>
  • Loading branch information
yashim-deriv and yashimwong committed Jul 4, 2023
1 parent d9815f4 commit cb17414
Show file tree
Hide file tree
Showing 27 changed files with 69,323 additions and 23,385 deletions.
92,135 changes: 68,797 additions & 23,338 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/appstore/src/modules/traders-hub/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const TradersHub = () => {
<Div100vhContainer
className={classNames('traders-hub--mobile', {
'traders-hub--mobile--eu-user': is_eu_user,
'traders-hub__wallets-bg': is_wallet_account || is_display_test_wallets,
'traders-hub__wallets-bg': is_wallet_account,
})}
height_offset='50px'
is_disabled={isDesktop()}
Expand Down
2 changes: 1 addition & 1 deletion packages/bot-skeleton/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"eslint-plugin-react-hooks": "^4.2.0"
},
"dependencies": {
"@deriv/deriv-api": "^1.0.11",
"@deriv/deriv-api": "^1.0.13",
"@deriv/indicators": "^1.0.0",
"@deriv/js-interpreter": "^3.0.0",
"@deriv/shared": "^1.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/bot-web-ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/cashier/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"@deriv/api": "^1.0.0",
"@deriv/api-types": "^1.0.94",
"@deriv/components": "^1.0.0",
"@deriv/deriv-api": "^1.0.11",
"@deriv/deriv-api": "^1.0.13",
"@deriv/hooks": "^1.0.0",
"@deriv/p2p": "^0.7.3",
"@deriv/shared": "^1.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/cfd/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
"@deriv/account": "^1.0.0",
"@deriv/api-types": "^1.0.94",
"@deriv/components": "^1.0.0",
"@deriv/deriv-api": "^1.0.11",
"@deriv/deriv-api": "^1.0.13",
"@deriv/shared": "^1.0.0",
"@deriv/stores": "^1.0.0",
"@deriv/translations": "^1.0.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint @typescript-eslint/triple-slash-reference: "off" */
/// <reference path="../../../@types/react-div-100vh/react-div-100vh-config.d.ts" />
import React from 'react';
import React, { ComponentProps } from 'react';
import Div100vh from 'react-div-100vh';

/* Div100vh is workaround for getting accurate height of 100vh from browsers on mobile,
Expand All @@ -15,14 +15,12 @@ import Div100vh from 'react-div-100vh';
/* To bypass usage of component altogether, use is_bypassed */

type TDiv100vhContainer = {
id?: string;
height_offset: string;
is_bypassed?: boolean;
is_disabled?: boolean;
max_height_offset?: string;
className: string;
max_autoheight_offset?: string;
};
} & ComponentProps<'div'>;

const Div100vhContainer = ({
children,
Expand Down
2 changes: 0 additions & 2 deletions packages/components/src/components/icon/icons.js
Original file line number Diff line number Diff line change
Expand Up @@ -605,8 +605,6 @@ import './common/ic-whats-app.svg';
import './common/ic-windows-logo.svg';
import './common/ic-windows.svg';
import './common/ic-wip.svg';
import './common/ic-withdraw-request-verification-sent.svg';
import './common/ic-withdraw-request-verification.svg';
import './common/ic-zingpay.svg';
import './common/ic-zoom-in.svg';
import './common/ic-zoom-out.svg';
Expand Down
13 changes: 10 additions & 3 deletions packages/components/src/components/input/input.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import classNames from 'classnames';
import React, { HTMLAttributes } from 'react';
import React, { ComponentProps, ComponentType, HTMLAttributes, RefObject } from 'react';
import Field from '../field';
import Text from '../text/text';

Expand Down Expand Up @@ -40,6 +40,13 @@ export type TInputProps = {
onMouseEnter?: React.MouseEventHandler<HTMLInputElement | HTMLTextAreaElement>;
onMouseLeave?: React.MouseEventHandler<HTMLInputElement | HTMLTextAreaElement>;
placeholder?: string;
ref?: RefObject<
ComponentType extends 'textarea'
? HTMLTextAreaElement
: ComponentType extends 'input'
? HTMLInputElement
: never
>;
required?: boolean;
trailing_icon?: React.ReactElement | null;
type?: string;
Expand All @@ -48,7 +55,7 @@ export type TInputProps = {
readOnly?: boolean;
is_autocomplete_disabled?: string;
is_hj_whitelisted?: string;
};
} & Omit<ComponentProps<'input'>, 'ref'>;

type TInputWrapper = {
has_footer: boolean;
Expand Down Expand Up @@ -129,7 +136,7 @@ const Input = React.forwardRef<HTMLInputElement & HTMLTextAreaElement, TInputPro
<textarea
ref={ref}
data-testid={data_testId}
{...props}
{...(props as ComponentProps<'textarea'>)}
className={classNames('dc-input__field dc-input__textarea', {
'dc-input__field--placeholder-visible': !label && props.placeholder,
})}
Expand Down
38 changes: 18 additions & 20 deletions packages/components/stories/icon/icons.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export const icons =
'IcAppstoreWalletUsdcLight',
'IcAppstoreWalletUsdtLight',
'IcAppstoreWalletsLink',
'IcAppstoreWarning',
'IcAppstoreWarning'
],
'brand': [
'IcBrandDerivEzWordmark',
Expand All @@ -67,7 +67,7 @@ export const icons =
'IcBrandDmt5FinancialStp',
'IcBrandDmt5Financial',
'IcBrandDmt5Synthetics',
'IcBrandDxtradeWordmark',
'IcBrandDxtradeWordmark'
],
'cashier': [
'IcCashierAdd',
Expand Down Expand Up @@ -243,7 +243,7 @@ export const icons =
'IcCashierWyreLight',
'IcCashierZenithbankDark',
'IcCashierZenithbankLight',
'IcCashier',
'IcCashier'
],
'common': [
'IcAccountCross',
Expand Down Expand Up @@ -614,11 +614,9 @@ export const icons =
'IcWindowsLogo',
'IcWindows',
'IcWip',
'IcWithdrawRequestVerificationSent',
'IcWithdrawRequestVerification',
'IcZingpay',
'IcZoomIn',
'IcZoomOut',
'IcZoomOut'
],
'contract': [
'IcContractBarrier',
Expand All @@ -636,7 +634,7 @@ export const icons =
'IcContractStartTimeCircle',
'IcContractStartTime',
'IcContractStrike',
'IcContractTarget',
'IcContractTarget'
],
'currency': [
'IcCurrencyAud',
Expand All @@ -660,10 +658,10 @@ export const icons =
'IcCurrencyUsdc',
'IcCurrencyUsdk',
'IcCurrencyUst',
'IcCurrencyVirtual',
'IcCurrencyVirtual'
],
'derivez': [
'IcDerivez',
'IcDerivez'
],
'dxtrade': [
'IcDxtradeDerivX',
Expand All @@ -680,7 +678,7 @@ export const icons =
'IcDxtradeFinancialPlatform',
'IcDxtradeFinancial',
'IcDxtradeOnePassword',
'IcDxtradeSyntheticPlatform',
'IcDxtradeSyntheticPlatform'
],
'flag': [
'IcFlagDe',
Expand All @@ -696,7 +694,7 @@ export const icons =
'IcFlagUk',
'IcFlagVi',
'IcFlagZhCn',
'IcFlagZhTw',
'IcFlagZhTw'
],
'mt5': [
'IcMt5Acuity',
Expand Down Expand Up @@ -725,7 +723,7 @@ export const icons =
'IcMt5SyntheticDashboard',
'IcMt5SyntheticIndices',
'IcMt5SyntheticPlatform',
'IcMt5TradeTypes',
'IcMt5TradeTypes'
],
'option': [
'IcOptionAccumulators',
Expand All @@ -743,7 +741,7 @@ export const icons =
'IcOptionOverUnder',
'IcOptionRaiseFall',
'IcOptionTouchNotouch',
'IcOptionUpDownAsian',
'IcOptionUpDownAsian'
],
'rebranding': [
'IcRebrandingBinaryBot',
Expand All @@ -768,7 +766,7 @@ export const icons =
'IcRebrandingMt5Logo',
'IcRebrandingMt5SwapFree',
'IcRebrandingSmarttraderDashboard',
'IcRebrandingSmarttrader',
'IcRebrandingSmarttrader'
],
'stock': [
'IcStockAdidasSalomon',
Expand Down Expand Up @@ -818,7 +816,7 @@ export const icons =
'IcStockVisa',
'IcStockWallMart',
'IcStockWaltDisney',
'IcStockZoom',
'IcStockZoom'
],
'tradetype': [
'IcTradetypeAccu',
Expand Down Expand Up @@ -856,7 +854,7 @@ export const icons =
'IcTradetypeTicklow',
'IcTradetypeUpordown',
'IcTradetypeVanillaLongCall',
'IcTradetypeVanillaLongPut',
'IcTradetypeVanillaLongPut'
],
'underlying': [
'IcUnderlying1HZ100V',
Expand Down Expand Up @@ -1015,7 +1013,7 @@ export const icons =
'IcUnderlyingWLDEUR',
'IcUnderlyingWLDGBP',
'IcUnderlyingWLDUSD',
'IcUnderlyingWLDXAU',
'IcUnderlyingWLDXAU'
],
'wallet': [
'IcWalletBitcoinDark',
Expand Down Expand Up @@ -1043,6 +1041,6 @@ export const icons =
'IcWalletTetherDark',
'IcWalletTetherLight',
'IcWalletUsdCoinDark',
'IcWalletUsdCoinLight',
],
}
'IcWalletUsdCoinLight'
]
}
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
"@deriv/cashier": "^1.0.0",
"@deriv/cfd": "^1.0.0",
"@deriv/components": "^1.0.0",
"@deriv/deriv-api": "^1.0.11",
"@deriv/deriv-api": "^1.0.13",
"@deriv/deriv-charts": "1.2.2",
"@deriv/hooks": "^1.0.0",
"@deriv/p2p": "^0.7.3",
Expand Down
32 changes: 32 additions & 0 deletions packages/core/src/App/Components/dev-tools/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import React from 'react';
import MockDialog from './mock-dialog';
import { useLocalStorageData } from '@deriv/hooks';

const DevTools = () => {
const [show_mockserver_panel, setShowMockServerPanel] = useLocalStorageData<boolean>(
'show_mockserver_panel',
false
);

React.useEffect(() => {
const handleShortcutKey = (event: globalThis.KeyboardEvent) => {
if (event.ctrlKey && event.key === '0') {
setShowMockServerPanel(prev => !prev);
}
};

window.addEventListener('keydown', handleShortcutKey);

return () => {
window.removeEventListener('keydown', handleShortcutKey);
};
}, [setShowMockServerPanel]);

if (show_mockserver_panel) {
return <MockDialog />;
}

return <React.Fragment />;
};

export default DevTools;
69 changes: 69 additions & 0 deletions packages/core/src/App/Components/dev-tools/mock-dialog.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
.mock-dialog {
position: absolute;
bottom: 4.6rem;
right: 1rem;
width: 34rem;
border-radius: $BORDER_RADIUS;
padding: 1.2rem 1.6rem;
background-color: var(--general-main-1);
box-shadow: 0 20px 13px rgba(0, 0, 0, 0.01), 0 4px 3px rgba(0, 0, 0, 0.02);
border: 1px solid var(--general-hover);
z-index: 69420;

&__title {
margin-bottom: 1.4rem;
}

&__status {
border-radius: 4px;
border: 2px solid;
padding: 0.8rem 1.2rem;
margin-bottom: 2.4rem;

&--online {
}
&--connecting {
}
&--offline {
background-color: #f3f4f6;
border-color: #e5e7eb;

.dc-text {
color: #6b7280;
}
}
}

&__form {
display: flex;
min-height: 40rem;
flex-direction: column;
gap: 2rem;

&--dropdown-container {
display: inline-flex;
gap: 1rem;

button {
height: unset;
}
}

&--input {
margin-bottom: unset;
}

&--submit-container {
display: flex;
justify-content: end;
gap: 1rem;

button:disabled {
cursor: not-allowed;
span {
color: #9ca3af;
}
}
}
}
}
Loading

0 comments on commit cb17414

Please sign in to comment.