diff --git a/tests/actions/PolicyCategoryTest.ts b/tests/actions/PolicyCategoryTest.ts index 2817a1661db4..7c060b40467e 100644 --- a/tests/actions/PolicyCategoryTest.ts +++ b/tests/actions/PolicyCategoryTest.ts @@ -6,6 +6,7 @@ import ONYXKEYS from '@src/ONYXKEYS'; import createRandomPolicy from '../utils/collections/policies'; import createRandomPolicyCategories from '../utils/collections/policyCategory'; import * as TestHelper from '../utils/TestHelper'; +import type {MockFetch} from '../utils/TestHelper'; import waitForBatchedUpdates from '../utils/waitForBatchedUpdates'; OnyxUpdateManager(); @@ -16,9 +17,10 @@ describe('actions/PolicyCategory', () => { }); }); + let mockFetch: MockFetch; beforeEach(() => { - // @ts-expect-error TODO: Remove this once TestHelper (https://github.com/Expensify/App/issues/25318) is migrated to TypeScript. global.fetch = TestHelper.getGlobalFetchMock(); + mockFetch = fetch as MockFetch; return Onyx.clear().then(waitForBatchedUpdates); }); @@ -27,8 +29,7 @@ describe('actions/PolicyCategory', () => { const fakePolicy = createRandomPolicy(0); fakePolicy.requiresCategory = false; - // @ts-expect-error TODO: Remove this once TestHelper (https://github.com/Expensify/App/issues/25318) is migrated to TypeScript. - fetch.pause(); + mockFetch?.pause?.(); Onyx.set(`${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, fakePolicy); Policy.setWorkspaceRequiresCategory(fakePolicy.id, true); await waitForBatchedUpdates(); @@ -46,8 +47,7 @@ describe('actions/PolicyCategory', () => { }, }); }); - // @ts-expect-error TODO: Remove this once TestHelper (https://github.com/Expensify/App/issues/25318) is migrated to TypeScript. - await fetch.resume(); + await mockFetch?.resume?.(); await waitForBatchedUpdates(); await new Promise((resolve) => { const connectionID = Onyx.connect({ @@ -68,8 +68,7 @@ describe('actions/PolicyCategory', () => { const fakePolicy = createRandomPolicy(0); const fakeCategories = createRandomPolicyCategories(3); const newCategoryName = 'New category'; - // @ts-expect-error TODO: Remove this once TestHelper (https://github.com/Expensify/App/issues/25318) is migrated to TypeScript. - fetch.pause(); + mockFetch?.pause?.(); Onyx.set(`${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, fakePolicy); Onyx.set(`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${fakePolicy.id}`, fakeCategories); Policy.createPolicyCategory(fakePolicy.id, newCategoryName); @@ -89,8 +88,7 @@ describe('actions/PolicyCategory', () => { }, }); }); - // @ts-expect-error TODO: Remove this once TestHelper (https://github.com/Expensify/App/issues/25318) is migrated to TypeScript. - await fetch.resume(); + await mockFetch?.resume?.(); await waitForBatchedUpdates(); await new Promise((resolve) => { const connectionID = Onyx.connect({ @@ -115,8 +113,7 @@ describe('actions/PolicyCategory', () => { const fakeCategories = createRandomPolicyCategories(3); const oldCategoryName = Object.keys(fakeCategories)[0]; const newCategoryName = 'Updated category'; - // @ts-expect-error TODO: Remove this once TestHelper (https://github.com/Expensify/App/issues/25318) is migrated to TypeScript. - fetch.pause(); + mockFetch?.pause?.(); Onyx.set(`${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, fakePolicy); Onyx.set(`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${fakePolicy.id}`, fakeCategories); Policy.renamePolicyCategory(fakePolicy.id, { @@ -140,8 +137,7 @@ describe('actions/PolicyCategory', () => { }, }); }); - // @ts-expect-error TODO: Remove this once TestHelper (https://github.com/Expensify/App/issues/25318) is migrated to TypeScript. - await fetch.resume(); + await mockFetch?.resume?.(); await waitForBatchedUpdates(); await new Promise((resolve) => { const connectionID = Onyx.connect({ @@ -170,8 +166,7 @@ describe('actions/PolicyCategory', () => { enabled: true, }, }; - // @ts-expect-error TODO: Remove this once TestHelper (https://github.com/Expensify/App/issues/25318) is migrated to TypeScript. - fetch.pause(); + mockFetch?.pause?.(); Onyx.set(`${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, fakePolicy); Onyx.set(`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${fakePolicy.id}`, fakeCategories); Policy.setWorkspaceCategoryEnabled(fakePolicy.id, categoriesToUpdate); @@ -191,8 +186,7 @@ describe('actions/PolicyCategory', () => { }, }); }); - // @ts-expect-error TODO: Remove this once TestHelper (https://github.com/Expensify/App/issues/25318) is migrated to TypeScript. - await fetch.resume(); + await mockFetch?.resume?.(); await waitForBatchedUpdates(); await new Promise((resolve) => { const connectionID = Onyx.connect({ @@ -217,8 +211,7 @@ describe('actions/PolicyCategory', () => { const fakeCategories = createRandomPolicyCategories(3); const categoryNameToDelete = Object.keys(fakeCategories)[0]; const categoriesToDelete = [categoryNameToDelete]; - // @ts-expect-error TODO: Remove this once TestHelper (https://github.com/Expensify/App/issues/25318) is migrated to TypeScript. - fetch.pause(); + mockFetch?.pause?.(); Onyx.set(`${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, fakePolicy); Onyx.set(`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${fakePolicy.id}`, fakeCategories); Policy.deleteWorkspaceCategories(fakePolicy.id, categoriesToDelete); @@ -235,8 +228,7 @@ describe('actions/PolicyCategory', () => { }, }); }); - // @ts-expect-error TODO: Remove this once TestHelper (https://github.com/Expensify/App/issues/25318) is migrated to TypeScript. - await fetch.resume(); + await mockFetch?.resume?.(); await waitForBatchedUpdates(); await new Promise((resolve) => { const connectionID = Onyx.connect({ diff --git a/tests/actions/PolicyMemberTest.ts b/tests/actions/PolicyMemberTest.ts index 8d982d4a1892..4f3afc51ec66 100644 --- a/tests/actions/PolicyMemberTest.ts +++ b/tests/actions/PolicyMemberTest.ts @@ -11,6 +11,7 @@ import createRandomPolicy from '../utils/collections/policies'; import createRandomReportAction from '../utils/collections/reportActions'; import createRandomReport from '../utils/collections/reports'; import * as TestHelper from '../utils/TestHelper'; +import type {MockFetch} from '../utils/TestHelper'; import waitForBatchedUpdates from '../utils/waitForBatchedUpdates'; OnyxUpdateManager(); @@ -21,9 +22,10 @@ describe('actions/PolicyMember', () => { }); }); + let mockFetch: MockFetch; beforeEach(() => { - // @ts-expect-error TODO: Remove this once TestHelper (https://github.com/Expensify/App/issues/25318) is migrated to TypeScript. global.fetch = TestHelper.getGlobalFetchMock(); + mockFetch = fetch as MockFetch; return Onyx.clear().then(waitForBatchedUpdates); }); @@ -39,8 +41,7 @@ describe('actions/PolicyMember', () => { actionName: CONST.REPORT.ACTIONS.TYPE.ACTIONABLE_JOIN_REQUEST, } as ReportAction; - // @ts-expect-error TODO: Remove this once TestHelper (https://github.com/Expensify/App/issues/25318) is migrated to TypeScript. - fetch.pause(); + mockFetch?.pause?.(); Onyx.set(`${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, fakePolicy); Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${fakeReport.reportID}`, fakeReport); Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${fakeReport.reportID}`, { @@ -67,8 +68,7 @@ describe('actions/PolicyMember', () => { }, }); }); - // @ts-expect-error TODO: Remove this once TestHelper (https://github.com/Expensify/App/issues/25318) is migrated to TypeScript. - await fetch.resume(); + await mockFetch?.resume?.(); await waitForBatchedUpdates(); await new Promise((resolve) => { const connectionID = Onyx.connect({ @@ -101,8 +101,7 @@ describe('actions/PolicyMember', () => { }, }; - // @ts-expect-error TODO: Remove this once TestHelper (https://github.com/Expensify/App/issues/25318) is migrated to TypeScript. - fetch.pause(); + mockFetch?.pause?.(); Onyx.set(`${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, fakePolicy); Onyx.set(`${ONYXKEYS.PERSONAL_DETAILS_LIST}`, {[fakeUser2.accountID]: fakeUser2}); await waitForBatchedUpdates(); @@ -121,8 +120,7 @@ describe('actions/PolicyMember', () => { }, }); }); - // @ts-expect-error TODO: Remove this once TestHelper (https://github.com/Expensify/App/issues/25318) is migrated to TypeScript. - await fetch.resume(); + await mockFetch?.resume?.(); await waitForBatchedUpdates(); await new Promise((resolve) => { const connectionID = Onyx.connect({ @@ -144,8 +142,7 @@ describe('actions/PolicyMember', () => { const fakeEmail = 'fake@gmail.com'; const fakeAccountID = 1; - // @ts-expect-error TODO: Remove this once TestHelper (https://github.com/Expensify/App/issues/25318) is migrated to TypeScript. - fetch.pause(); + mockFetch?.pause?.(); Onyx.set(`${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, fakePolicy); Onyx.merge(ONYXKEYS.SESSION, {email: fakeEmail, accountID: fakeAccountID}); Policy.requestWorkspaceOwnerChange(fakePolicy.id); @@ -164,8 +161,7 @@ describe('actions/PolicyMember', () => { }, }); }); - // @ts-expect-error TODO: Remove this once TestHelper (https://github.com/Expensify/App/issues/25318) is migrated to TypeScript. - await fetch.resume(); + await mockFetch?.resume?.(); await waitForBatchedUpdates(); await new Promise((resolve) => { const connectionID = Onyx.connect({ @@ -197,8 +193,7 @@ describe('actions/PolicyMember', () => { }; const fakeAccountID = 1; - // @ts-expect-error TODO: Remove this once TestHelper (https://github.com/Expensify/App/issues/25318) is migrated to TypeScript. - fetch.pause(); + mockFetch?.pause?.(); Onyx.set(`${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, fakePolicy); Onyx.merge(ONYXKEYS.SESSION, {email: fakeEmail, accountID: fakeAccountID}); Policy.addBillingCardAndRequestPolicyOwnerChange(fakePolicy.id, fakeCard); @@ -217,8 +212,7 @@ describe('actions/PolicyMember', () => { }, }); }); - // @ts-expect-error TODO: Remove this once TestHelper (https://github.com/Expensify/App/issues/25318) is migrated to TypeScript. - await fetch.resume(); + await mockFetch?.resume?.(); await waitForBatchedUpdates(); await new Promise((resolve) => { const connectionID = Onyx.connect({ diff --git a/tests/actions/PolicyProfileTest.ts b/tests/actions/PolicyProfileTest.ts index 21ee34568100..a6bc0ea541bc 100644 --- a/tests/actions/PolicyProfileTest.ts +++ b/tests/actions/PolicyProfileTest.ts @@ -6,6 +6,7 @@ import * as ReportUtils from '@src/libs/ReportUtils'; import ONYXKEYS from '@src/ONYXKEYS'; import createRandomPolicy from '../utils/collections/policies'; import * as TestHelper from '../utils/TestHelper'; +import type {MockFetch} from '../utils/TestHelper'; import waitForBatchedUpdates from '../utils/waitForBatchedUpdates'; OnyxUpdateManager(); @@ -16,9 +17,10 @@ describe('actions/PolicyProfile', () => { }); }); + let mockFetch: MockFetch; beforeEach(() => { - // @ts-expect-error TODO: Remove this once TestHelper (https://github.com/Expensify/App/issues/25318) is migrated to TypeScript. global.fetch = TestHelper.getGlobalFetchMock(); + mockFetch = fetch as MockFetch; return Onyx.clear().then(waitForBatchedUpdates); }); @@ -29,8 +31,7 @@ describe('actions/PolicyProfile', () => { const oldDescription = fakePolicy.description ?? ''; const newDescription = 'Updated description'; const parsedDescription = ReportUtils.getParsedComment(newDescription); - // @ts-expect-error TODO: Remove this once TestHelper (https://github.com/Expensify/App/issues/25318) is migrated to TypeScript. - fetch.pause(); + mockFetch?.pause?.(); Onyx.set(`${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, fakePolicy); Policy.updateWorkspaceDescription(fakePolicy.id, newDescription, oldDescription); await waitForBatchedUpdates(); @@ -48,8 +49,7 @@ describe('actions/PolicyProfile', () => { }, }); }); - // @ts-expect-error TODO: Remove this once TestHelper (https://github.com/Expensify/App/issues/25318) is migrated to TypeScript. - await fetch.resume(); + await mockFetch?.resume?.(); await waitForBatchedUpdates(); await new Promise((resolve) => { const connectionID = Onyx.connect({