diff --git a/src/pages/home/report/ReportActionItem.js b/src/pages/home/report/ReportActionItem.js index 2d0ed2f76e86..f5ca7080249c 100644 --- a/src/pages/home/report/ReportActionItem.js +++ b/src/pages/home/report/ReportActionItem.js @@ -606,7 +606,6 @@ function ReportActionItem(props) { preventDefaultContextMenu={!props.draftMessage && !hasErrors} withoutFocusOnSecondaryInteraction accessibilityLabel={props.translate('accessibilityHints.chatMessage')} - testID={props.action.reportActionID} > (Component) => (props) => ( + +)); jest.mock('@react-navigation/native', () => { const actualNav = jest.requireActual('@react-navigation/native'); return { ...actualNav, - useRoute: () => jest.fn(), + useRoute: () => mockedNavigate, }; }); -jest.mock('../../src/hooks/useLocalize', () => - jest.fn(() => ({ - translate: jest.fn(), - })), -); - beforeAll(() => Onyx.init({ keys: ONYXKEYS, @@ -64,7 +62,6 @@ beforeEach(() => { // Clear out Onyx after each test so that each test starts with a clean slate afterEach(() => { - jest.useRealTimers(); Onyx.clear(); PusherHelper.teardown(); }); @@ -110,11 +107,7 @@ const getFakeReportAction = (index) => ({ whisperedToAccountIDs: [], }); -const getMockedSortedReportActions = (length = 100) => - Array.from({length}, (__, i) => { - const reportAction = getFakeReportAction(i); - return reportAction; - }); +const getMockedSortedReportActions = (length = 100) => Array.from({length}, (__, i) => getFakeReportAction(i)); const currentUserAccountID = 5; @@ -140,6 +133,9 @@ function ReportActionsListWrapper() { test('should render ReportActionsList with 500 reportActions stored', () => { const scenario = async () => { await screen.findByTestId('report-actions-list'); + const hintText = Localize.translateLocal('accessibilityHints.chatMessage'); + // Esure that the list of items are rendered + await screen.findAllByLabelText(hintText); }; return waitForBatchedUpdates() @@ -176,9 +172,10 @@ test('should scroll and click some of the reports', () => { fireEvent.scroll(reportActionsList, eventData); - const reportItem = await screen.findByTestId('1'); + const hintText = Localize.translateLocal('accessibilityHints.chatMessage'); + const reportItems = await screen.findAllByLabelText(hintText); - fireEvent.press(reportItem, 'onLongPress'); + fireEvent.press(reportItems[0], 'onLongPress'); }; return waitForBatchedUpdates()