diff --git a/package-lock.json b/package-lock.json index e1ce1dde84dc..8394997955f7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -102,7 +102,7 @@ "react-native-linear-gradient": "^2.8.1", "react-native-localize": "^2.2.6", "react-native-modal": "^13.0.0", - "react-native-onyx": "2.0.64", + "react-native-onyx": "2.0.65", "react-native-pager-view": "6.3.4", "react-native-pdf": "6.7.3", "react-native-performance": "^5.1.0", @@ -37538,9 +37538,9 @@ } }, "node_modules/react-native-onyx": { - "version": "2.0.64", - "resolved": "https://registry.npmjs.org/react-native-onyx/-/react-native-onyx-2.0.64.tgz", - "integrity": "sha512-RFYiEQBFw9610iTGLXIZ1nQMWuf8VyVEMqiRMLpao75+VnbD6lzh0z7Uuj1eoKMDkjeXJhsPP3rh2MkLnqruug==", + "version": "2.0.65", + "resolved": "https://registry.npmjs.org/react-native-onyx/-/react-native-onyx-2.0.65.tgz", + "integrity": "sha512-1ilE2uzROrgh05cj6I6X2Nrr8T7QM4lCcr5JrfMTJpiLvV9UZMBvZk9xNJrr7KexUhpzcqhrsCbQeTT14ylT1w==", "dependencies": { "ascii-table": "0.0.9", "fast-equals": "^4.0.3", diff --git a/package.json b/package.json index 8cca007e5295..c561320cc6da 100644 --- a/package.json +++ b/package.json @@ -158,7 +158,7 @@ "react-native-linear-gradient": "^2.8.1", "react-native-localize": "^2.2.6", "react-native-modal": "^13.0.0", - "react-native-onyx": "2.0.64", + "react-native-onyx": "2.0.65", "react-native-pager-view": "6.3.4", "react-native-pdf": "6.7.3", "react-native-performance": "^5.1.0", diff --git a/src/libs/E2E/actions/e2eLogin.ts b/src/libs/E2E/actions/e2eLogin.ts index f98eab5005e1..25aee3c43d83 100644 --- a/src/libs/E2E/actions/e2eLogin.ts +++ b/src/libs/E2E/actions/e2eLogin.ts @@ -43,7 +43,7 @@ export default function (): Promise { // Subscribe to auth token, to check if we are authenticated return new Promise((resolve, reject) => { - const connectionId = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.SESSION, callback: (session) => { if (session?.authToken == null || session.authToken.length === 0) { @@ -67,7 +67,7 @@ export default function (): Promise { } // signal that auth was completed resolve(neededLogin); - Onyx.disconnect(connectionId); + Onyx.disconnect(connection); }, }); }); diff --git a/src/libs/E2E/actions/waitForAppLoaded.ts b/src/libs/E2E/actions/waitForAppLoaded.ts index bea739a1b4c7..ebb53657eade 100644 --- a/src/libs/E2E/actions/waitForAppLoaded.ts +++ b/src/libs/E2E/actions/waitForAppLoaded.ts @@ -4,7 +4,7 @@ import ONYXKEYS from '@src/ONYXKEYS'; // Once we get the sidebar loaded end mark we know that the app is ready to be used: export default function waitForAppLoaded(): Promise { return new Promise((resolve) => { - const connectionId = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.IS_SIDEBAR_LOADED, callback: (isSidebarLoaded) => { if (!isSidebarLoaded) { @@ -12,7 +12,7 @@ export default function waitForAppLoaded(): Promise { } resolve(); - Onyx.disconnect(connectionId); + Onyx.disconnect(connection); }, }); }); diff --git a/src/libs/Network/SequentialQueue.ts b/src/libs/Network/SequentialQueue.ts index 5646cb8956dd..fb09f7f216bd 100644 --- a/src/libs/Network/SequentialQueue.ts +++ b/src/libs/Network/SequentialQueue.ts @@ -147,10 +147,13 @@ function flush() { }); // Ensure persistedRequests are read from storage before proceeding with the queue - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.PERSISTED_REQUESTS, + // We exceptionally opt out of reusing the connection here to avoid extra callback calls due to + // an existing connection already made in PersistedRequests.ts. + reuseConnection: false, callback: () => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); process().finally(() => { Log.info('[SequentialQueue] Finished processing queue.'); isSequentialQueueRunning = false; diff --git a/src/libs/actions/App.ts b/src/libs/actions/App.ts index 0c1a157f76f3..24e554af111a 100644 --- a/src/libs/actions/App.ts +++ b/src/libs/actions/App.ts @@ -184,11 +184,11 @@ AppState.addEventListener('change', (nextAppState) => { function getPolicyParamsForOpenOrReconnect(): Promise { return new Promise((resolve) => { isReadyToOpenApp.then(() => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.POLICY, waitForCollectionCallback: true, callback: (policies) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); resolve({policyIDList: getNonOptimisticPolicyIDs(policies)}); }, }); diff --git a/src/libs/actions/Device/index.ts b/src/libs/actions/Device/index.ts index 7ef3a4fd289f..991f9ce6227b 100644 --- a/src/libs/actions/Device/index.ts +++ b/src/libs/actions/Device/index.ts @@ -16,10 +16,10 @@ function getDeviceID(): Promise { return; } - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.DEVICE_ID, callback: (id) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); deviceID = id ?? null; return resolve(id ?? null); }, diff --git a/src/libs/actions/Download.ts b/src/libs/actions/Download.ts index e82744aa5d02..74db1bf9164e 100644 --- a/src/libs/actions/Download.ts +++ b/src/libs/actions/Download.ts @@ -9,11 +9,11 @@ function setDownload(sourceID: string, isDownloading: boolean): Promise { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); const downloadsToDelete: Record = {}; Object.keys(records ?? {}).forEach((recordKey) => { downloadsToDelete[recordKey] = null; diff --git a/src/libs/actions/MapboxToken.ts b/src/libs/actions/MapboxToken.ts index 4a52bbf4e4a6..259feadf1d59 100644 --- a/src/libs/actions/MapboxToken.ts +++ b/src/libs/actions/MapboxToken.ts @@ -1,6 +1,7 @@ import {isAfter} from 'date-fns'; import type {NativeEventSubscription} from 'react-native'; import {AppState} from 'react-native'; +import type {Connection} from 'react-native-onyx'; import Onyx from 'react-native-onyx'; import * as ActiveClientManager from '@libs/ActiveClientManager'; import * as API from '@libs/API'; @@ -17,8 +18,8 @@ Onyx.connect({ }, }); -let connectionIDForToken: number | null; -let connectionIDForNetwork: number | null; +let tokenConnection: Connection | null; +let networkConnection: Connection | null; let appStateSubscription: NativeEventSubscription | null; let currentToken: MapboxAccessToken | undefined; let refreshTimeoutID: NodeJS.Timeout | undefined; @@ -57,13 +58,13 @@ const fetchToken = () => { }; const init = () => { - if (connectionIDForToken) { + if (tokenConnection) { console.debug('[MapboxToken] init() is already listening to Onyx so returning early'); return; } // When the token changes in Onyx, the expiration needs to be checked so a new token can be retrieved. - connectionIDForToken = Onyx.connect({ + tokenConnection = Onyx.connect({ key: ONYXKEYS.MAPBOX_ACCESS_TOKEN, callback: (token) => { // Only the leader should be in charge of the mapbox token, or else when you have multiple tabs open, the Onyx connection fires multiple times @@ -116,9 +117,9 @@ const init = () => { }); } - if (!connectionIDForNetwork) { + if (!networkConnection) { let network: Network | undefined; - connectionIDForNetwork = Onyx.connect({ + networkConnection = Onyx.connect({ key: ONYXKEYS.NETWORK, callback: (value) => { // When the network reconnects, check if the token has expired. If it has, then clearing the token will @@ -139,13 +140,13 @@ const init = () => { const stop = () => { console.debug('[MapboxToken] Stopping all listeners and timers'); - if (connectionIDForToken) { - Onyx.disconnect(connectionIDForToken); - connectionIDForToken = null; + if (tokenConnection) { + Onyx.disconnect(tokenConnection); + tokenConnection = null; } - if (connectionIDForNetwork) { - Onyx.disconnect(connectionIDForNetwork); - connectionIDForNetwork = null; + if (networkConnection) { + Onyx.disconnect(networkConnection); + networkConnection = null; } if (appStateSubscription) { appStateSubscription.remove(); diff --git a/src/libs/actions/TransactionEdit.ts b/src/libs/actions/TransactionEdit.ts index 98423ca48d0a..2ce2f775586e 100644 --- a/src/libs/actions/TransactionEdit.ts +++ b/src/libs/actions/TransactionEdit.ts @@ -27,10 +27,10 @@ function removeBackupTransaction(transactionID: string) { } function restoreOriginalTransactionFromBackup(transactionID: string, isDraft: boolean) { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.TRANSACTION_BACKUP}${transactionID}`, callback: (backupTransaction) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); // Use set to completely overwrite the original transaction Onyx.set(`${isDraft ? ONYXKEYS.COLLECTION.TRANSACTION_DRAFT : ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, backupTransaction ?? null); diff --git a/src/libs/actions/User.ts b/src/libs/actions/User.ts index 5e0b83f8521d..74e5e5d869f9 100644 --- a/src/libs/actions/User.ts +++ b/src/libs/actions/User.ts @@ -552,10 +552,10 @@ function triggerNotifications(onyxUpdates: OnyxServerUpdate[]) { const isChannelMuted = (reportId: string) => new Promise((resolve) => { - const connectionId = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${reportId}`, callback: (report) => { - Onyx.disconnect(connectionId); + Onyx.disconnect(connection); resolve( !report?.notificationPreference || diff --git a/src/libs/migrations/KeyReportActionsDraftByReportActionID.ts b/src/libs/migrations/KeyReportActionsDraftByReportActionID.ts index 9ec85cf35745..a6f9a3aa8ae6 100644 --- a/src/libs/migrations/KeyReportActionsDraftByReportActionID.ts +++ b/src/libs/migrations/KeyReportActionsDraftByReportActionID.ts @@ -15,12 +15,12 @@ type ReportActionsDraftsKey = `${typeof ONYXKEYS.COLLECTION.REPORT_ACTIONS_DRAFT */ export default function () { return new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT_ACTIONS_DRAFTS, waitForCollectionCallback: true, // eslint-disable-next-line @typescript-eslint/no-misused-promises callback: (allReportActionsDrafts) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); if (!allReportActionsDrafts) { Log.info('[Migrate Onyx] Skipped migration KeyReportActionsDraftByReportActionID because there were no reportActionsDrafts'); diff --git a/src/libs/migrations/NVPMigration.ts b/src/libs/migrations/NVPMigration.ts index 7af3bc927c6b..20f3d0a86495 100644 --- a/src/libs/migrations/NVPMigration.ts +++ b/src/libs/migrations/NVPMigration.ts @@ -28,10 +28,10 @@ export default function () { const resolveWhenDone = after(Object.entries(migrations).length + 2, () => resolve()); for (const [oldKey, newKey] of Object.entries(migrations)) { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: oldKey as OnyxKey, callback: (value) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); if (value === undefined) { resolveWhenDone(); return; @@ -43,10 +43,10 @@ export default function () { }, }); } - const connectionIDAccount = Onyx.connect({ + const accountConnection = Onyx.connect({ key: ONYXKEYS.ACCOUNT, callback: (value: OnyxEntry) => { - Onyx.disconnect(connectionIDAccount); + Onyx.disconnect(accountConnection); if (!value?.activePolicyID) { resolveWhenDone(); return; @@ -60,11 +60,11 @@ export default function () { }).then(resolveWhenDone); }, }); - const connectionIDRecentlyUsedTags = Onyx.connect({ + const recentlyUsedTagsConnection = Onyx.connect({ key: ONYXKEYS.COLLECTION.OLD_POLICY_RECENTLY_USED_TAGS, waitForCollectionCallback: true, callback: (value) => { - Onyx.disconnect(connectionIDRecentlyUsedTags); + Onyx.disconnect(recentlyUsedTagsConnection); if (!value) { resolveWhenDone(); return; diff --git a/src/libs/migrations/PronounsMigration.ts b/src/libs/migrations/PronounsMigration.ts index 81744fde298c..f4970d42c604 100644 --- a/src/libs/migrations/PronounsMigration.ts +++ b/src/libs/migrations/PronounsMigration.ts @@ -7,10 +7,10 @@ import type {PersonalDetails as TPersonalDetails} from '@src/types/onyx'; function getCurrentUserAccountIDFromOnyx(): Promise { return new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.SESSION, callback: (val) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); return resolve(val?.accountID ?? -1); }, }); @@ -19,10 +19,10 @@ function getCurrentUserAccountIDFromOnyx(): Promise { function getCurrentUserPersonalDetailsFromOnyx(currentUserAccountID: number): Promise> | null> { return new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.PERSONAL_DETAILS_LIST, callback: (val) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); return resolve(val?.[currentUserAccountID] ?? null); }, }); diff --git a/src/libs/migrations/RemoveEmptyReportActionsDrafts.ts b/src/libs/migrations/RemoveEmptyReportActionsDrafts.ts index 743e9587479b..ce2f8de77634 100644 --- a/src/libs/migrations/RemoveEmptyReportActionsDrafts.ts +++ b/src/libs/migrations/RemoveEmptyReportActionsDrafts.ts @@ -13,11 +13,11 @@ type ReportActionsDraftsKey = `${typeof ONYXKEYS.COLLECTION.REPORT_ACTIONS_DRAFT */ export default function (): Promise { return new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT_ACTIONS_DRAFTS, waitForCollectionCallback: true, callback: (allReportActionsDrafts) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); if (!allReportActionsDrafts) { Log.info('[Migrate Onyx] Skipped migration RemoveEmptyReportActionsDrafts because there were no reportActionsDrafts'); diff --git a/src/libs/migrations/RenameCardIsVirtual.ts b/src/libs/migrations/RenameCardIsVirtual.ts index 751c11d70eac..2d12f30dcf21 100644 --- a/src/libs/migrations/RenameCardIsVirtual.ts +++ b/src/libs/migrations/RenameCardIsVirtual.ts @@ -10,10 +10,10 @@ type OldCard = Card & {isVirtual?: boolean}; // This migration changes the property name on each card from card list from isVirtual to nameValuePairs.isVirtual export default function () { return new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.CARD_LIST, callback: (cardList: OnyxEntry>) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); if (!cardList || isEmptyObject(cardList)) { Log.info('[Migrate Onyx] Skipped migration RenameCardIsVirtual because there are no cards linked to the account'); diff --git a/src/libs/migrations/RenameReceiptFilename.ts b/src/libs/migrations/RenameReceiptFilename.ts index f01676595dd7..4ace549b49e0 100644 --- a/src/libs/migrations/RenameReceiptFilename.ts +++ b/src/libs/migrations/RenameReceiptFilename.ts @@ -13,11 +13,11 @@ export default function () { return new Promise((resolve) => { // Connect to the TRANSACTION collection key in Onyx to get all of the stored transactions. // Go through each transaction and change the property name - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.TRANSACTION, waitForCollectionCallback: true, callback: (transactions: OnyxCollection) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); if (!transactions || isEmptyObject(transactions)) { Log.info('[Migrate Onyx] Skipped migration RenameReceiptFilename because there are no transactions'); diff --git a/src/libs/migrations/TransactionBackupsToCollection.ts b/src/libs/migrations/TransactionBackupsToCollection.ts index 806a4a5999f5..addbcb02cc02 100644 --- a/src/libs/migrations/TransactionBackupsToCollection.ts +++ b/src/libs/migrations/TransactionBackupsToCollection.ts @@ -14,11 +14,11 @@ import type {Transaction} from '@src/types/onyx'; */ export default function (): Promise { return new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.TRANSACTION, waitForCollectionCallback: true, callback: (transactions: OnyxCollection) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); // Determine whether any transactions were stored if (!transactions || Object.keys(transactions).length === 0) { diff --git a/src/libs/onyxSubscribe.ts b/src/libs/onyxSubscribe.ts index afb8818ced40..76a33c1fa137 100644 --- a/src/libs/onyxSubscribe.ts +++ b/src/libs/onyxSubscribe.ts @@ -9,8 +9,8 @@ import type {OnyxCollectionKey, OnyxKey} from '@src/ONYXKEYS'; * @return Unsubscribe callback */ function onyxSubscribe(mapping: ConnectOptions) { - const connectionId = Onyx.connect(mapping); - return () => Onyx.disconnect(connectionId); + const connection = Onyx.connect(mapping); + return () => Onyx.disconnect(connection); } export default onyxSubscribe; diff --git a/src/setup/addUtilsToWindow.ts b/src/setup/addUtilsToWindow.ts index 9cdbbac06a65..3600ad035fb0 100644 --- a/src/setup/addUtilsToWindow.ts +++ b/src/setup/addUtilsToWindow.ts @@ -24,10 +24,10 @@ export default function addUtilsToWindow() { window.Onyx.get = function (key) { return new Promise((resolve) => { // eslint-disable-next-line rulesdir/prefer-onyx-connect-in-libs - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key, callback: (value) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); resolve(value); }, waitForCollectionCallback: true, diff --git a/tests/actions/IOUTest.ts b/tests/actions/IOUTest.ts index 405760435d14..18bb3411663c 100644 --- a/tests/actions/IOUTest.ts +++ b/tests/actions/IOUTest.ts @@ -83,11 +83,11 @@ describe('actions/IOU', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, waitForCollectionCallback: true, callback: (allReports) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); // A chat report, a transaction thread, and an iou report should be created const chatReports = Object.values(allReports ?? {}).filter((report) => report?.type === CONST.REPORT.TYPE.CHAT); @@ -114,11 +114,11 @@ describe('actions/IOU', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReportID}`, waitForCollectionCallback: false, callback: (reportActionsForIOUReport) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); // The IOU report should have a CREATED action and IOU action expect(Object.values(reportActionsForIOUReport ?? {}).length).toBe(2); @@ -161,11 +161,11 @@ describe('actions/IOU', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${transactionThread?.reportID}`, waitForCollectionCallback: false, callback: (reportActionsForTransactionThread) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); // The transaction thread should have a CREATED action expect(Object.values(reportActionsForTransactionThread ?? {}).length).toBe(1); @@ -184,11 +184,11 @@ describe('actions/IOU', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.TRANSACTION, waitForCollectionCallback: true, callback: (allTransactions) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); // There should be one transaction expect(Object.values(allTransactions ?? {}).length).toBe(1); @@ -221,11 +221,11 @@ describe('actions/IOU', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReportID}`, waitForCollectionCallback: false, callback: (reportActionsForIOUReport) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); expect(Object.values(reportActionsForIOUReport ?? {}).length).toBe(2); Object.values(reportActionsForIOUReport ?? {}).forEach((reportAction) => expect(reportAction?.pendingAction).toBeFalsy()); resolve(); @@ -236,11 +236,11 @@ describe('actions/IOU', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, waitForCollectionCallback: false, callback: (transaction) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); expect(transaction?.pendingAction).toBeFalsy(); resolve(); }, @@ -280,11 +280,11 @@ describe('actions/IOU', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, waitForCollectionCallback: true, callback: (allReports) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); // The same chat report should be reused, a transaction thread and an IOU report should be created expect(Object.values(allReports ?? {}).length).toBe(3); @@ -306,11 +306,11 @@ describe('actions/IOU', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReportID}`, waitForCollectionCallback: false, callback: (allIOUReportActions) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); iouCreatedAction = Object.values(allIOUReportActions ?? {}).find((reportAction) => reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.CREATED); iouAction = Object.values(allIOUReportActions ?? {}).find((reportAction): reportAction is OnyxTypes.ReportAction => @@ -344,11 +344,11 @@ describe('actions/IOU', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.TRANSACTION, waitForCollectionCallback: true, callback: (allTransactions) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); // There should be one transaction expect(Object.values(allTransactions ?? {}).length).toBe(1); @@ -383,11 +383,11 @@ describe('actions/IOU', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReportID}`, waitForCollectionCallback: false, callback: (reportActionsForIOUReport) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); expect(Object.values(reportActionsForIOUReport ?? {}).length).toBe(2); Object.values(reportActionsForIOUReport ?? {}).forEach((reportAction) => expect(reportAction?.pendingAction).toBeFalsy()); resolve(); @@ -398,10 +398,10 @@ describe('actions/IOU', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, callback: (transaction) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); expect(transaction?.pendingAction).toBeFalsy(); resolve(); }, @@ -481,11 +481,11 @@ describe('actions/IOU', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, waitForCollectionCallback: true, callback: (allReports) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); // No new reports should be created expect(Object.values(allReports ?? {}).length).toBe(3); @@ -506,11 +506,11 @@ describe('actions/IOU', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReportID}`, waitForCollectionCallback: false, callback: (reportActionsForIOUReport) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); expect(Object.values(reportActionsForIOUReport ?? {}).length).toBe(3); newIOUAction = Object.values(reportActionsForIOUReport ?? {}).find( @@ -543,11 +543,11 @@ describe('actions/IOU', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.TRANSACTION, waitForCollectionCallback: true, callback: (allTransactions) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); // There should be two transactions expect(Object.values(allTransactions ?? {}).length).toBe(2); @@ -575,11 +575,11 @@ describe('actions/IOU', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReportID}`, waitForCollectionCallback: false, callback: (reportActionsForIOUReport) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); expect(Object.values(reportActionsForIOUReport ?? {}).length).toBe(3); Object.values(reportActionsForIOUReport ?? {}).forEach((reportAction) => expect(reportAction?.pendingAction).toBeFalsy()); resolve(); @@ -590,11 +590,11 @@ describe('actions/IOU', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.TRANSACTION, waitForCollectionCallback: true, callback: (allTransactions) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); Object.values(allTransactions ?? {}).forEach((transaction) => expect(transaction?.pendingAction).toBeFalsy()); resolve(); }, @@ -620,11 +620,11 @@ describe('actions/IOU', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, waitForCollectionCallback: true, callback: (allReports) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); // A chat report, transaction thread and an iou report should be created const chatReports = Object.values(allReports ?? {}).filter((report) => report?.type === CONST.REPORT.TYPE.CHAT); @@ -652,11 +652,11 @@ describe('actions/IOU', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReportID}`, waitForCollectionCallback: false, callback: (reportActionsForIOUReport) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); // The chat report should have a CREATED action and IOU action expect(Object.values(reportActionsForIOUReport ?? {}).length).toBe(2); @@ -700,11 +700,11 @@ describe('actions/IOU', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.TRANSACTION, waitForCollectionCallback: true, callback: (allTransactions) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); // There should be one transaction expect(Object.values(allTransactions ?? {}).length).toBe(1); @@ -732,11 +732,11 @@ describe('actions/IOU', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReportID}`, waitForCollectionCallback: false, callback: (reportActionsForIOUReport) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); expect(Object.values(reportActionsForIOUReport ?? {}).length).toBe(2); iouAction = Object.values(reportActionsForIOUReport ?? {}).find( (reportAction): reportAction is OnyxTypes.ReportAction => @@ -751,11 +751,11 @@ describe('actions/IOU', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT_ACTIONS, waitForCollectionCallback: true, callback: (reportActionsForTransactionThread) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); expect(Object.values(reportActionsForTransactionThread ?? {}).length).toBe(3); transactionThreadAction = Object.values( reportActionsForTransactionThread?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${transactionThreadReport?.reportID}`] ?? {}, @@ -769,11 +769,11 @@ describe('actions/IOU', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, waitForCollectionCallback: false, callback: (transaction) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); expect(transaction?.pendingAction).toBe(CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD); expect(transaction?.errors).toBeTruthy(); expect(Object.values(transaction?.errors ?? {})[0]).toEqual(Localize.translateLocal('iou.error.genericCreateFailureMessage')); @@ -796,11 +796,11 @@ describe('actions/IOU', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${chatReportID}`, waitForCollectionCallback: false, callback: (reportActionsForReport) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); iouAction = Object.values(reportActionsForReport ?? {}).find( (reportAction): reportAction is OnyxTypes.ReportAction => ReportActionsUtils.isMoneyRequestAction(reportAction), @@ -816,11 +816,11 @@ describe('actions/IOU', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReportID}`, waitForCollectionCallback: false, callback: (reportActionsForReport) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); iouAction = Object.values(reportActionsForReport ?? {}).find( (reportAction): reportAction is OnyxTypes.ReportAction => ReportActionsUtils.isMoneyRequestAction(reportAction), @@ -836,11 +836,11 @@ describe('actions/IOU', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${transactionThreadReport?.reportID}`, waitForCollectionCallback: false, callback: (reportActionsForReport) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); expect(reportActionsForReport).toMatchObject({}); resolve(); }, @@ -852,11 +852,11 @@ describe('actions/IOU', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, waitForCollectionCallback: false, callback: (transaction) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); expect(transaction).toBeFalsy(); resolve(); }, @@ -878,11 +878,11 @@ describe('actions/IOU', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, waitForCollectionCallback: true, callback: (allReports) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); Object.values(allReports ?? {}).forEach((report) => expect(report).toBeFalsy()); resolve(); }, @@ -894,11 +894,11 @@ describe('actions/IOU', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT_ACTIONS, waitForCollectionCallback: false, callback: (allReportActions) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); Object.values(allReportActions ?? {}).forEach((reportAction) => expect(reportAction).toBeFalsy()); resolve(); }, @@ -910,11 +910,11 @@ describe('actions/IOU', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.TRANSACTION, waitForCollectionCallback: true, callback: (allTransactions) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); Object.values(allTransactions ?? {}).forEach((transaction) => expect(transaction).toBeFalsy()); resolve(); }, @@ -1099,11 +1099,11 @@ describe('actions/IOU', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, waitForCollectionCallback: true, callback: (allReports) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); // There should now be 10 reports expect(Object.values(allReports ?? {}).length).toBe(10); @@ -1176,11 +1176,11 @@ describe('actions/IOU', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT_ACTIONS, waitForCollectionCallback: true, callback: (allReportActions) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); // There should be reportActions on all 7 chat reports + 3 IOU reports in each 1:1 chat expect(Object.values(allReportActions ?? {}).length).toBe(10); @@ -1269,11 +1269,11 @@ describe('actions/IOU', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.TRANSACTION, waitForCollectionCallback: true, callback: (allTransactions) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); /* There should be 5 transactions * – one existing one with Jules @@ -1335,11 +1335,11 @@ describe('actions/IOU', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.PERSONAL_DETAILS_LIST, waitForCollectionCallback: false, callback: (allPersonalDetails) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); expect(allPersonalDetails).toMatchObject({ [VIT_ACCOUNT_ID]: { accountID: VIT_ACCOUNT_ID, @@ -1357,11 +1357,11 @@ describe('actions/IOU', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, waitForCollectionCallback: true, callback: (allReports) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); Object.values(allReports ?? {}).forEach((report) => { if (!report?.pendingFields) { return; @@ -1376,11 +1376,11 @@ describe('actions/IOU', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT_ACTIONS, waitForCollectionCallback: true, callback: (allReportActions) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); Object.values(allReportActions ?? {}).forEach((reportAction) => expect(reportAction?.pendingAction).toBeFalsy()); resolve(); }, @@ -1390,11 +1390,11 @@ describe('actions/IOU', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.TRANSACTION, waitForCollectionCallback: true, callback: (allTransactions) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); Object.values(allTransactions ?? {}).forEach((transaction) => expect(transaction?.pendingAction).toBeFalsy()); resolve(); }, @@ -1418,11 +1418,11 @@ describe('actions/IOU', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, waitForCollectionCallback: true, callback: (allReports) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); expect(Object.values(allReports ?? {}).length).toBe(3); @@ -1451,11 +1451,11 @@ describe('actions/IOU', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT_ACTIONS, waitForCollectionCallback: true, callback: (allReportActions) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); const reportActionsForIOUReport = allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${chatReport?.iouReportID}`]; @@ -1473,11 +1473,11 @@ describe('actions/IOU', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.TRANSACTION, waitForCollectionCallback: true, callback: (allTransactions) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); expect(Object.values(allTransactions ?? {}).length).toBe(1); transaction = Object.values(allTransactions ?? {}).find((t) => t); expect(transaction).toBeTruthy(); @@ -1499,11 +1499,11 @@ describe('actions/IOU', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, waitForCollectionCallback: true, callback: (allReports) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); expect(Object.values(allReports ?? {}).length).toBe(3); @@ -1523,11 +1523,11 @@ describe('actions/IOU', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT_ACTIONS, waitForCollectionCallback: true, callback: (allReportActions) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); const reportActionsForIOUReport = allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReport?.reportID}`]; expect(Object.values(reportActionsForIOUReport ?? {}).length).toBe(3); @@ -1549,11 +1549,11 @@ describe('actions/IOU', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, waitForCollectionCallback: true, callback: (allReports) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); expect(Object.values(allReports ?? {}).length).toBe(3); @@ -1573,11 +1573,11 @@ describe('actions/IOU', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT_ACTIONS, waitForCollectionCallback: true, callback: (allReportActions) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); const reportActionsForIOUReport = allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReport?.reportID}`]; expect(Object.values(reportActionsForIOUReport ?? {}).length).toBe(3); @@ -1622,11 +1622,11 @@ describe('actions/IOU', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, waitForCollectionCallback: true, callback: (allReports) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); iouReport = Object.values(allReports ?? {}).find((report) => report?.type === CONST.REPORT.TYPE.IOU); resolve(); @@ -1637,11 +1637,11 @@ describe('actions/IOU', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReport?.reportID}`, waitForCollectionCallback: false, callback: (reportActionsForIOUReport) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); [iouAction] = Object.values(reportActionsForIOUReport ?? {}).filter( (reportAction): reportAction is OnyxTypes.ReportAction => ReportActionsUtils.isMoneyRequestAction(reportAction), @@ -1654,11 +1654,11 @@ describe('actions/IOU', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.TRANSACTION, waitForCollectionCallback: true, callback: (allTransactions) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); transaction = Object.values(allTransactions ?? {}).find((t) => !isEmptyObject(t)); resolve(); @@ -1695,11 +1695,11 @@ describe('actions/IOU', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.TRANSACTION, waitForCollectionCallback: true, callback: (allTransactions) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); const updatedTransaction = Object.values(allTransactions ?? {}).find((t) => !isEmptyObject(t)); expect(updatedTransaction?.modifiedAmount).toBe(20000); @@ -1712,11 +1712,11 @@ describe('actions/IOU', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${thread.reportID}`, waitForCollectionCallback: false, callback: (allActions) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); const updatedAction = Object.values(allActions ?? {}).find((reportAction) => !isEmptyObject(reportAction)); expect(updatedAction?.actionName).toEqual('MODIFIEDEXPENSE'); expect(updatedAction && ReportActionsUtils.getOriginalMessage(updatedAction)).toEqual( @@ -1730,11 +1730,11 @@ describe('actions/IOU', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, waitForCollectionCallback: true, callback: (allReports) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); const updatedIOUReport = Object.values(allReports ?? {}).find((report) => report?.type === CONST.REPORT.TYPE.IOU); const updatedChatReport = Object.values(allReports ?? {}).find((report) => report?.reportID === iouReport?.chatReportID); expect(updatedIOUReport).toEqual( @@ -1776,11 +1776,11 @@ describe('actions/IOU', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, waitForCollectionCallback: true, callback: (allReports) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); [iouReport] = Object.values(allReports ?? {}).filter((report) => report?.type === CONST.REPORT.TYPE.IOU); resolve(); }, @@ -1790,11 +1790,11 @@ describe('actions/IOU', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReport?.reportID}`, waitForCollectionCallback: false, callback: (reportActionsForIOUReport) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); [iouAction] = Object.values(reportActionsForIOUReport ?? {}).filter( (reportAction): reportAction is OnyxTypes.ReportAction => ReportActionsUtils.isMoneyRequestAction(reportAction), @@ -1807,11 +1807,11 @@ describe('actions/IOU', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.TRANSACTION, waitForCollectionCallback: true, callback: (allTransactions) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); transaction = Object.values(allTransactions ?? {}).find((t) => !isEmptyObject(t)); resolve(); @@ -1850,11 +1850,11 @@ describe('actions/IOU', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.TRANSACTION, waitForCollectionCallback: true, callback: (allTransactions) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); const updatedTransaction = Object.values(allTransactions ?? {}).find((t) => !isEmptyObject(t)); expect(updatedTransaction?.modifiedAmount).toBe(undefined); @@ -1868,11 +1868,11 @@ describe('actions/IOU', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${thread.reportID}`, waitForCollectionCallback: false, callback: (allActions) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); const updatedAction = Object.values(allActions ?? {}).find((reportAction) => !isEmptyObject(reportAction)); expect(updatedAction?.actionName).toEqual('MODIFIEDEXPENSE'); expect(Object.values(updatedAction?.errors ?? {})[0]).toEqual(Localize.translateLocal('iou.error.genericEditFailureMessage')); @@ -1884,11 +1884,11 @@ describe('actions/IOU', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, waitForCollectionCallback: true, callback: (allReports) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); const updatedIOUReport = Object.values(allReports ?? {}).find((report) => report?.type === CONST.REPORT.TYPE.IOU); const updatedChatReport = Object.values(allReports ?? {}).find((report) => report?.reportID === iouReport?.chatReportID); expect(updatedIOUReport).toEqual( @@ -1935,11 +1935,11 @@ describe('actions/IOU', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, waitForCollectionCallback: true, callback: (allReports) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); chatReport = Object.values(allReports ?? {}).find((report) => report?.chatType === CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT); resolve(); @@ -1956,11 +1956,11 @@ describe('actions/IOU', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, waitForCollectionCallback: true, callback: (allReports) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); expenseReport = Object.values(allReports ?? {}).find((report) => report?.type === CONST.REPORT.TYPE.IOU); resolve(); @@ -1977,11 +1977,11 @@ describe('actions/IOU', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${expenseReport?.reportID}`, waitForCollectionCallback: false, callback: (allActions) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); expect(Object.values(allActions ?? {})).toEqual( expect.arrayContaining([ expect.objectContaining({ @@ -2007,11 +2007,11 @@ describe('actions/IOU', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, waitForCollectionCallback: true, callback: (allReports) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); const updatedIOUReport = Object.values(allReports ?? {}).find((report) => report?.type === CONST.REPORT.TYPE.IOU); const updatedChatReport = Object.values(allReports ?? {}).find((report) => report?.reportID === expenseReport?.chatReportID); expect(updatedIOUReport).toEqual( @@ -2048,11 +2048,11 @@ describe('actions/IOU', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, waitForCollectionCallback: true, callback: (allReports) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); chatReport = Object.values(allReports ?? {}).find((report) => report?.chatType === CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT); resolve(); @@ -2069,11 +2069,11 @@ describe('actions/IOU', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, waitForCollectionCallback: true, callback: (allReports) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); expenseReport = Object.values(allReports ?? {}).find((report) => report?.type === CONST.REPORT.TYPE.IOU); resolve(); @@ -2091,11 +2091,11 @@ describe('actions/IOU', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${expenseReport?.reportID}`, waitForCollectionCallback: false, callback: (allActions) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); const erroredAction = Object.values(allActions ?? {}).find((action) => !isEmptyObject(action?.errors)); expect(Object.values(erroredAction?.errors ?? {})[0]).toEqual(Localize.translateLocal('iou.error.other')); resolve(); @@ -2153,11 +2153,11 @@ describe('actions/IOU', () => { // When fetching all reports from Onyx const allReports = await new Promise>((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, waitForCollectionCallback: true, callback: (reports) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); resolve(reports); }, }); @@ -2189,11 +2189,11 @@ describe('actions/IOU', () => { // When fetching all report actions from Onyx const allReportActions = await new Promise>((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT_ACTIONS, waitForCollectionCallback: true, callback: (actions) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); resolve(actions); }, }); @@ -2209,11 +2209,11 @@ describe('actions/IOU', () => { // When fetching all transactions from Onyx const allTransactions = await new Promise>((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.TRANSACTION, waitForCollectionCallback: true, callback: (transactions) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); resolve(transactions); }, }); @@ -2241,11 +2241,11 @@ describe('actions/IOU', () => { // Then we check if the IOU report action is removed from the report actions collection let reportActionsForReport = await new Promise>((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReport?.reportID}`, waitForCollectionCallback: false, callback: (actionsForReport) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); resolve(actionsForReport); }, }); @@ -2259,11 +2259,11 @@ describe('actions/IOU', () => { // Then we check if the transaction is removed from the transactions collection const t = await new Promise>((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transaction?.transactionID}`, waitForCollectionCallback: false, callback: (transactionResult) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); resolve(transactionResult); }, }); @@ -2277,11 +2277,11 @@ describe('actions/IOU', () => { // Then we recheck the IOU report action from the report actions collection reportActionsForReport = await new Promise>((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReport?.reportID}`, waitForCollectionCallback: false, callback: (actionsForReport) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); resolve(actionsForReport); }, }); @@ -2294,11 +2294,11 @@ describe('actions/IOU', () => { // Then we recheck the transaction from the transactions collection const tr = await new Promise>((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transaction?.transactionID}`, waitForCollectionCallback: false, callback: (transactionResult) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); resolve(transactionResult); }, }); @@ -2318,11 +2318,11 @@ describe('actions/IOU', () => { await waitForBatchedUpdates(); let report = await new Promise>((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${iouReport?.reportID}`, waitForCollectionCallback: false, callback: (res) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); resolve(res); }, }); @@ -2336,11 +2336,11 @@ describe('actions/IOU', () => { await waitForBatchedUpdates(); report = await new Promise>((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${iouReport?.reportID}`, waitForCollectionCallback: false, callback: (res) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); resolve(res); }, }); @@ -2392,11 +2392,11 @@ describe('actions/IOU', () => { // Then expect that the IOU report still exists let allReports = await new Promise>((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, waitForCollectionCallback: true, callback: (reports) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); resolve(reports); }, }); @@ -2413,11 +2413,11 @@ describe('actions/IOU', () => { mockFetch?.resume?.(); allReports = await new Promise>((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, waitForCollectionCallback: true, callback: (reports) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); resolve(reports); }, }); @@ -2458,11 +2458,11 @@ describe('actions/IOU', () => { // Then The iou action has the transaction report id as a child report ID const allReportActions = await new Promise>((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT_ACTIONS, waitForCollectionCallback: true, callback: (actions) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); resolve(actions); }, }); @@ -2487,11 +2487,11 @@ describe('actions/IOU', () => { // Then The report for the given thread ID does not exist let report = await new Promise>((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${thread.reportID}`, waitForCollectionCallback: false, callback: (reportData) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); resolve(reportData); }, }); @@ -2502,11 +2502,11 @@ describe('actions/IOU', () => { // Then After resuming fetch, the report for the given thread ID still does not exist report = await new Promise>((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${thread.reportID}`, waitForCollectionCallback: false, callback: (reportData) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); resolve(reportData); }, }); @@ -2542,11 +2542,11 @@ describe('actions/IOU', () => { // Then The iou action has the transaction report id as a child report ID const allReportActions = await new Promise>((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT_ACTIONS, waitForCollectionCallback: true, callback: (actions) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); resolve(actions); }, }); @@ -2585,11 +2585,11 @@ describe('actions/IOU', () => { // Fetch the updated IOU Action from Onyx await new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReport?.reportID}`, waitForCollectionCallback: false, callback: (reportActionsForReport) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); createIOUAction = Object.values(reportActionsForReport ?? {}).find((reportAction): reportAction is OnyxTypes.ReportAction => ReportActionsUtils.isMoneyRequestAction(reportAction), ); @@ -2606,11 +2606,11 @@ describe('actions/IOU', () => { // Then, the report for the given thread ID does not exist const report = await new Promise>((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${thread.reportID}`, waitForCollectionCallback: false, callback: (reportData) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); resolve(reportData); }, }); @@ -2641,10 +2641,10 @@ describe('actions/IOU', () => { await waitForBatchedUpdates(); await new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${thread.reportID}`, callback: (report) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); expect(report).toBeTruthy(); resolve(); }, @@ -2680,11 +2680,11 @@ describe('actions/IOU', () => { // Then the transaction thread report should still exist await new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${thread.reportID}`, waitForCollectionCallback: false, callback: (report) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); expect(report).toBeTruthy(); resolve(); }, @@ -2695,10 +2695,10 @@ describe('actions/IOU', () => { // Then the transaction thread report should still exist mockFetch?.resume?.(); await new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${thread.reportID}`, callback: (report) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); expect(report).toBeTruthy(); resolve(); }, @@ -2730,11 +2730,11 @@ describe('actions/IOU', () => { await waitForBatchedUpdates(); const allReportActions = await new Promise>((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT_ACTIONS, waitForCollectionCallback: true, callback: (actions) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); resolve(actions); }, }); @@ -2758,11 +2758,11 @@ describe('actions/IOU', () => { // Fetch the updated IOU Action from Onyx due to addition of comment to transaction thread. // This needs to be fetched as `deleteMoneyRequest` depends on `childVisibleActionCount` in `createIOUAction`. await new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReport?.reportID}`, waitForCollectionCallback: false, callback: (reportActionsForReport) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); createIOUAction = Object.values(reportActionsForReport ?? {}).find((reportAction): reportAction is OnyxTypes.ReportAction => ReportActionsUtils.isMoneyRequestAction(reportAction), ); @@ -2830,11 +2830,11 @@ describe('actions/IOU', () => { // Then we expect the moneyRequestPreview to show [Deleted expense] await new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReport?.reportID}`, waitForCollectionCallback: false, callback: (reportActionsForReport) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); createIOUAction = Object.values(reportActionsForReport ?? {}).find((reportAction): reportAction is OnyxTypes.ReportAction => ReportActionsUtils.isMoneyRequestAction(reportAction), ); @@ -2850,11 +2850,11 @@ describe('actions/IOU', () => { // Then we expect the moneyRequestPreview to show [Deleted expense] await new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReport?.reportID}`, waitForCollectionCallback: false, callback: (reportActionsForReport) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); createIOUAction = Object.values(reportActionsForReport ?? {}).find((reportAction): reportAction is OnyxTypes.ReportAction => ReportActionsUtils.isMoneyRequestAction(reportAction), ); @@ -2969,11 +2969,11 @@ describe('actions/IOU', () => { await waitForBatchedUpdates(); const allReportActions = await new Promise>((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT_ACTIONS, waitForCollectionCallback: true, callback: (actions) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); resolve(actions); }, }); @@ -2998,11 +2998,11 @@ describe('actions/IOU', () => { await waitForBatchedUpdates(); let allReports = await new Promise>((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, waitForCollectionCallback: true, callback: (reports) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); resolve(reports); }, }); @@ -3018,11 +3018,11 @@ describe('actions/IOU', () => { mockFetch?.resume?.(); allReports = await new Promise>((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, waitForCollectionCallback: true, callback: (reports) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); resolve(reports); }, }); @@ -3068,11 +3068,11 @@ describe('actions/IOU', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, waitForCollectionCallback: true, callback: (allReports) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); chatReport = Object.values(allReports ?? {}).find((report) => report?.chatType === CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT); resolve(); @@ -3100,11 +3100,11 @@ describe('actions/IOU', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, waitForCollectionCallback: true, callback: (allReports) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); expenseReport = Object.values(allReports ?? {}).find((report) => report?.type === CONST.REPORT.TYPE.EXPENSE); Onyx.merge(`report_${expenseReport?.reportID}`, { statusNum: 0, @@ -3118,11 +3118,11 @@ describe('actions/IOU', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, waitForCollectionCallback: true, callback: (allReports) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); expenseReport = Object.values(allReports ?? {}).find((report) => report?.type === CONST.REPORT.TYPE.EXPENSE); // Verify report is a draft @@ -3142,11 +3142,11 @@ describe('actions/IOU', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, waitForCollectionCallback: true, callback: (allReports) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); expenseReport = Object.values(allReports ?? {}).find((report) => report?.type === CONST.REPORT.TYPE.EXPENSE); // Report was submitted correctly expect(expenseReport?.stateNum).toBe(1); @@ -3171,11 +3171,11 @@ describe('actions/IOU', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, waitForCollectionCallback: true, callback: (allReports) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); chatReport = Object.values(allReports ?? {}).find((report) => report?.chatType === CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT); resolve(); @@ -3203,11 +3203,11 @@ describe('actions/IOU', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, waitForCollectionCallback: true, callback: (allReports) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); expenseReport = Object.values(allReports ?? {}).find((report) => report?.type === CONST.REPORT.TYPE.EXPENSE); Onyx.merge(`report_${expenseReport?.reportID}`, { statusNum: 0, @@ -3221,11 +3221,11 @@ describe('actions/IOU', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, waitForCollectionCallback: true, callback: (allReports) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); expenseReport = Object.values(allReports ?? {}).find((report) => report?.type === CONST.REPORT.TYPE.EXPENSE); // Verify report is a draft @@ -3245,11 +3245,11 @@ describe('actions/IOU', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, waitForCollectionCallback: true, callback: (allReports) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); expenseReport = Object.values(allReports ?? {}).find((report) => report?.type === CONST.REPORT.TYPE.EXPENSE); // Report is closed since the default policy settings is Submit and Close @@ -3275,11 +3275,11 @@ describe('actions/IOU', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, waitForCollectionCallback: true, callback: (allReports) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); chatReport = Object.values(allReports ?? {}).find((report) => report?.chatType === CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT); resolve(); @@ -3307,11 +3307,11 @@ describe('actions/IOU', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, waitForCollectionCallback: true, callback: (allReports) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); expenseReport = Object.values(allReports ?? {}).find((report) => report?.type === CONST.REPORT.TYPE.EXPENSE); Onyx.merge(`report_${expenseReport?.reportID}`, { statusNum: 0, @@ -3325,11 +3325,11 @@ describe('actions/IOU', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, waitForCollectionCallback: true, callback: (allReports) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); expenseReport = Object.values(allReports ?? {}).find((report) => report?.type === CONST.REPORT.TYPE.EXPENSE); // Verify report is a draft @@ -3350,11 +3350,11 @@ describe('actions/IOU', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, waitForCollectionCallback: true, callback: (allReports) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); expenseReport = Object.values(allReports ?? {}).find((report) => report?.type === CONST.REPORT.TYPE.EXPENSE); // Report was submitted with some fail diff --git a/tests/actions/PolicyCategoryTest.ts b/tests/actions/PolicyCategoryTest.ts index 3225942e8fa8..e470771d492f 100644 --- a/tests/actions/PolicyCategoryTest.ts +++ b/tests/actions/PolicyCategoryTest.ts @@ -34,11 +34,11 @@ describe('actions/PolicyCategory', () => { Category.setWorkspaceRequiresCategory(fakePolicy.id, true); await waitForBatchedUpdates(); await new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, waitForCollectionCallback: false, callback: (policy) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); // Check if policy requiresCategory was updated with correct values expect(policy?.requiresCategory).toBeTruthy(); expect(policy?.pendingFields?.requiresCategory).toBe(CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE); @@ -50,11 +50,11 @@ describe('actions/PolicyCategory', () => { await mockFetch?.resume?.(); await waitForBatchedUpdates(); await new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, waitForCollectionCallback: false, callback: (policy) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); // Check if the policy pendingFields was cleared expect(policy?.pendingFields?.requiresCategory).toBeFalsy(); resolve(); @@ -74,11 +74,11 @@ describe('actions/PolicyCategory', () => { Category.createPolicyCategory(fakePolicy.id, newCategoryName); await waitForBatchedUpdates(); await new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${fakePolicy.id}`, waitForCollectionCallback: false, callback: (policyCategories) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); const newCategory = policyCategories?.[newCategoryName]; expect(newCategory?.name).toBe(newCategoryName); @@ -91,11 +91,11 @@ describe('actions/PolicyCategory', () => { await mockFetch?.resume?.(); await waitForBatchedUpdates(); await new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${fakePolicy.id}`, waitForCollectionCallback: false, callback: (policyCategories) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); const newCategory = policyCategories?.[newCategoryName]; expect(newCategory?.errors).toBeFalsy(); @@ -122,11 +122,11 @@ describe('actions/PolicyCategory', () => { }); await waitForBatchedUpdates(); await new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${fakePolicy.id}`, waitForCollectionCallback: false, callback: (policyCategories) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); expect(policyCategories?.[oldCategoryName]).toBeFalsy(); expect(policyCategories?.[newCategoryName]?.name).toBe(newCategoryName); @@ -140,11 +140,11 @@ describe('actions/PolicyCategory', () => { await mockFetch?.resume?.(); await waitForBatchedUpdates(); await new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${fakePolicy.id}`, waitForCollectionCallback: false, callback: (policyCategories) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); expect(policyCategories?.[newCategoryName]?.pendingAction).toBeFalsy(); expect(policyCategories?.[newCategoryName]?.pendingFields?.name).toBeFalsy(); @@ -172,11 +172,11 @@ describe('actions/PolicyCategory', () => { Category.setWorkspaceCategoryEnabled(fakePolicy.id, categoriesToUpdate); await waitForBatchedUpdates(); await new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${fakePolicy.id}`, waitForCollectionCallback: false, callback: (policyCategories) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); expect(policyCategories?.[categoryNameToUpdate]?.enabled).toBeTruthy(); expect(policyCategories?.[categoryNameToUpdate]?.pendingAction).toBe(CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE); @@ -189,11 +189,11 @@ describe('actions/PolicyCategory', () => { await mockFetch?.resume?.(); await waitForBatchedUpdates(); await new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${fakePolicy.id}`, waitForCollectionCallback: false, callback: (policyCategories) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); expect(policyCategories?.[categoryNameToUpdate]?.pendingAction).toBeFalsy(); expect(policyCategories?.[categoryNameToUpdate]?.pendingFields?.enabled).toBeFalsy(); @@ -217,11 +217,11 @@ describe('actions/PolicyCategory', () => { Category.deleteWorkspaceCategories(fakePolicy.id, categoriesToDelete); await waitForBatchedUpdates(); await new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${fakePolicy.id}`, waitForCollectionCallback: false, callback: (policyCategories) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); expect(policyCategories?.[categoryNameToDelete]?.pendingAction).toBe(CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE); resolve(); @@ -231,11 +231,11 @@ describe('actions/PolicyCategory', () => { await mockFetch?.resume?.(); await waitForBatchedUpdates(); await new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${fakePolicy.id}`, waitForCollectionCallback: false, callback: (policyCategories) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); expect(policyCategories?.[categoryNameToDelete]).toBeFalsy(); resolve(); diff --git a/tests/actions/PolicyMemberTest.ts b/tests/actions/PolicyMemberTest.ts index 98dcdb2c9626..f9ac32010a23 100644 --- a/tests/actions/PolicyMemberTest.ts +++ b/tests/actions/PolicyMemberTest.ts @@ -51,11 +51,11 @@ describe('actions/PolicyMember', () => { Member.acceptJoinRequest(fakeReport.reportID, fakeReportAction); await waitForBatchedUpdates(); await new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${fakeReport.reportID}`, waitForCollectionCallback: false, callback: (reportActions) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); const reportAction = reportActions?.[fakeReportAction.reportActionID] as ReportAction; @@ -70,11 +70,11 @@ describe('actions/PolicyMember', () => { await mockFetch?.resume?.(); await waitForBatchedUpdates(); await new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${fakeReport.reportID}`, waitForCollectionCallback: false, callback: (reportActions) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); const reportAction = reportActions?.[fakeReportAction.reportActionID]; @@ -107,11 +107,11 @@ describe('actions/PolicyMember', () => { Member.updateWorkspaceMembersRole(fakePolicy.id, [fakeUser2.accountID], CONST.POLICY.ROLE.ADMIN); await waitForBatchedUpdates(); await new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, waitForCollectionCallback: false, callback: (policy) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); const employee = policy?.employeeList?.[fakeUser2?.login ?? '']; expect(employee?.role).toBe(CONST.POLICY.ROLE.ADMIN); @@ -122,11 +122,11 @@ describe('actions/PolicyMember', () => { await mockFetch?.resume?.(); await waitForBatchedUpdates(); await new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, waitForCollectionCallback: false, callback: (policy) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); const employee = policy?.employeeList?.[fakeUser2?.login ?? '']; expect(employee?.pendingAction).toBeFalsy(); resolve(); @@ -147,11 +147,11 @@ describe('actions/PolicyMember', () => { Member.requestWorkspaceOwnerChange(fakePolicy.id); await waitForBatchedUpdates(); await new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, waitForCollectionCallback: false, callback: (policy) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); expect(policy?.errorFields).toBeFalsy(); expect(policy?.isLoading).toBeTruthy(); expect(policy?.isChangeOwnerSuccessful).toBeFalsy(); @@ -163,11 +163,11 @@ describe('actions/PolicyMember', () => { await mockFetch?.resume?.(); await waitForBatchedUpdates(); await new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, waitForCollectionCallback: false, callback: (policy) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); expect(policy?.isLoading).toBeFalsy(); expect(policy?.isChangeOwnerSuccessful).toBeTruthy(); expect(policy?.isChangeOwnerFailed)?.toBeFalsy(); @@ -198,11 +198,11 @@ describe('actions/PolicyMember', () => { Policy.addBillingCardAndRequestPolicyOwnerChange(fakePolicy.id, fakeCard); await waitForBatchedUpdates(); await new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, waitForCollectionCallback: false, callback: (policy) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); expect(policy?.errorFields).toBeFalsy(); expect(policy?.isLoading).toBeTruthy(); expect(policy?.isChangeOwnerSuccessful).toBeFalsy(); @@ -214,11 +214,11 @@ describe('actions/PolicyMember', () => { await mockFetch?.resume?.(); await waitForBatchedUpdates(); await new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, waitForCollectionCallback: false, callback: (policy) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); expect(policy?.isLoading).toBeFalsy(); expect(policy?.isChangeOwnerSuccessful).toBeTruthy(); expect(policy?.isChangeOwnerFailed)?.toBeFalsy(); diff --git a/tests/actions/PolicyProfileTest.ts b/tests/actions/PolicyProfileTest.ts index 121475de2ae5..7232ed33227f 100644 --- a/tests/actions/PolicyProfileTest.ts +++ b/tests/actions/PolicyProfileTest.ts @@ -36,11 +36,11 @@ describe('actions/PolicyProfile', () => { Policy.updateWorkspaceDescription(fakePolicy.id, newDescription, oldDescription); await waitForBatchedUpdates(); await new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, waitForCollectionCallback: false, callback: (policy) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); expect(policy?.description).toBe(parsedDescription); expect(policy?.pendingFields?.description).toBe(CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE); @@ -52,11 +52,11 @@ describe('actions/PolicyProfile', () => { await mockFetch?.resume?.(); await waitForBatchedUpdates(); await new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, waitForCollectionCallback: false, callback: (policy) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); expect(policy?.pendingFields?.description).toBeFalsy(); resolve(); diff --git a/tests/actions/PolicyTagTest.ts b/tests/actions/PolicyTagTest.ts index 54b3d58785a0..19749c7eb644 100644 --- a/tests/actions/PolicyTagTest.ts +++ b/tests/actions/PolicyTagTest.ts @@ -40,11 +40,11 @@ describe('actions/Policy', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, waitForCollectionCallback: false, callback: (policy) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); // RequiresTag is enabled and pending expect(policy?.requiresTag).toBeTruthy(); @@ -60,11 +60,11 @@ describe('actions/Policy', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, waitForCollectionCallback: false, callback: (policy) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); expect(policy?.pendingFields?.requiresTag).toBeFalsy(); resolve(); }, @@ -87,11 +87,11 @@ describe('actions/Policy', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, waitForCollectionCallback: false, callback: (policy) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); // RequiresTag is disabled and pending expect(policy?.requiresTag).toBeFalsy(); @@ -107,11 +107,11 @@ describe('actions/Policy', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, waitForCollectionCallback: false, callback: (policy) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); expect(policy?.pendingFields?.requiresTag).toBeFalsy(); resolve(); }, @@ -138,11 +138,11 @@ describe('actions/Policy', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, waitForCollectionCallback: false, callback: (policy) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); expect(policy?.pendingFields?.requiresTag).toBeFalsy(); expect(policy?.errors).toBeTruthy(); expect(policy?.requiresTag).toBeTruthy(); @@ -184,11 +184,11 @@ describe('actions/Policy', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY_TAGS}${fakePolicy.id}`, waitForCollectionCallback: false, callback: (policyTags) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); // Tag list name is updated and pending expect(Object.keys(policyTags?.[oldTagListName] ?? {}).length).toBe(0); @@ -205,11 +205,11 @@ describe('actions/Policy', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY_TAGS}${fakePolicy.id}`, waitForCollectionCallback: false, callback: (policyTags) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); expect(policyTags?.[newTagListName]?.pendingAction).toBeFalsy(); expect(Object.keys(policyTags?.[oldTagListName] ?? {}).length).toBe(0); @@ -254,11 +254,11 @@ describe('actions/Policy', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY_TAGS}${fakePolicy.id}`, waitForCollectionCallback: false, callback: (policyTags) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); expect(policyTags?.[newTagListName]).toBeFalsy(); expect(policyTags?.[oldTagListName]).toBeTruthy(); @@ -294,11 +294,11 @@ describe('actions/Policy', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY_TAGS}${fakePolicy.id}`, waitForCollectionCallback: false, callback: (policyTags) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); const newTag = policyTags?.[tagListName]?.tags?.[newTagName]; expect(newTag?.name).toBe(newTagName); @@ -316,11 +316,11 @@ describe('actions/Policy', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY_TAGS}${fakePolicy.id}`, waitForCollectionCallback: false, callback: (policyTags) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); const newTag = policyTags?.[tagListName]?.tags?.[newTagName]; expect(newTag?.errors).toBeFalsy(); @@ -358,11 +358,11 @@ describe('actions/Policy', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY_TAGS}${fakePolicy.id}`, waitForCollectionCallback: false, callback: (policyTags) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); const newTag = policyTags?.[tagListName]?.tags?.[newTagName]; expect(newTag?.errors).toBeTruthy(); @@ -403,11 +403,11 @@ describe('actions/Policy', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY_TAGS}${fakePolicy.id}`, waitForCollectionCallback: false, callback: (policyTags) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); Object.keys(tagsToUpdate).forEach((key) => { const updatedTag = policyTags?.[tagListName]?.tags[key]; @@ -427,11 +427,11 @@ describe('actions/Policy', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY_TAGS}${fakePolicy.id}`, waitForCollectionCallback: false, callback: (policyTags) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); Object.keys(tagsToUpdate).forEach((key) => { const updatedTag = policyTags?.[tagListName]?.tags[key]; @@ -478,11 +478,11 @@ describe('actions/Policy', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY_TAGS}${fakePolicy.id}`, waitForCollectionCallback: false, callback: (policyTags) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); Object.keys(tagsToUpdate).forEach((key) => { const updatedTag = policyTags?.[tagListName]?.tags[key]; @@ -529,11 +529,11 @@ describe('actions/Policy', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY_TAGS}${fakePolicy.id}`, waitForCollectionCallback: false, callback: (policyTags) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); const tags = policyTags?.[tagListName]?.tags; expect(tags?.[oldTagName]).toBeFalsy(); @@ -551,11 +551,11 @@ describe('actions/Policy', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY_TAGS}${fakePolicy.id}`, waitForCollectionCallback: false, callback: (policyTags) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); const tags = policyTags?.[tagListName]?.tags; expect(tags?.[newTagName]?.pendingAction).toBeFalsy(); @@ -601,11 +601,11 @@ describe('actions/Policy', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY_TAGS}${fakePolicy.id}`, waitForCollectionCallback: false, callback: (policyTags) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); const tags = policyTags?.[tagListName]?.tags; expect(tags?.[newTagName]).toBeFalsy(); @@ -641,11 +641,11 @@ describe('actions/Policy', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY_TAGS}${fakePolicy.id}`, waitForCollectionCallback: false, callback: (policyTags) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); tagsToDelete.forEach((tagName) => { expect(policyTags?.[tagListName]?.tags[tagName]?.pendingAction).toBe(CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE); @@ -661,11 +661,11 @@ describe('actions/Policy', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY_TAGS}${fakePolicy.id}`, waitForCollectionCallback: false, callback: (policyTags) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); tagsToDelete.forEach((tagName) => { expect(policyTags?.[tagListName]?.tags[tagName]).toBeFalsy(); @@ -703,11 +703,11 @@ describe('actions/Policy', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY_TAGS}${fakePolicy.id}`, waitForCollectionCallback: false, callback: (policyTags) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); tagsToDelete.forEach((tagName) => { expect(policyTags?.[tagListName]?.tags[tagName].pendingAction).toBeFalsy(); diff --git a/tests/actions/PolicyTaxTest.ts b/tests/actions/PolicyTaxTest.ts index ab56b0d5dbe1..ed4c32af9f2e 100644 --- a/tests/actions/PolicyTaxTest.ts +++ b/tests/actions/PolicyTaxTest.ts @@ -37,11 +37,11 @@ describe('actions/PolicyTax', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, waitForCollectionCallback: false, callback: (policy) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); expect(policy?.taxRates?.name).toBe(customTaxName); expect(policy?.taxRates?.pendingFields?.name).toBe(CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE); expect(policy?.taxRates?.errorFields).toBeFalsy(); @@ -55,11 +55,11 @@ describe('actions/PolicyTax', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, waitForCollectionCallback: false, callback: (policy) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); expect(policy?.taxRates?.pendingFields?.name).toBeFalsy(); expect(policy?.taxRates?.errorFields).toBeFalsy(); resolve(); @@ -78,11 +78,11 @@ describe('actions/PolicyTax', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, waitForCollectionCallback: false, callback: (policy) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); expect(policy?.taxRates?.name).toBe(customTaxName); expect(policy?.taxRates?.pendingFields?.name).toBe(CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE); expect(policy?.taxRates?.errorFields).toBeFalsy(); @@ -99,11 +99,11 @@ describe('actions/PolicyTax', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, waitForCollectionCallback: false, callback: (policy) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); expect(policy?.taxRates?.name).toBe(originalCustomTaxName); expect(policy?.taxRates?.pendingFields?.name).toBeFalsy(); expect(policy?.taxRates?.errorFields?.name).toBeTruthy(); @@ -125,11 +125,11 @@ describe('actions/PolicyTax', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, waitForCollectionCallback: false, callback: (policy) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); expect(policy?.taxRates?.defaultExternalID).toBe(taxCode); expect(policy?.taxRates?.pendingFields?.defaultExternalID).toBe(CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE); expect(policy?.taxRates?.errorFields).toBeFalsy(); @@ -143,11 +143,11 @@ describe('actions/PolicyTax', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, waitForCollectionCallback: false, callback: (policy) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); expect(policy?.taxRates?.pendingFields?.defaultExternalID).toBeFalsy(); expect(policy?.taxRates?.errorFields).toBeFalsy(); resolve(); @@ -166,11 +166,11 @@ describe('actions/PolicyTax', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, waitForCollectionCallback: false, callback: (policy) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); expect(policy?.taxRates?.defaultExternalID).toBe(taxCode); expect(policy?.taxRates?.pendingFields?.defaultExternalID).toBe(CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE); expect(policy?.taxRates?.errorFields).toBeFalsy(); @@ -187,11 +187,11 @@ describe('actions/PolicyTax', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, waitForCollectionCallback: false, callback: (policy) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); expect(policy?.taxRates?.defaultExternalID).toBe(originalDefaultExternalID); expect(policy?.taxRates?.pendingFields?.defaultExternalID).toBeFalsy(); expect(policy?.taxRates?.errorFields?.defaultExternalID).toBeTruthy(); @@ -212,11 +212,11 @@ describe('actions/PolicyTax', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, waitForCollectionCallback: false, callback: (policy) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); expect(policy?.taxRates?.foreignTaxDefault).toBe(taxCode); expect(policy?.taxRates?.pendingFields?.foreignTaxDefault).toBe(CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE); expect(policy?.taxRates?.errorFields).toBeFalsy(); @@ -230,11 +230,11 @@ describe('actions/PolicyTax', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, waitForCollectionCallback: false, callback: (policy) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); // Check if the policy pendingFields was cleared expect(policy?.taxRates?.pendingFields?.foreignTaxDefault).toBeFalsy(); expect(policy?.taxRates?.errorFields).toBeFalsy(); @@ -254,11 +254,11 @@ describe('actions/PolicyTax', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, waitForCollectionCallback: false, callback: (policy) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); expect(policy?.taxRates?.foreignTaxDefault).toBe(taxCode); expect(policy?.taxRates?.pendingFields?.foreignTaxDefault).toBe(CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE); expect(policy?.taxRates?.errorFields).toBeFalsy(); @@ -276,11 +276,11 @@ describe('actions/PolicyTax', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, waitForCollectionCallback: false, callback: (policy) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); // Check if the policy pendingFields was cleared expect(policy?.taxRates?.foreignTaxDefault).toBe(originalDefaultForeignCurrencyID); expect(policy?.taxRates?.pendingFields?.foreignTaxDefault).toBeFalsy(); @@ -306,11 +306,11 @@ describe('actions/PolicyTax', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, waitForCollectionCallback: false, callback: (policy) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); const createdTax = policy?.taxRates?.taxes?.[newTaxRate.code ?? '']; expect(createdTax?.code).toBe(newTaxRate.code); expect(createdTax?.name).toBe(newTaxRate.name); @@ -326,11 +326,11 @@ describe('actions/PolicyTax', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, waitForCollectionCallback: false, callback: (policy) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); const createdTax = policy?.taxRates?.taxes?.[newTaxRate.code ?? '']; expect(createdTax?.errors).toBeFalsy(); expect(createdTax?.pendingFields).toBeFalsy(); @@ -354,11 +354,11 @@ describe('actions/PolicyTax', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, waitForCollectionCallback: false, callback: (policy) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); const createdTax = policy?.taxRates?.taxes?.[newTaxRate.code ?? '']; expect(createdTax?.code).toBe(newTaxRate.code); expect(createdTax?.name).toBe(newTaxRate.name); @@ -377,11 +377,11 @@ describe('actions/PolicyTax', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, waitForCollectionCallback: false, callback: (policy) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); const createdTax = policy?.taxRates?.taxes?.[newTaxRate.code ?? '']; expect(createdTax?.errors).toBeTruthy(); resolve(); @@ -400,11 +400,11 @@ describe('actions/PolicyTax', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, waitForCollectionCallback: false, callback: (policy) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); const disabledTax = policy?.taxRates?.taxes?.[disableTaxID]; expect(disabledTax?.isDisabled).toBeTruthy(); expect(disabledTax?.pendingFields?.isDisabled).toBe(CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE); @@ -420,11 +420,11 @@ describe('actions/PolicyTax', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, waitForCollectionCallback: false, callback: (policy) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); const disabledTax = policy?.taxRates?.taxes?.[disableTaxID]; expect(disabledTax?.errorFields?.isDisabled).toBeFalsy(); expect(disabledTax?.pendingFields?.isDisabled).toBeFalsy(); @@ -444,11 +444,11 @@ describe('actions/PolicyTax', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, waitForCollectionCallback: false, callback: (policy) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); const disabledTax = policy?.taxRates?.taxes?.[disableTaxID]; expect(disabledTax?.isDisabled).toBeTruthy(); expect(disabledTax?.pendingFields?.isDisabled).toBe(CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE); @@ -467,11 +467,11 @@ describe('actions/PolicyTax', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, waitForCollectionCallback: false, callback: (policy) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); const disabledTax = policy?.taxRates?.taxes?.[disableTaxID]; expect(disabledTax?.isDisabled).toBe(!!originalTaxes[disableTaxID].isDisabled); expect(disabledTax?.errorFields?.isDisabled).toBeTruthy(); @@ -494,11 +494,11 @@ describe('actions/PolicyTax', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, waitForCollectionCallback: false, callback: (policy) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); const updatedTax = policy?.taxRates?.taxes?.[taxID]; expect(updatedTax?.name).toBe(newTaxName); expect(updatedTax?.pendingFields?.name).toBe(CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE); @@ -514,11 +514,11 @@ describe('actions/PolicyTax', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, waitForCollectionCallback: false, callback: (policy) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); const updatedTax = policy?.taxRates?.taxes?.[taxID]; expect(updatedTax?.errorFields?.name).toBeFalsy(); expect(updatedTax?.pendingFields?.name).toBeFalsy(); @@ -539,11 +539,11 @@ describe('actions/PolicyTax', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, waitForCollectionCallback: false, callback: (policy) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); const updatedTax = policy?.taxRates?.taxes?.[taxID]; expect(updatedTax?.name).toBe(newTaxName); expect(updatedTax?.pendingFields?.name).toBe(CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE); @@ -562,11 +562,11 @@ describe('actions/PolicyTax', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, waitForCollectionCallback: false, callback: (policy) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); const updatedTax = policy?.taxRates?.taxes?.[taxID]; expect(updatedTax?.name).toBe(originalTaxRate.name); expect(updatedTax?.errorFields?.name).toBeTruthy(); @@ -589,11 +589,11 @@ describe('actions/PolicyTax', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, waitForCollectionCallback: false, callback: (policy) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); const updatedTax = policy?.taxRates?.taxes?.[taxID]; expect(updatedTax?.value).toBe(stringTaxValue); expect(updatedTax?.pendingFields?.value).toBe(CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE); @@ -609,11 +609,11 @@ describe('actions/PolicyTax', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, waitForCollectionCallback: false, callback: (policy) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); const updatedTax = policy?.taxRates?.taxes?.[taxID]; expect(updatedTax?.errorFields?.value).toBeFalsy(); expect(updatedTax?.pendingFields?.value).toBeFalsy(); @@ -635,11 +635,11 @@ describe('actions/PolicyTax', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, waitForCollectionCallback: false, callback: (policy) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); const updatedTax = policy?.taxRates?.taxes?.[taxID]; expect(updatedTax?.value).toBe(stringTaxValue); expect(updatedTax?.pendingFields?.value).toBe(CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE); @@ -658,11 +658,11 @@ describe('actions/PolicyTax', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, waitForCollectionCallback: false, callback: (policy) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); const updatedTax = policy?.taxRates?.taxes?.[taxID]; expect(updatedTax?.value).toBe(originalTaxRate.value); expect(updatedTax?.errorFields?.value).toBeTruthy(); @@ -685,11 +685,11 @@ describe('actions/PolicyTax', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, waitForCollectionCallback: false, callback: (policy) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); const taxRates = policy?.taxRates; const deletedTax = taxRates?.taxes?.[taxID]; expect(taxRates?.pendingFields?.foreignTaxDefault).toBeFalsy(); @@ -706,11 +706,11 @@ describe('actions/PolicyTax', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, waitForCollectionCallback: false, callback: (policy) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); const taxRates = policy?.taxRates; const deletedTax = taxRates?.taxes?.[taxID]; expect(taxRates?.pendingFields?.foreignTaxDefault).toBeFalsy(); @@ -735,11 +735,11 @@ describe('actions/PolicyTax', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, waitForCollectionCallback: false, callback: (policy) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); const taxRates = policy?.taxRates; const deletedTax = taxRates?.taxes?.[taxID]; expect(taxRates?.pendingFields?.foreignTaxDefault).toBe(CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE); @@ -756,11 +756,11 @@ describe('actions/PolicyTax', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, waitForCollectionCallback: false, callback: (policy) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); const taxRates = policy?.taxRates; const deletedTax = taxRates?.taxes?.[taxID]; expect(taxRates?.pendingFields?.foreignTaxDefault).toBeFalsy(); @@ -782,11 +782,11 @@ describe('actions/PolicyTax', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, waitForCollectionCallback: false, callback: (policy) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); const taxRates = policy?.taxRates; const deletedTax = taxRates?.taxes?.[taxID]; expect(taxRates?.pendingFields?.foreignTaxDefault).toBeFalsy(); @@ -806,11 +806,11 @@ describe('actions/PolicyTax', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, waitForCollectionCallback: false, callback: (policy) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); const taxRates = policy?.taxRates; const deletedTax = taxRates?.taxes?.[taxID]; expect(taxRates?.pendingFields?.foreignTaxDefault).toBeFalsy(); diff --git a/tests/actions/PolicyTest.ts b/tests/actions/PolicyTest.ts index 17e9c09acfd3..5b95d50eed52 100644 --- a/tests/actions/PolicyTest.ts +++ b/tests/actions/PolicyTest.ts @@ -43,10 +43,10 @@ describe('actions/Policy', () => { await waitForBatchedUpdates(); let policy: OnyxEntry | OnyxCollection = await new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, callback: (workspace) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); resolve(workspace); }, }); @@ -63,11 +63,11 @@ describe('actions/Policy', () => { expect(policy?.employeeList).toEqual({[ESH_EMAIL]: {errors: {}, role: CONST.POLICY.ROLE.ADMIN}}); let allReports: OnyxCollection = await new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, waitForCollectionCallback: true, callback: (reports) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); resolve(reports); }, }); @@ -98,11 +98,11 @@ describe('actions/Policy', () => { }); let reportActions: OnyxCollection = await new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT_ACTIONS, waitForCollectionCallback: true, callback: (actions) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); resolve(actions); }, }); @@ -127,11 +127,11 @@ describe('actions/Policy', () => { await waitForBatchedUpdates(); policy = await new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.POLICY, waitForCollectionCallback: true, callback: (workspace) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); resolve(workspace); }, }); @@ -141,11 +141,11 @@ describe('actions/Policy', () => { expect(policy?.pendingAction).toBeFalsy(); allReports = await new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, waitForCollectionCallback: true, callback: (reports) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); resolve(reports); }, }); @@ -158,11 +158,11 @@ describe('actions/Policy', () => { }); reportActions = await new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT_ACTIONS, waitForCollectionCallback: true, callback: (actions) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); resolve(actions); }, }); diff --git a/tests/actions/ReportFieldTest.ts b/tests/actions/ReportFieldTest.ts index 13134e7e20fe..823cb1cc02db 100644 --- a/tests/actions/ReportFieldTest.ts +++ b/tests/actions/ReportFieldTest.ts @@ -24,10 +24,10 @@ OnyxUpdateManager(); describe('actions/ReportField', () => { function connectToFetchPolicy(policyID: string): Promise> { return new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, callback: (workspace) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); resolve(workspace); }, }); diff --git a/tests/unit/MigrationTest.ts b/tests/unit/MigrationTest.ts index e7352743627a..f184d2c40e2e 100644 --- a/tests/unit/MigrationTest.ts +++ b/tests/unit/MigrationTest.ts @@ -43,11 +43,11 @@ describe('Migrations', () => { return Onyx.multiSet(setQueries) .then(KeyReportActionsDraftByReportActionID) .then(() => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT_ACTIONS_DRAFTS, waitForCollectionCallback: true, callback: (allReportActionsDrafts) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); const expectedReportActionDraft1 = { 1: 'a', 2: 'b', @@ -75,11 +75,11 @@ describe('Migrations', () => { .then(KeyReportActionsDraftByReportActionID) .then(() => { expect(LogSpy).toHaveBeenCalledWith('[Migrate Onyx] Skipped migration KeyReportActionsDraftByReportActionID because there are no actions drafts to migrate'); - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT_ACTIONS_DRAFTS, waitForCollectionCallback: true, callback: (allReportActions) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); const expectedReportActionDraft = {}; expect(allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS_DRAFTS}1_1`]).toBeUndefined(); expect(allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS_DRAFTS}1_2`]).toBeUndefined(); @@ -99,11 +99,11 @@ describe('Migrations', () => { return Onyx.multiSet(setQueries) .then(KeyReportActionsDraftByReportActionID) .then(() => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT_ACTIONS_DRAFTS, waitForCollectionCallback: true, callback: (allReportActionsDrafts) => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); expect(allReportActionsDrafts?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS_DRAFTS}1_1`]).toBeUndefined(); }, }); diff --git a/tests/unit/ReportActionsUtilsTest.ts b/tests/unit/ReportActionsUtilsTest.ts index 0254288d6df9..d753069265f8 100644 --- a/tests/unit/ReportActionsUtilsTest.ts +++ b/tests/unit/ReportActionsUtilsTest.ts @@ -481,10 +481,10 @@ describe('ReportActionsUtils', () => { .then( () => new Promise((resolve) => { - const connectionID = Onyx.connect({ + const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.reportID}`, callback: () => { - Onyx.disconnect(connectionID); + Onyx.disconnect(connection); const res = ReportActionsUtils.getLastVisibleAction(report.reportID); expect(res).toEqual(action2); resolve();