From 0b174d759be1a2dd9246929f32a3f8a8f659fdd6 Mon Sep 17 00:00:00 2001 From: Github Date: Mon, 25 Nov 2024 15:28:42 +0100 Subject: [PATCH 1/2] Upgrade RNTL to the newest version --- package-lock.json | 16 +++++++++++----- package.json | 4 ++-- tests/ui/UnreadIndicatorsTest.tsx | 10 +++++----- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/package-lock.json b/package-lock.json index 83d0c122ab2f..f3f5257e6086 100644 --- a/package-lock.json +++ b/package-lock.json @@ -169,8 +169,8 @@ "@storybook/react-webpack5": "^8.1.6", "@storybook/theming": "^8.1.10", "@svgr/webpack": "^6.0.0", - "@testing-library/jest-native": "5.4.1", - "@testing-library/react-native": "11.5.1", + "@testing-library/jest-native": "5.4.2", + "@testing-library/react-native": "12.8.1", "@trivago/prettier-plugin-sort-imports": "^4.2.0", "@types/base-64": "^1.0.2", "@types/canvas-size": "^1.2.2", @@ -15321,7 +15321,9 @@ } }, "node_modules/@testing-library/jest-native": { - "version": "5.4.1", + "version": "5.4.2", + "resolved": "https://registry.npmjs.org/@testing-library/jest-native/-/jest-native-5.4.2.tgz", + "integrity": "sha512-Vo/CE1uvCVH1H8YPoOEXLXVsm+BjzSQTq35+wkri1fr0O5D+A2WZ+m3ni5g6f1OCzNKNGIAHmisBEWkDs1P1mw==", "dev": true, "license": "MIT", "dependencies": { @@ -15402,11 +15404,15 @@ } }, "node_modules/@testing-library/react-native": { - "version": "11.5.1", + "version": "12.8.1", + "resolved": "https://registry.npmjs.org/@testing-library/react-native/-/react-native-12.8.1.tgz", + "integrity": "sha512-/7PIFCpeqAD3j7nzKQhZtm1T6RR/O/tB1We7JHtYP5RpTBj8rPitEpt6xGrD8R0ymOh+DxDKK7Zovfv5uDSRWg==", "dev": true, "license": "MIT", "dependencies": { - "pretty-format": "^29.4.0" + "jest-matcher-utils": "^29.7.0", + "pretty-format": "^29.7.0", + "redent": "^3.0.0" }, "peerDependencies": { "jest": ">=28.0.0", diff --git a/package.json b/package.json index 4df25219e277..6f4b317c7211 100644 --- a/package.json +++ b/package.json @@ -226,8 +226,8 @@ "@storybook/react-webpack5": "^8.1.6", "@storybook/theming": "^8.1.10", "@svgr/webpack": "^6.0.0", - "@testing-library/jest-native": "5.4.1", - "@testing-library/react-native": "11.5.1", + "@testing-library/jest-native": "5.4.2", + "@testing-library/react-native": "12.8.1", "@trivago/prettier-plugin-sort-imports": "^4.2.0", "@types/base-64": "^1.0.2", "@types/canvas-size": "^1.2.2", diff --git a/tests/ui/UnreadIndicatorsTest.tsx b/tests/ui/UnreadIndicatorsTest.tsx index e6acd3e9a19d..b9b1e2bd8dc9 100644 --- a/tests/ui/UnreadIndicatorsTest.tsx +++ b/tests/ui/UnreadIndicatorsTest.tsx @@ -85,7 +85,7 @@ function navigateToSidebar(): Promise { function areYouOnChatListScreen(): boolean { const hintText = Localize.translateLocal('sidebarScreen.listOfChats'); - const sidebarLinks = screen.queryAllByLabelText(hintText); + const sidebarLinks = screen.queryAllByLabelText(hintText, {includeHiddenElements: true}); return !sidebarLinks?.at(0)?.props?.accessibilityElementsHidden; } @@ -365,12 +365,12 @@ describe('Unread Indicators', () => { await act(() => (NativeNavigation as NativeNavigationMock).triggerTransitionEnd()); // Verify that report we navigated to appears in a "read" state while the original unread report still shows as unread const hintText = Localize.translateLocal('accessibilityHints.chatUserDisplayNames'); - const displayNameTexts = screen.queryAllByLabelText(hintText); + const displayNameTexts = screen.queryAllByLabelText(hintText, {includeHiddenElements: true}); expect(displayNameTexts).toHaveLength(2); expect((displayNameTexts.at(0)?.props?.style as TextStyle)?.fontWeight).toBe(FontUtils.fontWeight.normal); expect(screen.getAllByText('C User').at(0)).toBeOnTheScreen(); expect((displayNameTexts.at(1)?.props?.style as TextStyle)?.fontWeight).toBe(FontUtils.fontWeight.bold); - expect(screen.getByText('B User')).toBeOnTheScreen(); + expect(screen.getByText('B User', {includeHiddenElements: true})).toBeOnTheScreen(); })); xit('Manually marking a chat message as unread shows the new line indicator and updates the LHN', () => @@ -524,7 +524,7 @@ describe('Unread Indicators', () => { .then(() => { // Verify the chat preview text matches the last comment from the current user const hintText = Localize.translateLocal('accessibilityHints.lastChatMessagePreview'); - const alternateText = screen.queryAllByLabelText(hintText); + const alternateText = screen.queryAllByLabelText(hintText, {includeHiddenElements: true}); expect(alternateText).toHaveLength(1); // This message is visible on the sidebar and the report screen, so there are two occurrences. @@ -537,7 +537,7 @@ describe('Unread Indicators', () => { }) .then(() => { const hintText = Localize.translateLocal('accessibilityHints.lastChatMessagePreview'); - const alternateText = screen.queryAllByLabelText(hintText); + const alternateText = screen.queryAllByLabelText(hintText, {includeHiddenElements: true}); expect(alternateText).toHaveLength(1); expect(screen.getAllByText('Comment 9').at(0)).toBeOnTheScreen(); }) From 5f31fb1f40684e6b5d962bebe20b030c70a49e3d Mon Sep 17 00:00:00 2001 From: Github Date: Thu, 28 Nov 2024 11:19:02 +0100 Subject: [PATCH 2/2] fix reassure test --- .../perf-test/ReportActionsList.perf-test.tsx | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/tests/perf-test/ReportActionsList.perf-test.tsx b/tests/perf-test/ReportActionsList.perf-test.tsx index f7debc510832..eb148bbad9bd 100644 --- a/tests/perf-test/ReportActionsList.perf-test.tsx +++ b/tests/perf-test/ReportActionsList.perf-test.tsx @@ -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'; @@ -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() { @@ -84,17 +99,17 @@ function ReportActionsListWrapper() { {}} listID={1} loadOlderChats={mockLoadChats} loadNewerChats={mockLoadChats} - transactionThreadReport={LHNTestUtilsModule.getFakeReport()} + transactionThreadReport={report} reportActions={ReportTestUtils.getMockedSortedReportActions(500)} /> @@ -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(, {scenario}); });