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

[NoQA] Reassure performance tests improvements #34641

Merged
merged 4 commits into from
Jan 26, 2024
Merged
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
7 changes: 0 additions & 7 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3050,13 +3050,6 @@ const CONST = {
*/
MAX_OPTIONS_SELECTOR_PAGE_LENGTH: 500,

/**
* Performance test setup - run the same test multiple times to get a more accurate result
*/
PERFORMANCE_TESTS: {
RUNS: 20,
mountiny marked this conversation as resolved.
Show resolved Hide resolved
},

/**
* Bank account names
*/
Expand Down
10 changes: 4 additions & 6 deletions tests/perf-test/ModifiedExpenseMessage.perf-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import createRandomReportAction from '../utils/collections/reportActions';
import createRandomReport from '../utils/collections/reports';
import waitForBatchedUpdates from '../utils/waitForBatchedUpdates';

const runs = CONST.PERFORMANCE_TESTS.RUNS;

beforeAll(() =>
Onyx.init({
keys: ONYXKEYS,
Expand All @@ -39,10 +37,10 @@ const getMockedPolicies = (length = 500) =>
length,
);

const mockedReportsMap = getMockedReports(5000) as Record<`${typeof ONYXKEYS.COLLECTION.REPORT}`, Report>;
const mockedPoliciesMap = getMockedPolicies(5000) as Record<`${typeof ONYXKEYS.COLLECTION.POLICY}`, Policy>;
const mockedReportsMap = getMockedReports(1000) as Record<`${typeof ONYXKEYS.COLLECTION.REPORT}`, Report>;
const mockedPoliciesMap = getMockedPolicies(1000) as Record<`${typeof ONYXKEYS.COLLECTION.POLICY}`, Policy>;

test('[ModifiedExpenseMessage] getForReportAction on 5k reports and policies', async () => {
test('[ModifiedExpenseMessage] getForReportAction on 1k reports and policies', async () => {
const reportAction = {
...createRandomReportAction(1),
actionName: CONST.REPORT.ACTIONS.TYPE.MODIFIEDEXPENSE,
Expand All @@ -60,5 +58,5 @@ test('[ModifiedExpenseMessage] getForReportAction on 5k reports and policies', a
});

await waitForBatchedUpdates();
await measureFunction(() => ModifiedExpenseMessage.getForReportAction(reportAction), {runs});
await measureFunction(() => ModifiedExpenseMessage.getForReportAction(reportAction));
});
13 changes: 5 additions & 8 deletions tests/perf-test/OptionsSelector.perf-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import React from 'react';
import {measurePerformance} from 'reassure';
import _ from 'underscore';
import OptionsSelector from '@src/components/OptionsSelector';
import CONST from '@src/CONST';
import variables from '@src/styles/variables';

jest.mock('../../src/components/withLocalize', () => (Component) => {
Expand Down Expand Up @@ -65,8 +64,6 @@ function OptionsSelectorWrapper(args) {
);
}

const runs = CONST.PERFORMANCE_TESTS.RUNS;

test('[OptionsSelector] should render text input with interactions', () => {
const scenario = (screen) => {
const textInput = screen.getByTestId('options-selector-input');
Expand All @@ -75,16 +72,16 @@ test('[OptionsSelector] should render text input with interactions', () => {
fireEvent.changeText(textInput, 'test3');
};

measurePerformance(<OptionsSelectorWrapper />, {scenario, runs});
measurePerformance(<OptionsSelectorWrapper />, {scenario});
});

test('[OptionsSelector] should render 1 section', () => {
measurePerformance(<OptionsSelectorWrapper />, {runs});
measurePerformance(<OptionsSelectorWrapper />);
});

test('[OptionsSelector] should render multiple sections', () => {
const sections = generateSections(mutlipleSectionsConfig);
measurePerformance(<OptionsSelectorWrapper sections={sections} />, {runs});
measurePerformance(<OptionsSelectorWrapper sections={sections} />);
});

test('[OptionsSelector] should press a list items', () => {
Expand All @@ -94,7 +91,7 @@ test('[OptionsSelector] should press a list items', () => {
fireEvent.press(screen.getByText('Item 10'));
};

measurePerformance(<OptionsSelectorWrapper />, {scenario, runs});
measurePerformance(<OptionsSelectorWrapper />, {scenario});
});

test('[OptionsSelector] should scroll and press few items', () => {
Expand Down Expand Up @@ -126,5 +123,5 @@ test('[OptionsSelector] should scroll and press few items', () => {
fireEvent.press(screen.getByText('Item 200'));
};

measurePerformance(<OptionsSelectorWrapper sections={sections} />, {scenario, runs});
measurePerformance(<OptionsSelectorWrapper sections={sections} />, {scenario});
});
29 changes: 21 additions & 8 deletions tests/perf-test/ReportActionCompose.perf-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {LocaleContextProvider} from '../../src/components/LocaleContextProvider'
import OnyxProvider from '../../src/components/OnyxProvider';
import {KeyboardStateProvider} from '../../src/components/withKeyboardState';
import {WindowDimensionsProvider} from '../../src/components/withWindowDimensions';
import CONST from '../../src/CONST';
import * as Localize from '../../src/libs/Localize';
import ONYXKEYS from '../../src/ONYXKEYS';
import ReportActionCompose from '../../src/pages/home/report/ReportActionCompose/ReportActionCompose';
Expand Down Expand Up @@ -51,6 +50,22 @@ jest.mock('../../src/libs/actions/EmojiPickerAction', () => {
};
});

jest.mock('../../src/components/withNavigationFocus', () => (Component) => {
function WithNavigationFocus(props) {
return (
<Component
// eslint-disable-next-line react/jsx-props-no-spreading
{...props}
isFocused={false}
/>
);
}

WithNavigationFocus.displayName = 'WithNavigationFocus';

return WithNavigationFocus;
});
Comment on lines +53 to +67
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did we have to add this here now? I dont see related change that would require the navigationFocus?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to add this to get rid of this warning from the console :

Warning: Failed prop type: Invalid prop 'isFocused' of type 'object' supplied to 'AttachmentPickerWithMenuItems', expected 'boolean'.

Changes requiring this mock have been added before. Although the tests passed, the above warning appeared.


beforeAll(() =>
Onyx.init({
keys: ONYXKEYS,
Expand All @@ -64,8 +79,6 @@ beforeEach(() => {
Onyx.merge(ONYXKEYS.NETWORK, {isOffline: false});
});

const runs = CONST.PERFORMANCE_TESTS.RUNS;

function ReportActionComposeWrapper() {
return (
<ComposeProviders components={[OnyxProvider, LocaleContextProvider, KeyboardStateProvider, WindowDimensionsProvider]}>
Expand Down Expand Up @@ -96,7 +109,7 @@ test('[ReportActionCompose] should render Composer with text input interactions'
fireEvent.press(composer);
};

return waitForBatchedUpdates().then(() => measurePerformance(<ReportActionComposeWrapper />, {scenario, runs}));
return waitForBatchedUpdates().then(() => measurePerformance(<ReportActionComposeWrapper />, {scenario}));
});

test('[ReportActionCompose] should press add attachemnt button', async () => {
Expand All @@ -108,7 +121,7 @@ test('[ReportActionCompose] should press add attachemnt button', async () => {
fireEvent.press(attachmentButton, mockEvent);
};

return waitForBatchedUpdates().then(() => measurePerformance(<ReportActionComposeWrapper />, {scenario, runs}));
return waitForBatchedUpdates().then(() => measurePerformance(<ReportActionComposeWrapper />, {scenario}));
});

test('[ReportActionCompose] should press add emoji button', async () => {
Expand All @@ -120,7 +133,7 @@ test('[ReportActionCompose] should press add emoji button', async () => {
fireEvent.press(emojiButton);
};

return waitForBatchedUpdates().then(() => measurePerformance(<ReportActionComposeWrapper />, {scenario, runs}));
return waitForBatchedUpdates().then(() => measurePerformance(<ReportActionComposeWrapper />, {scenario}));
});

test('[ReportActionCompose] should press send message button', async () => {
Expand All @@ -132,7 +145,7 @@ test('[ReportActionCompose] should press send message button', async () => {
fireEvent.press(sendButton);
};

return waitForBatchedUpdates().then(() => measurePerformance(<ReportActionComposeWrapper />, {scenario, runs}));
return waitForBatchedUpdates().then(() => measurePerformance(<ReportActionComposeWrapper />, {scenario}));
});

test('[ReportActionCompose] render composer with attachement modal interactions', async () => {
Expand All @@ -152,5 +165,5 @@ test('[ReportActionCompose] render composer with attachement modal interactions'
fireEvent.press(assignTaskButton, mockEvent);
};

return waitForBatchedUpdates().then(() => measurePerformance(<ReportActionComposeWrapper />, {scenario, runs}));
return waitForBatchedUpdates().then(() => measurePerformance(<ReportActionComposeWrapper />, {scenario}));
});
7 changes: 2 additions & 5 deletions tests/perf-test/ReportActionsList.perf-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import ComposeProviders from '../../src/components/ComposeProviders';
import {LocaleContextProvider} from '../../src/components/LocaleContextProvider';
import OnyxProvider from '../../src/components/OnyxProvider';
import {WindowDimensionsProvider} from '../../src/components/withWindowDimensions';
import CONST from '../../src/CONST';
import * as Localize from '../../src/libs/Localize';
import ONYXKEYS from '../../src/ONYXKEYS';
import ReportActionsList from '../../src/pages/home/report/ReportActionsList';
Expand Down Expand Up @@ -97,8 +96,6 @@ function ReportActionsListWrapper() {
);
}

const runs = CONST.PERFORMANCE_TESTS.RUNS;

test('[ReportActionsList] should render ReportActionsList with 500 reportActions stored', () => {
const scenario = async () => {
await screen.findByTestId('report-actions-list');
Expand All @@ -113,7 +110,7 @@ test('[ReportActionsList] should render ReportActionsList with 500 reportActions
[ONYXKEYS.PERSONAL_DETAILS_LIST]: LHNTestUtils.fakePersonalDetails,
}),
)
.then(() => measurePerformance(<ReportActionsListWrapper />, {scenario, runs}));
.then(() => measurePerformance(<ReportActionsListWrapper />, {scenario}));
});

test('[ReportActionsList] should scroll and click some of the reports', () => {
Expand Down Expand Up @@ -151,5 +148,5 @@ test('[ReportActionsList] should scroll and click some of the reports', () => {
[ONYXKEYS.PERSONAL_DETAILS_LIST]: LHNTestUtils.fakePersonalDetails,
}),
)
.then(() => measurePerformance(<ReportActionsListWrapper />, {scenario, runs}));
.then(() => measurePerformance(<ReportActionsListWrapper />, {scenario}));
});
18 changes: 8 additions & 10 deletions tests/perf-test/ReportActionsUtils.perf-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ const reportActions = createCollection<ReportAction>(

const reportId = '1';

const runs = CONST.PERFORMANCE_TESTS.RUNS;

describe('ReportActionsUtils', () => {
beforeAll(() => {
Onyx.init({
Expand Down Expand Up @@ -65,7 +63,7 @@ describe('ReportActionsUtils', () => {
*/
test('[ReportActionsUtils] getLastVisibleAction on 10k reportActions', async () => {
await waitForBatchedUpdates();
await measureFunction(() => ReportActionsUtils.getLastVisibleAction(reportId), {runs});
await measureFunction(() => ReportActionsUtils.getLastVisibleAction(reportId));
});

test('[ReportActionsUtils] getLastVisibleAction on 10k reportActions with actionsToMerge', async () => {
Expand All @@ -91,19 +89,19 @@ describe('ReportActionsUtils', () => {
} as unknown as ReportActions;

await waitForBatchedUpdates();
await measureFunction(() => ReportActionsUtils.getLastVisibleAction(reportId, actionsToMerge), {runs});
await measureFunction(() => ReportActionsUtils.getLastVisibleAction(reportId, actionsToMerge));
});

test('[ReportActionsUtils] getMostRecentIOURequestActionID on 10k ReportActions', async () => {
const reportActionsArray = ReportActionsUtils.getSortedReportActionsForDisplay(reportActions);

await waitForBatchedUpdates();
await measureFunction(() => ReportActionsUtils.getMostRecentIOURequestActionID(reportActionsArray), {runs});
await measureFunction(() => ReportActionsUtils.getMostRecentIOURequestActionID(reportActionsArray));
});

test('[ReportActionsUtils] getLastVisibleMessage on 10k ReportActions', async () => {
await waitForBatchedUpdates();
await measureFunction(() => ReportActionsUtils.getLastVisibleMessage(reportId), {runs});
await measureFunction(() => ReportActionsUtils.getLastVisibleMessage(reportId));
});

test('[ReportActionsUtils] getLastVisibleMessage on 10k ReportActions with actionsToMerge', async () => {
Expand All @@ -129,21 +127,21 @@ describe('ReportActionsUtils', () => {
} as unknown as ReportActions;

await waitForBatchedUpdates();
await measureFunction(() => ReportActionsUtils.getLastVisibleMessage(reportId, actionsToMerge), {runs});
await measureFunction(() => ReportActionsUtils.getLastVisibleMessage(reportId, actionsToMerge));
});

test('[ReportActionsUtils] getSortedReportActionsForDisplay on 10k ReportActions', async () => {
await waitForBatchedUpdates();
await measureFunction(() => ReportActionsUtils.getSortedReportActionsForDisplay(reportActions), {runs});
await measureFunction(() => ReportActionsUtils.getSortedReportActionsForDisplay(reportActions));
});

test('[ReportActionsUtils] getLastClosedReportAction on 10k ReportActions', async () => {
await waitForBatchedUpdates();
await measureFunction(() => ReportActionsUtils.getLastClosedReportAction(reportActions), {runs});
await measureFunction(() => ReportActionsUtils.getLastClosedReportAction(reportActions));
});

test('[ReportActionsUtils] getMostRecentReportActionLastModified', async () => {
await waitForBatchedUpdates();
await measureFunction(() => ReportActionsUtils.getMostRecentReportActionLastModified(), {runs});
await measureFunction(() => ReportActionsUtils.getMostRecentReportActionLastModified());
});
});
6 changes: 2 additions & 4 deletions tests/perf-test/ReportScreen.perf-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,6 @@ function ReportScreenWrapper(args) {
);
}

const runs = CONST.PERFORMANCE_TESTS.RUNS;

test.skip('[ReportScreen] should render ReportScreen with composer interactions', () => {
const {triggerTransitionEnd, addListener} = createAddListenerMock();
const scenario = async () => {
Expand Down Expand Up @@ -222,7 +220,7 @@ test.skip('[ReportScreen] should render ReportScreen with composer interactions'
navigation={navigation}
route={mockRoute}
/>,
{scenario, runs},
{scenario},
),
);
});
Expand Down Expand Up @@ -287,7 +285,7 @@ test.skip('[ReportScreen] should press of the report item', () => {
navigation={navigation}
route={mockRoute}
/>,
{scenario, runs},
{scenario},
),
);
});
Loading
Loading