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] Fix Reassure test after updating Onyx #44004

Merged
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
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 @@ -102,26 +102,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 @@ -130,10 +148,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 @@ -142,10 +161,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 @@ -154,25 +174,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
Loading