Skip to content

Commit

Permalink
post cr improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
OlimpiaZurek committed Nov 30, 2023
1 parent 7f7b821 commit 340125f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
11 changes: 8 additions & 3 deletions tests/perf-test/SidebarUtils.perf-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ import {measureFunction} from 'reassure';
import SidebarUtils from '@libs/SidebarUtils';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import {PersonalDetails} from '@src/types/onyx';
import Policy from '@src/types/onyx/Policy';
import Report from '@src/types/onyx/Report';
import ReportAction from '@src/types/onyx/ReportAction';
import createCollection from '../utils/collections/createCollection';
import createPersonalDetails from '../utils/collections/personalDetails';
import createRandomPolicy from '../utils/collections/policies';
import createRandomReportAction from '../utils/collections/reportActions';
import createRandomReport from '../utils/collections/reports';
import * as LHNTestUtils from '../utils/LHNTestUtils';
import waitForBatchedUpdates from '../utils/waitForBatchedUpdates';

beforeAll(() =>
Expand All @@ -37,12 +38,16 @@ const reportActions = createCollection<ReportAction>(
(index) => createRandomReportAction(index),
);

const mockedResponseMap: Partial<Report> = getMockedReports(5000);
const personalDetails = createCollection<PersonalDetails>(
(item) => item.accountID,
(index) => createPersonalDetails(index),
);

const mockedResponseMap = getMockedReports(5000) as Record<`${typeof ONYXKEYS.COLLECTION.REPORT}`, Report>;
const runs = CONST.PERFORMANCE_TESTS.RUNS;

test('getOptionData on 5k reports', async () => {
const report = createRandomReport(1);
const personalDetails = LHNTestUtils.fakePersonalDetails;
const preferredLocale = 'en';
const policy = createRandomPolicy(1);
const parentReportAction = createRandomReportAction(1);
Expand Down
2 changes: 1 addition & 1 deletion tests/utils/collections/createCollection.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default function createCollection<T>(createKey: (item: T, index: number) => string, createItem: (index: number) => T, length = 500): Record<string, T> {
export default function createCollection<T>(createKey: (item: T, index: number) => string | number, createItem: (index: number) => T, length = 500): Record<string, T> {
const map: Record<string, T> = {};

for (let i = 0; i < length; i++) {
Expand Down
12 changes: 12 additions & 0 deletions tests/utils/collections/personalDetails.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import {randAvatar, randEmail, randWord} from '@ngneat/falso';
import type {PersonalDetails} from '@src/types/onyx';

export default function createPersonalDetails(index: number): PersonalDetails {
return {
accountID: index,
avatar: randAvatar(),
displayName: randWord(),
lastName: randWord(),
login: randEmail(),
};
}

0 comments on commit 340125f

Please sign in to comment.