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

Improve coverall report time execution #17487

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
34 changes: 27 additions & 7 deletions .github/workflows/coveralls.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,41 @@ on:
- master
pull_request:
types: [opened, synchronize, edited]
name: Coveralls
name: Reporter
jobs:
build:
name: Reporter
test:
name: Run tests in parallel
runs-on: Runner_16cores_Deriv-app
strategy:
matrix:
shard: [1,2,3,4,5,6,7,8,9,10]
fail-fast: true
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
- name: Setup Node
uses: './.github/actions/setup_node'
- name: Install dependencies
uses: "./.github/actions/npm_install_from_cache"
- name: Build
uses: "./.github/actions/build"
- name: Build components package
working-directory: packages/components
run: npm run build
- name: Test
run: JEST_MAX_WORKERS=95% npm run test:jest -- --collectCoverage
- name: Coveralls
run: JEST_MAX_WORKERS=95% SHARD_INDEX=${{ matrix.shard }} npm run test:shard -- --collectCoverage
- name: Coveralls Parallel
uses: coverallsapp/github-action@3dfc5567390f6fa9267c0ee9c251e4c8c3f18949
with:
allow-empty: true
flag-name: ${{ matrix.shard}}
parallel: true

finish:
name: Coveralls Finished
needs: [test]
if: ${{ always() }}
runs-on: Runner_16cores_Deriv-app
steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@3dfc5567390f6fa9267c0ee9c251e4c8c3f18949
with:
parallel-finished: true
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
"test:stylelint": "stylelint \"./packages/*/src/**/*.s(a|c)ss\"",
"test:ci": "f () { npm run test:stylelint && npm run test:eslint-all ;}; f",
"test:jest": "jest --all --maxWorkers=${JEST_MAX_WORKERS:-'50%'}",
"test:shard": "jest --all --shard=${SHARD_INDEX}/10 --maxWorkers=${JEST_MAX_WORKERS:-'50%'} --coverage",
"test:performance": "cd e2e-tests && jest -c ./jest.config.js --detectOpenHandles performance",
"stylelint:fix": "stylelint \"./packages/*/src/**/*.s(a|c)ss\" --fix",
"translate": "f () { npm exec --workspace=@deriv/translations -- npm run translate ;}; f",
Expand All @@ -118,4 +119,4 @@
"optionalDependencies": {
"fsevents": "^2.3.2"
}
}
}
12 changes: 6 additions & 6 deletions packages/account/src/Types/common.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ export type TIDVFormValues = {
error_message?: string;
};

export type TPlatforms = typeof Platforms[keyof typeof Platforms];
export type TPlatforms = (typeof Platforms)[keyof typeof Platforms];

export type TServerError = {
code?: string;
Expand All @@ -172,7 +172,7 @@ export type TServerError = {
details?: { [key: string]: string };
fields?: string[];
};
export type TCFDPlatform = typeof CFD_PLATFORMS[keyof typeof CFD_PLATFORMS];
export type TCFDPlatform = (typeof CFD_PLATFORMS)[keyof typeof CFD_PLATFORMS];

export type TClosingAccountFormValues = {
'financial-priorities': boolean;
Expand Down Expand Up @@ -250,7 +250,7 @@ export type TAutoComplete = {
value: boolean;
text: string;
};
export type TPaymentMethodIdentifier = typeof IDENTIFIER_TYPES[keyof typeof IDENTIFIER_TYPES];
export type TPaymentMethodIdentifier = (typeof IDENTIFIER_TYPES)[keyof typeof IDENTIFIER_TYPES];

export type TPaymentMethodInfo = {
documents_required: number;
Expand Down Expand Up @@ -285,11 +285,11 @@ export type TProofOfOwnershipErrors = Record<

export type TFinancialInformationForm = Omit<SetFinancialAssessmentRequest, 'set_financial_assessment'>;

export type TAuthStatusCodes = typeof AUTH_STATUS_CODES[keyof typeof AUTH_STATUS_CODES];
export type TAuthStatusCodes = (typeof AUTH_STATUS_CODES)[keyof typeof AUTH_STATUS_CODES];

export type TMT5AccountStatus =
| typeof MT5_ACCOUNT_STATUS[keyof typeof MT5_ACCOUNT_STATUS]
| typeof TRADING_PLATFORM_STATUS[keyof typeof TRADING_PLATFORM_STATUS];
| (typeof MT5_ACCOUNT_STATUS)[keyof typeof MT5_ACCOUNT_STATUS]
| (typeof TRADING_PLATFORM_STATUS)[keyof typeof TRADING_PLATFORM_STATUS];

export type TFilesDescription = {
descriptions: { id: string; value: JSX.Element }[];
Expand Down
1 change: 1 addition & 0 deletions packages/appstore/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module.exports = {
'\\.s(c|a)ss$': '<rootDir>/../../__mocks__/styleMock.js',
'^.+\\.svg$': '<rootDir>/../../__mocks__/fileMock.js',
'@deriv-com/translations': '<rootDir>/../../__mocks__/translation.mock.js',
'^@deriv/account$': '<rootDir>/../account/src',
'@deriv-com/ui': '<rootDir>/../../__mocks__/deriv-com.ui.mock.js',
'^Assets/(.*)$': '<rootDir>/src/assets/$1',
'^Components/(.*)$': '<rootDir>/src/components/$1',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
import React from 'react';
import { fireEvent, render, screen } from '@testing-library/react';
import { BrowserHistory, createBrowserHistory } from 'history';
import { Router } from 'react-router';
import { BrowserHistory, createBrowserHistory } from 'history';

import { APIProvider } from '@deriv/api';
import { routes } from '@deriv/shared';
import { mockStore, P2PSettingsProvider } from '@deriv/stores';
import { fireEvent, render, screen } from '@testing-library/react';

import getRoutesConfig from 'Constants/routes-config';
import Cashier from '../cashier';
import { P2PSettingsProvider, mockStore } from '@deriv/stores';

import CashierProviders from '../../../cashier-providers';
import { routes } from '@deriv/shared';
import { APIProvider } from '@deriv/api';
import Cashier from '../cashier';

jest.mock('@deriv-com/ui', () => ({
...jest.requireActual('@deriv-com/ui'),
useDevice: jest.fn(() => ({ isDesktop: true })),
}));

jest.mock('@deriv/p2p', () => jest.fn(() => <div>P2P</div>));

jest.mock('@deriv/hooks', () => {
return {
...jest.requireActual('@deriv/hooks'),
Expand Down
29 changes: 22 additions & 7 deletions packages/cashier/src/stores/payment-agent-transfer-store.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import { action, observable, makeObservable } from 'mobx';
import ErrorStore from './error-store';
import { action, makeObservable, observable, reaction } from 'mobx';

import { PaymentAgentListResponse } from '@deriv/api-types';

import {
TPaymentAgentTransferRequest,
TPaymentAgentTransferReceipt,
TPaymentAgentTransferConfirm,
TPaymentAgentTransferReceipt,
TPaymentAgentTransferRequest,
TRootStore,
TTransferLimit,
TWebSocket,
TRootStore,
} from '../types';

import ErrorStore from './error-store';

export default class PaymentAgentTransferStore {
constructor(
public WS: TWebSocket,
Expand Down Expand Up @@ -89,17 +92,29 @@ export default class PaymentAgentTransferStore {
}

async onMountPaymentAgentTransfer() {
const { general_store, payment_agent } = this.root_store.modules.cashier;
const { client, modules } = this.root_store;
const { general_store, payment_agent } = modules.cashier;

general_store.setLoading(true);
this.onRemount = () => this.onMountPaymentAgentTransfer;
await general_store.onMountCommon();
if (!this.transfer_limit.min_withdrawal) {

const updateTransferLimits = async () => {
const response = await payment_agent.getPaymentAgentList();
const current_payment_agent = await this.getCurrentPaymentAgent(response);
this.setMinMaxPaymentAgentTransfer(current_payment_agent);
};

if (!this.transfer_limit.min_withdrawal) {
await updateTransferLimits();
}

general_store.setLoading(false);

reaction(
() => client?.loginid,
() => updateTransferLimits()
);
}

requestTryPaymentAgentTransfer = async ({
Expand Down
1 change: 1 addition & 0 deletions packages/cfd/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module.exports = {
'\\.s(c|a)ss$': '<rootDir>/../../__mocks__/styleMock.js',
'^.+\\.svg$': '<rootDir>/../../__mocks__/styleMock.js',
'@deriv-com/translations': '<rootDir>/../../__mocks__/translation.mock.js',
'^@deriv/account$': '<rootDir>/../account/src',
'@deriv-com/ui': '<rootDir>/../../__mocks__/deriv-com.ui.mock.js',
'^_common/(.*)$': '<rootDir>/src/_common/$1',
'^App/(.*)$': '<rootDir>/src/App/$1',
Expand Down
1 change: 1 addition & 0 deletions packages/core/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module.exports = {
'\\.s(c|a)ss$': '<rootDir>/../../__mocks__/styleMock.js',
'^.+\\.svg$': '<rootDir>/../../__mocks__/styleMock.js',
'@deriv-com/translations': '<rootDir>/../../__mocks__/translation.mock.js',
'^@deriv/account$': '<rootDir>/../account/src',
'@deriv-com/ui': '<rootDir>/../../__mocks__/deriv-com.ui.mock.js',
'^_common/(.*)$': '<rootDir>/src/_common/$1',
'^App/(.*)$': '<rootDir>/src/App/$1',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe('AccountInfoWallets component', () => {
},
};

it('should show "disabled_message" when "is_disabled" property is "true"', () => {
it('should show "disabled_message" when "is_disabled" property is "true"', async () => {
const mock = mockStore({
client: {
accounts: {
Expand Down Expand Up @@ -64,7 +64,7 @@ describe('AccountInfoWallets component', () => {
render(<AccountInfoWallets is_dialog_on={false} toggleDialog={toggleDialog} />, { wrapper: wrapper(mock) });

const popover = screen.getByTestId('dt_popover_wrapper');
userEvent.hover(popover);
await userEvent.hover(popover);
const disabled_message = screen.getByText(/test disabled message/i);
expect(disabled_message).toBeInTheDocument();
});
Expand Down Expand Up @@ -108,7 +108,7 @@ describe('AccountInfoWallets component', () => {
expect(div_element).not.toHaveClass('acc-info--show');
});

it('can not "toggleDialog" when "is_disabled" property is "true"', () => {
it('can not "toggleDialog" when "is_disabled" property is "true"', async () => {
const mock = mockStore({
client: {
accounts: {
Expand All @@ -134,7 +134,7 @@ describe('AccountInfoWallets component', () => {
render(<AccountInfoWallets is_dialog_on={false} toggleDialog={toggleDialog} />, { wrapper: wrapper(mock) });

const div_element = screen.getByTestId('dt_acc_info');
userEvent.click(div_element);
await userEvent.click(div_element);
expect(toggleDialog).toHaveBeenCalledTimes(0);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,18 @@ describe('AccountSwitcherWalletItem', () => {
expect(screen.getByText('Demo')).toBeInTheDocument();
});

it('calls closeAccountsDialog when clicked', () => {
it('calls closeAccountsDialog when clicked', async () => {
const store = mockStore({});
render(<AccountSwitcherWalletItemComponent props={props} store={store} />);
userEvent.click(screen.getByTestId('account-switcher-wallet-item'));
await userEvent.click(screen.getByTestId('account-switcher-wallet-item'));
expect(props.closeAccountsDialog).toHaveBeenCalled();
});

it('calls switchAccount when clicked not selected', async () => {
const switchAccount = jest.fn();
const store = mockStore({ client: { switchAccount, loginid: 'CR008' } });
render(<AccountSwitcherWalletItemComponent props={props} store={store} />);
userEvent.click(screen.getByTestId('account-switcher-wallet-item'));
await userEvent.click(screen.getByTestId('account-switcher-wallet-item'));
expect(switchAccount).toHaveBeenCalledWith('CR007');
expect(props.closeAccountsDialog).toHaveBeenCalled();
});
Expand All @@ -88,7 +88,7 @@ describe('AccountSwitcherWalletItem', () => {
const switchAccount = jest.fn();
const store = mockStore({ client: { switchAccount, loginid: 'CR007' } });
render(<AccountSwitcherWalletItemComponent props={props} store={store} />);
userEvent.click(screen.getByTestId('account-switcher-wallet-item'));
await userEvent.click(screen.getByTestId('account-switcher-wallet-item'));
expect(switchAccount).not.toHaveBeenCalled();
expect(props.closeAccountsDialog).toHaveBeenCalled();
});
Expand Down
Loading
Loading