Skip to content

Commit

Permalink
Merge pull request #44004 from callstack-internal/fix/43549/performan…
Browse files Browse the repository at this point in the history
…ce-test

[NOQA] Fix Reassure test after updating Onyx
  • Loading branch information
mountiny authored Jun 24, 2024
2 parents 5161249 + fe949a1 commit cbc21e0
Show file tree
Hide file tree
Showing 4 changed files with 287 additions and 122 deletions.
65 changes: 50 additions & 15 deletions tests/perf-test/ReportActionCompose.perf-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,26 +101,44 @@ function ReportActionComposeWrapper() {
}
const mockEvent = {preventDefault: jest.fn()};

test.skip('[ReportActionCompose] should render Composer with text input interactions', async () => {
test('[ReportActionCompose] should render Composer with text input interactions', async () => {
const scenario = async () => {
// Query for the composer
const composer = await screen.findByTestId('composer');
fireEvent.changeText(composer, '@test');
};

// Query for the suggestions
await screen.findByTestId('suggestions');
await waitForBatchedUpdates();
await measurePerformance(<ReportActionComposeWrapper />, {scenario});
});

test('[ReportActionCompose] should scroll to hide suggestions', async () => {
const scenario = async () => {
// Query for the composer
const composer = await screen.findByTestId('composer');

// scroll to hide suggestions
fireEvent.scroll(composer);
};

await waitForBatchedUpdates();
await measurePerformance(<ReportActionComposeWrapper />, {scenario});
});

test('[ReportActionCompose] should press to block suggestions', async () => {
const scenario = async () => {
// Query for the composer
const composer = await screen.findByTestId('composer');

// press to block suggestions
fireEvent.press(composer);
};

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

test.skip('[ReportActionCompose] should press add attachemnt button', async () => {
test('[ReportActionCompose] should press add attachemnt button', async () => {
const scenario = async () => {
// Query for the attachment button
const hintAttachmentButtonText = Localize.translateLocal('common.create');
Expand All @@ -129,10 +147,11 @@ test.skip('[ReportActionCompose] should press add attachemnt button', async () =
fireEvent.press(attachmentButton, mockEvent);
};

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

test.skip('[ReportActionCompose] should press add emoji button', async () => {
test('[ReportActionCompose] should press add emoji button', async () => {
const scenario = async () => {
// Query for the emoji button
const hintEmojiButtonText = Localize.translateLocal('reportActionCompose.emoji');
Expand All @@ -141,10 +160,11 @@ test.skip('[ReportActionCompose] should press add emoji button', async () => {
fireEvent.press(emojiButton);
};

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

test.skip('[ReportActionCompose] should press send message button', async () => {
test('[ReportActionCompose] should press send message button', async () => {
const scenario = async () => {
// Query for the send button
const hintSendButtonText = Localize.translateLocal('common.send');
Expand All @@ -153,25 +173,40 @@ test.skip('[ReportActionCompose] should press send message button', async () =>
fireEvent.press(sendButton);
};

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

test.skip('[ReportActionCompose] render composer with attachement modal interactions', async () => {
test('[ReportActionCompose] press add attachment button', async () => {
const scenario = async () => {
const hintAddAttachmentButtonText = Localize.translateLocal('reportActionCompose.addAttachment');
const hintAssignTaskButtonText = Localize.translateLocal('newTaskPage.assignTask');
const hintSplitBillButtonText = Localize.translateLocal('iou.splitExpense');

// Query for the attachment modal items
const addAttachmentButton = await screen.findByLabelText(hintAddAttachmentButtonText);
fireEvent.press(addAttachmentButton, mockEvent);
};

await waitForBatchedUpdates();
await measurePerformance(<ReportActionComposeWrapper />, {scenario});
});

test('[ReportActionCompose] should press split bill button', async () => {
const scenario = async () => {
const hintSplitBillButtonText = Localize.translateLocal('iou.splitExpense');
const splitBillButton = await screen.findByLabelText(hintSplitBillButtonText);
fireEvent.press(splitBillButton, mockEvent);
};

await waitForBatchedUpdates();
await measurePerformance(<ReportActionComposeWrapper />, {scenario});
});

test('[ReportActionCompose] should press assign task button', async () => {
const scenario = async () => {
const hintAssignTaskButtonText = Localize.translateLocal('newTaskPage.assignTask');
const assignTaskButton = await screen.findByLabelText(hintAssignTaskButtonText);
fireEvent.press(assignTaskButton, mockEvent);
};

return waitForBatchedUpdates().then(() => measurePerformance(<ReportActionComposeWrapper />, {scenario}));
await waitForBatchedUpdates();
await measurePerformance(<ReportActionComposeWrapper />, {scenario});
});
66 changes: 30 additions & 36 deletions tests/perf-test/ReportActionsList.perf-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import {ActionListContext, ReactionListContext} from '@src/pages/home/ReportScre
import variables from '@src/styles/variables';
import createRandomReportAction from '../utils/collections/reportActions';
import * as LHNTestUtilsModule from '../utils/LHNTestUtils';
import PusherHelper from '../utils/PusherHelper';
import * as ReportTestUtils from '../utils/ReportTestUtils';
import waitForBatchedUpdates from '../utils/waitForBatchedUpdates';
import wrapOnyxWithWaitForBatchedUpdates from '../utils/wrapOnyxWithWaitForBatchedUpdates';
Expand Down Expand Up @@ -66,26 +65,16 @@ beforeAll(() =>
}),
);

afterAll(() => {
jest.clearAllMocks();
});

const mockOnLayout = jest.fn();
const mockOnScroll = jest.fn();
const mockLoadChats = jest.fn();
const mockRef = {current: null, flatListRef: null, scrollPosition: null, setScrollPosition: () => {}};

// Initialize the network key for OfflineWithFeedback
beforeEach(() => {
PusherHelper.setup();
// Initialize the network key for OfflineWithFeedback
Onyx.merge(ONYXKEYS.NETWORK, {isOffline: false});
wrapOnyxWithWaitForBatchedUpdates(Onyx);
return Onyx.merge(ONYXKEYS.NETWORK, {isOffline: false});
});

// Clear out Onyx after each test so that each test starts with a clean slate
afterEach(() => {
Onyx.clear();
PusherHelper.teardown();
Onyx.clear().then(waitForBatchedUpdates);
});

function ReportActionsListWrapper() {
Expand Down Expand Up @@ -113,24 +102,35 @@ function ReportActionsListWrapper() {
);
}

test.skip('[ReportActionsList] should render ReportActionsList with 500 reportActions stored', () => {
test('[ReportActionsList] should render ReportActionsList with 500 reportActions stored', async () => {
const scenario = async () => {
await screen.findByTestId('report-actions-list');
};
await waitForBatchedUpdates();

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

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

test('[ReportActionsList] should render list items', async () => {
const scenario = async () => {
const hintText = Localize.translateLocal('accessibilityHints.chatMessage');
// Ensure that the list of items is rendered
await screen.findAllByLabelText(hintText);
};

return waitForBatchedUpdates()
.then(() =>
Onyx.multiSet({
[ONYXKEYS.PERSONAL_DETAILS_LIST]: LHNTestUtilsModule.fakePersonalDetails,
}),
)
.then(() => measurePerformance(<ReportActionsListWrapper />, {scenario}));
await waitForBatchedUpdates();

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

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

test.skip('[ReportActionsList] should scroll and click some of the reports', () => {
test('[ReportActionsList] should scroll through list of items', async () => {
const eventData = {
nativeEvent: {
contentOffset: {
Expand All @@ -152,18 +152,12 @@ test.skip('[ReportActionsList] should scroll and click some of the reports', ()
const scenario = async () => {
const reportActionsList = await screen.findByTestId('report-actions-list');
fireEvent.scroll(reportActionsList, eventData);

const hintText = Localize.translateLocal('accessibilityHints.chatMessage');
const reportItems = await screen.findAllByLabelText(hintText);

fireEvent.press(reportItems[0], 'onLongPress');
};
await waitForBatchedUpdates();

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

return waitForBatchedUpdates()
.then(() =>
Onyx.multiSet({
[ONYXKEYS.PERSONAL_DETAILS_LIST]: LHNTestUtilsModule.fakePersonalDetails,
}),
)
.then(() => measurePerformance(<ReportActionsListWrapper />, {scenario}));
await measurePerformance(<ReportActionsListWrapper />, {scenario});
});
Loading

0 comments on commit cbc21e0

Please sign in to comment.