Skip to content

Commit

Permalink
fix reassure test
Browse files Browse the repository at this point in the history
  • Loading branch information
OlimpiaZurek committed Nov 28, 2024
1 parent 0b174d7 commit 5f31fb1
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions tests/perf-test/ReportActionsList.perf-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ import {ReportAttachmentsProvider} from '@src/pages/home/report/ReportAttachment
import {ActionListContext, ReactionListContext} from '@src/pages/home/ReportScreenContext';
import type {PersonalDetailsList} from '@src/types/onyx';
import createRandomReportAction from '../utils/collections/reportActions';
import * as LHNTestUtilsModule from '../utils/LHNTestUtils';
import createRandomReport from '../utils/collections/reports';
import * as ReportTestUtils from '../utils/ReportTestUtils';
import * as TestHelper from '../utils/TestHelper';
import waitForBatchedUpdates from '../utils/waitForBatchedUpdates';
import wrapOnyxWithWaitForBatchedUpdates from '../utils/wrapOnyxWithWaitForBatchedUpdates';

Expand Down Expand Up @@ -71,11 +72,25 @@ const mockOnScroll = jest.fn();
const mockLoadChats = jest.fn();
const mockRef = {current: null, flatListRef: null, scrollPosition: null, setScrollPosition: () => {}};

const TEST_USER_ACCOUNT_ID = 1;
const TEST_USER_LOGIN = 'test@test.com';

const signUpWithTestUser = () => {
TestHelper.signInWithTestUser(TEST_USER_ACCOUNT_ID, TEST_USER_LOGIN);
};

const report = createRandomReport(1);
const parentReportAction = createRandomReportAction(1);

beforeEach(() => {
// Initialize the network key for OfflineWithFeedback
Onyx.merge(ONYXKEYS.NETWORK, {isOffline: false});
wrapOnyxWithWaitForBatchedUpdates(Onyx);
Onyx.clear().then(waitForBatchedUpdates);
signUpWithTestUser();
});

afterEach(() => {
Onyx.clear();
});

function ReportActionsListWrapper() {
Expand All @@ -84,17 +99,17 @@ function ReportActionsListWrapper() {
<ReactionListContext.Provider value={mockRef}>
<ActionListContext.Provider value={mockRef}>
<ReportActionsList
parentReportAction={createRandomReportAction(1)}
parentReportAction={parentReportAction}
parentReportActionForTransactionThread={undefined}
sortedReportActions={ReportTestUtils.getMockedSortedReportActions(500)}
report={LHNTestUtilsModule.getFakeReport()}
report={report}
onLayout={mockOnLayout}
onScroll={mockOnScroll}
onContentSizeChange={() => {}}
listID={1}
loadOlderChats={mockLoadChats}
loadNewerChats={mockLoadChats}
transactionThreadReport={LHNTestUtilsModule.getFakeReport()}
transactionThreadReport={report}
reportActions={ReportTestUtils.getMockedSortedReportActions(500)}
/>
</ActionListContext.Provider>
Expand All @@ -108,10 +123,5 @@ test('[ReportActionsList] should render ReportActionsList with 500 reportActions
await screen.findByTestId('report-actions-list');
};
await waitForBatchedUpdates();

Onyx.multiSet({
[ONYXKEYS.PERSONAL_DETAILS_LIST]: LHNTestUtilsModule.fakePersonalDetails,
});

await measureRenders(<ReportActionsListWrapper />, {scenario});
});

0 comments on commit 5f31fb1

Please sign in to comment.