Skip to content

Commit

Permalink
fix: updated deriv/api-types in p2p (#9535)
Browse files Browse the repository at this point in the history
* fix: updated deriv/api-types in p2p

* fix: added types for notification

* fix: test cases

* fix: circle ci issues pt.2
  • Loading branch information
aizad-deriv committed Aug 2, 2023
1 parent 5d256bb commit 159c803
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import React from 'react';
import { render, screen } from '@testing-library/react';
import { StoreProvider, mockStore } from '@deriv/stores';
import { APIProvider } from '@deriv/api';
import MainTitleBar from '..';

describe('MainTitleBar', () => {
const render_container = () => {
const mock = mockStore({});

const wrapper = ({ children }: { children: JSX.Element }) => (
<StoreProvider store={mock}>{children}</StoreProvider>
<APIProvider>
<StoreProvider store={mock}>{children}</StoreProvider>
</APIProvider>
);

return render(<MainTitleBar />, {
Expand Down
2 changes: 1 addition & 1 deletion packages/appstore/src/components/main-title-bar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const MainTitleBar = () => {
}, [selected_region]);

// TODO: Remove this when we have BE API ready
removeAllNotificationMessages();
removeAllNotificationMessages(true);

React.useEffect(() => {
filterNotificationMessages();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,21 @@ import React from 'react';
import { ContentFlag } from '@deriv/shared';
import { StoreProvider, mockStore } from '@deriv/stores';
import { render, screen } from '@testing-library/react';
import { APIProvider } from '@deriv/api';
import TradersHub from '..';

jest.mock('Components/modals/modal-manager', () => jest.fn(() => 'mockedModalManager'));
jest.mock('Components/cfds-listing', () => jest.fn(() => 'mockedCFDsListing'));
jest.mock('Components/options-multipliers-listing', () => jest.fn(() => 'mocked<OptionsAndMultipliersListing>'));
jest.mock('../../tour-guide/tour-guide', () => jest.fn(() => 'mocked<TourGuide>'));

describe('TradersHub', () => {
const render_container = (mock_store_override = {}) => {
const mock_store = mockStore(mock_store_override);
const wrapper = ({ children }: { children: JSX.Element }) => (
<StoreProvider store={mock_store}>{children}</StoreProvider>
<APIProvider>
<StoreProvider store={mock_store}>{children}</StoreProvider>
</APIProvider>
);

return render(<TradersHub />, {
Expand Down
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 @@ -8,7 +8,7 @@ import MainTitleBar from 'Components/main-title-bar';
import ModalManager from 'Components/modals/modal-manager';
import OptionsAndMultipliersListing from 'Components/options-multipliers-listing';
import ButtonToggleLoader from 'Components/pre-loader/button-toggle-loader';
import TourGuide from 'Modules/tour-guide/tour-guide';
import TourGuide from '../tour-guide/tour-guide';
import classNames from 'classnames';
import { observer } from 'mobx-react-lite';
import './traders-hub.scss';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/Stores/notification-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ export default class NotificationStore extends BaseStore {
this.handleClientNotifications();
}

removeAllNotificationMessages(should_close_persistent) {
removeAllNotificationMessages(should_close_persistent = false) {
this.notification_messages = should_close_persistent
? []
: [...this.notification_messages.filter(notifs => notifs.is_persistent)];
Expand Down
2 changes: 1 addition & 1 deletion packages/p2p/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"@deriv/shared": "^1.0.0",
"@deriv/stores": "^1.0.0",
"@deriv/translations": "^1.0.0",
"@deriv/api-types": "^1.0.94",
"@deriv/api-types": "^1.0.112",
"@testing-library/react": "^12.0.0",
"classnames": "^2.2.6",
"commander": "^3.0.2",
Expand Down
5 changes: 2 additions & 3 deletions packages/stores/src/mockStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,6 @@ const mock = (): TStores & { is_mock: boolean } => {
toggleRegulatorsCompareModal: jest.fn(),
financial_restricted_countries: false,
selected_account_type: 'real',
selected_platform_type: 'options',
no_CR_account: false,
no_MF_account: false,
multipliers_account_status: '',
Expand All @@ -392,7 +391,6 @@ const mock = (): TStores & { is_mock: boolean } => {
selectAccountType: jest.fn(),
is_wallet_migration_failed: false,
setWalletsMigrationFailedPopup: jest.fn(),
is_tour_open: false,
selected_platform_type: '',
available_platforms: [],
is_demo_low_risk: false,
Expand All @@ -412,11 +410,12 @@ const mock = (): TStores & { is_mock: boolean } => {
client_notifications: {},
filterNotificationMessages: jest.fn(),
refreshNotifications: jest.fn(),
removeAllNotificationMessages: jest.fn(),
removeNotificationByKey: jest.fn(),
removeNotificationMessage: jest.fn(),
setP2POrderProps: jest.fn(),
showAccountSwitchToRealNotification: jest.fn(),
setP2PRedirectTo: jest.fn(),
showAccountSwitchToRealNotification: jest.fn(),
},
portfolio: {
active_positions: [],
Expand Down
3 changes: 2 additions & 1 deletion packages/stores/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -562,11 +562,12 @@ type TNotificationStore = {
client_notifications: object;
filterNotificationMessages: () => void;
refreshNotifications: () => void;
removeAllNotificationMessages: (should_close_persistent: boolean) => void;
removeNotificationByKey: (key: string) => void;
removeNotificationMessage: (key: string, should_show_again?: boolean) => void;
setP2POrderProps: () => void;
showAccountSwitchToRealNotification: (loginid: string, currency: string) => void;
setP2PRedirectTo: () => void;
showAccountSwitchToRealNotification: (loginid: string, currency: string) => void;
};

type TBalance = {
Expand Down

0 comments on commit 159c803

Please sign in to comment.