Skip to content

Commit

Permalink
fixes after review
Browse files Browse the repository at this point in the history
  • Loading branch information
OlimpiaZurek committed Oct 18, 2023
1 parent 0908904 commit b9cb0d6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 25 deletions.
1 change: 0 additions & 1 deletion src/pages/home/report/ReportActionItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,6 @@ function ReportActionItem(props) {
preventDefaultContextMenu={!props.draftMessage && !hasErrors}
withoutFocusOnSecondaryInteraction
accessibilityLabel={props.translate('accessibilityHints.chatMessage')}
testID={props.action.reportActionID}
>
<Hoverable
shouldHandleScroll
Expand Down
45 changes: 21 additions & 24 deletions tests/perf-test/ReportActionsList.perf-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,29 @@ import wrapOnyxWithWaitForBatchedUpdates from '../utils/wrapOnyxWithWaitForBatch
import PusherHelper from '../utils/PusherHelper';
import variables from '../../src/styles/variables';
import {ActionListContext, ReactionListContext} from '../../src/pages/home/ReportScreenContext';
import ONYXKEYS from '../../src/ONYXKEYS';
import * as Localize from '../../src/libs/Localize';

const ONYXKEYS = {
PERSONAL_DETAILS_LIST: 'personalDetailsList',
SESSION: 'session',
COLLECTION: {
REPORT: 'report_',
REPORT_ACTIONS: 'reportActions_',
},
NETWORK: 'network',
};
jest.setTimeout(60000);

const mockedNavigate = jest.fn();

jest.mock('../../src/components/withNavigationFocus', () => (Component) => (props) => (
<Component
// eslint-disable-next-line react/jsx-props-no-spreading
{...props}
isFocused={false}
/>
));

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,
Expand All @@ -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();
});
Expand Down Expand Up @@ -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;

Expand All @@ -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()
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit b9cb0d6

Please sign in to comment.