diff --git a/tests/actions/IOUTest.ts b/tests/actions/IOUTest.ts index f15e72847724..d0ded176d722 100644 --- a/tests/actions/IOUTest.ts +++ b/tests/actions/IOUTest.ts @@ -59,8 +59,6 @@ import {subscribeToUserEvents} from '@libs/actions/User'; import type {ApiCommand} from '@libs/API/types'; import {WRITE_COMMANDS} from '@libs/API/types'; import {getMicroSecondOnyxErrorWithTranslationKey} from '@libs/ErrorUtils'; -// eslint-disable-next-line @typescript-eslint/no-deprecated -import {translateLocal} from '@libs/Localize'; import Navigation from '@libs/Navigation/Navigation'; import {rand64} from '@libs/NumberUtils'; import {getLoginsByAccountIDs} from '@libs/PersonalDetailsUtils'; @@ -107,7 +105,7 @@ import createRandomTransaction from '../utils/collections/transaction'; import getOnyxValue from '../utils/getOnyxValue'; import PusherHelper from '../utils/PusherHelper'; import type {MockFetch} from '../utils/TestHelper'; -import {getGlobalFetchMock, getOnyxData, setPersonalDetails, signInWithTestUser} from '../utils/TestHelper'; +import {getGlobalFetchMock, getOnyxData, setPersonalDetails, signInWithTestUser, translateLocal} from '../utils/TestHelper'; import waitForBatchedUpdates from '../utils/waitForBatchedUpdates'; import waitForBatchedUpdatesWithAct from '../utils/waitForBatchedUpdatesWithAct'; import waitForNetworkPromises from '../utils/waitForNetworkPromises'; @@ -1643,7 +1641,6 @@ describe('actions/IOU', () => { Onyx.disconnect(connection); expect(transaction?.pendingAction).toBe(CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD); expect(transaction?.errors).toBeTruthy(); - // eslint-disable-next-line @typescript-eslint/no-deprecated expect(Object.values(transaction?.errors ?? {}).at(0)).toEqual(translateLocal('iou.error.genericCreateFailureMessage')); resolve(); }, @@ -1946,7 +1943,6 @@ describe('actions/IOU', () => { const accountantEmployee = policyData?.employeeList?.[accountant.email]; expect(accountantEmployee).toBeTruthy(); expect(accountantEmployee?.errors).toBeTruthy(); - // eslint-disable-next-line @typescript-eslint/no-deprecated expect(Object.values(accountantEmployee?.errors ?? {}).at(0)).toEqual(translateLocal('workspace.people.error.genericAdd')); // Cleanup @@ -3463,7 +3459,6 @@ describe('actions/IOU', () => { callback: (allActions) => { Onyx.disconnect(connection); const erroredAction = Object.values(allActions ?? {}).find((action) => !isEmptyObject(action?.errors)); - // eslint-disable-next-line @typescript-eslint/no-deprecated expect(Object.values(erroredAction?.errors ?? {}).at(0)).toEqual(translateLocal('iou.error.other')); resolve(); }, diff --git a/tests/actions/PolicyMemberTest.ts b/tests/actions/PolicyMemberTest.ts index 3c1b428ffb28..6b1183ab9723 100644 --- a/tests/actions/PolicyMemberTest.ts +++ b/tests/actions/PolicyMemberTest.ts @@ -1,8 +1,6 @@ import Onyx from 'react-native-onyx'; import type {OnyxEntry} from 'react-native-onyx'; import DateUtils from '@libs/DateUtils'; -// eslint-disable-next-line @typescript-eslint/no-deprecated -import {translateLocal} from '@libs/Localize'; import CONST from '@src/CONST'; import OnyxUpdateManager from '@src/libs/actions/OnyxUpdateManager'; import * as Member from '@src/libs/actions/Policy/Member'; @@ -571,8 +569,7 @@ describe('actions/PolicyMember', () => { }); // Then it should show the singular member added success message - // eslint-disable-next-line @typescript-eslint/no-deprecated - expect(importedSpreadsheet?.importFinalModal.prompt).toBe(translateLocal('spreadsheet.importMembersSuccessfulDescription', {added: 1, updated: 0})); + expect(importedSpreadsheet?.importFinalModal.prompt).toBe(TestHelper.translateLocal('spreadsheet.importMembersSuccessfulDescription', {added: 1, updated: 0})); }); it('should show a "multiple members added message" when multiple new members are added', async () => { @@ -601,8 +598,7 @@ describe('actions/PolicyMember', () => { }); // Then it should show the plural member added success message - // eslint-disable-next-line @typescript-eslint/no-deprecated - expect(importedSpreadsheet?.importFinalModal.prompt).toBe(translateLocal('spreadsheet.importMembersSuccessfulDescription', {added: 2, updated: 0})); + expect(importedSpreadsheet?.importFinalModal.prompt).toBe(TestHelper.translateLocal('spreadsheet.importMembersSuccessfulDescription', {added: 2, updated: 0})); }); it('should show a "no members added/updated message" when no new members are added or updated', async () => { @@ -635,8 +631,7 @@ describe('actions/PolicyMember', () => { }); // Then it should show the no member added/updated message - // eslint-disable-next-line @typescript-eslint/no-deprecated - expect(importedSpreadsheet?.importFinalModal.prompt).toBe(translateLocal('spreadsheet.importMembersSuccessfulDescription', {added: 0, updated: 0})); + expect(importedSpreadsheet?.importFinalModal.prompt).toBe(TestHelper.translateLocal('spreadsheet.importMembersSuccessfulDescription', {added: 0, updated: 0})); }); it('should show a "single member updated message" when a member is updated', async () => { @@ -669,8 +664,7 @@ describe('actions/PolicyMember', () => { }); // Then it should show the singular member updated success message - // eslint-disable-next-line @typescript-eslint/no-deprecated - expect(importedSpreadsheet?.importFinalModal.prompt).toBe(translateLocal('spreadsheet.importMembersSuccessfulDescription', {added: 0, updated: 1})); + expect(importedSpreadsheet?.importFinalModal.prompt).toBe(TestHelper.translateLocal('spreadsheet.importMembersSuccessfulDescription', {added: 0, updated: 1})); }); it('should show a "multiple members updated message" when multiple members are updated', async () => { @@ -711,8 +705,7 @@ describe('actions/PolicyMember', () => { }); // Then it should show the plural member updated success message - // eslint-disable-next-line @typescript-eslint/no-deprecated - expect(importedSpreadsheet?.importFinalModal.prompt).toBe(translateLocal('spreadsheet.importMembersSuccessfulDescription', {added: 0, updated: 2})); + expect(importedSpreadsheet?.importFinalModal.prompt).toBe(TestHelper.translateLocal('spreadsheet.importMembersSuccessfulDescription', {added: 0, updated: 2})); }); it('should show a "single member added and updated message" when a member is both added and updated', async () => { @@ -748,8 +741,7 @@ describe('actions/PolicyMember', () => { }); // Then it should show the singular member added and updated success message - // eslint-disable-next-line @typescript-eslint/no-deprecated - expect(importedSpreadsheet?.importFinalModal.prompt).toBe(translateLocal('spreadsheet.importMembersSuccessfulDescription', {added: 1, updated: 1})); + expect(importedSpreadsheet?.importFinalModal.prompt).toBe(TestHelper.translateLocal('spreadsheet.importMembersSuccessfulDescription', {added: 1, updated: 1})); }); it('should show a "multiple members added and updated message" when multiple members are both added and updated', async () => { @@ -792,8 +784,7 @@ describe('actions/PolicyMember', () => { }); // Then it should show the plural member added and updated success message - // eslint-disable-next-line @typescript-eslint/no-deprecated - expect(importedSpreadsheet?.importFinalModal.prompt).toBe(translateLocal('spreadsheet.importMembersSuccessfulDescription', {added: 2, updated: 2})); + expect(importedSpreadsheet?.importFinalModal.prompt).toBe(TestHelper.translateLocal('spreadsheet.importMembersSuccessfulDescription', {added: 2, updated: 2})); }); }); }); diff --git a/tests/actions/PolicyTest.ts b/tests/actions/PolicyTest.ts index cfb6657254d7..731dce3a6489 100644 --- a/tests/actions/PolicyTest.ts +++ b/tests/actions/PolicyTest.ts @@ -2,8 +2,6 @@ import {Str} from 'expensify-common'; import type {OnyxCollection, OnyxEntry} from 'react-native-onyx'; import Onyx from 'react-native-onyx'; import {getOnboardingMessages} from '@libs/actions/Welcome/OnboardingFlow'; -// eslint-disable-next-line @typescript-eslint/no-deprecated -import {translateLocal} from '@libs/Localize'; // eslint-disable-next-line no-restricted-syntax import * as PersonalDetailsUtils from '@libs/PersonalDetailsUtils'; // eslint-disable-next-line no-restricted-syntax @@ -1080,8 +1078,7 @@ describe('actions/Policy', () => { }); const workspaceName = Policy.generateDefaultWorkspaceName(TEST_NON_PUBLIC_DOMAIN_EMAIL); - // eslint-disable-next-line @typescript-eslint/no-deprecated - expect(workspaceName).toBe(translateLocal('workspace.new.workspaceName', {userName: displayNameForWorkspace})); + expect(workspaceName).toBe(TestHelper.translateLocal('workspace.new.workspaceName', {userName: displayNameForWorkspace})); }); it('should generate a workspace name based on the display name when the domain is public and display name is available', () => { @@ -1094,8 +1091,7 @@ describe('actions/Policy', () => { }); const workspaceName = Policy.generateDefaultWorkspaceName(TEST_EMAIL); - // eslint-disable-next-line @typescript-eslint/no-deprecated - expect(workspaceName).toBe(translateLocal('workspace.new.workspaceName', {userName: displayNameForWorkspace})); + expect(workspaceName).toBe(TestHelper.translateLocal('workspace.new.workspaceName', {userName: displayNameForWorkspace})); }); it('should generate a workspace name based on the username when the domain is public and display name is not available', () => { @@ -1110,8 +1106,7 @@ describe('actions/Policy', () => { }); const workspaceName = Policy.generateDefaultWorkspaceName(TEST_EMAIL_2); - // eslint-disable-next-line @typescript-eslint/no-deprecated - expect(workspaceName).toBe(translateLocal('workspace.new.workspaceName', {userName: displayNameForWorkspace})); + expect(workspaceName).toBe(TestHelper.translateLocal('workspace.new.workspaceName', {userName: displayNameForWorkspace})); }); it('should generate a workspace name with an incremented number when there are existing policies with similar names', async () => { @@ -1129,8 +1124,7 @@ describe('actions/Policy', () => { await Onyx.set(ONYXKEYS.COLLECTION.POLICY, existingPolicies); const workspaceName = Policy.generateDefaultWorkspaceName(TEST_EMAIL); - // eslint-disable-next-line @typescript-eslint/no-deprecated - expect(workspaceName).toBe(translateLocal('workspace.new.workspaceName', {userName: TEST_DISPLAY_NAME, workspaceNumber: 2})); + expect(workspaceName).toBe(TestHelper.translateLocal('workspace.new.workspaceName', {userName: TEST_DISPLAY_NAME, workspaceNumber: 2})); }); it('should return "My Group Workspace" when the domain is SMS', () => { @@ -1141,8 +1135,7 @@ describe('actions/Policy', () => { }); const workspaceName = Policy.generateDefaultWorkspaceName(TEST_SMS_DOMAIN_EMAIL); - // eslint-disable-next-line @typescript-eslint/no-deprecated - expect(workspaceName).toBe(translateLocal('workspace.new.myGroupWorkspace', {})); + expect(workspaceName).toBe(TestHelper.translateLocal('workspace.new.myGroupWorkspace', {})); }); it('should generate a workspace name with an incremented number even if previous workspaces were created in english lang', async () => { @@ -1164,8 +1157,7 @@ describe('actions/Policy', () => { await Onyx.set(ONYXKEYS.COLLECTION.POLICY, existingPolicies); const workspaceName = Policy.generateDefaultWorkspaceName(TEST_EMAIL); - // eslint-disable-next-line @typescript-eslint/no-deprecated - expect(workspaceName).toBe(translateLocal('workspace.new.workspaceName', {userName: TEST_DISPLAY_NAME, workspaceNumber: 2})); + expect(workspaceName).toBe(TestHelper.translateLocal('workspace.new.workspaceName', {userName: TEST_DISPLAY_NAME, workspaceNumber: 2})); }); }); @@ -1232,8 +1224,7 @@ describe('actions/Policy', () => { // The policy join should have the genericAdd error expect(policyJoinData?.errors).toBeTruthy(); - // eslint-disable-next-line @typescript-eslint/no-deprecated - expect(Object.values(policyJoinData?.errors ?? {}).at(0)).toEqual(translateLocal('workspace.people.error.genericAdd')); + expect(Object.values(policyJoinData?.errors ?? {}).at(0)).toEqual(TestHelper.translateLocal('workspace.people.error.genericAdd')); mockFetch.succeed?.(); }); @@ -1271,8 +1262,7 @@ describe('actions/Policy', () => { // The policy join should have the genericAdd error expect(policyJoinData?.errors).toBeTruthy(); - // eslint-disable-next-line @typescript-eslint/no-deprecated - expect(Object.values(policyJoinData?.errors ?? {}).at(0)).toEqual(translateLocal('workspace.people.error.genericAdd')); + expect(Object.values(policyJoinData?.errors ?? {}).at(0)).toEqual(TestHelper.translateLocal('workspace.people.error.genericAdd')); mockFetch.succeed?.(); }); diff --git a/tests/actions/ReportTest.ts b/tests/actions/ReportTest.ts index 7a38197ad067..47703337fd89 100644 --- a/tests/actions/ReportTest.ts +++ b/tests/actions/ReportTest.ts @@ -17,8 +17,6 @@ import * as PersistedRequests from '@src/libs/actions/PersistedRequests'; import * as Report from '@src/libs/actions/Report'; import * as User from '@src/libs/actions/User'; import DateUtils from '@src/libs/DateUtils'; -// eslint-disable-next-line @typescript-eslint/no-deprecated -import {translateLocal} from '@src/libs/Localize'; import Log from '@src/libs/Log'; import * as SequentialQueue from '@src/libs/Network/SequentialQueue'; import * as ReportUtils from '@src/libs/ReportUtils'; @@ -2253,8 +2251,7 @@ describe('actions/Report', () => { const submitterEmployee = policyData?.employeeList?.[ownerEmail]; expect(submitterEmployee).toBeTruthy(); expect(submitterEmployee?.errors).toBeTruthy(); - // eslint-disable-next-line @typescript-eslint/no-deprecated - expect(Object.values(submitterEmployee?.errors ?? {}).at(0)).toEqual(translateLocal('workspace.people.error.genericAdd')); + expect(Object.values(submitterEmployee?.errors ?? {}).at(0)).toEqual(TestHelper.translateLocal('workspace.people.error.genericAdd')); // Cleanup mockFetch.succeed?.(); @@ -2412,8 +2409,7 @@ describe('actions/Report', () => { const submitterEmployee = policyData?.employeeList?.[ownerEmail]; expect(submitterEmployee).toBeTruthy(); expect(submitterEmployee?.errors).toBeTruthy(); - // eslint-disable-next-line @typescript-eslint/no-deprecated - expect(Object.values(submitterEmployee?.errors ?? {}).at(0)).toEqual(translateLocal('workspace.people.error.genericAdd')); + expect(Object.values(submitterEmployee?.errors ?? {}).at(0)).toEqual(TestHelper.translateLocal('workspace.people.error.genericAdd')); // Cleanup mockFetch.succeed?.(); diff --git a/tests/actions/TourTest.ts b/tests/actions/TourTest.ts index 3355f7f0361c..8ee1769d116e 100644 --- a/tests/actions/TourTest.ts +++ b/tests/actions/TourTest.ts @@ -1,8 +1,6 @@ import Onyx from 'react-native-onyx'; import OnyxUpdateManager from '@libs/actions/OnyxUpdateManager'; import {startTestDrive} from '@libs/actions/Tour'; -// eslint-disable-next-line @typescript-eslint/no-deprecated -import {translateLocal} from '@libs/Localize'; import Navigation from '@libs/Navigation/Navigation'; import Parser from '@libs/Parser'; import initOnyxDerivedValues from '@userActions/OnyxDerived'; @@ -65,8 +63,9 @@ describe('actions/Tour', () => { const testDriveTaskAction: ReportAction = { ...LHNTestUtils.getFakeReportAction(), childType: CONST.REPORT.TYPE.TASK, - // eslint-disable-next-line @typescript-eslint/no-deprecated - childReportName: Parser.replace(translateLocal('onboarding.testDrive.name', {testDriveURL: `${CONST.STAGING_NEW_EXPENSIFY_URL}/${ROUTES.TEST_DRIVE_DEMO_ROOT}`})), + childReportName: Parser.replace( + TestHelper.translateLocal('onboarding.testDrive.name', {testDriveURL: `${CONST.STAGING_NEW_EXPENSIFY_URL}/${ROUTES.TEST_DRIVE_DEMO_ROOT}`}), + ), childReportID: testDriveTaskReport.reportID, }; diff --git a/tests/perf-test/ReportActionCompose.perf-test.tsx b/tests/perf-test/ReportActionCompose.perf-test.tsx index 43e2f597dee9..f9edb3db4631 100644 --- a/tests/perf-test/ReportActionCompose.perf-test.tsx +++ b/tests/perf-test/ReportActionCompose.perf-test.tsx @@ -9,10 +9,10 @@ import type Navigation from '@libs/Navigation/Navigation'; import ComposeProviders from '@src/components/ComposeProviders'; import {LocaleContextProvider} from '@src/components/LocaleContextProvider'; import {KeyboardStateProvider} from '@src/components/withKeyboardState'; -import * as Localize from '@src/libs/Localize'; import ONYXKEYS from '@src/ONYXKEYS'; import ReportActionCompose from '@src/pages/home/report/ReportActionCompose/ReportActionCompose'; import * as LHNTestUtils from '../utils/LHNTestUtils'; +import {translateLocal} from '../utils/TestHelper'; import waitForBatchedUpdates from '../utils/waitForBatchedUpdates'; // mock PortalStateContext @@ -105,8 +105,7 @@ test('[ReportActionCompose] should render Composer with text input interactions' test('[ReportActionCompose] should press create button', async () => { const scenario = async () => { // Query for the create button - // eslint-disable-next-line @typescript-eslint/no-deprecated - const hintAttachmentButtonText = Localize.translateLocal('common.create'); + const hintAttachmentButtonText = translateLocal('common.create'); const createButton = await screen.findByLabelText(hintAttachmentButtonText); fireEvent.press(createButton, mockEvent); @@ -119,8 +118,7 @@ test('[ReportActionCompose] should press create button', async () => { test('[ReportActionCompose] should press send message button', async () => { const scenario = async () => { // Query for the send button - // eslint-disable-next-line @typescript-eslint/no-deprecated - const hintSendButtonText = Localize.translateLocal('common.send'); + const hintSendButtonText = translateLocal('common.send'); const sendButton = await screen.findByLabelText(hintSendButtonText); fireEvent.press(sendButton); diff --git a/tests/ui/GroupChatNameTests.tsx b/tests/ui/GroupChatNameTests.tsx index 844411fe84c4..dfda9928b9bc 100644 --- a/tests/ui/GroupChatNameTests.tsx +++ b/tests/ui/GroupChatNameTests.tsx @@ -6,8 +6,6 @@ import {act, render, screen, waitFor} from '@testing-library/react-native'; import React from 'react'; import Onyx from 'react-native-onyx'; -// eslint-disable-next-line @typescript-eslint/no-deprecated -import {translateLocal} from '@libs/Localize'; import {setSidebarLoaded} from '@userActions/App'; import {subscribeToUserEvents} from '@userActions/User'; import App from '@src/App'; @@ -187,8 +185,7 @@ function signInAndGetApp(reportName = '', participantAccountIDs?: number[]): Pro return waitForBatchedUpdatesWithAct() .then(async () => { await waitForBatchedUpdatesWithAct(); - // eslint-disable-next-line @typescript-eslint/no-deprecated - const hintText = translateLocal('loginForm.loginForm'); + const hintText = TestHelper.translateLocal('loginForm.loginForm'); const loginForm = screen.queryAllByLabelText(hintText); expect(loginForm).toHaveLength(1); }) @@ -250,16 +247,14 @@ describe('Tests for group chat name', () => { it('Should show correctly in LHN', () => signInAndGetApp('A, B, C, D', participantAccountIDs4).then(() => { // Verify the sidebar links are rendered - // eslint-disable-next-line @typescript-eslint/no-deprecated - const sidebarLinksHintText = translateLocal('sidebarScreen.listOfChats'); + const sidebarLinksHintText = TestHelper.translateLocal('sidebarScreen.listOfChats'); const sidebarLinks = screen.queryAllByLabelText(sidebarLinksHintText); expect(sidebarLinks).toHaveLength(1); // Verify there is only one option in the sidebar const optionRows = screen.queryAllByAccessibilityHint(TestHelper.getNavigateToChatHintRegex()); expect(optionRows).toHaveLength(1); - // eslint-disable-next-line @typescript-eslint/no-deprecated - const displayNameHintText = translateLocal('accessibilityHints.chatUserDisplayNames'); + const displayNameHintText = TestHelper.translateLocal('accessibilityHints.chatUserDisplayNames'); const displayNameText = screen.queryByLabelText(displayNameHintText); return waitFor(() => expect(displayNameText?.props?.children?.[0]).toBe('A, B, C, D')); @@ -268,16 +263,14 @@ describe('Tests for group chat name', () => { it('Should show correctly in LHN when report name is not present', () => signInAndGetApp('', participantAccountIDs4).then(() => { // Verify the sidebar links are rendered - // eslint-disable-next-line @typescript-eslint/no-deprecated - const sidebarLinksHintText = translateLocal('sidebarScreen.listOfChats'); + const sidebarLinksHintText = TestHelper.translateLocal('sidebarScreen.listOfChats'); const sidebarLinks = screen.queryAllByLabelText(sidebarLinksHintText); expect(sidebarLinks).toHaveLength(1); // Verify there is only one option in the sidebar const optionRows = screen.queryAllByAccessibilityHint(TestHelper.getNavigateToChatHintRegex()); expect(optionRows).toHaveLength(1); - // eslint-disable-next-line @typescript-eslint/no-deprecated - const displayNameHintText = translateLocal('accessibilityHints.chatUserDisplayNames'); + const displayNameHintText = TestHelper.translateLocal('accessibilityHints.chatUserDisplayNames'); const displayNameText = screen.queryByLabelText(displayNameHintText); return waitFor(() => expect(displayNameText?.props?.children?.[0]).toBe('A, B, C, D')); @@ -286,16 +279,14 @@ describe('Tests for group chat name', () => { it('Should show limited names with ellipsis in LHN when 8 participants are present', () => signInAndGetApp('', participantAccountIDs8).then(() => { // Verify the sidebar links are rendered - // eslint-disable-next-line @typescript-eslint/no-deprecated - const sidebarLinksHintText = translateLocal('sidebarScreen.listOfChats'); + const sidebarLinksHintText = TestHelper.translateLocal('sidebarScreen.listOfChats'); const sidebarLinks = screen.queryAllByLabelText(sidebarLinksHintText); expect(sidebarLinks).toHaveLength(1); // Verify there is only one option in the sidebar const optionRows = screen.queryAllByAccessibilityHint(TestHelper.getNavigateToChatHintRegex()); expect(optionRows).toHaveLength(1); - // eslint-disable-next-line @typescript-eslint/no-deprecated - const displayNameHintText = translateLocal('accessibilityHints.chatUserDisplayNames'); + const displayNameHintText = TestHelper.translateLocal('accessibilityHints.chatUserDisplayNames'); const displayNameText = screen.queryByLabelText(displayNameHintText); return waitFor(() => expect(displayNameText?.props?.children?.[0]).toBe('A, B, C, D, E...')); @@ -305,16 +296,14 @@ describe('Tests for group chat name', () => { signInAndGetApp('', participantAccountIDs4) .then(() => { // Verify the sidebar links are rendered - // eslint-disable-next-line @typescript-eslint/no-deprecated - const sidebarLinksHintText = translateLocal('sidebarScreen.listOfChats'); + const sidebarLinksHintText = TestHelper.translateLocal('sidebarScreen.listOfChats'); const sidebarLinks = screen.queryAllByLabelText(sidebarLinksHintText); expect(sidebarLinks).toHaveLength(1); // Verify there is only one option in the sidebar const optionRows = screen.queryAllByAccessibilityHint(TestHelper.getNavigateToChatHintRegex()); expect(optionRows).toHaveLength(1); - // eslint-disable-next-line @typescript-eslint/no-deprecated - const displayNameHintText = translateLocal('accessibilityHints.chatUserDisplayNames'); + const displayNameHintText = TestHelper.translateLocal('accessibilityHints.chatUserDisplayNames'); const displayNameText = screen.queryByLabelText(displayNameHintText); expect(displayNameText?.props?.children?.[0]).toBe('A, B, C, D'); @@ -333,10 +322,8 @@ describe('Tests for group chat name', () => { .then(async () => { // Wait for sidebar to be rendered await waitForBatchedUpdatesWithAct(); - // eslint-disable-next-line @typescript-eslint/no-deprecated - const sidebarLinksHintText = translateLocal('sidebarScreen.listOfChats'); - // eslint-disable-next-line @typescript-eslint/no-deprecated - const displayNameHintText = translateLocal('accessibilityHints.chatUserDisplayNames'); + const sidebarLinksHintText = TestHelper.translateLocal('sidebarScreen.listOfChats'); + const displayNameHintText = TestHelper.translateLocal('accessibilityHints.chatUserDisplayNames'); // Check sidebar links await waitFor(() => { @@ -368,16 +355,14 @@ describe('Tests for group chat name', () => { signInAndGetApp('Test chat', participantAccountIDs4) .then(() => { // Verify the sidebar links are rendered - // eslint-disable-next-line @typescript-eslint/no-deprecated - const sidebarLinksHintText = translateLocal('sidebarScreen.listOfChats'); + const sidebarLinksHintText = TestHelper.translateLocal('sidebarScreen.listOfChats'); const sidebarLinks = screen.queryAllByLabelText(sidebarLinksHintText); expect(sidebarLinks).toHaveLength(1); // Verify there is only one option in the sidebar const optionRows = screen.queryAllByAccessibilityHint(TestHelper.getNavigateToChatHintRegex()); expect(optionRows).toHaveLength(1); - // eslint-disable-next-line @typescript-eslint/no-deprecated - const displayNameHintText = translateLocal('accessibilityHints.chatUserDisplayNames'); + const displayNameHintText = TestHelper.translateLocal('accessibilityHints.chatUserDisplayNames'); const displayNameText = screen.queryByLabelText(displayNameHintText); expect(displayNameText?.props?.children?.[0]).toBe('Test chat'); @@ -395,16 +380,14 @@ describe('Tests for group chat name', () => { signInAndGetApp("Let's talk", participantAccountIDs8) .then(() => { // Verify the sidebar links are rendered - // eslint-disable-next-line @typescript-eslint/no-deprecated - const sidebarLinksHintText = translateLocal('sidebarScreen.listOfChats'); + const sidebarLinksHintText = TestHelper.translateLocal('sidebarScreen.listOfChats'); const sidebarLinks = screen.queryAllByLabelText(sidebarLinksHintText); expect(sidebarLinks).toHaveLength(1); // Verify there is only one option in the sidebar const optionRows = screen.queryAllByAccessibilityHint(TestHelper.getNavigateToChatHintRegex()); expect(optionRows).toHaveLength(1); - // eslint-disable-next-line @typescript-eslint/no-deprecated - const displayNameHintText = translateLocal('accessibilityHints.chatUserDisplayNames'); + const displayNameHintText = TestHelper.translateLocal('accessibilityHints.chatUserDisplayNames'); const displayNameText = screen.queryByLabelText(displayNameHintText); expect(displayNameText?.props?.children?.[0]).toBe("Let's talk"); @@ -421,16 +404,14 @@ describe('Tests for group chat name', () => { it('Should show last message preview in LHN', () => signInAndGetApp('A, B, C, D', participantAccountIDs4).then(() => { // Verify the sidebar links are rendered - // eslint-disable-next-line @typescript-eslint/no-deprecated - const sidebarLinksHintText = translateLocal('sidebarScreen.listOfChats'); + const sidebarLinksHintText = TestHelper.translateLocal('sidebarScreen.listOfChats'); const sidebarLinks = screen.queryAllByLabelText(sidebarLinksHintText); expect(sidebarLinks).toHaveLength(1); // Verify there is only one option in the sidebar const optionRows = screen.queryAllByAccessibilityHint(TestHelper.getNavigateToChatHintRegex()); expect(optionRows).toHaveLength(1); - // eslint-disable-next-line @typescript-eslint/no-deprecated - const lastChatHintText = translateLocal('accessibilityHints.lastChatMessagePreview'); + const lastChatHintText = TestHelper.translateLocal('accessibilityHints.lastChatMessagePreview'); const lastChatText = screen.queryByLabelText(lastChatHintText); return waitFor(() => expect(lastChatText?.props?.children).toBe('B: Test')); @@ -439,16 +420,14 @@ describe('Tests for group chat name', () => { it('Should sort the names before displaying', () => signInAndGetApp('', [USER_E_ACCOUNT_ID, ...participantAccountIDs4]).then(() => { // Verify the sidebar links are rendered - // eslint-disable-next-line @typescript-eslint/no-deprecated - const sidebarLinksHintText = translateLocal('sidebarScreen.listOfChats'); + const sidebarLinksHintText = TestHelper.translateLocal('sidebarScreen.listOfChats'); const sidebarLinks = screen.queryAllByLabelText(sidebarLinksHintText); expect(sidebarLinks).toHaveLength(1); // Verify there is only one option in the sidebar const optionRows = screen.queryAllByAccessibilityHint(TestHelper.getNavigateToChatHintRegex()); expect(optionRows).toHaveLength(1); - // eslint-disable-next-line @typescript-eslint/no-deprecated - const displayNameHintText = translateLocal('accessibilityHints.chatUserDisplayNames'); + const displayNameHintText = TestHelper.translateLocal('accessibilityHints.chatUserDisplayNames'); const displayNameText = screen.queryByLabelText(displayNameHintText); return waitFor(() => expect(displayNameText?.props?.children?.[0]).toBe('A, B, C, D, E')); diff --git a/tests/ui/LHNItemsPresence.tsx b/tests/ui/LHNItemsPresence.tsx index bb076daf72f2..6c5e8d96d981 100644 --- a/tests/ui/LHNItemsPresence.tsx +++ b/tests/ui/LHNItemsPresence.tsx @@ -7,8 +7,6 @@ import type {ValueOf} from 'type-fest'; import type {WithCurrentUserPersonalDetailsProps} from '@components/withCurrentUserPersonalDetails'; import initOnyxDerivedValues from '@libs/actions/OnyxDerived'; import DateUtils from '@libs/DateUtils'; -// eslint-disable-next-line @typescript-eslint/no-deprecated -import {translateLocal} from '@libs/Localize'; import {buildOptimisticExpenseReport, buildOptimisticIOUReportAction, buildTransactionThread} from '@libs/ReportUtils'; import {buildOptimisticTransaction} from '@libs/TransactionUtils'; import FontUtils from '@styles/utils/FontUtils'; @@ -100,8 +98,7 @@ const getOptionRows = () => { }; const getDisplayNames = () => { - // eslint-disable-next-line @typescript-eslint/no-deprecated - const hintText = translateLocal('accessibilityHints.chatUserDisplayNames'); + const hintText = TestHelper.translateLocal('accessibilityHints.chatUserDisplayNames'); return screen.queryAllByLabelText(hintText); }; diff --git a/tests/ui/MoneyRequestReportPreview.test.tsx b/tests/ui/MoneyRequestReportPreview.test.tsx index 383aa1db7581..983bd6af16c0 100644 --- a/tests/ui/MoneyRequestReportPreview.test.tsx +++ b/tests/ui/MoneyRequestReportPreview.test.tsx @@ -12,8 +12,6 @@ import type {MoneyRequestReportPreviewProps} from '@components/ReportActionItem/ import ScreenWrapper from '@components/ScreenWrapper'; import {convertToDisplayString} from '@libs/CurrencyUtils'; import DateUtils from '@libs/DateUtils'; -// eslint-disable-next-line @typescript-eslint/no-deprecated -import {translateLocal} from '@libs/Localize'; import {getFormattedCreated, isManagedCardTransaction} from '@libs/TransactionUtils'; import CONST from '@src/CONST'; import * as ReportActionUtils from '@src/libs/ReportActionsUtils'; @@ -92,8 +90,7 @@ const getTransactionDisplayAmountAndHeaderText = (transaction: Transaction) => { const created = getFormattedCreated(transaction); const date = DateUtils.formatWithUTCTimeZone(created, DateUtils.doesDateBelongToAPastYear(created) ? CONST.DATE.MONTH_DAY_YEAR_ABBR_FORMAT : CONST.DATE.MONTH_DAY_ABBR_FORMAT); const isTransactionMadeWithCard = isManagedCardTransaction(transaction); - // eslint-disable-next-line @typescript-eslint/no-deprecated - const cashOrCard = isTransactionMadeWithCard ? translateLocal('iou.card') : translateLocal('iou.cash'); + const cashOrCard = isTransactionMadeWithCard ? TestHelper.translateLocal('iou.card') : TestHelper.translateLocal('iou.cash'); const transactionHeaderText = `${date} ${CONST.DOT_SEPARATOR} ${cashOrCard}`; const transactionDisplayAmount = convertToDisplayString(transaction.amount, transaction.currency); return {transactionHeaderText, transactionDisplayAmount}; @@ -176,8 +173,7 @@ describe('MoneyRequestReportPreview', () => { await Onyx.multiSet({...mockOnyxTransactions, ...mockOnyxViolations}); }); await waitForBatchedUpdatesWithAct(); - // eslint-disable-next-line @typescript-eslint/no-deprecated - expect(screen.getAllByText(translateLocal('violations.reviewRequired'))).toHaveLength(2); + expect(screen.getAllByText(TestHelper.translateLocal('violations.reviewRequired'))).toHaveLength(2); }); it('renders a skeleton if the transaction is empty', async () => { @@ -219,12 +215,10 @@ describe('MoneyRequestReportPreview', () => { await waitForBatchedUpdatesWithAct(); // Verify the Review button is rendered - // eslint-disable-next-line @typescript-eslint/no-deprecated - expect(screen.getByText(translateLocal('common.review'))).toBeOnTheScreen(); + expect(screen.getByText(TestHelper.translateLocal('common.review'))).toBeOnTheScreen(); // Verify the button has the correct styling (danger icon) - // eslint-disable-next-line @typescript-eslint/no-deprecated - const reviewButton = screen.getByText(translateLocal('common.review')); + const reviewButton = screen.getByText(TestHelper.translateLocal('common.review')); expect(reviewButton).toBeOnTheScreen(); // Clean up mocks @@ -246,12 +240,10 @@ describe('MoneyRequestReportPreview', () => { await waitForBatchedUpdatesWithAct(); // Verify the Review button is NOT rendered - // eslint-disable-next-line @typescript-eslint/no-deprecated - expect(screen.queryByText(translateLocal('common.review'))).not.toBeOnTheScreen(); + expect(screen.queryByText(TestHelper.translateLocal('common.review'))).not.toBeOnTheScreen(); // But View button should be rendered instead - // eslint-disable-next-line @typescript-eslint/no-deprecated - expect(screen.getByText(translateLocal('common.view'))).toBeOnTheScreen(); + expect(screen.getByText(TestHelper.translateLocal('common.view'))).toBeOnTheScreen(); // Clean up mocks canReviewSpy.mockRestore(); @@ -274,8 +266,7 @@ describe('MoneyRequestReportPreview', () => { await waitForBatchedUpdatesWithAct(); // Find and press the Review button - // eslint-disable-next-line @typescript-eslint/no-deprecated - const reviewButton = screen.getByText(translateLocal('common.review')); + const reviewButton = screen.getByText(TestHelper.translateLocal('common.review')); expect(reviewButton).toBeOnTheScreen(); fireEvent.press(reviewButton); diff --git a/tests/ui/NewChatPageTest.tsx b/tests/ui/NewChatPageTest.tsx index b58ad118f2bc..d1a55f210e9a 100644 --- a/tests/ui/NewChatPageTest.tsx +++ b/tests/ui/NewChatPageTest.tsx @@ -8,13 +8,12 @@ import {LocaleContextProvider} from '@components/LocaleContextProvider'; import OnyxListItemProvider from '@components/OnyxListItemProvider'; import OptionsListContextProvider from '@components/OptionListContextProvider'; import ScreenWrapper from '@components/ScreenWrapper'; -// eslint-disable-next-line @typescript-eslint/no-deprecated -import {translateLocal} from '@libs/Localize'; import NewChatPage from '@pages/NewChatPage'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import type {NativeNavigationMock} from '../../__mocks__/@react-navigation/native'; import {fakePersonalDetails} from '../utils/LHNTestUtils'; +import {translateLocal} from '../utils/TestHelper'; import waitForBatchedUpdatesWithAct from '../utils/waitForBatchedUpdatesWithAct'; jest.mock('@react-navigation/native'); @@ -79,7 +78,6 @@ describe('NewChatPage', () => { (NativeNavigation as NativeNavigationMock).triggerTransitionEnd(); }); const spy = jest.spyOn(SectionList.prototype, 'scrollToLocation'); - // eslint-disable-next-line @typescript-eslint/no-deprecated const addButton = await waitFor(() => screen.getAllByText(translateLocal('newChatPage.addToGroup')).at(0)); if (addButton) { fireEvent.press(addButton); @@ -117,7 +115,6 @@ describe('NewChatPage', () => { // Then "Add to group" button should not appear const userOption = screen.getByLabelText(email); - // eslint-disable-next-line @typescript-eslint/no-deprecated const addButton = within(userOption).queryByText(translateLocal('newChatPage.addToGroup')); expect(addButton).not.toBeOnTheScreen(); }); diff --git a/tests/ui/OnboardingEmployees.tsx b/tests/ui/OnboardingEmployees.tsx index 504d2d929f1c..7075167a43c6 100644 --- a/tests/ui/OnboardingEmployees.tsx +++ b/tests/ui/OnboardingEmployees.tsx @@ -9,8 +9,6 @@ import OnyxListItemProvider from '@components/OnyxListItemProvider'; import {CurrentReportIDContextProvider} from '@hooks/useCurrentReportID'; import * as useResponsiveLayoutModule from '@hooks/useResponsiveLayout'; import type ResponsiveLayoutResult from '@hooks/useResponsiveLayout/types'; -// eslint-disable-next-line @typescript-eslint/no-deprecated -import {translateLocal} from '@libs/Localize'; import createPlatformStackNavigator from '@libs/Navigation/PlatformStackNavigation/createPlatformStackNavigator'; import type {OnboardingModalNavigatorParamList} from '@navigation/types'; import OnboardingEmployees from '@pages/OnboardingEmployees'; @@ -93,8 +91,7 @@ describe('OnboardingEmployees Page', () => { await waitForBatchedUpdatesWithAct(); await waitFor(() => { - // eslint-disable-next-line @typescript-eslint/no-deprecated - expect(screen.getByText(translateLocal('onboarding.employees.1-10'))).toBeOnTheScreen(); + expect(screen.getByText(TestHelper.translateLocal('onboarding.employees.1-10'))).toBeOnTheScreen(); }); unmount(); @@ -117,8 +114,7 @@ describe('OnboardingEmployees Page', () => { await waitForBatchedUpdatesWithAct(); await waitFor(() => { - // eslint-disable-next-line @typescript-eslint/no-deprecated - expect(screen.queryByText(translateLocal('onboarding.employees.1-10'))).not.toBeOnTheScreen(); + expect(screen.queryByText(TestHelper.translateLocal('onboarding.employees.1-10'))).not.toBeOnTheScreen(); }); unmount(); diff --git a/tests/ui/PaginationTest.tsx b/tests/ui/PaginationTest.tsx index 811ef16d20f5..0cd788701015 100644 --- a/tests/ui/PaginationTest.tsx +++ b/tests/ui/PaginationTest.tsx @@ -4,8 +4,6 @@ import {act, fireEvent, render, screen, waitFor, within} from '@testing-library/ import {addSeconds, format, subMinutes} from 'date-fns'; import React from 'react'; import Onyx from 'react-native-onyx'; -// eslint-disable-next-line @typescript-eslint/no-deprecated -import {translateLocal} from '@libs/Localize'; import {waitForIdle} from '@libs/Network/SequentialQueue'; import {setSidebarLoaded} from '@userActions/App'; import {subscribeToUserEvents} from '@userActions/User'; @@ -57,8 +55,7 @@ function getReportScreen(reportID = REPORT_ID) { } function scrollToOffset(offset: number) { - // eslint-disable-next-line @typescript-eslint/no-deprecated - const hintText = translateLocal('sidebarScreen.listOfChatMessages'); + const hintText = TestHelper.translateLocal('sidebarScreen.listOfChatMessages'); fireEvent.scroll(within(getReportScreen()).getByLabelText(hintText), { nativeEvent: { contentOffset: { @@ -89,11 +86,9 @@ function triggerListLayout(reportID?: string) { function getReportActions(reportID?: string) { const report = getReportScreen(reportID); return [ - // eslint-disable-next-line @typescript-eslint/no-deprecated - ...within(report).queryAllByLabelText(translateLocal('accessibilityHints.chatMessage')), + ...within(report).queryAllByLabelText(TestHelper.translateLocal('accessibilityHints.chatMessage')), // Created action has a different accessibility label. - // eslint-disable-next-line @typescript-eslint/no-deprecated - ...within(report).queryAllByLabelText(translateLocal('accessibilityHints.chatWelcomeMessage')), + ...within(report).queryAllByLabelText(TestHelper.translateLocal('accessibilityHints.chatWelcomeMessage')), ]; } @@ -201,8 +196,7 @@ async function signInAndGetApp(): Promise { // Render the App and sign in as a test user. render(); await waitForBatchedUpdatesWithAct(); - // eslint-disable-next-line @typescript-eslint/no-deprecated - const hintText = translateLocal('loginForm.loginForm'); + const hintText = TestHelper.translateLocal('loginForm.loginForm'); const loginForm = await screen.findAllByLabelText(hintText); expect(loginForm).toHaveLength(1); diff --git a/tests/ui/PersonalDetailsOnboarding.tsx b/tests/ui/PersonalDetailsOnboarding.tsx index a3e7dbef66dd..448a836eec9f 100644 --- a/tests/ui/PersonalDetailsOnboarding.tsx +++ b/tests/ui/PersonalDetailsOnboarding.tsx @@ -10,8 +10,6 @@ import OnyxListItemProvider from '@components/OnyxListItemProvider'; import {CurrentReportIDContextProvider} from '@hooks/useCurrentReportID'; import * as useResponsiveLayoutModule from '@hooks/useResponsiveLayout'; import type ResponsiveLayoutResult from '@hooks/useResponsiveLayout/types'; -// eslint-disable-next-line @typescript-eslint/no-deprecated -import {translateLocal} from '@libs/Localize'; import Navigation from '@libs/Navigation/Navigation'; import createPlatformStackNavigator from '@libs/Navigation/PlatformStackNavigation/createPlatformStackNavigator'; import type {OnboardingModalNavigatorParamList} from '@navigation/types'; @@ -101,8 +99,7 @@ describe('OnboardingPersonalDetails Page', () => { await waitForBatchedUpdatesWithAct(); // Submit the form - // eslint-disable-next-line @typescript-eslint/no-deprecated - fireEvent.press(screen.getByText(translateLocal('common.continue'))); + fireEvent.press(screen.getByText(TestHelper.translateLocal('common.continue'))); await waitFor(() => { expect(navigate).toHaveBeenCalledWith(ROUTES.ONBOARDING_PRIVATE_DOMAIN.getRoute()); @@ -133,8 +130,7 @@ describe('OnboardingPersonalDetails Page', () => { await waitForBatchedUpdatesWithAct(); // Submit the form - // eslint-disable-next-line @typescript-eslint/no-deprecated - fireEvent.press(screen.getByText(translateLocal('common.continue'))); + fireEvent.press(screen.getByText(TestHelper.translateLocal('common.continue'))); await waitFor(() => { expect(navigate).toHaveBeenCalledWith(ROUTES.ONBOARDING_PRIVATE_DOMAIN.getRoute()); diff --git a/tests/ui/PureReportActionItemTest.tsx b/tests/ui/PureReportActionItemTest.tsx index 6059494ee322..e8dba044995e 100644 --- a/tests/ui/PureReportActionItemTest.tsx +++ b/tests/ui/PureReportActionItemTest.tsx @@ -9,8 +9,6 @@ import {LocaleContextProvider} from '@components/LocaleContextProvider'; import OnyxListItemProvider from '@components/OnyxListItemProvider'; import OptionsListContextProvider from '@components/OptionListContextProvider'; import ScreenWrapper from '@components/ScreenWrapper'; -// eslint-disable-next-line @typescript-eslint/no-deprecated -import {translateLocal} from '@libs/Localize'; import {getIOUActionForReportID} from '@libs/ReportActionsUtils'; import PureReportActionItem from '@pages/home/report/PureReportActionItem'; import CONST from '@src/CONST'; @@ -20,6 +18,7 @@ import ONYXKEYS from '@src/ONYXKEYS'; import type {ReportAction} from '@src/types/onyx'; import type {OriginalMessage} from '@src/types/onyx/ReportAction'; import type ReportActionName from '@src/types/onyx/ReportActionName'; +import {translateLocal} from '../utils/TestHelper'; import waitForBatchedUpdatesWithAct from '../utils/waitForBatchedUpdatesWithAct'; import wrapOnyxWithWaitForBatchedUpdates from '../utils/wrapOnyxWithWaitForBatchedUpdates'; @@ -150,7 +149,6 @@ describe('PureReportActionItem', () => { await waitForBatchedUpdatesWithAct(); expect(screen.getByText(actorEmail)).toBeOnTheScreen(); - // eslint-disable-next-line @typescript-eslint/no-deprecated const parsedText = parseTextWithTrailingLink(translateLocal(translationKey as TranslationPaths)); if (!parsedText) { throw new Error('Text cannot be parsed, translation failed'); @@ -169,7 +167,6 @@ describe('PureReportActionItem', () => { await waitForBatchedUpdatesWithAct(); expect(screen.getByText(actorEmail)).toBeOnTheScreen(); - // eslint-disable-next-line @typescript-eslint/no-deprecated expect(screen.getByText(translateLocal('iou.approvedMessage'))).toBeOnTheScreen(); }); @@ -179,7 +176,6 @@ describe('PureReportActionItem', () => { await waitForBatchedUpdatesWithAct(); expect(screen.getByText(actorEmail)).toBeOnTheScreen(); - // eslint-disable-next-line @typescript-eslint/no-deprecated expect(screen.getByText(translateLocal('iou.forwarded'))).toBeOnTheScreen(); }); @@ -189,7 +185,6 @@ describe('PureReportActionItem', () => { await waitForBatchedUpdatesWithAct(); expect(screen.getByText(actorEmail)).toBeOnTheScreen(); - // eslint-disable-next-line @typescript-eslint/no-deprecated expect(screen.getByText(translateLocal('iou.submitted', {}))).toBeOnTheScreen(); }); @@ -200,7 +195,6 @@ describe('PureReportActionItem', () => { await waitForBatchedUpdatesWithAct(); expect(screen.getByText(actorEmail)).toBeOnTheScreen(); - // eslint-disable-next-line @typescript-eslint/no-deprecated expect(screen.getByText(translateLocal('iou.submitted', {memo}))).toBeOnTheScreen(); }); @@ -210,7 +204,6 @@ describe('PureReportActionItem', () => { await waitForBatchedUpdatesWithAct(); expect(screen.getByText(actorEmail)).toBeOnTheScreen(); - // eslint-disable-next-line @typescript-eslint/no-deprecated expect(screen.getByText(translateLocal('iou.submitted', {}))).toBeOnTheScreen(); }); }); diff --git a/tests/ui/ReportAttachments.tsx b/tests/ui/ReportAttachments.tsx index 49099d01d5f6..b420334dc81a 100644 --- a/tests/ui/ReportAttachments.tsx +++ b/tests/ui/ReportAttachments.tsx @@ -9,8 +9,6 @@ import OnyxListItemProvider from '@components/OnyxListItemProvider'; import {PlaybackContextProvider} from '@components/VideoPlayerContexts/PlaybackContext'; import {CurrentReportIDContextProvider} from '@hooks/useCurrentReportID'; import {WRITE_COMMANDS} from '@libs/API/types'; -// eslint-disable-next-line @typescript-eslint/no-deprecated -import {translateLocal} from '@libs/Localize'; import createPlatformStackNavigator from '@libs/Navigation/PlatformStackNavigation/createPlatformStackNavigator'; import {waitForIdle} from '@libs/Network/SequentialQueue'; import type {AuthScreensParamList} from '@navigation/types'; @@ -19,7 +17,7 @@ import {AttachmentModalContextProvider} from '@pages/media/AttachmentModalScreen import ONYXKEYS from '@src/ONYXKEYS'; import SCREENS from '@src/SCREENS'; import type {Report, ReportActions} from '@src/types/onyx'; -import {getFetchMockCalls, getGlobalFetchMock, setupGlobalFetchMock, signInWithTestUser} from '../utils/TestHelper'; +import {getFetchMockCalls, getGlobalFetchMock, setupGlobalFetchMock, signInWithTestUser, translateLocal} from '../utils/TestHelper'; import waitForBatchedUpdatesWithAct from '../utils/waitForBatchedUpdatesWithAct'; import wrapOnyxWithWaitForBatchedUpdates from '../utils/wrapOnyxWithWaitForBatchedUpdates'; @@ -197,7 +195,6 @@ describe('ReportAttachments', () => { await waitForBatchedUpdatesWithAct(); // Then the not here page and the loading spinner should not appear. - // eslint-disable-next-line @typescript-eslint/no-deprecated expect(screen.queryByText(translateLocal('notFound.notHere'))).toBeNull(); expect(screen.queryByTestId('attachment-loading-spinner')).toBeNull(); }); diff --git a/tests/ui/ReportDetailsPageTest.tsx b/tests/ui/ReportDetailsPageTest.tsx index 25241ba90e31..967666338d8b 100644 --- a/tests/ui/ReportDetailsPageTest.tsx +++ b/tests/ui/ReportDetailsPageTest.tsx @@ -3,8 +3,6 @@ import React from 'react'; import Onyx from 'react-native-onyx'; import {LocaleContextProvider} from '@components/LocaleContextProvider'; import OnyxListItemProvider from '@components/OnyxListItemProvider'; -// eslint-disable-next-line @typescript-eslint/no-deprecated -import {translateLocal} from '@libs/Localize'; import type Navigation from '@libs/Navigation/Navigation'; import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types'; import type {ReportDetailsNavigatorParamList} from '@libs/Navigation/types'; @@ -16,6 +14,7 @@ import type {Report} from '@src/types/onyx'; import createRandomReportAction from '../utils/collections/reportActions'; import {createRandomReport} from '../utils/collections/reports'; import createRandomTransaction from '../utils/collections/transaction'; +import {translateLocal} from '../utils/TestHelper'; import waitForBatchedUpdatesWithAct from '../utils/waitForBatchedUpdatesWithAct'; jest.mock('@src/components/ConfirmedRoute.tsx'); @@ -90,14 +89,11 @@ describe('ReportDetailsPage', () => { , ); await waitForBatchedUpdatesWithAct(); - // eslint-disable-next-line @typescript-eslint/no-deprecated const submitText = translateLocal('actionableMentionTrackExpense.submit'); await screen.findByText(submitText); // Categorize and share are temporarily disabled - // eslint-disable-next-line @typescript-eslint/no-deprecated // const categorizeText = translateLocal('actionableMentionTrackExpense.categorize'); - // eslint-disable-next-line @typescript-eslint/no-deprecated // const shareText = translateLocal('actionableMentionTrackExpense.share'); // await screen.findByText(categorizeText); // await screen.findByText(shareText); diff --git a/tests/ui/SwitchToExpensifyClassicTest.tsx b/tests/ui/SwitchToExpensifyClassicTest.tsx index 82e99c7b7ae4..baa38ec09480 100644 --- a/tests/ui/SwitchToExpensifyClassicTest.tsx +++ b/tests/ui/SwitchToExpensifyClassicTest.tsx @@ -1,8 +1,6 @@ import * as NativeNavigation from '@react-navigation/native'; import {act, fireEvent, render, screen} from '@testing-library/react-native'; import Onyx from 'react-native-onyx'; -// eslint-disable-next-line @typescript-eslint/no-deprecated -import {translateLocal} from '@libs/Localize'; import App from '@src/App'; import ONYXKEYS from '@src/ONYXKEYS'; import type {NativeNavigationMock} from '../../__mocks__/@react-navigation/native'; @@ -22,8 +20,7 @@ TestHelper.setupApp(); TestHelper.setupGlobalFetchMock(); function navigateToSetting() { - // eslint-disable-next-line @typescript-eslint/no-deprecated - const hintText = translateLocal('sidebarScreen.buttonMySettings'); + const hintText = TestHelper.translateLocal('sidebarScreen.buttonMySettings'); const mySettingButton = screen.queryByAccessibilityHint(hintText); if (mySettingButton) { fireEvent(mySettingButton, 'press'); @@ -32,8 +29,7 @@ function navigateToSetting() { } function navigateToExpensifyClassicFlow() { - // eslint-disable-next-line @typescript-eslint/no-deprecated - const hintText = translateLocal('exitSurvey.goToExpensifyClassic'); + const hintText = TestHelper.translateLocal('exitSurvey.goToExpensifyClassic'); const switchToExpensifyClassicBtn = screen.queryByAccessibilityHint(hintText); if (switchToExpensifyClassicBtn) { fireEvent(switchToExpensifyClassicBtn, 'press'); @@ -46,8 +42,7 @@ function signInAppAndEnterTestFlow(dismissedValue?: boolean): Promise { return waitForBatchedUpdatesWithAct() .then(async () => { await waitForBatchedUpdatesWithAct(); - // eslint-disable-next-line @typescript-eslint/no-deprecated - const hintText = translateLocal('loginForm.loginForm'); + const hintText = TestHelper.translateLocal('loginForm.loginForm'); const loginForm = screen.queryAllByLabelText(hintText); expect(loginForm).toHaveLength(1); @@ -79,8 +74,7 @@ describe('Switch to Expensify Classic flow', () => { test('Should navigate to exit survey reason page', () => { signInAppAndEnterTestFlow(true).then(() => { - // eslint-disable-next-line @typescript-eslint/no-deprecated - expect(screen.getAllByText(translateLocal('exitSurvey.reasonPage.subtitle')).at(0)).toBeOnTheScreen(); + expect(screen.getAllByText(TestHelper.translateLocal('exitSurvey.reasonPage.subtitle')).at(0)).toBeOnTheScreen(); }); }); }); diff --git a/tests/ui/UnreadIndicatorsTest.tsx b/tests/ui/UnreadIndicatorsTest.tsx index 9d4d040a5d1d..01330a8155dd 100644 --- a/tests/ui/UnreadIndicatorsTest.tsx +++ b/tests/ui/UnreadIndicatorsTest.tsx @@ -14,8 +14,6 @@ import {addComment, deleteReportComment, markCommentAsUnread, readNewestAction} import {subscribeToUserEvents} from '@libs/actions/User'; import {lastItem} from '@libs/CollectionUtils'; import DateUtils from '@libs/DateUtils'; -// eslint-disable-next-line @typescript-eslint/no-deprecated -import {translateLocal} from '@libs/Localize'; import LocalNotification from '@libs/Notification/LocalNotification'; import {rand64} from '@libs/NumberUtils'; import {getReportActionText} from '@libs/ReportActionsUtils'; @@ -56,8 +54,7 @@ afterEach(() => { }); function scrollUpToRevealNewMessagesBadge() { - // eslint-disable-next-line @typescript-eslint/no-deprecated - const hintText = translateLocal('sidebarScreen.listOfChatMessages'); + const hintText = TestHelper.translateLocal('sidebarScreen.listOfChatMessages'); fireEvent.scroll(screen.getByLabelText(hintText), { nativeEvent: { contentOffset: { @@ -78,8 +75,7 @@ function scrollUpToRevealNewMessagesBadge() { } function isNewMessagesBadgeVisible(): boolean { - // eslint-disable-next-line @typescript-eslint/no-deprecated - const hintText = translateLocal('accessibilityHints.scrollToNewestMessages'); + const hintText = TestHelper.translateLocal('accessibilityHints.scrollToNewestMessages'); const badge = screen.queryByAccessibilityHint(hintText); const badgeProps = badge?.props as {style: ViewStyle}; const transformStyle = badgeProps.style.transform?.[0] as {translateY: number}; @@ -88,8 +84,7 @@ function isNewMessagesBadgeVisible(): boolean { } function navigateToSidebar(): Promise { - // eslint-disable-next-line @typescript-eslint/no-deprecated - const hintText = translateLocal('accessibilityHints.navigateToChatsList'); + const hintText = TestHelper.translateLocal('accessibilityHints.navigateToChatsList'); const reportHeaderBackButton = screen.queryByAccessibilityHint(hintText); if (reportHeaderBackButton) { fireEvent(reportHeaderBackButton, 'press'); @@ -98,8 +93,7 @@ function navigateToSidebar(): Promise { } function areYouOnChatListScreen(): boolean { - // eslint-disable-next-line @typescript-eslint/no-deprecated - const hintText = translateLocal('sidebarScreen.listOfChats'); + const hintText = TestHelper.translateLocal('sidebarScreen.listOfChats'); const sidebarLinks = screen.queryAllByLabelText(hintText, {includeHiddenElements: true}); return !sidebarLinks?.at(0)?.props?.accessibilityElementsHidden; @@ -253,8 +247,7 @@ describe('Unread Indicators', () => { expect((LocalNotification.showCommentNotification as jest.Mock).mock.calls).toHaveLength(0); // Verify the sidebar links are rendered - // eslint-disable-next-line @typescript-eslint/no-deprecated - const sidebarLinksHintText = translateLocal('sidebarScreen.listOfChats'); + const sidebarLinksHintText = TestHelper.translateLocal('sidebarScreen.listOfChats'); const sidebarLinks = screen.queryAllByLabelText(sidebarLinksHintText); expect(sidebarLinks).toHaveLength(1); @@ -263,8 +256,7 @@ describe('Unread Indicators', () => { expect(optionRows).toHaveLength(1); // And that the text is bold - // eslint-disable-next-line @typescript-eslint/no-deprecated - const displayNameHintText = translateLocal('accessibilityHints.chatUserDisplayNames'); + const displayNameHintText = TestHelper.translateLocal('accessibilityHints.chatUserDisplayNames'); const displayNameText = screen.queryByLabelText(displayNameHintText); expect((displayNameText?.props?.style as TextStyle)?.fontWeight).toBe(FontUtils.fontWeight.bold); @@ -274,18 +266,15 @@ describe('Unread Indicators', () => { act(() => (NativeNavigation as NativeNavigationMock).triggerTransitionEnd()); // That the report actions are visible along with the created action - // eslint-disable-next-line @typescript-eslint/no-deprecated - const welcomeMessageHintText = translateLocal('accessibilityHints.chatWelcomeMessage'); + const welcomeMessageHintText = TestHelper.translateLocal('accessibilityHints.chatWelcomeMessage'); const createdAction = screen.queryByLabelText(welcomeMessageHintText); expect(createdAction).toBeTruthy(); - // eslint-disable-next-line @typescript-eslint/no-deprecated - const reportCommentsHintText = translateLocal('accessibilityHints.chatMessage'); + const reportCommentsHintText = TestHelper.translateLocal('accessibilityHints.chatMessage'); const reportComments = screen.queryAllByLabelText(reportCommentsHintText); expect(reportComments).toHaveLength(9); // Since the last read timestamp is the timestamp of action 3 we should have an unread indicator above the next "unread" action which will // have actionID of 4 - // eslint-disable-next-line @typescript-eslint/no-deprecated - const newMessageLineIndicatorHintText = translateLocal('accessibilityHints.newMessageLineIndicator'); + const newMessageLineIndicatorHintText = TestHelper.translateLocal('accessibilityHints.newMessageLineIndicator'); const unreadIndicator = screen.queryAllByLabelText(newMessageLineIndicatorHintText); expect(unreadIndicator).toHaveLength(1); const reportActionID = unreadIndicator.at(0)?.props?.['data-action-id'] as string; @@ -301,8 +290,7 @@ describe('Unread Indicators', () => { .then(() => { act(() => (NativeNavigation as NativeNavigationMock).triggerTransitionEnd()); // Verify the unread indicator is present - // eslint-disable-next-line @typescript-eslint/no-deprecated - const newMessageLineIndicatorHintText = translateLocal('accessibilityHints.newMessageLineIndicator'); + const newMessageLineIndicatorHintText = TestHelper.translateLocal('accessibilityHints.newMessageLineIndicator'); const unreadIndicator = screen.queryAllByLabelText(newMessageLineIndicatorHintText); expect(unreadIndicator).toHaveLength(1); }) @@ -325,8 +313,7 @@ describe('Unread Indicators', () => { }) .then(() => { // Verify the unread indicator is not present - // eslint-disable-next-line @typescript-eslint/no-deprecated - const newMessageLineIndicatorHintText = translateLocal('accessibilityHints.newMessageLineIndicator'); + const newMessageLineIndicatorHintText = TestHelper.translateLocal('accessibilityHints.newMessageLineIndicator'); const unreadIndicator = screen.queryAllByLabelText(newMessageLineIndicatorHintText); expect(unreadIndicator).toHaveLength(0); // Tap on the chat again @@ -334,8 +321,7 @@ describe('Unread Indicators', () => { }) .then(() => { // Verify the unread indicator is not present - // eslint-disable-next-line @typescript-eslint/no-deprecated - const newMessageLineIndicatorHintText = translateLocal('accessibilityHints.newMessageLineIndicator'); + const newMessageLineIndicatorHintText = TestHelper.translateLocal('accessibilityHints.newMessageLineIndicator'); const unreadIndicator = screen.queryAllByLabelText(newMessageLineIndicatorHintText); expect(unreadIndicator).toHaveLength(0); expect(areYouOnChatListScreen()).toBe(false); @@ -408,8 +394,7 @@ describe('Unread Indicators', () => { const optionRows = screen.queryAllByAccessibilityHint(TestHelper.getNavigateToChatHintRegex()); expect(optionRows).toHaveLength(2); // Verify the text for both chats are bold indicating that nothing has not yet been read - // eslint-disable-next-line @typescript-eslint/no-deprecated - const displayNameHintTexts = translateLocal('accessibilityHints.chatUserDisplayNames'); + const displayNameHintTexts = TestHelper.translateLocal('accessibilityHints.chatUserDisplayNames'); const displayNameTexts = screen.queryAllByLabelText(displayNameHintTexts); expect(displayNameTexts).toHaveLength(2); const firstReportOption = displayNameTexts.at(0); @@ -427,8 +412,7 @@ describe('Unread Indicators', () => { .then(() => { 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 - // eslint-disable-next-line @typescript-eslint/no-deprecated - const hintText = translateLocal('accessibilityHints.chatUserDisplayNames'); + const hintText = TestHelper.translateLocal('accessibilityHints.chatUserDisplayNames'); const displayNameTexts = screen.queryAllByLabelText(hintText, {includeHiddenElements: true}); expect(displayNameTexts).toHaveLength(2); expect((displayNameTexts.at(0)?.props?.style as TextStyle)?.fontWeight).toBe(FontUtils.fontWeight.normal); @@ -449,8 +433,7 @@ describe('Unread Indicators', () => { }) .then(() => { // Verify the indicator appears above the last action - // eslint-disable-next-line @typescript-eslint/no-deprecated - const newMessageLineIndicatorHintText = translateLocal('accessibilityHints.newMessageLineIndicator'); + const newMessageLineIndicatorHintText = TestHelper.translateLocal('accessibilityHints.newMessageLineIndicator'); const unreadIndicator = screen.queryAllByLabelText(newMessageLineIndicatorHintText); expect(unreadIndicator).toHaveLength(1); const reportActionID = unreadIndicator.at(0)?.props?.['data-action-id'] as string; @@ -463,8 +446,7 @@ describe('Unread Indicators', () => { .then(navigateToSidebar) .then(() => { // Verify the report is marked as unread in the sidebar - // eslint-disable-next-line @typescript-eslint/no-deprecated - const hintText = translateLocal('accessibilityHints.chatUserDisplayNames'); + const hintText = TestHelper.translateLocal('accessibilityHints.chatUserDisplayNames'); const displayNameTexts = screen.queryAllByLabelText(hintText); expect(displayNameTexts).toHaveLength(1); expect((displayNameTexts.at(0)?.props?.style as TextStyle)?.fontWeight).toBe(FontUtils.fontWeight.bold); @@ -476,8 +458,7 @@ describe('Unread Indicators', () => { .then(() => navigateToSidebar()) .then(() => { // Verify the report is now marked as read - // eslint-disable-next-line @typescript-eslint/no-deprecated - const hintText = translateLocal('accessibilityHints.chatUserDisplayNames'); + const hintText = TestHelper.translateLocal('accessibilityHints.chatUserDisplayNames'); const displayNameTexts = screen.queryAllByLabelText(hintText); expect(displayNameTexts).toHaveLength(1); expect((displayNameTexts.at(0)?.props?.style as TextStyle)?.fontWeight).toBe(undefined); @@ -487,8 +468,7 @@ describe('Unread Indicators', () => { return navigateToSidebarOption(0); }) .then(() => { - // eslint-disable-next-line @typescript-eslint/no-deprecated - const newMessageLineIndicatorHintText = translateLocal('accessibilityHints.newMessageLineIndicator'); + const newMessageLineIndicatorHintText = TestHelper.translateLocal('accessibilityHints.newMessageLineIndicator'); const unreadIndicator = screen.queryAllByLabelText(newMessageLineIndicatorHintText); expect(unreadIndicator).toHaveLength(0); @@ -508,8 +488,7 @@ describe('Unread Indicators', () => { }) .then(async () => { act(() => (NativeNavigation as NativeNavigationMock).triggerTransitionEnd()); - // eslint-disable-next-line @typescript-eslint/no-deprecated - const newMessageLineIndicatorHintText = translateLocal('accessibilityHints.newMessageLineIndicator'); + const newMessageLineIndicatorHintText = TestHelper.translateLocal('accessibilityHints.newMessageLineIndicator'); const unreadIndicator = screen.queryAllByLabelText(newMessageLineIndicatorHintText); expect(unreadIndicator).toHaveLength(1); @@ -518,8 +497,7 @@ describe('Unread Indicators', () => { return waitForBatchedUpdates(); }) .then(() => { - // eslint-disable-next-line @typescript-eslint/no-deprecated - const newMessageLineIndicatorHintText = translateLocal('accessibilityHints.newMessageLineIndicator'); + const newMessageLineIndicatorHintText = TestHelper.translateLocal('accessibilityHints.newMessageLineIndicator'); const unreadIndicator = screen.queryAllByLabelText(newMessageLineIndicatorHintText); expect(unreadIndicator).toHaveLength(1); })); @@ -534,8 +512,7 @@ describe('Unread Indicators', () => { return navigateToSidebarOption(0); }) .then(() => { - // eslint-disable-next-line @typescript-eslint/no-deprecated - const newMessageLineIndicatorHintText = translateLocal('accessibilityHints.newMessageLineIndicator'); + const newMessageLineIndicatorHintText = TestHelper.translateLocal('accessibilityHints.newMessageLineIndicator'); const unreadIndicator = screen.queryAllByLabelText(newMessageLineIndicatorHintText); expect(unreadIndicator).toHaveLength(1); @@ -544,8 +521,7 @@ describe('Unread Indicators', () => { }) .then(() => navigateToSidebarOption(0)) .then(() => { - // eslint-disable-next-line @typescript-eslint/no-deprecated - const newMessageLineIndicatorHintText = translateLocal('accessibilityHints.newMessageLineIndicator'); + const newMessageLineIndicatorHintText = TestHelper.translateLocal('accessibilityHints.newMessageLineIndicator'); const unreadIndicator = screen.queryAllByLabelText(newMessageLineIndicatorHintText); expect(unreadIndicator).toHaveLength(0); @@ -554,8 +530,7 @@ describe('Unread Indicators', () => { return waitForBatchedUpdates(); }) .then(() => { - // eslint-disable-next-line @typescript-eslint/no-deprecated - const newMessageLineIndicatorHintText = translateLocal('accessibilityHints.newMessageLineIndicator'); + const newMessageLineIndicatorHintText = TestHelper.translateLocal('accessibilityHints.newMessageLineIndicator'); let unreadIndicator = screen.queryAllByLabelText(newMessageLineIndicatorHintText); expect(unreadIndicator).toHaveLength(1); @@ -596,8 +571,7 @@ describe('Unread Indicators', () => { }) .then(() => { // Verify the chat preview text matches the last comment from the current user - // eslint-disable-next-line @typescript-eslint/no-deprecated - const hintText = translateLocal('accessibilityHints.lastChatMessagePreview'); + const hintText = TestHelper.translateLocal('accessibilityHints.lastChatMessagePreview'); const alternateText = screen.queryAllByLabelText(hintText, {includeHiddenElements: true}); expect(alternateText).toHaveLength(1); @@ -610,8 +584,7 @@ describe('Unread Indicators', () => { return waitForBatchedUpdates(); }) .then(() => { - // eslint-disable-next-line @typescript-eslint/no-deprecated - const hintText = translateLocal('accessibilityHints.lastChatMessagePreview'); + const hintText = TestHelper.translateLocal('accessibilityHints.lastChatMessagePreview'); const alternateText = screen.queryAllByLabelText(hintText, {includeHiddenElements: true}); expect(alternateText).toHaveLength(1); expect(screen.getAllByText('Comment 9').at(0)).toBeOnTheScreen(); @@ -649,8 +622,7 @@ describe('Unread Indicators', () => { } const secondNewReportAction = reportActions ? lastItem(reportActions) : undefined; - // eslint-disable-next-line @typescript-eslint/no-deprecated - const newMessageLineIndicatorHintText = translateLocal('accessibilityHints.newMessageLineIndicator'); + const newMessageLineIndicatorHintText = TestHelper.translateLocal('accessibilityHints.newMessageLineIndicator'); const unreadIndicator = screen.queryAllByLabelText(newMessageLineIndicatorHintText); expect(unreadIndicator).toHaveLength(1); const reportActionID = unreadIndicator.at(0)?.props?.['data-action-id'] as string; @@ -675,8 +647,7 @@ describe('Unread Indicators', () => { }); // Then the new line indicator shouldn't be displayed - // eslint-disable-next-line @typescript-eslint/no-deprecated - const newMessageLineIndicatorHintText = translateLocal('accessibilityHints.newMessageLineIndicator'); + const newMessageLineIndicatorHintText = TestHelper.translateLocal('accessibilityHints.newMessageLineIndicator'); const unreadIndicator = screen.queryAllByLabelText(newMessageLineIndicatorHintText); expect(unreadIndicator).toHaveLength(0); }); @@ -744,8 +715,7 @@ describe('Unread Indicators', () => { await waitForBatchedUpdates(); // Then the new line indicator shouldn't be displayed - // eslint-disable-next-line @typescript-eslint/no-deprecated - const newMessageLineIndicatorHintText = translateLocal('accessibilityHints.newMessageLineIndicator'); + const newMessageLineIndicatorHintText = TestHelper.translateLocal('accessibilityHints.newMessageLineIndicator'); const unreadIndicator = screen.queryAllByLabelText(newMessageLineIndicatorHintText); expect(unreadIndicator).toHaveLength(0); }); @@ -779,8 +749,7 @@ describe('Unread Indicators', () => { markCommentAsUnread(REPORT_ID, {reportActionID: -1} as unknown as ReportAction); // Marking the chat as unread from LHN passing a dummy reportActionID await waitForBatchedUpdates(); - // eslint-disable-next-line @typescript-eslint/no-deprecated - const hintText = translateLocal('accessibilityHints.chatUserDisplayNames'); + const hintText = TestHelper.translateLocal('accessibilityHints.chatUserDisplayNames'); const displayNameTexts = screen.queryAllByLabelText(hintText); expect(displayNameTexts).toHaveLength(1); expect((displayNameTexts.at(0)?.props?.style as TextStyle)?.fontWeight).toBe(FontUtils.fontWeight.bold); diff --git a/tests/ui/WalletExpensifyCardPageTest.tsx b/tests/ui/WalletExpensifyCardPageTest.tsx index da1eb5836cfe..a1b573117c3e 100644 --- a/tests/ui/WalletExpensifyCardPageTest.tsx +++ b/tests/ui/WalletExpensifyCardPageTest.tsx @@ -9,8 +9,6 @@ import OnyxListItemProvider from '@components/OnyxListItemProvider'; import {CurrentReportIDContextProvider} from '@hooks/useCurrentReportID'; import * as useResponsiveLayoutModule from '@hooks/useResponsiveLayout'; import type ResponsiveLayoutResult from '@hooks/useResponsiveLayout/types'; -// eslint-disable-next-line @typescript-eslint/no-deprecated -import {translateLocal} from '@libs/Localize'; import createPlatformStackNavigator from '@libs/Navigation/PlatformStackNavigation/createPlatformStackNavigator'; import type {SettingsNavigatorParamList} from '@navigation/types'; import ExpensifyCardPage from '@pages/settings/Wallet/ExpensifyCardPage'; @@ -103,14 +101,12 @@ describe('ExpensifyCardPage', () => { // Verify that the "Report Fraud" option is displayed on the screen. await waitFor(() => { - // eslint-disable-next-line @typescript-eslint/no-deprecated - expect(screen.getByText(translateLocal('cardPage.reportFraud'))).toBeOnTheScreen(); + expect(screen.getByText(TestHelper.translateLocal('cardPage.reportFraud'))).toBeOnTheScreen(); }); // Verify that the "Reveal Details" option is displayed on the screen. await waitFor(() => { - // eslint-disable-next-line @typescript-eslint/no-deprecated - expect(screen.getByText(translateLocal('cardPage.cardDetails.revealDetails'))).toBeOnTheScreen(); + expect(screen.getByText(TestHelper.translateLocal('cardPage.cardDetails.revealDetails'))).toBeOnTheScreen(); }); // Unmount the component after assertions to clean up. @@ -153,14 +149,12 @@ describe('ExpensifyCardPage', () => { // Verify that the "Report Fraud" option is NOT displayed on the screen. await waitFor(() => { - // eslint-disable-next-line @typescript-eslint/no-deprecated - expect(screen.queryByText(translateLocal('cardPage.reportFraud'))).not.toBeOnTheScreen(); + expect(screen.queryByText(TestHelper.translateLocal('cardPage.reportFraud'))).not.toBeOnTheScreen(); }); // Verify that the "Reveal Details" option is NOT displayed on the screen. await waitFor(() => { - // eslint-disable-next-line @typescript-eslint/no-deprecated - expect(screen.queryByText(translateLocal('cardPage.cardDetails.revealDetails'))).not.toBeOnTheScreen(); + expect(screen.queryByText(TestHelper.translateLocal('cardPage.cardDetails.revealDetails'))).not.toBeOnTheScreen(); }); // Unmount the component after assertions to clean up. @@ -197,8 +191,7 @@ describe('ExpensifyCardPage', () => { // Verify that the "PIN" option is not displayed on the screen. await waitFor(() => { - // eslint-disable-next-line @typescript-eslint/no-deprecated - expect(screen.queryByText(translateLocal('cardPage.physicalCardPin'))).not.toBeOnTheScreen(); + expect(screen.queryByText(TestHelper.translateLocal('cardPage.physicalCardPin'))).not.toBeOnTheScreen(); }); // Unmount the component after assertions to clean up. @@ -235,8 +228,7 @@ describe('ExpensifyCardPage', () => { // Verify that the "PIN" option is displayed on the screen. await waitFor(() => { - // eslint-disable-next-line @typescript-eslint/no-deprecated - expect(screen.getByText(translateLocal('cardPage.physicalCardPin'))).toBeOnTheScreen(); + expect(screen.getByText(TestHelper.translateLocal('cardPage.physicalCardPin'))).toBeOnTheScreen(); }); // Unmount the component after assertions to clean up. diff --git a/tests/ui/WorkEmailOnboarding.tsx b/tests/ui/WorkEmailOnboarding.tsx index dba4b2c168c5..f4cf99bab6cc 100644 --- a/tests/ui/WorkEmailOnboarding.tsx +++ b/tests/ui/WorkEmailOnboarding.tsx @@ -13,8 +13,6 @@ import type ResponsiveLayoutResult from '@hooks/useResponsiveLayout/types'; import {openOldDotLink} from '@libs/actions/Link'; import {AddWorkEmail} from '@libs/actions/Session'; import HttpUtils from '@libs/HttpUtils'; -// eslint-disable-next-line @typescript-eslint/no-deprecated -import {translateLocal} from '@libs/Localize'; import Navigation from '@libs/Navigation/Navigation'; import createPlatformStackNavigator from '@libs/Navigation/PlatformStackNavigation/createPlatformStackNavigator'; import type {OnboardingModalNavigatorParamList} from '@navigation/types'; @@ -253,17 +251,14 @@ describe('OnboardingWorkEmail Page', () => { await waitForBatchedUpdatesWithAct(); await waitFor(() => { - // eslint-disable-next-line @typescript-eslint/no-deprecated - expect(screen.getByText(translateLocal('onboarding.workEmail.title'))).toBeOnTheScreen(); + expect(screen.getByText(TestHelper.translateLocal('onboarding.workEmail.title'))).toBeOnTheScreen(); }); await waitFor(() => { - // eslint-disable-next-line @typescript-eslint/no-deprecated - expect(screen.getByText(translateLocal('onboarding.workEmail.addWorkEmail'))).toBeOnTheScreen(); + expect(screen.getByText(TestHelper.translateLocal('onboarding.workEmail.addWorkEmail'))).toBeOnTheScreen(); }); await waitFor(() => { - // eslint-disable-next-line @typescript-eslint/no-deprecated - expect(screen.getByText(translateLocal('common.skip'))).toBeOnTheScreen(); + expect(screen.getByText(TestHelper.translateLocal('common.skip'))).toBeOnTheScreen(); }); unmount(); @@ -426,8 +421,7 @@ describe('OnboardingWorkEmailValidation Page', () => { await waitForBatchedUpdatesWithAct(); await waitFor(() => { - // eslint-disable-next-line @typescript-eslint/no-deprecated - expect(screen.getByText(translateLocal('onboarding.workEmailValidation.magicCodeSent', {workEmail}))).toBeOnTheScreen(); + expect(screen.getByText(TestHelper.translateLocal('onboarding.workEmailValidation.magicCodeSent', {workEmail}))).toBeOnTheScreen(); }); unmount(); @@ -456,8 +450,7 @@ describe('OnboardingWorkEmailValidation Page', () => { await waitForBatchedUpdatesWithAct(); await waitFor(() => { - // eslint-disable-next-line @typescript-eslint/no-deprecated - expect(screen.getByText(translateLocal('onboarding.mergeBlockScreen.subtitle', {workEmail}))).toBeOnTheScreen(); + expect(screen.getByText(TestHelper.translateLocal('onboarding.mergeBlockScreen.subtitle', {workEmail}))).toBeOnTheScreen(); }); unmount(); @@ -480,8 +473,7 @@ describe('OnboardingWorkEmailValidation Page', () => { const {unmount} = renderOnboardingWorkEmailValidationPage(SCREENS.ONBOARDING.WORK_EMAIL_VALIDATION, {backTo: ''}); await waitForBatchedUpdatesWithAct(); - // eslint-disable-next-line @typescript-eslint/no-deprecated - const skipButton = screen.getByText(translateLocal('common.skip')); + const skipButton = screen.getByText(TestHelper.translateLocal('common.skip')); const mockEvent = { nativeEvent: {}, @@ -636,8 +628,7 @@ describe('OnboardingWorkEmailValidation Page', () => { await waitForBatchedUpdatesWithAct(); await waitFor(() => { - // eslint-disable-next-line @typescript-eslint/no-deprecated - expect(screen.getByText(translateLocal('onboarding.mergeBlockScreen.subtitle', {workEmail}))).toBeOnTheScreen(); + expect(screen.getByText(TestHelper.translateLocal('onboarding.mergeBlockScreen.subtitle', {workEmail}))).toBeOnTheScreen(); }); unmount(); diff --git a/tests/ui/WorkspaceCategoriesTest.tsx b/tests/ui/WorkspaceCategoriesTest.tsx index fd6fca86cc02..94904743cbab 100644 --- a/tests/ui/WorkspaceCategoriesTest.tsx +++ b/tests/ui/WorkspaceCategoriesTest.tsx @@ -9,8 +9,6 @@ import OnyxListItemProvider from '@components/OnyxListItemProvider'; import {CurrentReportIDContextProvider} from '@hooks/useCurrentReportID'; import * as useResponsiveLayoutModule from '@hooks/useResponsiveLayout'; import type ResponsiveLayoutResult from '@hooks/useResponsiveLayout/types'; -// eslint-disable-next-line @typescript-eslint/no-deprecated -import {translateLocal} from '@libs/Localize'; import createPlatformStackNavigator from '@libs/Navigation/PlatformStackNavigation/createPlatformStackNavigator'; import type {WorkspaceSplitNavigatorParamList} from '@navigation/types'; import WorkspaceCategoriesPage from '@pages/workspace/categories/WorkspaceCategoriesPage'; @@ -131,8 +129,7 @@ describe('WorkspaceCategories', () => { // Wait for menu items to be visible await waitFor(() => { - // eslint-disable-next-line @typescript-eslint/no-deprecated - const deleteText = translateLocal('workspace.categories.deleteCategories'); + const deleteText = TestHelper.translateLocal('workspace.categories.deleteCategories'); expect(screen.getByText(deleteText)).toBeOnTheScreen(); }); @@ -153,21 +150,18 @@ describe('WorkspaceCategories', () => { // After clicking delete categories dropdown menu item, verify the confirmation modal appears await waitFor(() => { - // eslint-disable-next-line @typescript-eslint/no-deprecated - const confirmModalPrompt = translateLocal('workspace.categories.deleteCategoriesPrompt'); + const confirmModalPrompt = TestHelper.translateLocal('workspace.categories.deleteCategoriesPrompt'); expect(screen.getByText(confirmModalPrompt)).toBeOnTheScreen(); }); // Verify the delete button in the modal is visible await waitFor(() => { - // eslint-disable-next-line @typescript-eslint/no-deprecated - const deleteConfirmButton = screen.getByLabelText(translateLocal('common.delete')); + const deleteConfirmButton = screen.getByLabelText(TestHelper.translateLocal('common.delete')); expect(deleteConfirmButton).toBeOnTheScreen(); }); // Click the delete button in the confirmation modal - // eslint-disable-next-line @typescript-eslint/no-deprecated - const deleteConfirmButton = screen.getByLabelText(translateLocal('common.delete')); + const deleteConfirmButton = screen.getByLabelText(TestHelper.translateLocal('common.delete')); fireEvent.press(deleteConfirmButton); await waitForBatchedUpdatesWithAct(); @@ -241,8 +235,7 @@ describe('WorkspaceCategories', () => { // Wait for menu items to be visible await waitFor(() => { - // eslint-disable-next-line @typescript-eslint/no-deprecated - const disableText = translateLocal('workspace.categories.disableCategories'); + const disableText = TestHelper.translateLocal('workspace.categories.disableCategories'); expect(screen.getByText(disableText)).toBeOnTheScreen(); }); @@ -263,8 +256,7 @@ describe('WorkspaceCategories', () => { // After clicking disable categories dropdown menu item, verify the blocking modal appears await waitFor(() => { - // eslint-disable-next-line @typescript-eslint/no-deprecated - const blockingPrompt = translateLocal('workspace.categories.cannotDeleteOrDisableAllCategories.title'); + const blockingPrompt = TestHelper.translateLocal('workspace.categories.cannotDeleteOrDisableAllCategories.title'); expect(screen.getByText(blockingPrompt)).toBeOnTheScreen(); }); diff --git a/tests/ui/WorkspaceTagsTest.tsx b/tests/ui/WorkspaceTagsTest.tsx index fdfec72ef3c7..cd4b61f27259 100644 --- a/tests/ui/WorkspaceTagsTest.tsx +++ b/tests/ui/WorkspaceTagsTest.tsx @@ -9,8 +9,6 @@ import OnyxListItemProvider from '@components/OnyxListItemProvider'; import {CurrentReportIDContextProvider} from '@hooks/useCurrentReportID'; import * as useResponsiveLayoutModule from '@hooks/useResponsiveLayout'; import type ResponsiveLayoutResult from '@hooks/useResponsiveLayout/types'; -// eslint-disable-next-line @typescript-eslint/no-deprecated -import {translateLocal} from '@libs/Localize'; import createPlatformStackNavigator from '@libs/Navigation/PlatformStackNavigation/createPlatformStackNavigator'; import type {WorkspaceSplitNavigatorParamList} from '@navigation/types'; import WorkspaceTagsPage from '@pages/workspace/tags/WorkspaceTagsPage'; @@ -124,8 +122,7 @@ describe('WorkspaceTags', () => { // Wait for the "Select" option to appear await waitFor(() => { - // eslint-disable-next-line @typescript-eslint/no-deprecated - expect(screen.getByText(translateLocal('common.select'))).toBeOnTheScreen(); + expect(screen.getByText(TestHelper.translateLocal('common.select'))).toBeOnTheScreen(); }); unmount(); @@ -170,8 +167,7 @@ describe('WorkspaceTags', () => { fireEvent.press(screen.getByTestId(dropdownMenuButtonTestID)); await waitFor(() => { - // eslint-disable-next-line @typescript-eslint/no-deprecated - expect(screen.getByText(translateLocal('workspace.tags.disableTags'))).toBeOnTheScreen(); + expect(screen.getByText(TestHelper.translateLocal('workspace.tags.disableTags'))).toBeOnTheScreen(); }); const disableMenuItem = screen.getByTestId('PopoverMenuItem-Disable tags'); @@ -179,8 +175,7 @@ describe('WorkspaceTags', () => { fireEvent.press(disableMenuItem, mockEvent); await waitFor(() => { - // eslint-disable-next-line @typescript-eslint/no-deprecated - expect(screen.getByText(translateLocal('workspace.tags.cannotDeleteOrDisableAllTags.title'))).toBeOnTheScreen(); + expect(screen.getByText(TestHelper.translateLocal('workspace.tags.cannotDeleteOrDisableAllTags.title'))).toBeOnTheScreen(); }); unmount(); diff --git a/tests/ui/components/EmptySearchViewTest.tsx b/tests/ui/components/EmptySearchViewTest.tsx index 0d66cc4df24e..5852885bc7a4 100644 --- a/tests/ui/components/EmptySearchViewTest.tsx +++ b/tests/ui/components/EmptySearchViewTest.tsx @@ -3,12 +3,11 @@ import React from 'react'; import Onyx from 'react-native-onyx'; import {LocaleContextProvider} from '@components/LocaleContextProvider'; import OnyxListItemProvider from '@components/OnyxListItemProvider'; -// eslint-disable-next-line @typescript-eslint/no-deprecated -import {translateLocal} from '@libs/Localize'; import {buildQueryStringFromFilterFormValues, buildSearchQueryJSON} from '@libs/SearchQueryUtils'; import EmptySearchView from '@pages/Search/EmptySearchView'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; +import {translateLocal} from '../../utils/TestHelper'; import waitForBatchedUpdatesWithAct from '../../utils/waitForBatchedUpdatesWithAct'; // Wrapper component with OnyxListItemProvider @@ -68,13 +67,10 @@ describe('EmptySearchView', () => { await waitForBatchedUpdatesWithAct(); // Then it should display create expenses and take a test drive buttons - // eslint-disable-next-line @typescript-eslint/no-deprecated expect(await screen.findByText(translateLocal('iou.createExpense'))).toBeVisible(); - // eslint-disable-next-line @typescript-eslint/no-deprecated expect(await screen.findByText(translateLocal('emptySearchView.takeATestDrive'))).toBeVisible(); // And correct modal subtitle - // eslint-disable-next-line @typescript-eslint/no-deprecated expect(screen.getByText(translateLocal('search.searchResults.emptyExpenseResults.subtitle'))).toBeVisible(); }); @@ -96,13 +92,10 @@ describe('EmptySearchView', () => { ); // Then it should display create expenses button - // eslint-disable-next-line @typescript-eslint/no-deprecated expect(await screen.findByText(translateLocal('iou.createExpense'))).toBeVisible(); - // eslint-disable-next-line @typescript-eslint/no-deprecated expect(screen.queryByText(translateLocal('emptySearchView.takeATestDrive'))).not.toBeOnTheScreen(); // And correct modal subtitle - // eslint-disable-next-line @typescript-eslint/no-deprecated expect(screen.getByText(translateLocal('search.searchResults.emptyExpenseResults.subtitleWithOnlyCreateButton'))).toBeVisible(); }); @@ -149,11 +142,9 @@ describe('EmptySearchView', () => { await waitForBatchedUpdatesWithAct(); // Then it should display the submit empty results title - // eslint-disable-next-line @typescript-eslint/no-deprecated expect(screen.getByText(translateLocal('search.searchResults.emptySubmitResults.title'))).toBeVisible(); // And it should display the "Create Report" button - // eslint-disable-next-line @typescript-eslint/no-deprecated expect(screen.getByText(translateLocal('report.newReport.createReport'))).toBeVisible(); }); @@ -187,11 +178,9 @@ describe('EmptySearchView', () => { await waitForBatchedUpdatesWithAct(); // Then it should display the submit empty results title - // eslint-disable-next-line @typescript-eslint/no-deprecated expect(screen.getByText(translateLocal('search.searchResults.emptySubmitResults.title'))).toBeVisible(); // And it should not display the "Create Report" button - // eslint-disable-next-line @typescript-eslint/no-deprecated expect(screen.queryByText(translateLocal('report.newReport.createReport'))).not.toBeOnTheScreen(); }); }); @@ -218,13 +207,10 @@ describe('EmptySearchView', () => { ); // Then it should display send invoice and take a test drive buttons - // eslint-disable-next-line @typescript-eslint/no-deprecated expect(await screen.findByText(translateLocal('workspace.invoices.sendInvoice'))).toBeVisible(); - // eslint-disable-next-line @typescript-eslint/no-deprecated expect(await screen.findByText(translateLocal('emptySearchView.takeATestDrive'))).toBeVisible(); // And correct modal subtitle - // eslint-disable-next-line @typescript-eslint/no-deprecated expect(screen.getByText(translateLocal('search.searchResults.emptyInvoiceResults.subtitle'))).toBeVisible(); }); @@ -246,13 +232,10 @@ describe('EmptySearchView', () => { ); // Then it should display Send invoice button - // eslint-disable-next-line @typescript-eslint/no-deprecated expect(await screen.findByText(translateLocal('workspace.invoices.sendInvoice'))).toBeVisible(); - // eslint-disable-next-line @typescript-eslint/no-deprecated expect(screen.queryByText(translateLocal('emptySearchView.takeATestDrive'))).not.toBeOnTheScreen(); // And correct modal subtitle - // eslint-disable-next-line @typescript-eslint/no-deprecated expect(screen.getByText(translateLocal('search.searchResults.emptyInvoiceResults.subtitleWithOnlyCreateButton'))).toBeVisible(); }); }); diff --git a/tests/ui/components/IOURequestStepConfirmationPageTest.tsx b/tests/ui/components/IOURequestStepConfirmationPageTest.tsx index 9a57c97486f0..57736af5bdf7 100644 --- a/tests/ui/components/IOURequestStepConfirmationPageTest.tsx +++ b/tests/ui/components/IOURequestStepConfirmationPageTest.tsx @@ -4,13 +4,11 @@ import Onyx from 'react-native-onyx'; import {CurrentUserPersonalDetailsProvider} from '@components/CurrentUserPersonalDetailsProvider'; import {LocaleContextProvider} from '@components/LocaleContextProvider'; import OnyxListItemProvider from '@components/OnyxListItemProvider'; -// eslint-disable-next-line @typescript-eslint/no-deprecated -import {translateLocal} from '@libs/Localize'; import IOURequestStepConfirmationWithWritableReportOrNotFound from '@pages/iou/request/step/IOURequestStepConfirmation'; import ONYXKEYS from '@src/ONYXKEYS'; import type Transaction from '@src/types/onyx/Transaction'; import * as IOU from '../../../src/libs/actions/IOU'; -import {signInWithTestUser} from '../../utils/TestHelper'; +import {signInWithTestUser, translateLocal} from '../../utils/TestHelper'; import waitForBatchedUpdatesWithAct from '../../utils/waitForBatchedUpdatesWithAct'; jest.mock('@rnmapbox/maps', () => { @@ -165,7 +163,6 @@ describe('IOURequestStepConfirmationPageTest', () => { , ); - // eslint-disable-next-line @typescript-eslint/no-deprecated fireEvent.press(await screen.findByText(translateLocal('iou.splitExpense'))); expect(IOU.startSplitBill).toHaveBeenCalledTimes(1); }); @@ -215,7 +212,6 @@ describe('IOURequestStepConfirmationPageTest', () => { , ); - // eslint-disable-next-line @typescript-eslint/no-deprecated fireEvent.press(await screen.findByText(translateLocal('iou.createExpenses', {expensesNumber: 2}))); expect(IOU.startSplitBill).toHaveBeenCalledTimes(2); }); diff --git a/tests/ui/components/OnboardingHelpDropdownButtonTest.tsx b/tests/ui/components/OnboardingHelpDropdownButtonTest.tsx index 59629f7c145a..3940d2426525 100644 --- a/tests/ui/components/OnboardingHelpDropdownButtonTest.tsx +++ b/tests/ui/components/OnboardingHelpDropdownButtonTest.tsx @@ -7,12 +7,11 @@ import OnboardingHelpDropdownButton from '@components/OnboardingHelpDropdownButt import OnyxListItemProvider from '@components/OnyxListItemProvider'; import {openExternalLink} from '@libs/actions/Link'; import {cancelBooking, clearBookingDraft, rescheduleBooking} from '@libs/actions/ScheduleCall'; -// eslint-disable-next-line @typescript-eslint/no-deprecated -import {translateLocal} from '@libs/Localize'; import Navigation from '@libs/Navigation/Navigation'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; +import {translateLocal} from '../../utils/TestHelper'; import waitForBatchedUpdatesWithAct from '../../utils/waitForBatchedUpdatesWithAct'; // Mock the dependencies @@ -117,14 +116,10 @@ describe('OnboardingHelpDropdownButton', () => { await waitForBatchedUpdatesWithAct(); // Then only schedule call option is visible - // eslint-disable-next-line @typescript-eslint/no-deprecated const scheduleCallOption = screen.getByText(translateLocal('getAssistancePage.scheduleACall')); expect(scheduleCallOption).toBeOnTheScreen(); - // eslint-disable-next-line @typescript-eslint/no-deprecated expect(screen.queryByText(translateLocal('getAssistancePage.registerForWebinar'))).not.toBeOnTheScreen(); - // eslint-disable-next-line @typescript-eslint/no-deprecated expect(screen.queryByText(translateLocal('common.reschedule'))).not.toBeOnTheScreen(); - // eslint-disable-next-line @typescript-eslint/no-deprecated expect(screen.queryByText(translateLocal('common.cancel'))).not.toBeOnTheScreen(); // When schedule call option is pressed @@ -153,14 +148,10 @@ describe('OnboardingHelpDropdownButton', () => { await waitForBatchedUpdatesWithAct(); // Then only webinar registration option is visible - // eslint-disable-next-line @typescript-eslint/no-deprecated const registerOption = screen.getByText(translateLocal('getAssistancePage.registerForWebinar')); expect(registerOption).toBeOnTheScreen(); - // eslint-disable-next-line @typescript-eslint/no-deprecated expect(screen.queryByText(translateLocal('getAssistancePage.scheduleACall'))).not.toBeOnTheScreen(); - // eslint-disable-next-line @typescript-eslint/no-deprecated expect(screen.queryByText(translateLocal('common.reschedule'))).not.toBeOnTheScreen(); - // eslint-disable-next-line @typescript-eslint/no-deprecated expect(screen.queryByText(translateLocal('common.cancel'))).not.toBeOnTheScreen(); // When webinar registration option is pressed @@ -195,7 +186,6 @@ describe('OnboardingHelpDropdownButton', () => { await waitForBatchedUpdatesWithAct(); // Then dropdown button displays "Call scheduled" text - // eslint-disable-next-line @typescript-eslint/no-deprecated const dropdownButton = screen.getByText(translateLocal('scheduledCall.callScheduled')); expect(dropdownButton).toBeOnTheScreen(); @@ -207,13 +197,9 @@ describe('OnboardingHelpDropdownButton', () => { await waitForBatchedUpdatesWithAct(); // Then all expected menu options are present - // eslint-disable-next-line @typescript-eslint/no-deprecated expect(screen.getByText(translateLocal('common.reschedule'))).toBeOnTheScreen(); - // eslint-disable-next-line @typescript-eslint/no-deprecated expect(screen.getByText(translateLocal('common.cancel'))).toBeOnTheScreen(); - // eslint-disable-next-line @typescript-eslint/no-deprecated expect(screen.getByText(translateLocal('getAssistancePage.registerForWebinar'))).toBeOnTheScreen(); - // eslint-disable-next-line @typescript-eslint/no-deprecated expect(screen.queryByText(translateLocal('getAssistancePage.scheduleACall'))).not.toBeOnTheScreen(); }); @@ -248,14 +234,12 @@ describe('OnboardingHelpDropdownButton', () => { renderOnboardingHelpDropdownButton(props); await waitForBatchedUpdatesWithAct(); - // eslint-disable-next-line @typescript-eslint/no-deprecated const dropdownButton = screen.getByText(translateLocal('scheduledCall.callScheduled')); fireEvent.press(dropdownButton); await waitForBatchedUpdatesWithAct(); // When webinar menu item is pressed - // eslint-disable-next-line @typescript-eslint/no-deprecated const webinarMenuItem = screen.getByText(translateLocal('getAssistancePage.registerForWebinar')); fireEvent.press(webinarMenuItem, createMockPressEvent(webinarMenuItem)); @@ -271,14 +255,12 @@ describe('OnboardingHelpDropdownButton', () => { renderOnboardingHelpDropdownButton(props); await waitForBatchedUpdatesWithAct(); - // eslint-disable-next-line @typescript-eslint/no-deprecated const dropdownButton = screen.getByText(translateLocal('scheduledCall.callScheduled')); fireEvent.press(dropdownButton); await waitForBatchedUpdatesWithAct(); // When reschedule option is pressed - // eslint-disable-next-line @typescript-eslint/no-deprecated const rescheduleMenuItem = screen.getByText(translateLocal('common.reschedule')); fireEvent.press(rescheduleMenuItem, createMockPressEvent(rescheduleMenuItem)); @@ -294,14 +276,12 @@ describe('OnboardingHelpDropdownButton', () => { renderOnboardingHelpDropdownButton(props); await waitForBatchedUpdatesWithAct(); - // eslint-disable-next-line @typescript-eslint/no-deprecated const dropdownButton = screen.getByText(translateLocal('scheduledCall.callScheduled')); fireEvent.press(dropdownButton); await waitForBatchedUpdatesWithAct(); // When cancel option is pressed - // eslint-disable-next-line @typescript-eslint/no-deprecated const cancelMenuItem = screen.getByText(translateLocal('common.cancel')); fireEvent.press(cancelMenuItem, createMockPressEvent(cancelMenuItem)); diff --git a/tests/unit/CardFeedUtilsTest.ts b/tests/unit/CardFeedUtilsTest.ts index 9d6fa275568a..2084b93022ed 100644 --- a/tests/unit/CardFeedUtilsTest.ts +++ b/tests/unit/CardFeedUtilsTest.ts @@ -1,11 +1,10 @@ /* eslint-disable @typescript-eslint/naming-convention */ import type {OnyxCollection} from 'react-native-onyx'; import {getCardFeedNamesWithType, getCardFeedsForDisplay, getCardFeedsForDisplayPerPolicy, getSelectedCardsFromFeeds} from '@libs/CardFeedUtils'; -// eslint-disable-next-line @typescript-eslint/no-deprecated -import {translateLocal} from '@libs/Localize'; import CONST from '@src/CONST'; import IntlStore from '@src/languages/IntlStore'; import type {CardFeeds, CardList, CompanyCardFeed, WorkspaceCardsList} from '@src/types/onyx'; +import {translateLocal} from '../utils/TestHelper'; import waitForBatchedUpdates from '../utils/waitForBatchedUpdates'; const fakeWorkspace: Record = { @@ -101,7 +100,6 @@ describe('Card Feed Utils', () => { return waitForBatchedUpdates(); }); it('returns display name of workspace & domain cards', () => { - // eslint-disable-next-line @typescript-eslint/no-deprecated const cardFeedNamesWithType = getCardFeedNamesWithType({workspaceCardFeeds: fakeWorkspace, translate: translateLocal}); expect(Object.keys(cardFeedNamesWithType).length).toBe(2); expect(Object.values(cardFeedNamesWithType).every((cardFeedName) => cardFeedName.name === 'All Expensify')).toBe(true); @@ -115,7 +113,6 @@ describe('Card Feed Utils', () => { }); it('returns empty object when workspaceCardFeeds is empty', () => { - // eslint-disable-next-line @typescript-eslint/no-deprecated const names = getCardFeedNamesWithType({workspaceCardFeeds: {key: {}}, translate: translateLocal}); expect(names).toEqual({}); }); diff --git a/tests/unit/CarouselItemTest.tsx b/tests/unit/CarouselItemTest.tsx index 43fac78a438f..9ce9f929eac2 100644 --- a/tests/unit/CarouselItemTest.tsx +++ b/tests/unit/CarouselItemTest.tsx @@ -5,10 +5,9 @@ import CarouselItem from '@components/Attachments/AttachmentCarousel/CarouselIte import {LocaleContextProvider} from '@components/LocaleContextProvider'; import OnyxListItemProvider from '@components/OnyxListItemProvider'; import {PlaybackContextProvider} from '@components/VideoPlayerContexts/PlaybackContext'; -// eslint-disable-next-line @typescript-eslint/no-deprecated -import {translateLocal} from '@libs/Localize'; import {AttachmentModalContextProvider} from '@pages/media/AttachmentModalScreen/AttachmentModalContext'; import ONYXKEYS from '@src/ONYXKEYS'; +import {translateLocal} from '../utils/TestHelper'; import waitForBatchedUpdatesWithAct from '../utils/waitForBatchedUpdatesWithAct'; describe('CarouselItem', () => { @@ -39,7 +38,6 @@ describe('CarouselItem', () => { await waitForBatchedUpdatesWithAct(); // Then initially the attachment should be hidden so the reveal button should be displayed. - // eslint-disable-next-line @typescript-eslint/no-deprecated expect(screen.getByTestId('moderationButton')).toHaveTextContent(translateLocal('moderation.revealMessage')); }); }); diff --git a/tests/unit/MergeTransactionUtilsTest.ts b/tests/unit/MergeTransactionUtilsTest.ts index 7b8edb622ce2..45becac87681 100644 --- a/tests/unit/MergeTransactionUtilsTest.ts +++ b/tests/unit/MergeTransactionUtilsTest.ts @@ -1,5 +1,3 @@ -// eslint-disable-next-line @typescript-eslint/no-deprecated -import {translateLocal} from '@libs/Localize'; import { buildMergedTransactionData, getDisplayValue, @@ -16,6 +14,7 @@ import {getTransactionDetails} from '@libs/ReportUtils'; import CONST from '@src/CONST'; import createRandomMergeTransaction from '../utils/collections/mergeTransaction'; import createRandomTransaction from '../utils/collections/transaction'; +import {translateLocal} from '../utils/TestHelper'; // Mock localeCompare function for tests const mockLocaleCompare = (a: string, b: string) => a.localeCompare(b); @@ -619,7 +618,6 @@ describe('MergeTransactionUtils', () => { }; // When we get display value for merchant - // eslint-disable-next-line @typescript-eslint/no-deprecated const result = getDisplayValue('merchant', transaction, translateLocal); // Then it should return empty string @@ -635,9 +633,7 @@ describe('MergeTransactionUtils', () => { }; // When we get display values for boolean fields - // eslint-disable-next-line @typescript-eslint/no-deprecated const reimbursableResult = getDisplayValue('reimbursable', transaction, translateLocal); - // eslint-disable-next-line @typescript-eslint/no-deprecated const billableResult = getDisplayValue('billable', transaction, translateLocal); // Then it should return translated Yes/No values @@ -654,7 +650,6 @@ describe('MergeTransactionUtils', () => { }; // When we get display value for amount - // eslint-disable-next-line @typescript-eslint/no-deprecated const result = getDisplayValue('amount', transaction, translateLocal); // Then it should return formatted currency string @@ -671,7 +666,6 @@ describe('MergeTransactionUtils', () => { }; // When we get display value for description - // eslint-disable-next-line @typescript-eslint/no-deprecated const result = getDisplayValue('description', transaction, translateLocal); // Then it should return cleaned text without HTML and with spaces instead of line breaks @@ -686,7 +680,6 @@ describe('MergeTransactionUtils', () => { }; // When we get display value for tag - // eslint-disable-next-line @typescript-eslint/no-deprecated const result = getDisplayValue('tag', transaction, translateLocal); // Then it should return sanitized tag names separated by commas @@ -700,7 +693,6 @@ describe('MergeTransactionUtils', () => { {email: 'test2@example.com', displayName: 'Test User 2', avatarUrl: '', login: 'test2'}, {email: 'test1@example.com', displayName: 'Test User 1', avatarUrl: '', login: 'test1'}, ]; - // eslint-disable-next-line @typescript-eslint/no-deprecated const result = getDisplayValue('attendees', transaction, translateLocal); expect(result).toBe('Test User 2, Test User 1'); @@ -716,9 +708,7 @@ describe('MergeTransactionUtils', () => { }; // When we get display values for string fields - // eslint-disable-next-line @typescript-eslint/no-deprecated const merchantResult = getDisplayValue('merchant', transaction, translateLocal); - // eslint-disable-next-line @typescript-eslint/no-deprecated const categoryResult = getDisplayValue('category', transaction, translateLocal); // Then it should return the string values @@ -737,11 +727,9 @@ describe('MergeTransactionUtils', () => { }; // When we get the error text for attendees field - // eslint-disable-next-line @typescript-eslint/no-deprecated const result = getMergeFieldErrorText(translateLocal, mergeField); // Then it should return the specific attendees error message - // eslint-disable-next-line @typescript-eslint/no-deprecated expect(result).toBe(translateLocal('transactionMerge.detailsPage.pleaseSelectAttendees')); }); @@ -754,11 +742,9 @@ describe('MergeTransactionUtils', () => { }; // When we get the error text for merchant field - // eslint-disable-next-line @typescript-eslint/no-deprecated const result = getMergeFieldErrorText(translateLocal, mergeField); // Then it should return the generic error message with lowercase field name - // eslint-disable-next-line @typescript-eslint/no-deprecated expect(result).toBe(translateLocal('transactionMerge.detailsPage.pleaseSelectError', {field: 'merchant'})); }); }); diff --git a/tests/unit/ReportActionsUtilsTest.ts b/tests/unit/ReportActionsUtilsTest.ts index b45065426208..c3a90ad06806 100644 --- a/tests/unit/ReportActionsUtilsTest.ts +++ b/tests/unit/ReportActionsUtilsTest.ts @@ -1,8 +1,6 @@ import type {KeyValueMapping} from 'react-native-onyx'; import Onyx from 'react-native-onyx'; import {formatPhoneNumber} from '@libs/LocalePhoneNumber'; -// eslint-disable-next-line @typescript-eslint/no-deprecated -import {translateLocal} from '@libs/Localize'; import {isExpenseReport} from '@libs/ReportUtils'; import IntlStore from '@src/languages/IntlStore'; import {actionR14932 as mockIOUAction, originalMessageR14932 as mockOriginalMessage} from '../../__mocks__/reportData/actions'; @@ -15,6 +13,7 @@ import type {Card, OriginalMessageIOU, Report, ReportAction} from '../../src/typ import createRandomReportAction from '../utils/collections/reportActions'; import {createRandomReport} from '../utils/collections/reports'; import * as LHNTestUtils from '../utils/LHNTestUtils'; +import {translateLocal} from '../utils/TestHelper'; import waitForBatchedUpdates from '../utils/waitForBatchedUpdates'; import wrapOnyxWithWaitForBatchedUpdates from '../utils/wrapOnyxWithWaitForBatchedUpdates'; @@ -1458,7 +1457,6 @@ describe('ReportActionsUtils', () => { }; const actual = ReportActionsUtils.getPolicyChangeLogUpdateEmployee(action); - // eslint-disable-next-line @typescript-eslint/no-deprecated const expected = translateLocal('report.actions.type.updatedCustomField1', {email: formatPhoneNumber(email), newValue, previousValue}); expect(actual).toBe(expected); }); @@ -1480,7 +1478,6 @@ describe('ReportActionsUtils', () => { }; const actual = ReportActionsUtils.getPolicyChangeLogDeleteMemberMessage(action); - // eslint-disable-next-line @typescript-eslint/no-deprecated const expected = translateLocal('report.actions.type.removeMember', {email: formatPhoneNumber(email), role: translateLocal('workspace.common.roleName', {role}).toLowerCase()}); expect(actual).toBe(expected); }); diff --git a/tests/unit/SidebarFilterTest.ts b/tests/unit/SidebarFilterTest.ts index 301c2f7b7c26..113d16fec0b4 100644 --- a/tests/unit/SidebarFilterTest.ts +++ b/tests/unit/SidebarFilterTest.ts @@ -1,13 +1,11 @@ import {screen} from '@testing-library/react-native'; import Onyx from 'react-native-onyx'; import DateUtils from '@libs/DateUtils'; -// eslint-disable-next-line @typescript-eslint/no-deprecated -import {translateLocal} from '@libs/Localize'; import CONST from '@src/CONST'; import type {Report} from '@src/types/onyx'; import type {ReportCollectionDataSet} from '@src/types/onyx/Report'; import * as LHNTestUtils from '../utils/LHNTestUtils'; -import {getNavigateToChatHintRegex} from '../utils/TestHelper'; +import {getNavigateToChatHintRegex, translateLocal} from '../utils/TestHelper'; import waitForBatchedUpdates from '../utils/waitForBatchedUpdates'; import wrapOnyxWithWaitForBatchedUpdates from '../utils/wrapOnyxWithWaitForBatchedUpdates'; @@ -95,7 +93,6 @@ xdescribe('Sidebar', () => { // Then no reports are rendered in the LHN .then(() => { - // eslint-disable-next-line @typescript-eslint/no-deprecated const hintText = translateLocal('accessibilityHints.chatUserDisplayNames'); const displayNames = screen.queryAllByLabelText(hintText); expect(displayNames).toHaveLength(0); @@ -129,7 +126,6 @@ xdescribe('Sidebar', () => { // Then the report should be rendered in the LHN since it has a draft .then(() => { - // eslint-disable-next-line @typescript-eslint/no-deprecated const hintText = translateLocal('accessibilityHints.chatUserDisplayNames'); const displayNames = screen.queryAllByLabelText(hintText); expect(displayNames).toHaveLength(1); @@ -387,7 +383,6 @@ xdescribe('Sidebar', () => { .then(() => { if (booleansWhichRemovesActiveReport.indexOf(JSON.stringify(boolArr)) > -1) { // Only one report visible - // eslint-disable-next-line @typescript-eslint/no-deprecated const displayNamesHintText = translateLocal('accessibilityHints.chatUserDisplayNames'); const displayNames = screen.queryAllByLabelText(displayNamesHintText); @@ -434,7 +429,6 @@ xdescribe('Sidebar', () => { // Then the reports 1 and 2 are shown and 3 is not .then(() => { - // eslint-disable-next-line @typescript-eslint/no-deprecated const hintText = translateLocal('accessibilityHints.chatUserDisplayNames'); const displayNames = screen.queryAllByLabelText(hintText); expect(displayNames).toHaveLength(2); @@ -507,7 +501,6 @@ xdescribe('Sidebar', () => { // Then both reports are visible .then(() => { - // eslint-disable-next-line @typescript-eslint/no-deprecated const hintText = translateLocal('accessibilityHints.chatUserDisplayNames'); const displayNames = screen.queryAllByLabelText(hintText); expect(displayNames).toHaveLength(2); @@ -562,7 +555,6 @@ xdescribe('Sidebar', () => { // Then neither reports are visible .then(() => { - // eslint-disable-next-line @typescript-eslint/no-deprecated const hintText = translateLocal('accessibilityHints.chatUserDisplayNames'); const displayNames = screen.queryAllByLabelText(hintText); expect(displayNames).toHaveLength(0); @@ -588,7 +580,6 @@ xdescribe('Sidebar', () => { // Then they are all visible .then(() => { - // eslint-disable-next-line @typescript-eslint/no-deprecated const hintText = translateLocal('accessibilityHints.chatUserDisplayNames'); const displayNames = screen.queryAllByLabelText(hintText); expect(displayNames).toHaveLength(3); @@ -630,7 +621,6 @@ xdescribe('Sidebar', () => { // Then neither reports are visible .then(() => { - // eslint-disable-next-line @typescript-eslint/no-deprecated const hintText = translateLocal('accessibilityHints.chatUserDisplayNames'); const displayNames = screen.queryAllByLabelText(hintText); expect(displayNames).toHaveLength(0); @@ -651,7 +641,6 @@ xdescribe('Sidebar', () => { // Then both rooms are visible .then(() => { - // eslint-disable-next-line @typescript-eslint/no-deprecated const hintText = translateLocal('accessibilityHints.chatUserDisplayNames'); const displayNames = screen.queryAllByLabelText(hintText); expect(displayNames).toHaveLength(2); @@ -738,7 +727,6 @@ xdescribe('Sidebar', () => { .then(() => { if (booleansWhichRemovesActiveReport.indexOf(JSON.stringify(boolArr)) > -1) { // Only one report visible - // eslint-disable-next-line @typescript-eslint/no-deprecated const displayNamesHintText = translateLocal('accessibilityHints.chatUserDisplayNames'); const displayNames = screen.queryAllByLabelText(displayNamesHintText); @@ -975,7 +963,6 @@ xdescribe('Sidebar', () => { ) .then(() => { - // eslint-disable-next-line @typescript-eslint/no-deprecated expect(screen.getByText(translateLocal('common.emptyLHN.title'))).toBeOnTheScreen(); }) ); diff --git a/tests/unit/SidebarOrderTest.ts b/tests/unit/SidebarOrderTest.ts index 85b6a3b685cb..cc58fe70fa79 100644 --- a/tests/unit/SidebarOrderTest.ts +++ b/tests/unit/SidebarOrderTest.ts @@ -3,8 +3,6 @@ import {screen} from '@testing-library/react-native'; import Onyx from 'react-native-onyx'; import {addComment} from '@libs/actions/Report'; import DateUtils from '@libs/DateUtils'; -// eslint-disable-next-line @typescript-eslint/no-deprecated -import {translateLocal} from '@libs/Localize'; import initOnyxDerivedValues from '@userActions/OnyxDerived'; import CONST from '@src/CONST'; import IntlStore from '@src/languages/IntlStore'; @@ -85,8 +83,7 @@ describe('Sidebar', () => { LHNTestUtils.getDefaultRenderedSidebarLinks(); // Then it should render with the empty state message and not show the reports list - // eslint-disable-next-line @typescript-eslint/no-deprecated - expect(screen.getByText(translateLocal('common.emptyLHN.title'))).toBeOnTheScreen(); + expect(screen.getByText(TestHelper.translateLocal('common.emptyLHN.title'))).toBeOnTheScreen(); expect(screen.queryByTestId('lhn-options-list')).not.toBeOnTheScreen(); }); @@ -171,8 +168,7 @@ describe('Sidebar', () => { // Then the component should be rendered with the mostly recently updated report first .then(() => { - // eslint-disable-next-line @typescript-eslint/no-deprecated - const hintText = translateLocal('accessibilityHints.chatUserDisplayNames'); + const hintText = TestHelper.translateLocal('accessibilityHints.chatUserDisplayNames'); const displayNames = screen.queryAllByLabelText(hintText); expect(displayNames).toHaveLength(3); @@ -225,8 +221,7 @@ describe('Sidebar', () => { .then(() => { const pencilIcon = screen.queryAllByTestId('Pencil Icon'); expect(pencilIcon).toHaveLength(1); - // eslint-disable-next-line @typescript-eslint/no-deprecated - const hintText = translateLocal('accessibilityHints.chatUserDisplayNames'); + const hintText = TestHelper.translateLocal('accessibilityHints.chatUserDisplayNames'); const displayNames = screen.queryAllByLabelText(hintText); expect(displayNames).toHaveLength(3); expect(displayNames.at(0)).toHaveTextContent('Email Two'); // this has `hasDraft` flag enabled so it will be on top @@ -332,8 +327,7 @@ describe('Sidebar', () => { // Then the order of the reports should be 4 > 3 > 2 > 1 .then(() => { - // eslint-disable-next-line @typescript-eslint/no-deprecated - const hintText = translateLocal('accessibilityHints.chatUserDisplayNames'); + const hintText = TestHelper.translateLocal('accessibilityHints.chatUserDisplayNames'); const displayNames = screen.queryAllByLabelText(hintText); expect(displayNames).toHaveLength(4); expect(displayNames.at(0)).toHaveTextContent(taskReportName); @@ -407,8 +401,7 @@ describe('Sidebar', () => { // Then the order of the reports should be 4 > 3 > 2 > 1 .then(() => { - // eslint-disable-next-line @typescript-eslint/no-deprecated - const hintText = translateLocal('accessibilityHints.chatUserDisplayNames'); + const hintText = TestHelper.translateLocal('accessibilityHints.chatUserDisplayNames'); const displayNames = screen.queryAllByLabelText(hintText); expect(displayNames).toHaveLength(4); expect(displayNames.at(0)).toHaveTextContent('Email Four'); @@ -488,8 +481,7 @@ describe('Sidebar', () => { // Then the order of the reports should be 4 > 3 > 2 > 1 .then(() => { - // eslint-disable-next-line @typescript-eslint/no-deprecated - const hintText = translateLocal('accessibilityHints.chatUserDisplayNames'); + const hintText = TestHelper.translateLocal('accessibilityHints.chatUserDisplayNames'); const displayNames = screen.queryAllByLabelText(hintText); expect(displayNames).toHaveLength(4); expect(displayNames.at(0)).toHaveTextContent(`Email One's expenses`); @@ -549,8 +541,7 @@ describe('Sidebar', () => { // Then the order of the reports should be 2 > 3 > 1 // ^--- (2 goes to the front and pushes 3 down) .then(() => { - // eslint-disable-next-line @typescript-eslint/no-deprecated - const hintText = translateLocal('accessibilityHints.chatUserDisplayNames'); + const hintText = TestHelper.translateLocal('accessibilityHints.chatUserDisplayNames'); const displayNames = screen.queryAllByLabelText(hintText); expect(displayNames).toHaveLength(3); expect(displayNames.at(0)).toHaveTextContent('Email Three'); @@ -716,8 +707,7 @@ describe('Sidebar', () => { // there is a pencil icon // there is a pinned icon .then(() => { - // eslint-disable-next-line @typescript-eslint/no-deprecated - const hintText = translateLocal('accessibilityHints.chatUserDisplayNames'); + const hintText = TestHelper.translateLocal('accessibilityHints.chatUserDisplayNames'); const displayNames = screen.queryAllByLabelText(hintText); expect(displayNames).toHaveLength(4); expect(screen.queryAllByTestId('Pin Icon')).toHaveLength(1); @@ -772,8 +762,7 @@ describe('Sidebar', () => { // Then the reports are in alphabetical order .then(() => { - // eslint-disable-next-line @typescript-eslint/no-deprecated - const hintText = translateLocal('accessibilityHints.chatUserDisplayNames'); + const hintText = TestHelper.translateLocal('accessibilityHints.chatUserDisplayNames'); const displayNames = screen.queryAllByLabelText(hintText); expect(displayNames).toHaveLength(3); expect(displayNames.at(0)).toHaveTextContent('Email Four'); @@ -836,8 +825,7 @@ describe('Sidebar', () => { // Then the reports are in alphabetical order .then(() => { - // eslint-disable-next-line @typescript-eslint/no-deprecated - const hintText = translateLocal('accessibilityHints.chatUserDisplayNames'); + const hintText = TestHelper.translateLocal('accessibilityHints.chatUserDisplayNames'); const displayNames = screen.queryAllByLabelText(hintText); expect(displayNames).toHaveLength(3); expect(displayNames.at(0)).toHaveTextContent('Email Four'); @@ -909,8 +897,7 @@ describe('Sidebar', () => { // Then the first report is in last position .then(() => { - // eslint-disable-next-line @typescript-eslint/no-deprecated - const hintText = translateLocal('accessibilityHints.chatUserDisplayNames'); + const hintText = TestHelper.translateLocal('accessibilityHints.chatUserDisplayNames'); const displayNames = screen.queryAllByLabelText(hintText); expect(displayNames).toHaveLength(3); expect(displayNames.at(0)).toHaveTextContent('Email Four'); @@ -953,8 +940,7 @@ describe('Sidebar', () => { // Then the reports are ordered alphabetically since their lastVisibleActionCreated are the same .then(() => { - // eslint-disable-next-line @typescript-eslint/no-deprecated - const hintText = translateLocal('accessibilityHints.chatUserDisplayNames'); + const hintText = TestHelper.translateLocal('accessibilityHints.chatUserDisplayNames'); const displayNames = screen.queryAllByLabelText(hintText); expect(displayNames).toHaveLength(3); expect(displayNames.at(0)).toHaveTextContent('Email Four'); @@ -994,8 +980,7 @@ describe('Sidebar', () => { // Then the reports are in alphabetical order .then(() => { - // eslint-disable-next-line @typescript-eslint/no-deprecated - const hintText = translateLocal('accessibilityHints.chatUserDisplayNames'); + const hintText = TestHelper.translateLocal('accessibilityHints.chatUserDisplayNames'); const displayNames = screen.queryAllByLabelText(hintText); expect(displayNames).toHaveLength(3); expect(displayNames.at(0)).toHaveTextContent('Email Four'); @@ -1059,8 +1044,7 @@ describe('Sidebar', () => { // Then the first report is in last position .then(() => { - // eslint-disable-next-line @typescript-eslint/no-deprecated - const hintText = translateLocal('accessibilityHints.chatUserDisplayNames'); + const hintText = TestHelper.translateLocal('accessibilityHints.chatUserDisplayNames'); const displayNames = screen.queryAllByLabelText(hintText); expect(displayNames).toHaveLength(3); expect(displayNames.at(0)).toHaveTextContent('Email Four'); diff --git a/tests/unit/SidebarTest.ts b/tests/unit/SidebarTest.ts index 7f83ffad3cff..3f2fa09cfd8b 100644 --- a/tests/unit/SidebarTest.ts +++ b/tests/unit/SidebarTest.ts @@ -3,7 +3,6 @@ import Onyx from 'react-native-onyx'; import DateUtils from '@libs/DateUtils'; import initOnyxDerivedValues from '@userActions/OnyxDerived'; import CONST from '@src/CONST'; -import * as Localize from '@src/libs/Localize'; import ONYXKEYS from '@src/ONYXKEYS'; import type {ReportCollectionDataSet} from '@src/types/onyx/Report'; import type {ReportActionsCollectionDataSet} from '@src/types/onyx/ReportAction'; @@ -105,12 +104,10 @@ describe('Sidebar', () => { }); }) .then(() => { - // eslint-disable-next-line @typescript-eslint/no-deprecated - const hintText = Localize.translateLocal('accessibilityHints.chatUserDisplayNames'); + const hintText = TestHelper.translateLocal('accessibilityHints.chatUserDisplayNames'); const displayNames = screen.queryAllByLabelText(hintText); expect(displayNames.at(0)).toHaveTextContent('Report (archived)'); - // eslint-disable-next-line @typescript-eslint/no-deprecated - const hintMessagePreviewText = Localize.translateLocal('accessibilityHints.lastChatMessagePreview'); + const hintMessagePreviewText = TestHelper.translateLocal('accessibilityHints.lastChatMessagePreview'); const messagePreviewTexts = screen.queryAllByLabelText(hintMessagePreviewText); expect(messagePreviewTexts.at(0)).toHaveTextContent('This chat room has been archived.'); }) @@ -170,12 +167,10 @@ describe('Sidebar', () => { }); }) .then(() => { - // eslint-disable-next-line @typescript-eslint/no-deprecated - const hintText = Localize.translateLocal('accessibilityHints.chatUserDisplayNames'); + const hintText = TestHelper.translateLocal('accessibilityHints.chatUserDisplayNames'); const displayNames = screen.queryAllByLabelText(hintText); expect(displayNames.at(0)).toHaveTextContent('Report (archived)'); - // eslint-disable-next-line @typescript-eslint/no-deprecated - const hintMessagePreviewText = Localize.translateLocal('accessibilityHints.lastChatMessagePreview'); + const hintMessagePreviewText = TestHelper.translateLocal('accessibilityHints.lastChatMessagePreview'); const messagePreviewTexts = screen.queryAllByLabelText(hintMessagePreviewText); expect(messagePreviewTexts.at(0)).toHaveTextContent('This chat is no longer active because Vikings Policy is no longer an active workspace.'); }) diff --git a/tests/unit/ValidationUtilsTest.ts b/tests/unit/ValidationUtilsTest.ts index 4585c526ca19..b73d974a9a75 100644 --- a/tests/unit/ValidationUtilsTest.ts +++ b/tests/unit/ValidationUtilsTest.ts @@ -1,7 +1,5 @@ import {addDays, format, startOfDay, subYears} from 'date-fns'; import {TextEncoder} from 'util'; -// eslint-disable-next-line @typescript-eslint/no-deprecated -import {translateLocal} from '@libs/Localize'; import CONST from '@src/CONST'; import type {Country} from '@src/CONST'; import { @@ -22,6 +20,7 @@ import { meetsMaximumAgeRequirement, meetsMinimumAgeRequirement, } from '@src/libs/ValidationUtils'; +import {translateLocal} from '../utils/TestHelper'; global.TextEncoder = TextEncoder as typeof global.TextEncoder; @@ -216,7 +215,6 @@ describe('ValidationUtils', () => { const invalidDate: string = format(subYears(new Date(), 17), CONST.DATE.FNS_FORMAT_STRING); // Date of birth 17 years ago const error = getAgeRequirementError(invalidDate, 18, 150); expect(error).toEqual( - // eslint-disable-next-line @typescript-eslint/no-deprecated translateLocal('privatePersonalDetails.error.dateShouldBeBefore', {dateString: format(startOfDay(subYears(new Date(), 18)), CONST.DATE.FNS_FORMAT_STRING)}), ); }); @@ -225,7 +223,6 @@ describe('ValidationUtils', () => { const invalidDate: string = format(subYears(new Date(), 160), CONST.DATE.FNS_FORMAT_STRING); // Date of birth 160 years ago const error = getAgeRequirementError(invalidDate, 18, 150); expect(error).toEqual( - // eslint-disable-next-line @typescript-eslint/no-deprecated translateLocal('privatePersonalDetails.error.dateShouldBeAfter', {dateString: format(startOfDay(subYears(new Date(), 150)), CONST.DATE.FNS_FORMAT_STRING)}), ); }); @@ -233,7 +230,6 @@ describe('ValidationUtils', () => { test('Should return an error message for an invalid date', () => { const invalidDate = '2023-07-32'; // Invalid date const error = getAgeRequirementError(invalidDate, 18, 150); - // eslint-disable-next-line @typescript-eslint/no-deprecated expect(error).toBe(translateLocal('common.error.dateInvalid')); }); }); diff --git a/tests/unit/ViolationUtilsTest.ts b/tests/unit/ViolationUtilsTest.ts index f3b4a1fcab4f..00f070e31c29 100644 --- a/tests/unit/ViolationUtilsTest.ts +++ b/tests/unit/ViolationUtilsTest.ts @@ -1,14 +1,13 @@ import {beforeEach} from '@jest/globals'; import Onyx from 'react-native-onyx'; import {convertAmountToDisplayString} from '@libs/CurrencyUtils'; -// eslint-disable-next-line @typescript-eslint/no-deprecated -import {translateLocal} from '@libs/Localize'; import {getTransactionViolations, hasWarningTypeViolation, isViolationDismissed} from '@libs/TransactionUtils'; import ViolationsUtils from '@libs/Violations/ViolationsUtils'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import type {Policy, PolicyCategories, PolicyTagLists, Report, Transaction, TransactionViolation} from '@src/types/onyx'; import type {TransactionCollectionDataSet} from '@src/types/onyx/Transaction'; +import {translateLocal} from '../utils/TestHelper'; const categoryOutOfPolicyViolation = { name: CONST.VIOLATIONS.CATEGORY_OUT_OF_POLICY, @@ -659,23 +658,19 @@ const brokenCardConnection530Violation: TransactionViolation = { describe('getViolationTranslation', () => { it('should return the correct message for broken card connection violation', () => { - // eslint-disable-next-line @typescript-eslint/no-deprecated const brokenCardConnectionViolationExpected = translateLocal('violations.rter', { brokenBankConnection: true, isAdmin: true, rterType: CONST.RTER_VIOLATION_TYPES.BROKEN_CARD_CONNECTION, isTransactionOlderThan7Days: false, }); - // eslint-disable-next-line @typescript-eslint/no-deprecated expect(ViolationsUtils.getViolationTranslation(brokenCardConnectionViolation, translateLocal)).toBe(brokenCardConnectionViolationExpected); - // eslint-disable-next-line @typescript-eslint/no-deprecated const brokenCardConnection530ViolationExpected = translateLocal('violations.rter', { brokenBankConnection: true, isAdmin: false, rterType: CONST.RTER_VIOLATION_TYPES.BROKEN_CARD_CONNECTION_530, isTransactionOlderThan7Days: false, }); - // eslint-disable-next-line @typescript-eslint/no-deprecated expect(ViolationsUtils.getViolationTranslation(brokenCardConnection530Violation, translateLocal)).toBe(brokenCardConnection530ViolationExpected); }); }); @@ -703,18 +698,14 @@ describe('getRBRMessages', () => { it('should return all violations and missing field error', () => { const missingFieldError = 'Missing required field'; - // eslint-disable-next-line @typescript-eslint/no-deprecated const result = ViolationsUtils.getRBRMessages(mockTransaction, mockViolations, translateLocal, missingFieldError, []); - // eslint-disable-next-line @typescript-eslint/no-deprecated const expectedResult = `Missing required field. ${translateLocal('violations.missingCategory')}. ${translateLocal('violations.missingTag')}.`; expect(result).toBe(expectedResult); }); it('should filter out empty strings', () => { - // eslint-disable-next-line @typescript-eslint/no-deprecated const result = ViolationsUtils.getRBRMessages(mockTransaction, mockViolations, translateLocal, undefined, []); - // eslint-disable-next-line @typescript-eslint/no-deprecated const expectedResult = `${translateLocal('violations.missingCategory')}. ${translateLocal('violations.missingTag')}.`; expect(result).toBe(expectedResult); diff --git a/tests/utils/TestHelper.ts b/tests/utils/TestHelper.ts index be8179a60b91..acd2306e5aa4 100644 --- a/tests/utils/TestHelper.ts +++ b/tests/utils/TestHelper.ts @@ -5,12 +5,13 @@ import Onyx from 'react-native-onyx'; import type {ConnectOptions, OnyxEntry, OnyxKey} from 'react-native-onyx/dist/types'; import type {ApiCommand, ApiRequestCommandParameters} from '@libs/API/types'; import {formatPhoneNumberWithCountryCode} from '@libs/LocalePhoneNumber'; -// eslint-disable-next-line @typescript-eslint/no-deprecated -import {translateLocal} from '@libs/Localize'; +import {translate} from '@libs/Localize'; import Pusher from '@libs/Pusher'; import PusherConnectionManager from '@libs/PusherConnectionManager'; import CONFIG from '@src/CONFIG'; import CONST from '@src/CONST'; +import IntlStore from '@src/languages/IntlStore'; +import type {TranslationParameters, TranslationPaths} from '@src/languages/types'; import * as Session from '@src/libs/actions/Session'; import HttpUtils from '@src/libs/HttpUtils'; import * as NumberUtils from '@src/libs/NumberUtils'; @@ -345,8 +346,17 @@ function assertFormDataMatchesObject(obj: Report, formData?: FormData) { } } +/** + * A local version of translate that uses the current locale from IntlStore + * This is useful in tests where we don't have access to the full app context + * to provide the locale. + */ +function translateLocal(phrase: TPath, ...parameters: TranslationParameters) { + const currentLocale = IntlStore.getCurrentLocale(); + return translate(currentLocale, phrase, ...parameters); +} + function getNavigateToChatHintRegex(): RegExp { - // eslint-disable-next-line @typescript-eslint/no-deprecated const hintTextPrefix = translateLocal('accessibilityHints.navigatesToChat'); return new RegExp(hintTextPrefix, 'i'); } @@ -372,6 +382,7 @@ function localeCompare(a: string, b: string): number { export type {MockFetch, FormData}; export { + translateLocal, assertFormDataMatchesObject, buildPersonalDetails, buildTestReportComment,