From 7815c67b11828c9e9ac81fb33d6a22c49ae9e8d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A1bio=20Henriques?= Date: Wed, 7 Oct 2026 15:27:41 +0100 Subject: [PATCH 1/6] Use newest Onyx changes --- package-lock.json | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 5081ddc3f5c4..57da063dd0d9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -127,7 +127,7 @@ "react-native-nitro-fetch": "1.6.2", "react-native-nitro-modules": "0.37.1", "react-native-nitro-sqlite": "9.8.3", - "react-native-onyx": "3.0.117", + "react-native-onyx": "git+https://github.com/Expensify/react-native-onyx.git#513b3efb3c8ca2bda3e147ad064f4179464c9ee2", "react-native-pager-view": "9.0.4", "react-native-pdf": "7.0.2", "react-native-permissions": "^5.4.0", @@ -37870,9 +37870,9 @@ } }, "node_modules/react-native-onyx": { - "version": "3.0.117", - "resolved": "https://registry.npmjs.org/react-native-onyx/-/react-native-onyx-3.0.117.tgz", - "integrity": "sha512-0gidHoohos8p6746M03GtL+l8kA8kWM/E+9Cq0/wHFcsP8S1Qg68qIcRXYlgrdO8WBbl7r4hhKKqK2+ZB2ox6w==", + "version": "3.0.119", + "resolved": "git+ssh://git@github.com/Expensify/react-native-onyx.git#513b3efb3c8ca2bda3e147ad064f4179464c9ee2", + "integrity": "sha512-L3cZcTNKn1ePv2Fr5fr79MpAks+oxzSZY/V/DinHD+JWttAAJc1hLAZl4OvSk3kXwmHTFAMmuonDcQZNUQbWTg==", "license": "MIT", "dependencies": { "ascii-table": "0.0.9", diff --git a/package.json b/package.json index bb1a0a91ab7c..0c0bce94ce27 100644 --- a/package.json +++ b/package.json @@ -203,7 +203,7 @@ "react-native-nitro-fetch": "1.6.2", "react-native-nitro-modules": "0.37.1", "react-native-nitro-sqlite": "9.8.3", - "react-native-onyx": "3.0.117", + "react-native-onyx": "git+https://github.com/Expensify/react-native-onyx.git#513b3efb3c8ca2bda3e147ad064f4179464c9ee2", "react-native-pager-view": "9.0.4", "react-native-pdf": "7.0.2", "react-native-permissions": "^5.4.0", From e3b9aca0bed504bd39b2cd803f885dd90a596c90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A1bio=20Henriques?= Date: Wed, 7 Oct 2026 16:13:03 +0100 Subject: [PATCH 2/6] Replace Onyx.disconnect with connection.unsubscribe Onyx.disconnect() is removed in favor of calling unsubscribe() directly on the Connection returned by connect()/connectWithoutView(). --- .../MultifactorAuthenticationMainContext.tsx | 2 +- src/libs/ConciergeResponseIndicator/index.ts | 8 +- src/libs/Network/SequentialQueue.ts | 2 +- src/libs/actions/Device/index.ts | 2 +- src/libs/actions/Export.ts | 2 +- src/libs/actions/ImportSpreadsheet.ts | 4 +- src/libs/actions/Link.ts | 4 +- src/libs/actions/MapboxToken.ts | 2 +- src/libs/actions/OnyxDerived/index.ts | 2 +- src/libs/actions/Report/index.ts | 8 +- src/libs/actions/TransactionEdit.ts | 16 +-- src/libs/actions/User.ts | 2 +- src/libs/cleanupPreMountedDraftReports.ts | 4 +- .../migrations/ConvertGpsPointsTo2DArray.ts | 2 +- .../MoveFilesOutOfDocuments/index.native.ts | 4 +- src/libs/readOnceOnyxValue.ts | 2 +- src/libs/subscribeToFullReconnect.ts | 2 +- src/libs/telemetry/crashDiagnostics/index.ts | 2 +- src/setup/addUtilsToWindow.ts | 2 +- .../index.native.ts | 2 +- tests/actions/AttachmentTest.ts | 4 +- tests/actions/BetaOverridesTest.ts | 2 +- .../ClearOnyxAndSeedFullReconnectTest.ts | 22 ++-- tests/actions/DelegateTest.ts | 24 ++-- tests/actions/EarlyRenewalOfferTest.ts | 2 +- tests/actions/IOU/MoneyRequestSettersTest.ts | 8 +- tests/actions/IOU/PerDiemTest.ts | 6 +- tests/actions/IOU/RequestMoneyTest.ts | 88 +++++++-------- tests/actions/IOU/SplitReportTotalsTest.ts | 2 +- .../actions/IOUTest/DeleteMoneyRequestTest.ts | 78 ++++++------- tests/actions/IOUTest/DuplicateTest.ts | 10 +- tests/actions/IOUTest/HoldTest.ts | 16 +-- tests/actions/IOUTest/PayMoneyRequestTest.ts | 44 ++++---- tests/actions/IOUTest/ReceiptTest.ts | 2 +- tests/actions/IOUTest/ReportWorkflowTest.ts | 50 ++++----- tests/actions/IOUTest/SendInvoiceTest.ts | 2 +- tests/actions/IOUTest/SplitTest.ts | 56 ++++----- tests/actions/IOUTest/TrackExpenseTest.ts | 56 ++++----- .../actions/IOUTest/UpdateMoneyRequestTest.ts | 22 ++-- tests/actions/MergeTransactionTest.ts | 56 ++++----- tests/actions/PolicyCategoryTest.ts | 40 +++---- tests/actions/PolicyExpensifyCardTest.ts | 4 +- tests/actions/PolicyMemberTest.ts | 76 ++++++------- tests/actions/PolicyProfileTest.ts | 4 +- tests/actions/PolicyRulesTest.ts | 2 +- tests/actions/PolicyTagTest.ts | 16 +-- tests/actions/PolicyTaxTest.ts | 70 ++++++------ tests/actions/PolicyTest.ts | 106 +++++++++--------- tests/actions/PolicyTravelSettingsTest.ts | 2 +- tests/actions/QueuedOnyxUpdatesTest.ts | 10 +- tests/actions/ReimbursementAccountTest.ts | 20 ++-- tests/actions/ReportFieldTest.ts | 2 +- tests/actions/ReportTest.ts | 92 +++++++-------- tests/actions/TravelTest.ts | 2 +- tests/actions/UserTest.ts | 16 +-- tests/actions/VacationDelegateTest.ts | 2 +- tests/actions/WorkflowTest.ts | 2 +- tests/ui/AddDomainPageTest.tsx | 4 +- tests/ui/ClearReportActionErrorsUITest.tsx | 2 +- tests/ui/DistanceRequestStartPageTest.tsx | 2 +- tests/ui/EnableTravelContentTest.tsx | 2 +- .../ui/IOURequestRedirectToStartPageTest.tsx | 2 +- tests/ui/IOURequestStartPageTest.tsx | 2 +- tests/ui/IOURequestStepScanTest.tsx | 2 +- ...equestReportTransactionsNavigationTest.tsx | 2 +- tests/ui/RecentlyAddedSectionTest.tsx | 8 +- tests/ui/SessionTest.tsx | 4 +- tests/ui/ShareSubmitScanFieldsTest.tsx | 2 +- tests/ui/UnreadIndicatorsTest.tsx | 10 +- ...orkspaceWorkflowsApprovalsEditPageTest.tsx | 4 +- ...orkspaceWorkflowsLockedBankAccountTest.tsx | 2 +- ...kspaceWorkflowsSmartLimitApprovalsTest.tsx | 2 +- .../IOURequestStepConfirmationPageTest.tsx | 6 +- .../ProductTrainingContextProvider.tsx | 2 +- tests/unit/ClearReportActionErrorsTest.ts | 2 +- .../unit/CopyPolicySettingsNavigationTest.tsx | 2 +- tests/unit/DistanceRateTest.ts | 6 +- tests/unit/ExpenseAddedGrowlTest.tsx | 2 +- tests/unit/MiddlewareTest.ts | 20 ++-- .../MigratedUserWelcomeModalGuard.test.ts | 2 +- tests/unit/ReportActionsUtilsTest.ts | 2 +- tests/unit/ReportUtilsTest.ts | 12 +- tests/unit/ReportUtilsThreadSummaryTest.ts | 2 +- tests/unit/SearchActionsTest.ts | 4 +- tests/unit/SequentialQueueTest.ts | 6 +- tests/unit/SplitExpenseAutoAdjustmentTest.ts | 30 ++--- tests/unit/TransactionTest.ts | 22 ++-- tests/unit/TryNewDotUtilsTest.ts | 2 +- tests/unit/hooks/useInsightsFilters.test.ts | 2 +- .../TransactionThreadNavigationTest.ts | 2 +- tests/utils/TestHelper.ts | 2 +- 91 files changed, 634 insertions(+), 634 deletions(-) diff --git a/src/components/MultifactorAuthentication/Context/MultifactorAuthenticationMainContext.tsx b/src/components/MultifactorAuthentication/Context/MultifactorAuthenticationMainContext.tsx index 8b0453a4538f..30b9d8f63de7 100644 --- a/src/components/MultifactorAuthentication/Context/MultifactorAuthenticationMainContext.tsx +++ b/src/components/MultifactorAuthentication/Context/MultifactorAuthenticationMainContext.tsx @@ -83,7 +83,7 @@ function MultifactorAuthenticationContextProvider({children}: MultifactorAuthent deviceBiometricsState = data; }, }); - return () => Onyx.disconnect(connection); + return () => connection.unsubscribe(); }, [accountID]); const startStateRef = useRef(undefined); diff --git a/src/libs/ConciergeResponseIndicator/index.ts b/src/libs/ConciergeResponseIndicator/index.ts index 342274899bcd..fc4c721989b9 100644 --- a/src/libs/ConciergeResponseIndicator/index.ts +++ b/src/libs/ConciergeResponseIndicator/index.ts @@ -311,10 +311,10 @@ function subscribeToReport(responseReportActionID: string, reportID: string) { }, }); if (reportSubscriptions.get(reportID) !== reportSubscription) { - Onyx.disconnect(reportConnection); + reportConnection.unsubscribe(); return; } - reportSubscription.cleanups.push(() => Onyx.disconnect(reportConnection)); + reportSubscription.cleanups.push(() => reportConnection.unsubscribe()); // Watch only the question/response reports while a request is tracked. This non-render // subscription detects failed sends and reconciles durable replies after missed events. @@ -329,10 +329,10 @@ function subscribeToReport(responseReportActionID: string, reportID: string) { }); // The initial callback can finish the last request before connectWithoutView returns. if (reportSubscriptions.get(reportID) !== reportSubscription) { - Onyx.disconnect(connection); + connection.unsubscribe(); return; } - reportSubscription.cleanups.push(() => Onyx.disconnect(connection)); + reportSubscription.cleanups.push(() => connection.unsubscribe()); } /** Register a local or peer request without broadcasting it back to other tabs. */ diff --git a/src/libs/Network/SequentialQueue.ts b/src/libs/Network/SequentialQueue.ts index 24fe33b21c1a..aae36752426d 100644 --- a/src/libs/Network/SequentialQueue.ts +++ b/src/libs/Network/SequentialQueue.ts @@ -694,7 +694,7 @@ function flush(shouldResetPromise = true) { requestsLength: getAllPersistedRequests().length, ongoingCommand: getPersistedOngoingRequest()?.command ?? 'null', }); - Onyx.disconnect(connection); + connection.unsubscribe(); process().finally(() => { const remainingPersistedRequests = getAllPersistedRequests().length; const hasOngoingRequest = !!getPersistedOngoingRequest(); diff --git a/src/libs/actions/Device/index.ts b/src/libs/actions/Device/index.ts index 1be531989c44..e0dc3626c297 100644 --- a/src/libs/actions/Device/index.ts +++ b/src/libs/actions/Device/index.ts @@ -24,7 +24,7 @@ function getDeviceID(): Promise { const connection = Onyx.connectWithoutView({ key: ONYXKEYS.DEVICE_ID, callback: (id) => { - Onyx.disconnect(connection); + connection.unsubscribe(); deviceID = id ?? null; return resolve(id ?? null); }, diff --git a/src/libs/actions/Export.ts b/src/libs/actions/Export.ts index 157da051d2aa..772ef8c6223c 100644 --- a/src/libs/actions/Export.ts +++ b/src/libs/actions/Export.ts @@ -76,7 +76,7 @@ function clearStaleExportDownloads() { const connectionID = Onyx.connectWithoutView({ key: ONYXKEYS.COLLECTION.EXPORT_DOWNLOAD, callback: (exportDownloads) => { - Onyx.disconnect(connectionID); + connectionID.unsubscribe(); if (!exportDownloads) { return; } diff --git a/src/libs/actions/ImportSpreadsheet.ts b/src/libs/actions/ImportSpreadsheet.ts index 918968161781..b22849233170 100644 --- a/src/libs/actions/ImportSpreadsheet.ts +++ b/src/libs/actions/ImportSpreadsheet.ts @@ -118,7 +118,7 @@ function waitForImportFinalModal(importFinalModalID: string): ImportFinalModalRe } isPending = false; - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(spreadsheet.importFinalModal); }, }); @@ -132,7 +132,7 @@ function waitForImportFinalModal(importFinalModalID: string): ImportFinalModalRe } isPending = false; - Onyx.disconnect(connection); + connection.unsubscribe(); }, }; } diff --git a/src/libs/actions/Link.ts b/src/libs/actions/Link.ts index d5a11aa7765a..2962cfc9a74e 100644 --- a/src/libs/actions/Link.ts +++ b/src/libs/actions/Link.ts @@ -560,7 +560,7 @@ function openReportFromDeepLink( const handleDeeplinkNavigation = () => { // We want to disconnect the connection so it won't trigger the deeplink again // every time the data is changed, for example, when re-login. - Onyx.disconnect(connection); + connection.unsubscribe(); const state = navigationRef.getRootState(); const currentFocusedRoute = findFocusedRoute(state); @@ -623,7 +623,7 @@ function openReportFromDeepLink( // eslint-disable-next-line rulesdir/prefer-early-return callback: (report) => { if (report?.errorFields?.notFound || report?.reportID || (report === undefined && CONST.REGEX.NON_NUMERIC.test(reportID))) { - Onyx.disconnect(reportConnection); + reportConnection.unsubscribe(); navigateHandler(report); } }, diff --git a/src/libs/actions/MapboxToken.ts b/src/libs/actions/MapboxToken.ts index d1eb3e6057f4..d8065f08fb79 100644 --- a/src/libs/actions/MapboxToken.ts +++ b/src/libs/actions/MapboxToken.ts @@ -140,7 +140,7 @@ const init = () => { const stop = () => { console.debug('[MapboxToken] Stopping all listeners and timers'); if (tokenConnection) { - Onyx.disconnect(tokenConnection); + tokenConnection.unsubscribe(); tokenConnection = null; } if (unsubscribeReachability) { diff --git a/src/libs/actions/OnyxDerived/index.ts b/src/libs/actions/OnyxDerived/index.ts index cfe1ec657075..ff51d1182014 100644 --- a/src/libs/actions/OnyxDerived/index.ts +++ b/src/libs/actions/OnyxDerived/index.ts @@ -64,7 +64,7 @@ function init() { const connection = Onyx.connectWithoutView({ key, callback: (storedDerivedValue) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(storedDerivedValue); }, }); diff --git a/src/libs/actions/Report/index.ts b/src/libs/actions/Report/index.ts index fcf980837f6c..87115e0bec74 100644 --- a/src/libs/actions/Report/index.ts +++ b/src/libs/actions/Report/index.ts @@ -2670,7 +2670,7 @@ function navigateToAndOpenReport({ callback: (updatedReport) => { const notFoundError = updatedReport?.errorFields?.notFound; if (notFoundError === null) { - Onyx.disconnect(reportConnection); + reportConnection.unsubscribe(); return; } @@ -2679,7 +2679,7 @@ function navigateToAndOpenReport({ } hasAttemptedFallback = true; - Onyx.disconnect(reportConnection); + reportConnection.unsubscribe(); createAndOpenNewOptimisticChat(chat.reportID); }, }); @@ -2818,7 +2818,7 @@ function navigateToAndOpenReportWithAccountIDs( callback: (updatedReport) => { const notFoundError = updatedReport?.errorFields?.notFound; if (notFoundError === null) { - Onyx.disconnect(reportConnection); + reportConnection.unsubscribe(); return; } @@ -2827,7 +2827,7 @@ function navigateToAndOpenReportWithAccountIDs( } hasAttemptedFallback = true; - Onyx.disconnect(reportConnection); + reportConnection.unsubscribe(); createAndOpenNewOptimisticChat(chat.reportID); }, }); diff --git a/src/libs/actions/TransactionEdit.ts b/src/libs/actions/TransactionEdit.ts index 52d6f73bc2a4..d64bf2d00c1b 100644 --- a/src/libs/actions/TransactionEdit.ts +++ b/src/libs/actions/TransactionEdit.ts @@ -11,7 +11,7 @@ import Onyx from 'react-native-onyx'; import {generateTransactionID} from './Transaction'; -let connection: Connection; +let connection: Connection | undefined; /** * Makes a backup copy of a transaction object that can be restored when the user cancels editing a transaction. @@ -24,7 +24,7 @@ function createBackupTransaction(transaction: OnyxEntry, isDraft: b // In Strict Mode, the backup logic useEffect is triggered twice on mount. The restore logic is delayed because we need to connect to the onyx first, // so it's possible that the restore logic is executed after creating the backup for the 2nd time which will completely clear the backup. // To avoid that, we need to cancel the pending connection. - Onyx.disconnect(connection); + connection?.unsubscribe(); const newTransaction = { ...transaction, }; @@ -41,7 +41,7 @@ function createBackupTransaction(transaction: OnyxEntry, isDraft: b const conn = Onyx.connectWithoutView({ key: `${ONYXKEYS.COLLECTION.TRANSACTION_BACKUP}${transaction.transactionID}`, callback: (transactionBackup) => { - Onyx.disconnect(conn); + conn.unsubscribe(); // Treat a backup missing `transactionID` as corrupted (a partial route-fetch shape can // leak in via Pusher) and overwrite it instead of restoring from it. if (transactionBackup?.transactionID) { @@ -76,7 +76,7 @@ function restoreOriginalTransactionFromBackup(transactionID: string | undefined, connection = Onyx.connectWithoutView({ key: `${ONYXKEYS.COLLECTION.TRANSACTION_BACKUP}${transactionID}`, callback: (backupTransaction) => { - Onyx.disconnect(connection); + connection?.unsubscribe(); // Use set to completely overwrite the original transaction Onyx.set(`${isDraft ? ONYXKEYS.COLLECTION.TRANSACTION_DRAFT : ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, backupTransaction ?? null); @@ -197,11 +197,11 @@ function removeBackupTransactionWithImageCleanup(transactionID: string | undefin const backupConn = Onyx.connectWithoutView({ key: `${ONYXKEYS.COLLECTION.TRANSACTION_BACKUP}${transactionID}`, callback: (backupTransaction) => { - Onyx.disconnect(backupConn); + backupConn.unsubscribe(); const currentConn = Onyx.connectWithoutView({ key: `${isDraft ? ONYXKEYS.COLLECTION.TRANSACTION_DRAFT : ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, callback: (currentTransaction) => { - Onyx.disconnect(currentConn); + currentConn.unsubscribe(); revokeOdometerImageUri(backupTransaction?.comment?.odometerStartImage, currentTransaction?.comment?.odometerStartImage); revokeOdometerImageUri(backupTransaction?.comment?.odometerEndImage, currentTransaction?.comment?.odometerEndImage); removeBackupTransaction(transactionID); @@ -220,11 +220,11 @@ function restoreOriginalTransactionFromBackupWithImageCleanup(transactionID: str connection = Onyx.connectWithoutView({ key: `${ONYXKEYS.COLLECTION.TRANSACTION_BACKUP}${transactionID}`, callback: (backupTransaction) => { - Onyx.disconnect(connection); + connection?.unsubscribe(); const currentConn = Onyx.connectWithoutView({ key: `${isDraft ? ONYXKEYS.COLLECTION.TRANSACTION_DRAFT : ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, callback: (currentTransaction) => { - Onyx.disconnect(currentConn); + currentConn.unsubscribe(); revokeOdometerImageUri(currentTransaction?.comment?.odometerStartImage, backupTransaction?.comment?.odometerStartImage); revokeOdometerImageUri(currentTransaction?.comment?.odometerEndImage, backupTransaction?.comment?.odometerEndImage); 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 596613f79440..4acac3fcf0eb 100644 --- a/src/libs/actions/User.ts +++ b/src/libs/actions/User.ts @@ -764,7 +764,7 @@ const isChannelMuted = (reportId: string, currentUserAccountID: number) => const connection = Onyx.connectWithoutView({ key: `${ONYXKEYS.COLLECTION.REPORT}${reportId}`, callback: (report) => { - Onyx.disconnect(connection); + connection.unsubscribe(); const notificationPreference = report?.participants?.[currentUserAccountID]?.notificationPreference; resolve(!notificationPreference || notificationPreference === CONST.REPORT.NOTIFICATION_PREFERENCE.MUTE || ReportUtils.isHiddenForCurrentUser(notificationPreference)); diff --git a/src/libs/cleanupPreMountedDraftReports.ts b/src/libs/cleanupPreMountedDraftReports.ts index fdb0b8c3c198..a7395c40e6bc 100644 --- a/src/libs/cleanupPreMountedDraftReports.ts +++ b/src/libs/cleanupPreMountedDraftReports.ts @@ -39,7 +39,7 @@ function cleanupReportDrafts(markers: OnyxCollection) { let reportDraftsConnection: ReturnType; function handleReportDrafts(reportDrafts: OnyxCollection) { - Onyx.disconnect(reportDraftsConnection); + reportDraftsConnection.unsubscribe(); Onyx.multiSet(getPreMountedDraftReportCleanupData(markers, reportDrafts)); } @@ -60,7 +60,7 @@ function cleanupPreMountedDraftReports() { let markersConnection: ReturnType; function handleMarkers(markers: OnyxCollection) { - Onyx.disconnect(markersConnection); + markersConnection.unsubscribe(); if (!Object.keys(markers ?? {}).length) { return; } diff --git a/src/libs/migrations/ConvertGpsPointsTo2DArray.ts b/src/libs/migrations/ConvertGpsPointsTo2DArray.ts index 7ab02fd3ad77..486b12c01cdf 100644 --- a/src/libs/migrations/ConvertGpsPointsTo2DArray.ts +++ b/src/libs/migrations/ConvertGpsPointsTo2DArray.ts @@ -20,7 +20,7 @@ export default function (): Promise { const connection = Onyx.connectWithoutView({ key: ONYXKEYS.GPS_DRAFT_DETAILS, callback: (gpsDraftDetails: OnyxEntry) => { - Onyx.disconnect(connection); + connection.unsubscribe(); // gpsPoints may still be in the old 1D format from before the schema change const gpsPoints = gpsDraftDetails?.gpsPoints; diff --git a/src/libs/migrations/MoveFilesOutOfDocuments/index.native.ts b/src/libs/migrations/MoveFilesOutOfDocuments/index.native.ts index 4fef50c58a13..5ce358e7dfef 100644 --- a/src/libs/migrations/MoveFilesOutOfDocuments/index.native.ts +++ b/src/libs/migrations/MoveFilesOutOfDocuments/index.native.ts @@ -66,7 +66,7 @@ function updateAttachmentRecordPaths(): Promise { const connection = Onyx.connectWithoutView({ key: ONYXKEYS.ATTACHMENT_RECORD_PATHS_MIGRATED, callback: (hasMigrated) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(hasMigrated); }, }); @@ -79,7 +79,7 @@ function updateAttachmentRecordPaths(): Promise { const connection = Onyx.connectWithoutView({ key: ONYXKEYS.COLLECTION.ATTACHMENT, callback: (attachments: OnyxCollection) => { - Onyx.disconnect(connection); + connection.unsubscribe(); const updates: Record = {}; for (const [key, attachment] of Object.entries(attachments ?? {})) { diff --git a/src/libs/readOnceOnyxValue.ts b/src/libs/readOnceOnyxValue.ts index 794048e6d59f..166fcdcc4a24 100644 --- a/src/libs/readOnceOnyxValue.ts +++ b/src/libs/readOnceOnyxValue.ts @@ -8,7 +8,7 @@ function readOnceOnyxValue(key: TKey): Promise { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value); }, }); diff --git a/src/libs/subscribeToFullReconnect.ts b/src/libs/subscribeToFullReconnect.ts index 47d143909614..ca80ca507a44 100644 --- a/src/libs/subscribeToFullReconnect.ts +++ b/src/libs/subscribeToFullReconnect.ts @@ -26,7 +26,7 @@ Onyx.connectWithoutView({ const connection = Onyx.connectWithoutView({ key: ONYXKEYS.LAST_FULL_RECONNECT_TIME, callback: (lastFullReconnectTimeOnyxValue) => { - Onyx.disconnect(connection); + connection.unsubscribe(); lastFullReconnectTime = lastFullReconnectTimeOnyxValue ?? ''; doFullReconnectIfNecessary(); }, diff --git a/src/libs/telemetry/crashDiagnostics/index.ts b/src/libs/telemetry/crashDiagnostics/index.ts index a2ce5ab31516..ad489cda8c6f 100644 --- a/src/libs/telemetry/crashDiagnostics/index.ts +++ b/src/libs/telemetry/crashDiagnostics/index.ts @@ -532,7 +532,7 @@ function cleanupCrashDiagnostics() { livenessChannel = undefined; } if (reportsConnection) { - Onyx.disconnect(reportsConnection); + reportsConnection.unsubscribe(); reportsConnection = undefined; } if (typeof window !== 'undefined') { diff --git a/src/setup/addUtilsToWindow.ts b/src/setup/addUtilsToWindow.ts index ec3935f4e2b3..10e8ff2f457b 100644 --- a/src/setup/addUtilsToWindow.ts +++ b/src/setup/addUtilsToWindow.ts @@ -35,7 +35,7 @@ export default function addUtilsToWindow() { const connection = Onyx.connectWithoutView({ key, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value); }, }); diff --git a/src/setup/backgroundLocationTrackingTask/index.native.ts b/src/setup/backgroundLocationTrackingTask/index.native.ts index e3adb8cdc311..c7772a2a7226 100644 --- a/src/setup/backgroundLocationTrackingTask/index.native.ts +++ b/src/setup/backgroundLocationTrackingTask/index.native.ts @@ -24,7 +24,7 @@ function getGpsDraftDetails(): Promise> { const connection = Onyx.connectWithoutView({ key: ONYXKEYS.GPS_DRAFT_DETAILS, callback: (gpsDraftDetails: OnyxEntry) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(gpsDraftDetails); }, }); diff --git a/tests/actions/AttachmentTest.ts b/tests/actions/AttachmentTest.ts index 7f386edcd0b9..697659a18ac4 100644 --- a/tests/actions/AttachmentTest.ts +++ b/tests/actions/AttachmentTest.ts @@ -94,7 +94,7 @@ describe('AttachmentStorage', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.ATTACHMENT, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value); }, }); @@ -161,7 +161,7 @@ describe('AttachmentStorage', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.ATTACHMENT, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value); }, }); diff --git a/tests/actions/BetaOverridesTest.ts b/tests/actions/BetaOverridesTest.ts index 66a71c9ca6e0..32f7e7099556 100644 --- a/tests/actions/BetaOverridesTest.ts +++ b/tests/actions/BetaOverridesTest.ts @@ -13,7 +13,7 @@ function getBetaOverrides(): Promise { const connection = Onyx.connect({ key: ONYXKEYS.BETA_OVERRIDES, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value); }, }); diff --git a/tests/actions/ClearOnyxAndSeedFullReconnectTest.ts b/tests/actions/ClearOnyxAndSeedFullReconnectTest.ts index 269ef7bff55f..94300d4bc2ad 100644 --- a/tests/actions/ClearOnyxAndSeedFullReconnectTest.ts +++ b/tests/actions/ClearOnyxAndSeedFullReconnectTest.ts @@ -36,7 +36,7 @@ describe('actions/clearOnyxAndSeedFullReconnect', () => { expect(typeof value).toBe('string'); expect((value ?? '').length > 0).toBe(true); expect((value ?? '') >= before).toBe(true); - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(); }, }); @@ -58,7 +58,7 @@ describe('actions/clearOnyxAndSeedFullReconnect', () => { key: ONYXKEYS.SESSION, callback: (value) => { expect(value?.authToken).toBe('preserved-auth-token'); - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(); }, }); @@ -69,7 +69,7 @@ describe('actions/clearOnyxAndSeedFullReconnect', () => { key: ONYXKEYS.NVP_PRIORITY_MODE, callback: (value) => { expect(value).toBeUndefined(); - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(); }, }); @@ -91,7 +91,7 @@ describe('actions/clearOnyxAndSeedFullReconnect', () => { key: ONYXKEYS.IS_LOADING_APP, callback: (value) => { expect(value).toBe(true); - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(); }, }); @@ -103,7 +103,7 @@ describe('actions/clearOnyxAndSeedFullReconnect', () => { callback: (value) => { expect(typeof value).toBe('string'); expect((value ?? '').length > 0).toBe(true); - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(); }, }); @@ -124,7 +124,7 @@ describe('actions/clearOnyxAndSeedFullReconnect', () => { key: ONYXKEYS.IS_LOADING_APP, callback: (value) => { expect(value).toBe(false); - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(); }, }); @@ -144,7 +144,7 @@ describe('actions/clearOnyxAndSeedFullReconnect', () => { callback: (value) => { expect(typeof value).toBe('string'); expect((value ?? '').length > 0).toBe(true); - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(); }, }); @@ -169,7 +169,7 @@ describe('actions/clearOnyxAndSeedFullReconnect', () => { key: ONYXKEYS.NVP_PRIORITY_MODE, callback: (value) => { expect(value).toBeUndefined(); - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(); }, }); @@ -180,7 +180,7 @@ describe('actions/clearOnyxAndSeedFullReconnect', () => { key: ONYXKEYS.HAS_LOADED_APP, callback: (value) => { expect(value).toBeUndefined(); - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(); }, }); @@ -191,7 +191,7 @@ describe('actions/clearOnyxAndSeedFullReconnect', () => { key: ONYXKEYS.SESSION, callback: (value) => { expect(value?.authToken).toBe('preserved-auth-token'); - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(); }, }); @@ -202,7 +202,7 @@ describe('actions/clearOnyxAndSeedFullReconnect', () => { key: ONYXKEYS.IS_LOADING_APP, callback: (value) => { expect(value).toBe(true); - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(); }, }); diff --git a/tests/actions/DelegateTest.ts b/tests/actions/DelegateTest.ts index 9311bc06435b..014f06aff223 100644 --- a/tests/actions/DelegateTest.ts +++ b/tests/actions/DelegateTest.ts @@ -63,7 +63,7 @@ describe('actions/Delegate', () => { callback: (account) => { // @ts-expect-error - errorFields is not defined in the type expect(account?.delegatedAccess?.delegators?.at(0)?.errorFields).toBeDefined(); - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(); }, }); @@ -78,7 +78,7 @@ describe('actions/Delegate', () => { callback: (account) => { // @ts-expect-error - errorFields is not defined in the type expect(account?.delegatedAccess?.delegators?.at(0)?.errorFields).toBeUndefined(); - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(); }, }); @@ -101,7 +101,7 @@ describe('actions/Delegate', () => { callback: (account) => { expect(account?.delegatedAccess?.delegates?.at(0)?.email).toBe('test@test.com'); expect(account?.delegatedAccess?.delegates?.at(0)?.role).toBe(CONST.DELEGATE_ROLE.ALL); - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(); }, }); @@ -161,7 +161,7 @@ describe('actions/Delegate', () => { key: ONYXKEYS.ACCOUNT, callback: (account) => { expect(account?.delegatedAccess?.delegates?.at(0)?.pendingAction).toBe(CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE); - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(); }, }); @@ -210,7 +210,7 @@ describe('actions/Delegate', () => { // The targeted errors should be cleared expect(errorFields?.addDelegate?.['test@test.com']).toBeUndefined(); - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(); }, }); @@ -244,7 +244,7 @@ describe('actions/Delegate', () => { const firstDelegate = account?.delegatedAccess?.delegates?.at(0); expect(firstDelegate?.pendingAction).toBe(CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE); expect(firstDelegate?.pendingFields?.role).toBe(CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE); - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(); }, }); @@ -272,7 +272,7 @@ describe('actions/Delegate', () => { key: ONYXKEYS.ACCOUNT, callback: (account) => { expect(isConnectedAsDelegate({delegatedAccess: account?.delegatedAccess})).toBe(false); - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(); }, }); @@ -326,7 +326,7 @@ describe('actions/Delegate', () => { key: ONYXKEYS.IS_LOADING_APP, callback: (value) => { expect(value).toBe(true); - Onyx.disconnect(conn); + conn.unsubscribe(); resolve(); }, }); @@ -338,7 +338,7 @@ describe('actions/Delegate', () => { key: ONYXKEYS.HAS_LOADED_APP, callback: (value) => { expect(value).toBe(true); - Onyx.disconnect(conn); + conn.unsubscribe(); resolve(); }, }); @@ -350,7 +350,7 @@ describe('actions/Delegate', () => { key: ONYXKEYS.NVP_PRIORITY_MODE, callback: (value) => { expect(value).toBeUndefined(); - Onyx.disconnect(conn); + conn.unsubscribe(); resolve(); }, }); @@ -377,7 +377,7 @@ describe('actions/Delegate', () => { expect(typeof value).toBe('string'); expect(value && value.length > 0).toBe(true); expect((value ?? '') >= before).toBe(true); - Onyx.disconnect(conn); + conn.unsubscribe(); resolve(); }, }); @@ -389,7 +389,7 @@ describe('actions/Delegate', () => { key: ONYXKEYS.NVP_PRIORITY_MODE, callback: (value) => { expect(value).toBeUndefined(); - Onyx.disconnect(conn); + conn.unsubscribe(); resolve(); }, }); diff --git a/tests/actions/EarlyRenewalOfferTest.ts b/tests/actions/EarlyRenewalOfferTest.ts index 8cbdb77b164b..3331929eb704 100644 --- a/tests/actions/EarlyRenewalOfferTest.ts +++ b/tests/actions/EarlyRenewalOfferTest.ts @@ -51,7 +51,7 @@ describe('actions/EarlyRenewalOffer', () => { let eligibility: unknown; const connection = Onyx.connectWithoutView({key: ONYXKEYS.EARLY_RENEWAL_OFFER_ELIGIBILITY, callback: (value) => (eligibility = value)}); await waitForBatchedUpdates(); - Onyx.disconnect(connection); + connection.unsubscribe(); expect(eligibility).toEqual({canClaim: true}); }); }); diff --git a/tests/actions/IOU/MoneyRequestSettersTest.ts b/tests/actions/IOU/MoneyRequestSettersTest.ts index 5fb7403a9214..d04f1a9f57ea 100644 --- a/tests/actions/IOU/MoneyRequestSettersTest.ts +++ b/tests/actions/IOU/MoneyRequestSettersTest.ts @@ -344,7 +344,7 @@ describe('actions/IOU', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, callback: (transaction) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(transaction?.taxCode).toBe(ruleTaxCode); expect(transaction?.taxAmount).toBe(5); resolve(); @@ -385,7 +385,7 @@ describe('actions/IOU', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, callback: (transaction) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(transaction?.taxCode).toBe(taxCode); expect(transaction?.taxAmount).toBe(taxAmount); resolve(); @@ -423,7 +423,7 @@ describe('actions/IOU', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, callback: (transaction) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(transaction?.taxCode).toBe(taxCode); expect(transaction?.taxAmount).toBe(taxAmount); resolve(); @@ -453,7 +453,7 @@ describe('actions/IOU', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, callback: (transaction) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(transaction?.taxCode).toBe(''); expect(transaction?.taxAmount).toBeUndefined(); resolve(); diff --git a/tests/actions/IOU/PerDiemTest.ts b/tests/actions/IOU/PerDiemTest.ts index 670ca6297765..c0308fd81c2f 100644 --- a/tests/actions/IOU/PerDiemTest.ts +++ b/tests/actions/IOU/PerDiemTest.ts @@ -1065,7 +1065,7 @@ describe('PerDiem', () => { key: `${ONYXKEYS.COLLECTION.POLICY_RECENTLY_USED_TAGS}${policyID}`, callback: (recentlyUsedTags) => { resolve(recentlyUsedTags ?? {}); - Onyx.disconnect(connection); + connection.unsubscribe(); }, }); }); @@ -1152,7 +1152,7 @@ describe('PerDiem', () => { key: ONYXKEYS.COLLECTION.TRANSACTION, callback: (val) => { resolve(val ?? {}); - Onyx.disconnect(connection); + connection.unsubscribe(); }, }); }); @@ -1330,7 +1330,7 @@ describe('PerDiem', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.TRANSACTION, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value); }, }); diff --git a/tests/actions/IOU/RequestMoneyTest.ts b/tests/actions/IOU/RequestMoneyTest.ts index 4da3db9478a3..abee026bb632 100644 --- a/tests/actions/IOU/RequestMoneyTest.ts +++ b/tests/actions/IOU/RequestMoneyTest.ts @@ -241,7 +241,7 @@ describe('actions/IOU', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, callback: (allReports) => { - Onyx.disconnect(connection); + connection.unsubscribe(); // 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); @@ -274,13 +274,13 @@ describe('actions/IOU', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_METADATA}${iouReportID}`, callback: (iouReportMetadata) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(iouReportMetadata?.isOptimisticReport).toBe(true); const loadingStateConnection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.RAM_ONLY_REPORT_LOADING_STATE}${iouReportID}`, callback: (iouReportLoadingState) => { - Onyx.disconnect(loadingStateConnection); + loadingStateConnection.unsubscribe(); expect(iouReportLoadingState?.hasOnceLoadedReportActions).toBe(true); resolve(); }, @@ -295,7 +295,7 @@ describe('actions/IOU', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReportID}`, callback: (reportActionsForIOUReport) => { - Onyx.disconnect(connection); + connection.unsubscribe(); // The IOU report should have a CREATED action and IOU action expect(Object.values(reportActionsForIOUReport ?? {}).length).toBe(2); @@ -341,7 +341,7 @@ describe('actions/IOU', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${transactionThread?.reportID}`, callback: (reportActionsForTransactionThread) => { - Onyx.disconnect(connection); + connection.unsubscribe(); // The transaction thread should have a CREATED action expect(Object.values(reportActionsForTransactionThread ?? {}).length).toBe(1); @@ -363,7 +363,7 @@ describe('actions/IOU', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.TRANSACTION, callback: (allTransactions) => { - Onyx.disconnect(connection); + connection.unsubscribe(); // There should be one transaction expect(Object.values(allTransactions ?? {}).length).toBe(1); @@ -398,7 +398,7 @@ describe('actions/IOU', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.SNAPSHOT, callback: (snapshotData) => { - Onyx.disconnect(connection); + connection.unsubscribe(); // Snapshot data shouldn't be updated optimistically for requestMoney when the current search query type is invoice. // Post-init, a known-but-empty collection resolves to the frozen `{}` (the legacy @@ -416,7 +416,7 @@ describe('actions/IOU', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReportID}`, callback: (reportActionsForIOUReport) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(Object.values(reportActionsForIOUReport ?? {}).length).toBe(2); for (const reportAction of Object.values(reportActionsForIOUReport ?? {})) { expect(reportAction?.pendingAction).toBeFalsy(); @@ -432,7 +432,7 @@ describe('actions/IOU', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, callback: (transaction) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(transaction?.pendingAction).toBeFalsy(); resolve(); }, @@ -508,7 +508,7 @@ describe('actions/IOU', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, callback: (allReports) => { - Onyx.disconnect(connection); + connection.unsubscribe(); // The same chat report should be reused, a transaction thread and an IOU report should be created expect(Object.values(allReports ?? {}).length).toBe(3); @@ -536,7 +536,7 @@ describe('actions/IOU', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReportID}`, callback: (allIOUReportActions) => { - Onyx.disconnect(connection); + connection.unsubscribe(); iouCreatedAction = Object.values(allIOUReportActions ?? {}).find((reportAction) => reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.CREATED); iouAction = Object.values(allIOUReportActions ?? {}).find((reportAction): reportAction is ReportAction => @@ -573,7 +573,7 @@ describe('actions/IOU', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.TRANSACTION, callback: (allTransactions) => { - Onyx.disconnect(connection); + connection.unsubscribe(); // There should be one transaction expect(Object.values(allTransactions ?? {}).length).toBe(1); @@ -611,7 +611,7 @@ describe('actions/IOU', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReportID}`, callback: (reportActionsForIOUReport) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(Object.values(reportActionsForIOUReport ?? {}).length).toBe(2); for (const reportAction of Object.values(reportActionsForIOUReport ?? {})) { expect(reportAction?.pendingAction).toBeFalsy(); @@ -627,7 +627,7 @@ describe('actions/IOU', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, callback: (transaction) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(transaction?.pendingAction).toBeFalsy(); resolve(); }, @@ -744,7 +744,7 @@ describe('actions/IOU', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, callback: (allReports) => { - Onyx.disconnect(connection); + connection.unsubscribe(); // No new reports should be created expect(Object.values(allReports ?? {}).length).toBe(3); @@ -768,7 +768,7 @@ describe('actions/IOU', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReportID}`, callback: (reportActionsForIOUReport) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(Object.values(reportActionsForIOUReport ?? {}).length).toBe(3); newIOUAction = Object.values(reportActionsForIOUReport ?? {}).find( @@ -804,7 +804,7 @@ describe('actions/IOU', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.TRANSACTION, callback: (allTransactions) => { - Onyx.disconnect(connection); + connection.unsubscribe(); // There should be two transactions expect(Object.values(allTransactions ?? {}).length).toBe(2); @@ -833,7 +833,7 @@ describe('actions/IOU', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReportID}`, callback: (reportActionsForIOUReport) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(Object.values(reportActionsForIOUReport ?? {}).length).toBe(3); for (const reportAction of Object.values(reportActionsForIOUReport ?? {})) { expect(reportAction?.pendingAction).toBeFalsy(); @@ -849,7 +849,7 @@ describe('actions/IOU', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.TRANSACTION, callback: (allTransactions) => { - Onyx.disconnect(connection); + connection.unsubscribe(); for (const transaction of Object.values(allTransactions ?? {})) { expect(transaction?.pendingAction).toBeFalsy(); } @@ -913,7 +913,7 @@ describe('actions/IOU', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, callback: (allReports) => { - Onyx.disconnect(connection); + connection.unsubscribe(); // 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); @@ -944,7 +944,7 @@ describe('actions/IOU', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReportID}`, callback: (reportActionsForIOUReport) => { - Onyx.disconnect(connection); + connection.unsubscribe(); // The chat report should have a CREATED action and IOU action expect(Object.values(reportActionsForIOUReport ?? {}).length).toBe(2); @@ -990,7 +990,7 @@ describe('actions/IOU', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.TRANSACTION, callback: (allTransactions) => { - Onyx.disconnect(connection); + connection.unsubscribe(); // There should be one transaction expect(Object.values(allTransactions ?? {}).length).toBe(1); @@ -1021,7 +1021,7 @@ describe('actions/IOU', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReportID}`, callback: (reportActionsForIOUReport) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(Object.values(reportActionsForIOUReport ?? {}).length).toBe(2); iouAction = Object.values(reportActionsForIOUReport ?? {}).find((reportAction): reportAction is ReportAction => isMoneyRequestAction(reportAction), @@ -1038,7 +1038,7 @@ describe('actions/IOU', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT_ACTIONS, callback: (reportActionsForTransactionThread) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(Object.values(reportActionsForTransactionThread ?? {}).length).toBe(3); transactionThreadAction = Object.values( reportActionsForTransactionThread?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${transactionThreadReport?.reportID}`] ?? {}, @@ -1055,7 +1055,7 @@ describe('actions/IOU', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, callback: (transaction) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(transaction?.pendingAction).toBe(CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD); expect(transaction?.errors).toBeTruthy(); expect(Object.values(transaction?.errors ?? {}).at(0)).toEqual(translateLocal('iou.error.genericCreateFailureMessage')); @@ -1083,7 +1083,7 @@ describe('actions/IOU', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${chatReportID}`, callback: (reportActionsForReport) => { - Onyx.disconnect(connection); + connection.unsubscribe(); iouAction = Object.values(reportActionsForReport ?? {}).find((reportAction): reportAction is ReportAction => isMoneyRequestAction(reportAction), ); @@ -1101,7 +1101,7 @@ describe('actions/IOU', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReportID}`, callback: (reportActionsForReport) => { - Onyx.disconnect(connection); + connection.unsubscribe(); iouAction = Object.values(reportActionsForReport ?? {}).find((reportAction): reportAction is ReportAction => isMoneyRequestAction(reportAction), ); @@ -1119,7 +1119,7 @@ describe('actions/IOU', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${transactionThreadReport?.reportID}`, callback: (reportActionsForReport) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(reportActionsForReport).toMatchObject({}); resolve(); }, @@ -1134,7 +1134,7 @@ describe('actions/IOU', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, callback: (transaction) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(transaction).toBeFalsy(); resolve(); }, @@ -1163,7 +1163,7 @@ describe('actions/IOU', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, callback: (allReports) => { - Onyx.disconnect(connection); + connection.unsubscribe(); for (const report of Object.values(allReports ?? {})) { expect(report).toBeFalsy(); } @@ -1180,7 +1180,7 @@ describe('actions/IOU', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT_ACTIONS, callback: (allReportActions) => { - Onyx.disconnect(connection); + connection.unsubscribe(); for (const reportAction of Object.values(allReportActions ?? {})) { expect(reportAction).toBeFalsy(); } @@ -1197,7 +1197,7 @@ describe('actions/IOU', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.TRANSACTION, callback: (allTransactions) => { - Onyx.disconnect(connection); + connection.unsubscribe(); for (const transaction of Object.values(allTransactions ?? {})) { expect(transaction).toBeFalsy(); } @@ -1576,7 +1576,7 @@ describe('actions/IOU', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${expenseReport.reportID}`, callback: (report) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(report?.nonReimbursableTotal ?? 0); }, }); @@ -1626,7 +1626,7 @@ describe('actions/IOU', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${expenseReport?.reportID}`, callback: (report) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(report?.nonReimbursableTotal ?? 0); }, }); @@ -1767,7 +1767,7 @@ describe('actions/IOU', () => { key: `${ONYXKEYS.COLLECTION.POLICY_RECENTLY_USED_TAGS}${policyID}`, callback: (recentlyUsedTags) => { resolve(recentlyUsedTags ?? {}); - Onyx.disconnect(connection); + connection.unsubscribe(); }, }); }); @@ -2036,7 +2036,7 @@ describe('actions/IOU', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, callback: (reports) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(reports); }, }); @@ -2058,7 +2058,7 @@ describe('actions/IOU', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT_ACTIONS, callback: (actions) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(actions); }, }); @@ -2077,7 +2077,7 @@ describe('actions/IOU', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.TRANSACTION, callback: (transactions) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(transactions); }, }); @@ -2137,7 +2137,7 @@ describe('actions/IOU', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, callback: (reports) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(reports?.[`${ONYXKEYS.COLLECTION.REPORT}${transactionThreadReport?.reportID}`]); }, }); @@ -2215,7 +2215,7 @@ describe('actions/IOU', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, callback: (allReports) => { - Onyx.disconnect(connection); + connection.unsubscribe(); // A NEW chat report should be created for RORY and CARLOS // The existing chat report between RORY and JULES should still exist @@ -2307,7 +2307,7 @@ describe('actions/IOU', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, callback: (allReports) => { - Onyx.disconnect(connection); + connection.unsubscribe(); // The existing chat report should be reused const chatReports = Object.values(allReports ?? {}).filter((report) => report?.type === CONST.REPORT.TYPE.CHAT); @@ -2390,7 +2390,7 @@ describe('actions/IOU', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, callback: (allReports) => { - Onyx.disconnect(connection); + connection.unsubscribe(); // The policy expense chat report should be reused (participant validation skipped) const policyExpenseChats = Object.values(allReports ?? {}).filter((report) => report?.chatType === CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT); @@ -2468,7 +2468,7 @@ describe('actions/IOU', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, callback: (allReports) => { - Onyx.disconnect(connection); + connection.unsubscribe(); // Even though participants don't match (JULES vs CARLOS), // since the chatReport is a policy expense chat, it should be reused @@ -2547,7 +2547,7 @@ describe('actions/IOU', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, callback: (allReports) => { - Onyx.disconnect(connection); + connection.unsubscribe(); // The self-DM report should be reused (participant validation should be skipped) // No new 1:1 DM chat with accountID 0 should be created diff --git a/tests/actions/IOU/SplitReportTotalsTest.ts b/tests/actions/IOU/SplitReportTotalsTest.ts index bb5d9ec220cc..aed8bf51d856 100644 --- a/tests/actions/IOU/SplitReportTotalsTest.ts +++ b/tests/actions/IOU/SplitReportTotalsTest.ts @@ -742,7 +742,7 @@ describe('actions/IOU', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_METADATA}${reportID}`, callback: (metadata) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(metadata?.pendingNewTransactionIDs); }, }); diff --git a/tests/actions/IOUTest/DeleteMoneyRequestTest.ts b/tests/actions/IOUTest/DeleteMoneyRequestTest.ts index 38a4430fe6f0..5f1a48f370c1 100644 --- a/tests/actions/IOUTest/DeleteMoneyRequestTest.ts +++ b/tests/actions/IOUTest/DeleteMoneyRequestTest.ts @@ -187,7 +187,7 @@ describe('actions/IOU/DeleteMoneyRequest', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, callback: (reports) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(reports); }, }); @@ -223,7 +223,7 @@ describe('actions/IOU/DeleteMoneyRequest', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT_ACTIONS, callback: (actions) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(actions); }, }); @@ -291,7 +291,7 @@ describe('actions/IOU/DeleteMoneyRequest', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReport?.reportID}`, callback: (actionsForReport) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(actionsForReport); }, }); @@ -308,7 +308,7 @@ describe('actions/IOU/DeleteMoneyRequest', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transaction?.transactionID}`, callback: (transactionResult) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(transactionResult); }, }); @@ -326,7 +326,7 @@ describe('actions/IOU/DeleteMoneyRequest', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReport?.reportID}`, callback: (actionsForReport) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(actionsForReport); }, }); @@ -342,7 +342,7 @@ describe('actions/IOU/DeleteMoneyRequest', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transaction?.transactionID}`, callback: (transactionResult) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(transactionResult); }, }); @@ -380,7 +380,7 @@ describe('actions/IOU/DeleteMoneyRequest', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${iouReport?.reportID}`, callback: (res) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(res); }, }); @@ -397,7 +397,7 @@ describe('actions/IOU/DeleteMoneyRequest', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${iouReport?.reportID}`, callback: (res) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(res); }, }); @@ -471,7 +471,7 @@ describe('actions/IOU/DeleteMoneyRequest', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, callback: (reports) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(reports); }, }); @@ -491,7 +491,7 @@ describe('actions/IOU/DeleteMoneyRequest', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, callback: (reports) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(reports); }, }); @@ -549,7 +549,7 @@ describe('actions/IOU/DeleteMoneyRequest', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT_ACTIONS, callback: (actions) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(actions); }, }); @@ -591,7 +591,7 @@ describe('actions/IOU/DeleteMoneyRequest', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${thread.reportID}`, callback: (reportData) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(reportData); }, }); @@ -605,7 +605,7 @@ describe('actions/IOU/DeleteMoneyRequest', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${thread.reportID}`, callback: (reportData) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(reportData); }, }); @@ -659,7 +659,7 @@ describe('actions/IOU/DeleteMoneyRequest', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT_ACTIONS, callback: (actions) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(actions); }, }); @@ -720,7 +720,7 @@ describe('actions/IOU/DeleteMoneyRequest', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReport?.reportID}`, callback: (reportActionsForReport) => { - Onyx.disconnect(connection); + connection.unsubscribe(); createIOUAction = Object.values(reportActionsForReport ?? {}).find((reportAction): reportAction is ReportAction => isMoneyRequestAction(reportAction), ); @@ -754,7 +754,7 @@ describe('actions/IOU/DeleteMoneyRequest', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${thread.reportID}`, callback: (reportData) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(reportData); }, }); @@ -803,7 +803,7 @@ describe('actions/IOU/DeleteMoneyRequest', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${thread.reportID}`, callback: (report) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(report).toBeTruthy(); resolve(); }, @@ -844,7 +844,7 @@ describe('actions/IOU/DeleteMoneyRequest', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT_ACTIONS, callback: (actions) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(actions); }, }); @@ -880,7 +880,7 @@ describe('actions/IOU/DeleteMoneyRequest', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${thread.reportID}`, callback: (report) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(report?.reportID).toBeFalsy(); resolve(); }, @@ -897,7 +897,7 @@ describe('actions/IOU/DeleteMoneyRequest', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${thread.reportID}`, callback: (report) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(report).toBeFalsy(); resolve(); }, @@ -947,7 +947,7 @@ describe('actions/IOU/DeleteMoneyRequest', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT_ACTIONS, callback: (actions) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(actions); }, }); @@ -983,7 +983,7 @@ describe('actions/IOU/DeleteMoneyRequest', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReport?.reportID}`, callback: (reportActionsForReport) => { - Onyx.disconnect(connection); + connection.unsubscribe(); createIOUAction = Object.values(reportActionsForReport ?? {}).find((reportAction): reportAction is ReportAction => isMoneyRequestAction(reportAction), ); @@ -1080,7 +1080,7 @@ describe('actions/IOU/DeleteMoneyRequest', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReport?.reportID}`, callback: (reportActionsForReport) => { - Onyx.disconnect(connection); + connection.unsubscribe(); createIOUAction = Object.values(reportActionsForReport ?? {}).find((reportAction): reportAction is ReportAction => isMoneyRequestAction(reportAction), ); @@ -1099,7 +1099,7 @@ describe('actions/IOU/DeleteMoneyRequest', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReport?.reportID}`, callback: (reportActionsForReport) => { - Onyx.disconnect(connection); + connection.unsubscribe(); createIOUAction = Object.values(reportActionsForReport ?? {}).find((reportAction): reportAction is ReportAction => isMoneyRequestAction(reportAction), ); @@ -1280,7 +1280,7 @@ describe('actions/IOU/DeleteMoneyRequest', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT_ACTIONS, callback: (actions) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(actions); }, }); @@ -1319,7 +1319,7 @@ describe('actions/IOU/DeleteMoneyRequest', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, callback: (reports) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(reports); }, }); @@ -1336,7 +1336,7 @@ describe('actions/IOU/DeleteMoneyRequest', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, callback: (reports) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(reports); }, }); @@ -1478,7 +1478,7 @@ describe('actions/IOU/DeleteMoneyRequest', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${thread.reportID}`, callback: (report) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(report).toBeTruthy(); resolve(); }, @@ -1517,7 +1517,7 @@ describe('actions/IOU/DeleteMoneyRequest', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT_ACTIONS, callback: (actions) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(actions); }, }); @@ -1675,7 +1675,7 @@ describe('actions/IOU/DeleteMoneyRequest', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${expenseReport.reportID}`, callback: (val) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(val); }, }); @@ -1838,7 +1838,7 @@ describe('actions/IOU/DeleteMoneyRequest', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transaction1.transactionID}`, callback: (val) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(val); }, }); @@ -1906,7 +1906,7 @@ describe('actions/IOU/DeleteMoneyRequest', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transaction1.transactionID}`, callback: (val) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(val); }, }); @@ -2053,7 +2053,7 @@ describe('actions/IOU/DeleteMoneyRequest', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${expenseReport.reportID}`, callback: (val) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(val); }, }); @@ -2081,7 +2081,7 @@ describe('actions/IOU/DeleteMoneyRequest', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${expenseReport.reportID}`, callback: (val) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(val); }, }); @@ -2132,7 +2132,7 @@ describe('actions/IOU/DeleteMoneyRequest', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${expenseReport.reportID}`, callback: (val) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(val); }, }); @@ -2178,7 +2178,7 @@ describe('actions/IOU/DeleteMoneyRequest', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${expenseReport.reportID}`, callback: (val) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(val); }, }); @@ -2232,7 +2232,7 @@ describe('actions/IOU/DeleteMoneyRequest', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${expenseReport.reportID}`, callback: (val) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(val); }, }); @@ -2282,7 +2282,7 @@ describe('actions/IOU/DeleteMoneyRequest', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${expenseReport.reportID}`, callback: (val) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(val); }, }); @@ -2315,7 +2315,7 @@ describe('actions/IOU/DeleteMoneyRequest', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${expenseReport.reportID}`, callback: (val) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(val); }, }); diff --git a/tests/actions/IOUTest/DuplicateTest.ts b/tests/actions/IOUTest/DuplicateTest.ts index f98a16e351a2..9621728ec848 100644 --- a/tests/actions/IOUTest/DuplicateTest.ts +++ b/tests/actions/IOUTest/DuplicateTest.ts @@ -724,7 +724,7 @@ describe('actions/Duplicate', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${transactionThreadReport1.reportID}`, callback: (report) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(report).toBeTruthy(); resolve(); }, @@ -734,7 +734,7 @@ describe('actions/Duplicate', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${transactionThreadReport2.reportID}`, callback: (report) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(report).toBeTruthy(); resolve(); }, @@ -835,7 +835,7 @@ describe('actions/Duplicate', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${transactionThreadReport1.reportID}`, callback: (report) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(report?.reportID).toBeFalsy(); resolve(); }, @@ -846,7 +846,7 @@ describe('actions/Duplicate', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${transactionThreadReport2.reportID}`, callback: (report) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(report?.reportID).toBeFalsy(); resolve(); }, @@ -3043,7 +3043,7 @@ describe('actions/Duplicate', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transaction2.transactionID}`, callback: (transaction) => { - Onyx.disconnect(connection); + connection.unsubscribe(); // Then the duplicate transaction should correctly be set on hold. expect(transaction?.comment?.hold).toBeDefined(); resolve(); diff --git a/tests/actions/IOUTest/HoldTest.ts b/tests/actions/IOUTest/HoldTest.ts index 5095387b74d6..0fd69134f0da 100644 --- a/tests/actions/IOUTest/HoldTest.ts +++ b/tests/actions/IOUTest/HoldTest.ts @@ -147,12 +147,12 @@ describe('actions/IOU/Hold', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${transactionThread.reportID}`, callback: (report) => { - Onyx.disconnect(connection); + connection.unsubscribe(); const lastVisibleActionCreated = report?.lastVisibleActionCreated; const connection2 = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${transactionThread.reportID}`, callback: (reportActions) => { - Onyx.disconnect(connection2); + connection2.unsubscribe(); resolve(); const lastAction = getSortedReportActions(Object.values(reportActions ?? {}), true).at(0); const message = getReportActionMessage(lastAction); @@ -221,7 +221,7 @@ describe('actions/IOU/Hold', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReport.reportID}`, callback: (reportActions) => { - Onyx.disconnect(connection); + connection.unsubscribe(); const updatedIOUAction = reportActions?.[iouAction.reportActionID]; // Verify that IOU action now has childReportID set optimistically expect(updatedIOUAction?.childReportID).toBeDefined(); @@ -321,7 +321,7 @@ describe('actions/IOU/Hold', () => { const connection1 = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transaction1.transactionID}`, callback: (updatedTransaction1) => { - Onyx.disconnect(connection1); + connection1.unsubscribe(); // Both transactions should have pending hold action set expect(updatedTransaction1?.comment?.hold).toBeDefined(); checkBothTransactions(); @@ -330,7 +330,7 @@ describe('actions/IOU/Hold', () => { const connection2 = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transaction2.transactionID}`, callback: (updatedTransaction2) => { - Onyx.disconnect(connection2); + connection2.unsubscribe(); expect(updatedTransaction2?.comment?.hold).toBeDefined(); checkBothTransactions(); }, @@ -669,12 +669,12 @@ describe('actions/IOU/Hold', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${transactionThread.reportID}`, callback: (report) => { - Onyx.disconnect(connection); + connection.unsubscribe(); const lastVisibleActionCreated = report?.lastVisibleActionCreated; const connection2 = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${transactionThread.reportID}`, callback: (reportActions) => { - Onyx.disconnect(connection2); + connection2.unsubscribe(); resolve(); const lastAction = getSortedReportActions(Object.values(reportActions ?? {}), true).at(0); // Then the transaction thread report lastVisibleActionCreated should equal the unhold action created timestamp. @@ -767,7 +767,7 @@ describe('actions/IOU/Hold', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transaction.transactionID}`, callback: (updatedTransaction) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(updatedTransaction?.pendingAction).toBeFalsy(); expect(updatedTransaction?.comment?.hold).toBeTruthy(); expect(Object.values(updatedTransaction?.errors ?? {})).toEqual( diff --git a/tests/actions/IOUTest/PayMoneyRequestTest.ts b/tests/actions/IOUTest/PayMoneyRequestTest.ts index 0b464a9e5001..cf6775bee5bb 100644 --- a/tests/actions/IOUTest/PayMoneyRequestTest.ts +++ b/tests/actions/IOUTest/PayMoneyRequestTest.ts @@ -172,7 +172,7 @@ describe('actions/IOU/PayMoneyRequest', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, callback: (allReports) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(Object.values(allReports ?? {}).length).toBe(3); @@ -204,7 +204,7 @@ describe('actions/IOU/PayMoneyRequest', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT_ACTIONS, callback: (allReportActions) => { - Onyx.disconnect(connection); + connection.unsubscribe(); const reportActionsForIOUReport = allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${chatReport?.iouReportID}`]; @@ -225,7 +225,7 @@ describe('actions/IOU/PayMoneyRequest', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.TRANSACTION, callback: (allTransactions) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(Object.values(allTransactions ?? {}).length).toBe(1); transaction = Object.values(allTransactions ?? {}).find((t) => t); expect(transaction).toBeTruthy(); @@ -269,7 +269,7 @@ describe('actions/IOU/PayMoneyRequest', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, callback: (allReports) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(Object.values(allReports ?? {}).length).toBe(3); @@ -292,7 +292,7 @@ describe('actions/IOU/PayMoneyRequest', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT_ACTIONS, callback: (allReportActions) => { - Onyx.disconnect(connection); + connection.unsubscribe(); const reportActionsForIOUReport = allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReport?.reportID}`]; expect(Object.values(reportActionsForIOUReport ?? {}).length).toBe(3); @@ -315,7 +315,7 @@ describe('actions/IOU/PayMoneyRequest', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, callback: (allReports) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(Object.values(allReports ?? {}).length).toBe(3); @@ -338,7 +338,7 @@ describe('actions/IOU/PayMoneyRequest', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT_ACTIONS, callback: (allReportActions) => { - Onyx.disconnect(connection); + connection.unsubscribe(); const reportActionsForIOUReport = allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReport?.reportID}`]; expect(Object.values(reportActionsForIOUReport ?? {}).length).toBe(3); @@ -400,7 +400,7 @@ describe('actions/IOU/PayMoneyRequest', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, callback: (allReports) => { - Onyx.disconnect(connection); + connection.unsubscribe(); chatReport = Object.values(allReports ?? {}).find((report) => report?.chatType === CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT); resolve(); @@ -455,7 +455,7 @@ describe('actions/IOU/PayMoneyRequest', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, callback: (allReports) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expenseReport = Object.values(allReports ?? {}).find((report) => report?.type === CONST.REPORT.TYPE.IOU); resolve(); @@ -494,7 +494,7 @@ describe('actions/IOU/PayMoneyRequest', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${expenseReport?.reportID}`, callback: (allActions) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(Object.values(allActions ?? {})).toEqual( expect.arrayContaining([ expect.objectContaining({ @@ -523,7 +523,7 @@ describe('actions/IOU/PayMoneyRequest', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, callback: (allReports) => { - Onyx.disconnect(connection); + connection.unsubscribe(); 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( @@ -580,7 +580,7 @@ describe('actions/IOU/PayMoneyRequest', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, callback: (allReports) => { - Onyx.disconnect(connection); + connection.unsubscribe(); chatReport = Object.values(allReports ?? {}).find((report) => report?.chatType === CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT); resolve(); @@ -635,7 +635,7 @@ describe('actions/IOU/PayMoneyRequest', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, callback: (allReports) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expenseReport = Object.values(allReports ?? {}).find((report) => report?.type === CONST.REPORT.TYPE.IOU); resolve(); @@ -675,7 +675,7 @@ describe('actions/IOU/PayMoneyRequest', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${expenseReport?.reportID}`, callback: (allActions) => { - Onyx.disconnect(connection); + connection.unsubscribe(); const erroredAction = Object.values(allActions ?? {}).find((action) => !isEmptyObject(action?.errors)); expect(Object.values(erroredAction?.errors ?? {}).at(0)).toEqual(translateLocal('iou.error.other')); resolve(); @@ -733,7 +733,7 @@ describe('actions/IOU/PayMoneyRequest', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReport.reportID}`, callback: (reportActions) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(Object.values(reportActions ?? {}).pop()); }, }); @@ -743,7 +743,7 @@ describe('actions/IOU/PayMoneyRequest', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${chatReport.reportID}`, callback: (report) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(report?.lastVisibleActionCreated).toBe(chatReport.lastVisibleActionCreated); expect(report?.hasOutstandingChildRequest).toBe(false); expect(report?.iouReportID).toBeUndefined(); @@ -759,7 +759,7 @@ describe('actions/IOU/PayMoneyRequest', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${iouReport.reportID}`, callback: (report) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(report?.hasOutstandingChildRequest).toBe(false); expect(report?.statusNum).toBe(CONST.REPORT.STATUS_NUM.REIMBURSED); expect(report?.lastVisibleActionCreated).toBe(payReportAction?.created); @@ -820,7 +820,7 @@ describe('actions/IOU/PayMoneyRequest', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReport.reportID}`, callback: (reportActions) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(Object.values(reportActions ?? {}).pop()); }, }); @@ -1229,7 +1229,7 @@ describe('actions/IOU/PayMoneyRequest', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${iouReport.reportID}`, callback: (report) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(report?.hasOutstandingChildRequest).toBe(false); expect(report?.statusNum).toBe(CONST.REPORT.STATUS_NUM.REIMBURSED); resolve(); @@ -1284,7 +1284,7 @@ describe('actions/IOU/PayMoneyRequest', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${iouReport.reportID}`, callback: (report) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(report?.hasOutstandingChildRequest).toBe(false); expect(report?.statusNum).toBe(CONST.REPORT.STATUS_NUM.REIMBURSED); resolve(); @@ -1382,7 +1382,7 @@ describe('actions/IOU/PayMoneyRequest', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${chatReport.reportID}`, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value); }, }); @@ -1640,7 +1640,7 @@ describe('actions/IOU/PayMoneyRequest', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${iouReport.reportID}`, callback: (report) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(report?.hasOutstandingChildRequest).toBe(false); expect(report?.statusNum).toBe(CONST.REPORT.STATUS_NUM.REIMBURSED); resolve(); diff --git a/tests/actions/IOUTest/ReceiptTest.ts b/tests/actions/IOUTest/ReceiptTest.ts index 3cbb6758d14d..5938fb5b391d 100644 --- a/tests/actions/IOUTest/ReceiptTest.ts +++ b/tests/actions/IOUTest/ReceiptTest.ts @@ -114,7 +114,7 @@ describe('actions/IOU/Receipt', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.TRANSACTION, callback: (transactions) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(transactions[`${ONYXKEYS.COLLECTION.TRANSACTION}${id}`]); }, }); diff --git a/tests/actions/IOUTest/ReportWorkflowTest.ts b/tests/actions/IOUTest/ReportWorkflowTest.ts index 7b8390a52b57..5f9571ab3faa 100644 --- a/tests/actions/IOUTest/ReportWorkflowTest.ts +++ b/tests/actions/IOUTest/ReportWorkflowTest.ts @@ -185,7 +185,7 @@ describe('actions/IOU/ReportWorkflow', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, callback: (allReports) => { - Onyx.disconnect(connection); + connection.unsubscribe(); chatReport = Object.values(allReports ?? {}).find((report) => report?.chatType === CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT); resolve(); @@ -237,7 +237,7 @@ describe('actions/IOU/ReportWorkflow', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, callback: (allReports) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expenseReport = Object.values(allReports ?? {}).find((report) => report?.type === CONST.REPORT.TYPE.EXPENSE); Onyx.merge(`report_${expenseReport?.reportID}`, { statusNum: 0, @@ -254,7 +254,7 @@ describe('actions/IOU/ReportWorkflow', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, callback: (allReports) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expenseReport = Object.values(allReports ?? {}).find((report) => report?.type === CONST.REPORT.TYPE.EXPENSE); // Verify report is a draft @@ -293,7 +293,7 @@ describe('actions/IOU/ReportWorkflow', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, callback: (allReports) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expenseReport = Object.values(allReports ?? {}).find((report) => report?.type === CONST.REPORT.TYPE.EXPENSE); // Report was submitted correctly expect(expenseReport?.stateNum).toBe(1); @@ -851,7 +851,7 @@ describe('actions/IOU/ReportWorkflow', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, callback: (allReports) => { - Onyx.disconnect(connection); + connection.unsubscribe(); chatReport = Object.values(allReports ?? {}).find((report) => report?.chatType === CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT); resolve(); @@ -938,7 +938,7 @@ describe('actions/IOU/ReportWorkflow', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, callback: (allReports) => { - Onyx.disconnect(connection); + connection.unsubscribe(); chatReport = Object.values(allReports ?? {}).find((report) => report?.chatType === CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT); resolve(); }, @@ -990,7 +990,7 @@ describe('actions/IOU/ReportWorkflow', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, callback: (allReports) => { - Onyx.disconnect(connection); + connection.unsubscribe(); chatReport = Object.values(allReports ?? {}).find((report) => report?.chatType === CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT); resolve(); }, @@ -1042,7 +1042,7 @@ describe('actions/IOU/ReportWorkflow', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.POLICY, callback: (allPolicies) => { - Onyx.disconnect(connection); + connection.unsubscribe(); policy = Object.values(allPolicies ?? {}).find((p): p is OnyxEntry => p?.name === "Carlos's Workspace"); expect(policy).toBeTruthy(); resolve(); @@ -1056,7 +1056,7 @@ describe('actions/IOU/ReportWorkflow', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, callback: (allReports) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expenseReport = Object.values(allReports ?? {}).find((report) => report?.type === CONST.REPORT.TYPE.EXPENSE); Onyx.merge(`report_${expenseReport?.reportID}`, { @@ -1081,7 +1081,7 @@ describe('actions/IOU/ReportWorkflow', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, callback: (allReports) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expenseReport = Object.values(allReports ?? {}).find((report) => report?.type === CONST.REPORT.TYPE.EXPENSE); resolve(); @@ -1123,7 +1123,7 @@ describe('actions/IOU/ReportWorkflow', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, callback: (allReports) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expenseReport = Object.values(allReports ?? {}).find((report) => report?.type === CONST.REPORT.TYPE.EXPENSE); resolve(); @@ -1179,7 +1179,7 @@ describe('actions/IOU/ReportWorkflow', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.POLICY, callback: (allPolicies) => { - Onyx.disconnect(connection); + connection.unsubscribe(); policy = Object.values(allPolicies ?? {}).find((p): p is OnyxEntry => p?.id === policy?.id); resolve(); }, @@ -1192,7 +1192,7 @@ describe('actions/IOU/ReportWorkflow', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, callback: (allReports) => { - Onyx.disconnect(connection); + connection.unsubscribe(); chatReport = Object.values(allReports ?? {}).find((report) => report?.chatType === CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT); expect(canIOUBePaid(expenseReport, chatReport, policy, {}, CARLOS_EMAIL, CARLOS_ACCOUNT_ID, [], true, false)).toBe(false); @@ -1240,7 +1240,7 @@ describe('actions/IOU/ReportWorkflow', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, callback: (allReports) => { - Onyx.disconnect(connection); + connection.unsubscribe(); chatReport = Object.values(allReports ?? {}).find((report) => report?.chatType === CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT); resolve(); }, @@ -1292,7 +1292,7 @@ describe('actions/IOU/ReportWorkflow', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, callback: (allReports) => { - Onyx.disconnect(connection); + connection.unsubscribe(); chatReport = Object.values(allReports ?? {}).find((report) => report?.chatType === CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT); resolve(); }, @@ -1344,7 +1344,7 @@ describe('actions/IOU/ReportWorkflow', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.POLICY, callback: (allPolicies) => { - Onyx.disconnect(connection); + connection.unsubscribe(); policy = Object.values(allPolicies ?? {}).find((p): p is OnyxEntry => p?.name === "Carlos's Workspace"); expect(policy).toBeTruthy(); resolve(); @@ -1358,7 +1358,7 @@ describe('actions/IOU/ReportWorkflow', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, callback: (allReports) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expenseReport = Object.values(allReports ?? {}).find((report) => report?.type === CONST.REPORT.TYPE.EXPENSE); Onyx.merge(`report_${expenseReport?.reportID}`, { @@ -1383,7 +1383,7 @@ describe('actions/IOU/ReportWorkflow', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, callback: (allReports) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expenseReport = Object.values(allReports ?? {}).find((report) => report?.type === CONST.REPORT.TYPE.EXPENSE); // Verify report is a draft @@ -1423,7 +1423,7 @@ describe('actions/IOU/ReportWorkflow', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, callback: (allReports) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expenseReport = Object.values(allReports ?? {}).find((report) => report?.type === CONST.REPORT.TYPE.EXPENSE); // Report was submitted with some fail @@ -1478,7 +1478,7 @@ describe('actions/IOU/ReportWorkflow', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.POLICY, callback: (allPolicies) => { - Onyx.disconnect(connection); + connection.unsubscribe(); policy = Object.values(allPolicies ?? {}).find((p): p is OnyxEntry => p?.id === policyID); expect(policy).toBeTruthy(); expect(policy?.approvalMode).toBe(CONST.POLICY.APPROVAL_MODE.DYNAMICEXTERNAL); @@ -1493,7 +1493,7 @@ describe('actions/IOU/ReportWorkflow', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, callback: (allReports) => { - Onyx.disconnect(connection); + connection.unsubscribe(); chatReport = Object.values(allReports ?? {}).find( (report) => report?.chatType === CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT && report.policyID === policyID, ); @@ -1547,7 +1547,7 @@ describe('actions/IOU/ReportWorkflow', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, callback: (allReports) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expenseReport = Object.values(allReports ?? {}).find((report) => report?.type === CONST.REPORT.TYPE.EXPENSE && report?.policyID === policyID); Onyx.merge(`report_${expenseReport?.reportID}`, { statusNum: 0, @@ -1564,7 +1564,7 @@ describe('actions/IOU/ReportWorkflow', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, callback: (allReports) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expenseReport = Object.values(allReports ?? {}).find((report) => report?.type === CONST.REPORT.TYPE.EXPENSE && report?.policyID === policyID); expect(expenseReport?.stateNum).toBe(0); @@ -1603,7 +1603,7 @@ describe('actions/IOU/ReportWorkflow', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, callback: (allReports) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expenseReport = Object.values(allReports ?? {}).find((report) => report?.type === CONST.REPORT.TYPE.EXPENSE && report?.policyID === policyID); expect(expenseReport?.stateNum).toBe(CONST.REPORT.STATE_NUM.OPEN); @@ -3969,7 +3969,7 @@ describe('actions/IOU/ReportWorkflow', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${chatReport.reportID}`, callback: (report) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(report?.iouReportID); }, }); diff --git a/tests/actions/IOUTest/SendInvoiceTest.ts b/tests/actions/IOUTest/SendInvoiceTest.ts index e2934888ee46..5f5ff14723c3 100644 --- a/tests/actions/IOUTest/SendInvoiceTest.ts +++ b/tests/actions/IOUTest/SendInvoiceTest.ts @@ -885,7 +885,7 @@ describe('actions/SendInvoice', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.TRANSACTION, callback: (allTransactions) => { - Onyx.disconnect(connection); + connection.unsubscribe(); const transactionValue = Object.values(allTransactions).at(0); expect(transactionValue?.errors).not.toBeUndefined(); expect(transactionValue?.pendingAction).toBe(CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD); diff --git a/tests/actions/IOUTest/SplitTest.ts b/tests/actions/IOUTest/SplitTest.ts index 6e878ca90369..2cb76ad2799e 100644 --- a/tests/actions/IOUTest/SplitTest.ts +++ b/tests/actions/IOUTest/SplitTest.ts @@ -441,7 +441,7 @@ describe('split expense', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, callback: (allReports) => { - Onyx.disconnect(connection); + connection.unsubscribe(); // There should now be 10 reports expect(Object.values(allReports ?? {}).length).toBe(10); @@ -518,7 +518,7 @@ describe('split expense', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT_ACTIONS, callback: (allReportActions) => { - Onyx.disconnect(connection); + connection.unsubscribe(); // There should be reportActions on all 7 chat reports + 3 IOU reports in each 1:1 chat expect(Object.values(allReportActions ?? {}).length).toBe(10); @@ -604,7 +604,7 @@ describe('split expense', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.TRANSACTION, callback: (allTransactions) => { - Onyx.disconnect(connection); + connection.unsubscribe(); /* There should be 5 transactions * – one existing one with Jules @@ -669,7 +669,7 @@ describe('split expense', () => { const connection = Onyx.connect({ key: ONYXKEYS.PERSONAL_DETAILS_LIST, callback: (allPersonalDetails) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(allPersonalDetails).toMatchObject({ [VIT_ACCOUNT_ID]: { accountID: VIT_ACCOUNT_ID, @@ -690,7 +690,7 @@ describe('split expense', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, callback: (allReports) => { - Onyx.disconnect(connection); + connection.unsubscribe(); for (const report of Object.values(allReports ?? {})) { if (!report?.pendingFields) { continue; @@ -710,7 +710,7 @@ describe('split expense', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT_ACTIONS, callback: (allReportActions) => { - Onyx.disconnect(connection); + connection.unsubscribe(); for (const reportAction of Object.values(allReportActions ?? {})) { expect(reportAction?.pendingAction).toBeFalsy(); } @@ -725,7 +725,7 @@ describe('split expense', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.TRANSACTION, callback: (allTransactions) => { - Onyx.disconnect(connection); + connection.unsubscribe(); for (const transaction of Object.values(allTransactions ?? {})) { expect(transaction?.pendingAction).toBeFalsy(); } @@ -774,7 +774,7 @@ describe('split expense', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${workspaceReportID}`, callback: (reportActions) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(Object.values(reportActions ?? {}).find((action) => action.actionName === CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW)); }, }); @@ -784,7 +784,7 @@ describe('split expense', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${workspaceReportID}`, callback: (report) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(report?.lastVisibleActionCreated).toBe(reportPreviewAction?.created); resolve(report); }, @@ -962,7 +962,7 @@ describe('split expense', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, callback: (reportActions) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve( Object.values(reportActions ?? {}) .filter((action) => isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.IOU)) @@ -977,7 +977,7 @@ describe('split expense', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, callback: (reportVal) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(reportVal); }, }); @@ -1032,7 +1032,7 @@ describe('split expense', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.TRANSACTION, callback: (transactions) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(Object.values(transactions ?? {}).find((transaction) => transaction?.amount === -(transactionAmount / 2))); }, }); @@ -1088,7 +1088,7 @@ describe('split expense', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, callback: (reportVal) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(reportVal); }, }); @@ -1165,7 +1165,7 @@ describe('split expense', () => { key: `${ONYXKEYS.COLLECTION.POLICY_RECENTLY_USED_TAGS}${policyID}`, callback: (recentlyUsedTags) => { resolve(recentlyUsedTags ?? {}); - Onyx.disconnect(connection); + connection.unsubscribe(); }, }); }); @@ -1491,7 +1491,7 @@ describe('split expense', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.TRANSACTION, callback: (transactions) => { - Onyx.disconnect(connection); + connection.unsubscribe(); const splits = Object.values(transactions ?? {}).filter((t) => t?.transactionID !== originalTransactionID && t?.comment?.originalTransactionID === originalTransactionID); resolve(splits.filter((split): split is Transaction => split != null)); }, @@ -1560,7 +1560,7 @@ describe('split expense', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.TRANSACTION, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value); }, }); @@ -1626,7 +1626,7 @@ describe('split expense', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, callback: (reports) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(reports); }, }); @@ -1639,7 +1639,7 @@ describe('split expense', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.TRANSACTION, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value); }, }); @@ -1697,7 +1697,7 @@ describe('split expense', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.TRANSACTION, callback: (transactions) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(transactions); }, }); @@ -1711,7 +1711,7 @@ describe('split expense', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT_ACTIONS, callback: (actions) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(actions); }, }); @@ -1964,7 +1964,7 @@ describe('startSplitBill', () => { key: `${ONYXKEYS.COLLECTION.POLICY_RECENTLY_USED_TAGS}${policyID}`, callback: (recentlyUsedTags) => { resolve(recentlyUsedTags ?? {}); - Onyx.disconnect(connection); + connection.unsubscribe(); }, }); }); @@ -2175,7 +2175,7 @@ describe('updateSplitTransactionsFromSplitExpensesFlow', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${iouAction.childReportID}`, callback: (val) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(val); }, }); @@ -2300,7 +2300,7 @@ describe('updateSplitTransactionsFromSplitExpensesFlow', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.SNAPSHOT}${hash}`, callback: (val) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(val); }, }); @@ -2436,7 +2436,7 @@ describe('updateSplitTransactionsFromSplitExpensesFlow', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.SNAPSHOT}${unapprovedCashHash}`, callback: (val) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(val); }, }); @@ -2673,7 +2673,7 @@ describe('updateSplitTransactionsFromSplitExpensesFlow', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${differentReportID}`, callback: (val) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(val); }, }); @@ -8943,7 +8943,7 @@ describe('setDraftSplitTransaction', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.SPLIT_TRANSACTION_DRAFT}${transactionID}`, callback: (transaction) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(transaction?.taxCode).toBe(ruleTaxCode); expect(transaction?.taxAmount).toBe(5); resolve(); @@ -8984,7 +8984,7 @@ describe('setDraftSplitTransaction', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.SPLIT_TRANSACTION_DRAFT}${transactionID}`, callback: (transaction) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(transaction?.taxCode).toBe(taxCode); expect(transaction?.taxAmount).toBe(taxAmount); resolve(); @@ -9021,7 +9021,7 @@ describe('setDraftSplitTransaction', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.SPLIT_TRANSACTION_DRAFT}${transactionID}`, callback: (transaction) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(transaction?.taxCode).toBeUndefined(); expect(transaction?.taxAmount).toBeUndefined(); resolve(); diff --git a/tests/actions/IOUTest/TrackExpenseTest.ts b/tests/actions/IOUTest/TrackExpenseTest.ts index 2f622f819bf2..d94190d7eadc 100644 --- a/tests/actions/IOUTest/TrackExpenseTest.ts +++ b/tests/actions/IOUTest/TrackExpenseTest.ts @@ -346,7 +346,7 @@ describe('actions/IOU/TrackExpense', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.TRANSACTION, callback: (transactions) => { - Onyx.disconnect(connection); + connection.unsubscribe(); const trackedExpenseTransaction = Object.values(transactions ?? {}).at(0); // Then the transaction must remain a distance request @@ -362,7 +362,7 @@ describe('actions/IOU/TrackExpense', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT_ACTIONS, callback: (reportActions) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(reportActions); }, }); @@ -457,7 +457,7 @@ describe('actions/IOU/TrackExpense', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.TRANSACTION, callback: (transactions) => { - Onyx.disconnect(connection); + connection.unsubscribe(); const categorizedTransaction = transactions?.[`${ONYXKEYS.COLLECTION.TRANSACTION}${transaction?.transactionID}`]; // Then the transaction must remain a distance request, ensuring that the optimistic data is correctly built and the transaction type remains accurate. @@ -478,7 +478,7 @@ describe('actions/IOU/TrackExpense', () => { const connection = Onyx.connect({ key: ONYXKEYS.NVP_QUICK_ACTION_GLOBAL_CREATE, callback: (quickAction) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(); // Then the quickAction.action should be set to REQUEST_DISTANCE @@ -551,7 +551,7 @@ describe('actions/IOU/TrackExpense', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${selfDMReport.reportID}`, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value); }, }); @@ -612,7 +612,7 @@ describe('actions/IOU/TrackExpense', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${policyExpenseChat.reportID}`, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value); }, }); @@ -621,7 +621,7 @@ describe('actions/IOU/TrackExpense', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${policy.id}`, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value); }, }); @@ -699,7 +699,7 @@ describe('actions/IOU/TrackExpense', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${selfDMReport.reportID}`, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value); }, }); @@ -760,7 +760,7 @@ describe('actions/IOU/TrackExpense', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${policyExpenseChat.reportID}`, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value); }, }); @@ -769,7 +769,7 @@ describe('actions/IOU/TrackExpense', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${policy.id}`, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value); }, }); @@ -851,7 +851,7 @@ describe('actions/IOU/TrackExpense', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${selfDMReport.reportID}`, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value); }, }); @@ -912,7 +912,7 @@ describe('actions/IOU/TrackExpense', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${policy.id}`, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value); }, }); @@ -1000,7 +1000,7 @@ describe('actions/IOU/TrackExpense', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${selfDMReport.reportID}`, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value); }, }); @@ -1061,7 +1061,7 @@ describe('actions/IOU/TrackExpense', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, callback: (reports) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(reports); }, }); @@ -1168,7 +1168,7 @@ describe('actions/IOU/TrackExpense', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${selfDMReport.reportID}`, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value); }, }); @@ -1230,7 +1230,7 @@ describe('actions/IOU/TrackExpense', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${accountantExpenseChatID}`, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value); }, }); @@ -1239,7 +1239,7 @@ describe('actions/IOU/TrackExpense', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${archivedExpenseReportID}`, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value); }, }); @@ -1747,7 +1747,7 @@ describe('actions/IOU/TrackExpense', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, callback: (val) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(val); }, }); @@ -1770,7 +1770,7 @@ describe('actions/IOU/TrackExpense', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, callback: (val) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(val); }, }); @@ -2383,7 +2383,7 @@ describe('actions/IOU/TrackExpense', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, callback: (reports) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(reports); }, }); @@ -2411,7 +2411,7 @@ describe('actions/IOU/TrackExpense', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT_ACTIONS, callback: (actions) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(actions); }, }); @@ -2430,7 +2430,7 @@ describe('actions/IOU/TrackExpense', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.TRANSACTION, callback: (transactions) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(transactions); }, }); @@ -2486,7 +2486,7 @@ describe('actions/IOU/TrackExpense', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${thread.reportID}`, callback: (report) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(report).toBeTruthy(); resolve(); }, @@ -2525,7 +2525,7 @@ describe('actions/IOU/TrackExpense', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT_ACTIONS, callback: (actions) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(actions); }, }); @@ -2604,7 +2604,7 @@ describe('actions/IOU/TrackExpense', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${thread.reportID}`, callback: (report) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(report).toBeTruthy(); resolve(); }, @@ -2698,7 +2698,7 @@ describe('actions/IOU/TrackExpense', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, callback: (actions) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(actions); }, }); @@ -2708,7 +2708,7 @@ describe('actions/IOU/TrackExpense', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT_ACTIONS, callback: (actions) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(actions); }, }); @@ -2718,7 +2718,7 @@ describe('actions/IOU/TrackExpense', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.TRANSACTION, callback: (actions) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(actions); }, }); diff --git a/tests/actions/IOUTest/UpdateMoneyRequestTest.ts b/tests/actions/IOUTest/UpdateMoneyRequestTest.ts index 148aaec1ae3b..aff27c0d5745 100644 --- a/tests/actions/IOUTest/UpdateMoneyRequestTest.ts +++ b/tests/actions/IOUTest/UpdateMoneyRequestTest.ts @@ -208,7 +208,7 @@ describe('actions/IOU/UpdateMoneyRequest', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, callback: (transaction) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(transaction?.taxCode).toBe(ruleTaxCode); expect(transaction?.taxAmount).toBe(5); resolve(); @@ -221,7 +221,7 @@ describe('actions/IOU/UpdateMoneyRequest', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${transactionThreadReportID}`, callback: (reportActions) => { - Onyx.disconnect(connection); + connection.unsubscribe(); const reportAction = Object.values(reportActions ?? {}).at(0); if (isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.MODIFIED_EXPENSE)) { const originalMessage = getOriginalMessage(reportAction); @@ -297,7 +297,7 @@ describe('actions/IOU/UpdateMoneyRequest', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, callback: (transaction) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(transaction?.taxCode).toBe(taxCode); expect(transaction?.taxAmount).toBe(taxAmount); resolve(); @@ -352,7 +352,7 @@ describe('actions/IOU/UpdateMoneyRequest', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, callback: (transaction) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(transaction?.taxCode).toBeUndefined(); expect(transaction?.taxAmount).toBeUndefined(); resolve(); @@ -418,7 +418,7 @@ describe('actions/IOU/UpdateMoneyRequest', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`, callback: (transactionViolations) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(transactionViolations).toHaveLength(1); expect(transactionViolations?.at(0)?.name).toEqual(CONST.VIOLATIONS.MISSING_CATEGORY); resolve(); @@ -567,7 +567,7 @@ describe('actions/IOU/UpdateMoneyRequest', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.TRANSACTION, callback: (transactions) => { - Onyx.disconnect(connection); + connection.unsubscribe(); const newTransaction = transactions[`${ONYXKEYS.COLLECTION.TRANSACTION}${fakeTransaction.transactionID}`]; resolve(newTransaction); }, @@ -642,7 +642,7 @@ describe('actions/IOU/UpdateMoneyRequest', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.TRANSACTION, callback: (transactions) => { - Onyx.disconnect(connection); + connection.unsubscribe(); const newTransaction = transactions[`${ONYXKEYS.COLLECTION.TRANSACTION}${fakeTransaction.transactionID}`]; resolve(newTransaction); }, @@ -856,7 +856,7 @@ describe('actions/IOU/UpdateMoneyRequest', () => { const connection = Onyx.connectWithoutView({ key: ONYXKEYS.NVP_RECENT_ATTENDEES, callback: (attendees) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(attendees); }, }); @@ -896,7 +896,7 @@ describe('actions/IOU/UpdateMoneyRequest', () => { const connection = Onyx.connectWithoutView({ key: ONYXKEYS.NVP_RECENT_ATTENDEES, callback: (attendees) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(attendees); }, }); @@ -968,7 +968,7 @@ describe('actions/IOU/UpdateMoneyRequest', () => { key: `${ONYXKEYS.COLLECTION.POLICY_RECENTLY_USED_TAGS}${policy.id}`, callback: (recentlyUsedTags) => { resolve(recentlyUsedTags ?? {}); - Onyx.disconnect(connection); + connection.unsubscribe(); }, }); }); @@ -1034,7 +1034,7 @@ describe('actions/IOU/UpdateMoneyRequest', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`, callback: (transactionViolations) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(transactionViolations?.some((violation) => violation.name === CONST.VIOLATIONS.TAG_OUT_OF_POLICY)).toBe(false); resolve(); }, diff --git a/tests/actions/MergeTransactionTest.ts b/tests/actions/MergeTransactionTest.ts index 1b567012c9f1..3473030574fb 100644 --- a/tests/actions/MergeTransactionTest.ts +++ b/tests/actions/MergeTransactionTest.ts @@ -362,7 +362,7 @@ describe('mergeTransactionRequest', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.TRANSACTION}${targetTransaction.transactionID}`, callback: (transaction) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(transaction ?? null); }, }); @@ -372,7 +372,7 @@ describe('mergeTransactionRequest', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.TRANSACTION}${sourceTransaction.transactionID}`, callback: (transaction) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(transaction ?? null); }, }); @@ -382,7 +382,7 @@ describe('mergeTransactionRequest', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${sourceExpenseReport.reportID}`, callback: (report) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(report ?? null); }, }); @@ -392,7 +392,7 @@ describe('mergeTransactionRequest', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.MERGE_TRANSACTION}${mergeTransactionID}`, callback: (transaction) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(transaction ?? null); }, }); @@ -489,7 +489,7 @@ describe('mergeTransactionRequest', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.TRANSACTION}${targetTransaction.transactionID}`, callback: (transaction) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(transaction ?? null); }, }); @@ -623,7 +623,7 @@ describe('mergeTransactionRequest', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.TRANSACTION}${targetTransaction.transactionID}`, callback: (transaction) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(transaction ?? null); }, }); @@ -633,7 +633,7 @@ describe('mergeTransactionRequest', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.TRANSACTION}${sourceTransaction.transactionID}`, callback: (transaction) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(transaction ?? null); }, }); @@ -643,7 +643,7 @@ describe('mergeTransactionRequest', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${targetExpenseReport.reportID}`, callback: (report) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(report ?? null); }, }); @@ -653,7 +653,7 @@ describe('mergeTransactionRequest', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${sourceExpenseReport.reportID}`, callback: (report) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(report ?? null); }, }); @@ -762,7 +762,7 @@ describe('mergeTransactionRequest', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.TRANSACTION}${targetTransaction.transactionID}`, callback: (transaction) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(transaction ?? null); }, }); @@ -772,7 +772,7 @@ describe('mergeTransactionRequest', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.TRANSACTION}${sourceTransaction.transactionID}`, callback: (transaction) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(transaction ?? null); }, }); @@ -782,7 +782,7 @@ describe('mergeTransactionRequest', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${sourceReport.reportID}`, callback: (report) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(report ?? null); }, }); @@ -876,7 +876,7 @@ describe('mergeTransactionRequest', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${targetTransaction.transactionID}`, callback: (violations) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(violations ?? null); }, }); @@ -907,7 +907,7 @@ describe('mergeTransactionRequest', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${targetReport.reportID}`, callback: (report) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(report ?? null); }, }); @@ -920,7 +920,7 @@ describe('mergeTransactionRequest', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${sourceExpenseReport.reportID}`, callback: (actions) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(actions ?? null); }, }); @@ -945,7 +945,7 @@ describe('mergeTransactionRequest', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${targetTransactionThreadID}`, callback: (report) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(report ?? null); }, }); @@ -972,7 +972,7 @@ describe('mergeTransactionRequest', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${sourceExpenseReport.reportID}`, callback: (actions) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(actions ?? null); }, }); @@ -984,7 +984,7 @@ describe('mergeTransactionRequest', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${targetTransactionThreadID}`, callback: (report) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(report ?? null); }, }); @@ -1112,7 +1112,7 @@ describe('mergeTransactionRequest', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${sourceReport.reportID}`, callback: (report) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(report ?? null); }, }); @@ -1126,7 +1126,7 @@ describe('mergeTransactionRequest', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${parentReportID}`, callback: (val) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(val ?? null); }, }); @@ -1247,7 +1247,7 @@ describe('mergeTransactionRequest', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${thread.reportID}`, callback: (report) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(report).toBeTruthy(); resolve(); }, @@ -1329,7 +1329,7 @@ describe('mergeTransactionRequest', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${thread.reportID}`, callback: (report) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(report?.reportID).toBeFalsy(); resolve(); }, @@ -1351,7 +1351,7 @@ describe('mergeTransactionRequest', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${thread.reportID}`, callback: (report) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(report).toBeFalsy(); resolve(); }, @@ -1436,7 +1436,7 @@ describe('mergeTransactionRequest', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${thread.reportID}`, callback: (report) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(report).toBeTruthy(); resolve(); }, @@ -1484,7 +1484,7 @@ describe('mergeTransactionRequest', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${thread.reportID}`, callback: (report) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(report?.reportID).toBeFalsy(); resolve(); }, @@ -1500,7 +1500,7 @@ describe('mergeTransactionRequest', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${thread.reportID}`, callback: (report) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(report).toBeFalsy(); resolve(); }, @@ -1880,7 +1880,7 @@ describe('setupMergeTransactionData', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.MERGE_TRANSACTION}${transactionID}`, callback: (transaction) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(transaction ?? null); }, }); @@ -1923,7 +1923,7 @@ describe('setMergeTransactionKey', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.MERGE_TRANSACTION}${transactionID}`, callback: (transaction) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(transaction ?? null); }, }); diff --git a/tests/actions/PolicyCategoryTest.ts b/tests/actions/PolicyCategoryTest.ts index 2587abc3d0f8..4d57f2ecdac4 100644 --- a/tests/actions/PolicyCategoryTest.ts +++ b/tests/actions/PolicyCategoryTest.ts @@ -70,7 +70,7 @@ describe('actions/PolicyCategory', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, callback: (policy) => { - Onyx.disconnect(connection); + connection.unsubscribe(); // 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); @@ -85,7 +85,7 @@ describe('actions/PolicyCategory', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, callback: (policy) => { - Onyx.disconnect(connection); + connection.unsubscribe(); // Check if the policy pendingFields was cleared expect(policy?.pendingFields?.requiresCategory).toBeFalsy(); resolve(); @@ -117,7 +117,7 @@ describe('actions/PolicyCategory', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${fakePolicy.id}`, callback: (policyCategories) => { - Onyx.disconnect(connection); + connection.unsubscribe(); const newCategory = policyCategories?.[newCategoryName]; expect(newCategory?.name).toBe(newCategoryName); @@ -133,7 +133,7 @@ describe('actions/PolicyCategory', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${fakePolicy.id}`, callback: (policyCategories) => { - Onyx.disconnect(connection); + connection.unsubscribe(); const newCategory = policyCategories?.[newCategoryName]; expect(newCategory?.errors).toBeFalsy(); @@ -169,7 +169,7 @@ describe('actions/PolicyCategory', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${fakePolicy.id}`, callback: (policyCategories) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(policyCategories?.[oldCategoryName ?? '']).toBeFalsy(); expect(policyCategories?.[newCategoryName]?.name).toBe(newCategoryName); @@ -186,7 +186,7 @@ describe('actions/PolicyCategory', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${fakePolicy.id}`, callback: (policyCategories) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(policyCategories?.[newCategoryName]?.pendingAction).toBeFalsy(); expect(policyCategories?.[newCategoryName]?.pendingFields?.name).toBeFalsy(); @@ -229,7 +229,7 @@ describe('actions/PolicyCategory', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${fakePolicy.id}`, callback: (policyCategories) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(policyCategories?.[categoryNameToUpdate]?.enabled).toBeTruthy(); expect(policyCategories?.[categoryNameToUpdate]?.pendingAction).toBe(CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE); @@ -245,7 +245,7 @@ describe('actions/PolicyCategory', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${fakePolicy.id}`, callback: (policyCategories) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(policyCategories?.[categoryNameToUpdate]?.pendingAction).toBeFalsy(); expect(policyCategories?.[categoryNameToUpdate]?.pendingFields?.enabled).toBeFalsy(); @@ -274,7 +274,7 @@ describe('actions/PolicyCategory', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${fakePolicy.id}`, callback: (policyCategories) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(policyCategories?.[categoryNameToDelete]?.pendingAction).toBe(CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE); resolve(); @@ -287,7 +287,7 @@ describe('actions/PolicyCategory', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${fakePolicy.id}`, callback: (policyCategories) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(policyCategories?.[categoryNameToDelete]).toBeFalsy(); resolve(); @@ -326,7 +326,7 @@ describe('actions/PolicyCategory', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, callback: (policy) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(policy?.pendingFields?.areCategoriesEnabled).toBe(CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE); resolve(); }, @@ -336,7 +336,7 @@ describe('actions/PolicyCategory', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${fakePolicy.id}`, callback: (policyCategories) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(Object.values(policyCategories ?? {}).every((category) => category.enabled === false)).toBeTruthy(); resolve(); }, @@ -349,7 +349,7 @@ describe('actions/PolicyCategory', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, callback: (policy) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(policy?.areCategoriesEnabled).toBe(false); expect(policy?.requiresCategory).toBe(false); expect(policy?.pendingFields?.areCategoriesEnabled).toBeFalsy(); @@ -387,7 +387,7 @@ describe('actions/PolicyCategory', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, callback: (policy) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(policy?.pendingFields?.areCategoriesEnabled).toBe(CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE); resolve(); }, @@ -397,7 +397,7 @@ describe('actions/PolicyCategory', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${fakePolicy.id}`, callback: (policyCategories) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(Object.values(policyCategories ?? {}).every((category) => category.enabled === true)).toBeTruthy(); resolve(); }, @@ -410,7 +410,7 @@ describe('actions/PolicyCategory', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, callback: (policy) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(policy?.areCategoriesEnabled).toBe(true); expect(policy?.requiresCategory).toBe(true); expect(policy?.pendingFields?.areCategoriesEnabled).toBeFalsy(); @@ -819,7 +819,7 @@ describe('actions/PolicyCategory', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${fakePolicy.id}`, callback: (policyCategories) => { - Onyx.disconnect(connection); + connection.unsubscribe(); const category = policyCategories?.[categoryName]; expect(category?.maxAmountNoReceipt).toBe(CONST.DISABLED_MAX_EXPENSE_VALUE); @@ -840,7 +840,7 @@ describe('actions/PolicyCategory', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${fakePolicy.id}`, callback: (policyCategories) => { - Onyx.disconnect(connection); + connection.unsubscribe(); const category = policyCategories?.[categoryName]; expect(category?.maxAmountNoReceipt).toBe(CONST.DISABLED_MAX_EXPENSE_VALUE); @@ -892,7 +892,7 @@ describe('actions/PolicyCategory', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${fakePolicy.id}`, callback: (policyCategories) => { - Onyx.disconnect(connection); + connection.unsubscribe(); const category = policyCategories?.[categoryName]; expect(category?.maxAmountNoReceipt).toBe(0); @@ -913,7 +913,7 @@ describe('actions/PolicyCategory', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${fakePolicy.id}`, callback: (policyCategories) => { - Onyx.disconnect(connection); + connection.unsubscribe(); const category = policyCategories?.[categoryName]; expect(category?.maxAmountNoReceipt).toBe(0); diff --git a/tests/actions/PolicyExpensifyCardTest.ts b/tests/actions/PolicyExpensifyCardTest.ts index 1e1587f60ae4..b72090d71abd 100644 --- a/tests/actions/PolicyExpensifyCardTest.ts +++ b/tests/actions/PolicyExpensifyCardTest.ts @@ -26,7 +26,7 @@ function getLoadingState() { const connection = Onyx.connect({ key: loadingStateKey, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value); }, }); @@ -38,7 +38,7 @@ function getCardSettingsForFund(key: typeof unresolvedFundSettingsKey | typeof w const connection = Onyx.connect({ key, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value); }, }); diff --git a/tests/actions/PolicyMemberTest.ts b/tests/actions/PolicyMemberTest.ts index 5555a635a8fc..d8362835626f 100644 --- a/tests/actions/PolicyMemberTest.ts +++ b/tests/actions/PolicyMemberTest.ts @@ -63,7 +63,7 @@ describe('actions/PolicyMember', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${fakeReport.reportID}`, callback: (reportActions) => { - Onyx.disconnect(connection); + connection.unsubscribe(); const reportAction = reportActions?.[fakeReportAction.reportActionID]; @@ -88,7 +88,7 @@ describe('actions/PolicyMember', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${fakeReport.reportID}`, callback: (reportActions) => { - Onyx.disconnect(connection); + connection.unsubscribe(); const reportAction = reportActions?.[fakeReportAction.reportActionID]; @@ -127,7 +127,7 @@ describe('actions/PolicyMember', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, callback: (policy) => { - Onyx.disconnect(connection); + connection.unsubscribe(); const employee = policy?.employeeList?.[fakeUser2?.login ?? '']; // Then the policy employee role of the user should be set to admin. expect(employee?.role).toBe(CONST.POLICY.ROLE.ADMIN); @@ -140,7 +140,7 @@ describe('actions/PolicyMember', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${adminRoom.reportID}`, callback: (report) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(); // Then the user's notification preference on the admin room should be set to always. expect(report?.participants?.[fakeUser2.accountID].notificationPreference).toBe(CONST.REPORT.NOTIFICATION_PREFERENCE.ALWAYS); @@ -153,7 +153,7 @@ describe('actions/PolicyMember', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, callback: (policy) => { - Onyx.disconnect(connection); + connection.unsubscribe(); const employee = policy?.employeeList?.[fakeUser2?.login ?? '']; expect(employee?.pendingAction).toBeFalsy(); resolve(); @@ -168,7 +168,7 @@ describe('actions/PolicyMember', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, callback: (policy) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(); const employee = policy?.employeeList?.[fakeUser2?.login ?? '']; // Then the policy employee role of the user should be set to user. @@ -180,7 +180,7 @@ describe('actions/PolicyMember', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${adminRoom.reportID}`, callback: (report) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(); // Then the user should be removed from the admin room participants list of the policy. expect(report?.participants?.[fakeUser2.accountID]).toBeUndefined(); @@ -203,7 +203,7 @@ describe('actions/PolicyMember', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, callback: (policy) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(policy?.errorFields).toBeFalsy(); expect(policy?.isLoading).toBeTruthy(); expect(policy?.isChangeOwnerSuccessful).toBeFalsy(); @@ -218,7 +218,7 @@ describe('actions/PolicyMember', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, callback: (policy) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(policy?.isLoading).toBeFalsy(); expect(policy?.isChangeOwnerSuccessful).toBeTruthy(); expect(policy?.isChangeOwnerFailed)?.toBeFalsy(); @@ -296,7 +296,7 @@ describe('actions/PolicyMember', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, callback: (policy) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(policy?.errorFields).toBeFalsy(); expect(policy?.isLoading).toBeTruthy(); expect(policy?.isChangeOwnerSuccessful).toBeFalsy(); @@ -311,7 +311,7 @@ describe('actions/PolicyMember', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, callback: (policy) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(policy?.isLoading).toBeFalsy(); expect(policy?.isChangeOwnerSuccessful).toBeTruthy(); expect(policy?.isChangeOwnerFailed)?.toBeFalsy(); @@ -342,7 +342,7 @@ describe('actions/PolicyMember', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, callback: (policy) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(policy?.isLoading).toBeFalsy(); expect(policy?.isChangeOwnerSuccessful).toBeTruthy(); expect(policy?.owner).toBe(fakeEmail); @@ -399,7 +399,7 @@ describe('actions/PolicyMember', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, callback: (policy) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(policy?.errorFields).toBeFalsy(); expect(policy?.isLoading).toBeTruthy(); expect(policy?.isChangeOwnerSuccessful).toBeFalsy(); @@ -423,7 +423,7 @@ describe('actions/PolicyMember', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, callback: (policy) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(policy?.isLoading).toBeFalsy(); expect(policy?.isChangeOwnerSuccessful).toBeTruthy(); expect(policy?.isChangeOwnerFailed).toBeFalsy(); @@ -481,7 +481,7 @@ describe('actions/PolicyMember', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, callback: (policyResult) => { - Onyx.disconnect(connection); + connection.unsubscribe(); const newEmployee = policyResult?.employeeList?.[newUserEmail]; expect(newEmployee).not.toBeUndefined(); expect(newEmployee?.email).toBe(newUserEmail); @@ -568,7 +568,7 @@ describe('actions/PolicyMember', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${adminRoomID}`, callback: (report) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(report); }, }); @@ -583,7 +583,7 @@ describe('actions/PolicyMember', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${adminRoomID}`, callback: (report) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(report); }, }); @@ -614,7 +614,7 @@ describe('actions/PolicyMember', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, callback: (policyResult) => { - Onyx.disconnect(connection); + connection.unsubscribe(); const newEmployee = policyResult?.employeeList?.[newUserEmail]; expect(newEmployee?.role).toBe(CONST.POLICY.ROLE.EDITOR); resolve(); @@ -646,7 +646,7 @@ describe('actions/PolicyMember', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, callback: (policyResult) => { - Onyx.disconnect(connection); + connection.unsubscribe(); const newEmployee = policyResult?.employeeList?.[newUserEmail]; expect(newEmployee?.role).toBe(CONST.POLICY.ROLE.USER); resolve(); @@ -688,7 +688,7 @@ describe('actions/PolicyMember', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${adminRoomID}`, callback: (report) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(report); }, }); @@ -737,7 +737,7 @@ describe('actions/PolicyMember', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${workspaceReportID}`, callback: (nvp) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(!!nvp?.private_isArchived); }, }); @@ -746,7 +746,7 @@ describe('actions/PolicyMember', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${expenseReportID}`, callback: (nvp) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(!!nvp?.private_isArchived); }, }); @@ -796,7 +796,7 @@ describe('actions/PolicyMember', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${expenseReportID}`, callback: (nvp) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(!!nvp?.private_isArchived); }, }); @@ -920,7 +920,7 @@ describe('actions/PolicyMember', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_METADATA}${adminRoomID}`, callback: (reportMetadata) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(reportMetadata); }, }); @@ -936,7 +936,7 @@ describe('actions/PolicyMember', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_METADATA}${adminRoomID}`, callback: (reportMetadata) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(reportMetadata); }, }); @@ -1012,7 +1012,7 @@ describe('actions/PolicyMember', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, callback: (policyResult) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(policyResult?.connections?.[CONST.POLICY.CONNECTIONS.NAME.NETSUITE]?.options?.config?.exporter); }, }); @@ -1065,7 +1065,7 @@ describe('actions/PolicyMember', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${workspaceReportID}`, callback: (nvp) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(!!nvp?.private_isArchived); }, }); @@ -1074,7 +1074,7 @@ describe('actions/PolicyMember', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${expenseReportID}`, callback: (nvp) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(!!nvp?.private_isArchived); }, }); @@ -1115,7 +1115,7 @@ describe('actions/PolicyMember', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, callback: (policyData) => { - Onyx.disconnect(connection); + connection.unsubscribe(); if (policyData) { resolve(policyData); } else { @@ -1167,7 +1167,7 @@ describe('actions/PolicyMember', () => { const connection = Onyx.connectWithoutView({ key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, callback: (policyResult) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(policyResult?.employeeList); }, }); @@ -1215,7 +1215,7 @@ describe('actions/PolicyMember', () => { const connection = Onyx.connectWithoutView({ key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, callback: (policyResult) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(policyResult?.employeeList); }, }); @@ -1420,7 +1420,7 @@ describe('actions/PolicyMember', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.WORKSPACE_INVITE_MEMBERS_DRAFT}${policyID}`, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value); }, }); @@ -1461,7 +1461,7 @@ describe('actions/PolicyMember', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.WORKSPACE_INVITE_MEMBERS_DRAFT}${policyID}`, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value); }, }); @@ -1497,7 +1497,7 @@ describe('actions/PolicyMember', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.WORKSPACE_INVITE_MEMBERS_DRAFT}${policyID}`, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value); }, }); @@ -1529,7 +1529,7 @@ describe('actions/PolicyMember', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.WORKSPACE_INVITE_MEMBERS_DRAFT}${policyID1}`, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value); }, }); @@ -1539,7 +1539,7 @@ describe('actions/PolicyMember', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.WORKSPACE_INVITE_MEMBERS_DRAFT}${policyID2}`, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value); }, }); @@ -1571,7 +1571,7 @@ describe('actions/PolicyMember', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.WORKSPACE_INVITE_MEMBERS_DRAFT}${policyID}`, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value); }, }); @@ -1602,7 +1602,7 @@ describe('actions/PolicyMember', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.WORKSPACE_INVITE_MEMBERS_DRAFT}${policyID}`, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value); }, }); diff --git a/tests/actions/PolicyProfileTest.ts b/tests/actions/PolicyProfileTest.ts index b7de75f02905..d4d35f485944 100644 --- a/tests/actions/PolicyProfileTest.ts +++ b/tests/actions/PolicyProfileTest.ts @@ -42,7 +42,7 @@ describe('actions/PolicyProfile', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, callback: (policy) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(policy?.description).toBe(parsedDescription); expect(policy?.pendingFields?.description).toBe(CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE); @@ -57,7 +57,7 @@ describe('actions/PolicyProfile', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, callback: (policy) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(policy?.pendingFields?.description).toBeFalsy(); resolve(); diff --git a/tests/actions/PolicyRulesTest.ts b/tests/actions/PolicyRulesTest.ts index 2f9fc87051ea..0f07a1444d1d 100644 --- a/tests/actions/PolicyRulesTest.ts +++ b/tests/actions/PolicyRulesTest.ts @@ -39,7 +39,7 @@ function getPolicy(policyID: string): Promise { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, callback: (policy) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(policy); }, }); diff --git a/tests/actions/PolicyTagTest.ts b/tests/actions/PolicyTagTest.ts index 8e4eee936769..9d327a77ef14 100644 --- a/tests/actions/PolicyTagTest.ts +++ b/tests/actions/PolicyTagTest.ts @@ -74,7 +74,7 @@ describe('actions/Policy', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, callback: (policy) => { - Onyx.disconnect(connection); + connection.unsubscribe(); // RequiresTag is enabled and pending expect(policy?.requiresTag).toBeTruthy(); @@ -93,7 +93,7 @@ describe('actions/Policy', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, callback: (policy) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(policy?.pendingFields?.requiresTag).toBeFalsy(); resolve(); }, @@ -120,7 +120,7 @@ describe('actions/Policy', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, callback: (policy) => { - Onyx.disconnect(connection); + connection.unsubscribe(); // RequiresTag is disabled and pending expect(policy?.requiresTag).toBeFalsy(); @@ -139,7 +139,7 @@ describe('actions/Policy', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, callback: (policy) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(policy?.pendingFields?.requiresTag).toBeFalsy(); resolve(); }, @@ -170,7 +170,7 @@ describe('actions/Policy', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, callback: (policy) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(policy?.pendingFields?.requiresTag).toBeFalsy(); expect(policy?.errors).toBeTruthy(); expect(policy?.requiresTag).toBeTruthy(); @@ -223,7 +223,7 @@ describe('actions/Policy', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, callback: (policy) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(policy?.showTagGLCodes).toBeTruthy(); expect(policy?.pendingFields?.showTagGLCodes).toBe(CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE); @@ -241,7 +241,7 @@ describe('actions/Policy', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, callback: (policy) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(policy?.pendingFields?.showTagGLCodes).toBeFalsy(); resolve(); }, @@ -270,7 +270,7 @@ describe('actions/Policy', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, callback: (policy) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(policy?.pendingFields?.showTagGLCodes).toBeFalsy(); expect(policy?.errorFields?.showTagGLCodes).toBeTruthy(); expect(policy?.showTagGLCodes).toBeTruthy(); diff --git a/tests/actions/PolicyTaxTest.ts b/tests/actions/PolicyTaxTest.ts index 737fe3a2be21..bf8c9f58a1e3 100644 --- a/tests/actions/PolicyTaxTest.ts +++ b/tests/actions/PolicyTaxTest.ts @@ -66,7 +66,7 @@ describe('actions/PolicyTax', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, callback: (policy) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(policy?.taxRates?.name).toBe(customTaxName); expect(policy?.taxRates?.pendingFields?.name).toBe(CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE); expect(policy?.taxRates?.errorFields).toBeFalsy(); @@ -83,7 +83,7 @@ describe('actions/PolicyTax', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, callback: (policy) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(policy?.taxRates?.pendingFields?.name).toBeFalsy(); expect(policy?.taxRates?.errorFields).toBeFalsy(); resolve(); @@ -105,7 +105,7 @@ describe('actions/PolicyTax', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, callback: (policy) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(policy?.taxRates?.name).toBe(customTaxName); expect(policy?.taxRates?.pendingFields?.name).toBe(CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE); expect(policy?.taxRates?.errorFields).toBeFalsy(); @@ -125,7 +125,7 @@ describe('actions/PolicyTax', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, callback: (policy) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(policy?.taxRates?.name).toBe(originalCustomTaxName); expect(policy?.taxRates?.pendingFields?.name).toBeFalsy(); expect(policy?.taxRates?.errorFields?.name).toBeTruthy(); @@ -150,7 +150,7 @@ describe('actions/PolicyTax', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, callback: (policy) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(policy?.taxRates?.defaultExternalID).toBe(taxCode); expect(policy?.taxRates?.pendingFields?.defaultExternalID).toBe(CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE); expect(policy?.taxRates?.errorFields).toBeFalsy(); @@ -167,7 +167,7 @@ describe('actions/PolicyTax', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, callback: (policy) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(policy?.taxRates?.pendingFields?.defaultExternalID).toBeFalsy(); expect(policy?.taxRates?.errorFields).toBeFalsy(); resolve(); @@ -189,7 +189,7 @@ describe('actions/PolicyTax', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, callback: (policy) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(policy?.taxRates?.defaultExternalID).toBe(taxCode); expect(policy?.taxRates?.pendingFields?.defaultExternalID).toBe(CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE); expect(policy?.taxRates?.errorFields).toBeFalsy(); @@ -209,7 +209,7 @@ describe('actions/PolicyTax', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, callback: (policy) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(policy?.taxRates?.defaultExternalID).toBe(originalDefaultExternalID); expect(policy?.taxRates?.pendingFields?.defaultExternalID).toBeFalsy(); expect(policy?.taxRates?.errorFields?.defaultExternalID).toBeTruthy(); @@ -233,7 +233,7 @@ describe('actions/PolicyTax', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, callback: (policy) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(policy?.taxRates?.foreignTaxDefault).toBe(taxCode); expect(policy?.taxRates?.pendingFields?.foreignTaxDefault).toBe(CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE); expect(policy?.taxRates?.errorFields).toBeFalsy(); @@ -250,7 +250,7 @@ describe('actions/PolicyTax', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, callback: (policy) => { - Onyx.disconnect(connection); + connection.unsubscribe(); // Check if the policy pendingFields was cleared expect(policy?.taxRates?.pendingFields?.foreignTaxDefault).toBeFalsy(); expect(policy?.taxRates?.errorFields).toBeFalsy(); @@ -273,7 +273,7 @@ describe('actions/PolicyTax', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, callback: (policy) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(policy?.taxRates?.foreignTaxDefault).toBe(taxCode); expect(policy?.taxRates?.pendingFields?.foreignTaxDefault).toBe(CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE); expect(policy?.taxRates?.errorFields).toBeFalsy(); @@ -294,7 +294,7 @@ describe('actions/PolicyTax', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, callback: (policy) => { - Onyx.disconnect(connection); + connection.unsubscribe(); // Check if the policy pendingFields was cleared expect(policy?.taxRates?.foreignTaxDefault).toBe(originalDefaultForeignCurrencyID); expect(policy?.taxRates?.pendingFields?.foreignTaxDefault).toBeFalsy(); @@ -323,7 +323,7 @@ describe('actions/PolicyTax', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, callback: (policy) => { - Onyx.disconnect(connection); + connection.unsubscribe(); const createdTax = policy?.taxRates?.taxes?.[newTaxRate.code ?? '']; expect(createdTax?.code).toBe(newTaxRate.code); expect(createdTax?.name).toBe(newTaxRate.name); @@ -342,7 +342,7 @@ describe('actions/PolicyTax', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, callback: (policy) => { - Onyx.disconnect(connection); + connection.unsubscribe(); const createdTax = policy?.taxRates?.taxes?.[newTaxRate.code ?? '']; expect(createdTax?.errors).toBeFalsy(); expect(createdTax?.pendingFields).toBeFalsy(); @@ -369,7 +369,7 @@ describe('actions/PolicyTax', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, callback: (policy) => { - Onyx.disconnect(connection); + connection.unsubscribe(); const createdTax = policy?.taxRates?.taxes?.[newTaxRate.code ?? '']; expect(createdTax?.code).toBe(newTaxRate.code); expect(createdTax?.name).toBe(newTaxRate.name); @@ -391,7 +391,7 @@ describe('actions/PolicyTax', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, callback: (policy) => { - Onyx.disconnect(connection); + connection.unsubscribe(); const createdTax = policy?.taxRates?.taxes?.[newTaxRate.code ?? '']; expect(createdTax?.errors).toBeTruthy(); resolve(); @@ -413,7 +413,7 @@ describe('actions/PolicyTax', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, callback: (policy) => { - Onyx.disconnect(connection); + connection.unsubscribe(); const disabledTax = policy?.taxRates?.taxes?.[disableTaxID]; expect(disabledTax?.isDisabled).toBeTruthy(); expect(disabledTax?.pendingFields?.isDisabled).toBe(CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE); @@ -432,7 +432,7 @@ describe('actions/PolicyTax', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, callback: (policy) => { - Onyx.disconnect(connection); + connection.unsubscribe(); const disabledTax = policy?.taxRates?.taxes?.[disableTaxID]; expect(disabledTax?.errorFields?.isDisabled).toBeFalsy(); expect(disabledTax?.pendingFields?.isDisabled).toBeFalsy(); @@ -455,7 +455,7 @@ describe('actions/PolicyTax', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, callback: (policy) => { - Onyx.disconnect(connection); + connection.unsubscribe(); const disabledTax = policy?.taxRates?.taxes?.[disableTaxID]; expect(disabledTax?.isDisabled).toBeTruthy(); expect(disabledTax?.pendingFields?.isDisabled).toBe(CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE); @@ -477,7 +477,7 @@ describe('actions/PolicyTax', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, callback: (policy) => { - Onyx.disconnect(connection); + connection.unsubscribe(); const disabledTax = policy?.taxRates?.taxes?.[disableTaxID]; expect(disabledTax?.isDisabled).toBe(!!originalTaxes[disableTaxID].isDisabled); expect(disabledTax?.errorFields?.isDisabled).toBeTruthy(); @@ -504,7 +504,7 @@ describe('actions/PolicyTax', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, callback: (policy) => { - Onyx.disconnect(connection); + connection.unsubscribe(); const updatedTax = policy?.taxRates?.taxes?.[taxID]; expect(updatedTax?.name).toBe(newTaxName); expect(updatedTax?.pendingFields?.name).toBe(CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE); @@ -523,7 +523,7 @@ describe('actions/PolicyTax', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, callback: (policy) => { - Onyx.disconnect(connection); + connection.unsubscribe(); const updatedTax = policy?.taxRates?.taxes?.[taxID]; expect(updatedTax?.errorFields?.name).toBeFalsy(); expect(updatedTax?.pendingFields?.name).toBeFalsy(); @@ -548,7 +548,7 @@ describe('actions/PolicyTax', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, callback: (policy) => { - Onyx.disconnect(connection); + connection.unsubscribe(); const updatedTax = policy?.taxRates?.taxes?.[taxID]; expect(updatedTax?.name).toBe(newTaxName); expect(updatedTax?.pendingFields?.name).toBe(CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE); @@ -570,7 +570,7 @@ describe('actions/PolicyTax', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, callback: (policy) => { - Onyx.disconnect(connection); + connection.unsubscribe(); const updatedTax = policy?.taxRates?.taxes?.[taxID]; expect(updatedTax?.name).toBe(originalTaxRate.name); expect(updatedTax?.errorFields?.name).toBeTruthy(); @@ -597,7 +597,7 @@ describe('actions/PolicyTax', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, callback: (policy) => { - Onyx.disconnect(connection); + connection.unsubscribe(); const updatedTax = policy?.taxRates?.taxes?.[taxID]; expect(updatedTax?.value).toBe(stringTaxValue); expect(updatedTax?.pendingFields?.value).toBe(CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE); @@ -616,7 +616,7 @@ describe('actions/PolicyTax', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, callback: (policy) => { - Onyx.disconnect(connection); + connection.unsubscribe(); const updatedTax = policy?.taxRates?.taxes?.[taxID]; expect(updatedTax?.errorFields?.value).toBeFalsy(); expect(updatedTax?.pendingFields?.value).toBeFalsy(); @@ -642,7 +642,7 @@ describe('actions/PolicyTax', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, callback: (policy) => { - Onyx.disconnect(connection); + connection.unsubscribe(); const updatedTax = policy?.taxRates?.taxes?.[taxID]; expect(updatedTax?.value).toBe(stringTaxValue); expect(updatedTax?.pendingFields?.value).toBe(CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE); @@ -664,7 +664,7 @@ describe('actions/PolicyTax', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, callback: (policy) => { - Onyx.disconnect(connection); + connection.unsubscribe(); const updatedTax = policy?.taxRates?.taxes?.[taxID]; expect(updatedTax?.value).toBe(originalTaxRate.value); expect(updatedTax?.errorFields?.value).toBeTruthy(); @@ -690,7 +690,7 @@ describe('actions/PolicyTax', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, callback: (policy) => { - Onyx.disconnect(connection); + connection.unsubscribe(); const taxRates = policy?.taxRates; const deletedTax = taxRates?.taxes?.[taxID]; expect(taxRates?.pendingFields?.foreignTaxDefault).toBeFalsy(); @@ -710,7 +710,7 @@ describe('actions/PolicyTax', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, callback: (policy) => { - Onyx.disconnect(connection); + connection.unsubscribe(); const taxRates = policy?.taxRates; const deletedTax = taxRates?.taxes?.[taxID]; expect(taxRates?.pendingFields?.foreignTaxDefault).toBeFalsy(); @@ -742,7 +742,7 @@ describe('actions/PolicyTax', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicyWithForeignTaxDefault.id}`, callback: (policy) => { - Onyx.disconnect(connection); + connection.unsubscribe(); const taxRates = policy?.taxRates; const deletedTax = taxRates?.taxes?.[taxID]; expect(taxRates?.pendingFields?.foreignTaxDefault).toBe(CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE); @@ -762,7 +762,7 @@ describe('actions/PolicyTax', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicyWithForeignTaxDefault.id}`, callback: (policy) => { - Onyx.disconnect(connection); + connection.unsubscribe(); const taxRates = policy?.taxRates; const deletedTax = taxRates?.taxes?.[taxID]; expect(taxRates?.pendingFields?.foreignTaxDefault).toBeFalsy(); @@ -787,7 +787,7 @@ describe('actions/PolicyTax', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, callback: (policy) => { - Onyx.disconnect(connection); + connection.unsubscribe(); const taxRates = policy?.taxRates; const deletedTax = taxRates?.taxes?.[taxID]; expect(taxRates?.pendingFields?.foreignTaxDefault).toBeFalsy(); @@ -810,7 +810,7 @@ describe('actions/PolicyTax', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, callback: (policy) => { - Onyx.disconnect(connection); + connection.unsubscribe(); const taxRates = policy?.taxRates; const deletedTax = taxRates?.taxes?.[taxID]; expect(taxRates?.pendingFields?.foreignTaxDefault).toBeFalsy(); @@ -852,7 +852,7 @@ describe('actions/PolicyTax', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, callback: (policy) => { - Onyx.disconnect(connection); + connection.unsubscribe(); const taxRates = policy?.taxRates; const updatedTaxRate = taxRates?.taxes?.[newTaxCode]; diff --git a/tests/actions/PolicyTest.ts b/tests/actions/PolicyTest.ts index 242ed1cc80be..216a59112811 100644 --- a/tests/actions/PolicyTest.ts +++ b/tests/actions/PolicyTest.ts @@ -198,7 +198,7 @@ describe('actions/Policy', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, callback: (workspace) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(workspace); }, }); @@ -208,7 +208,7 @@ describe('actions/Policy', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.NVP_ACTIVE_POLICY_ID}`, callback: (id) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(id); }, }); @@ -243,7 +243,7 @@ describe('actions/Policy', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, callback: (reports) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(reports); }, }); @@ -276,7 +276,7 @@ describe('actions/Policy', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT_ACTIONS, callback: (actions) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(actions); }, }); @@ -333,7 +333,7 @@ describe('actions/Policy', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.POLICY, callback: (workspace) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(workspace); }, }); @@ -346,7 +346,7 @@ describe('actions/Policy', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, callback: (reports) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(reports); }, }); @@ -362,7 +362,7 @@ describe('actions/Policy', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT_ACTIONS, callback: (actions) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(actions); }, }); @@ -431,7 +431,7 @@ describe('actions/Policy', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, callback: (workspace) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(workspace); }, }); @@ -462,7 +462,7 @@ describe('actions/Policy', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, callback: (reports) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(reports); }, }); @@ -495,7 +495,7 @@ describe('actions/Policy', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT_ACTIONS, callback: (actions) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(actions); }, }); @@ -538,7 +538,7 @@ describe('actions/Policy', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.POLICY, callback: (workspace) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(workspace); }, }); @@ -551,7 +551,7 @@ describe('actions/Policy', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, callback: (reports) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(reports); }, }); @@ -567,7 +567,7 @@ describe('actions/Policy', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT_ACTIONS, callback: (actions) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(actions); }, }); @@ -621,7 +621,7 @@ describe('actions/Policy', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, callback: (workspace) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(workspace); }, }); @@ -693,7 +693,7 @@ describe('actions/Policy', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, callback: (workspace) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(workspace); }, }); @@ -778,7 +778,7 @@ describe('actions/Policy', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, callback: (reports) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(reports); }, }); @@ -831,7 +831,7 @@ describe('actions/Policy', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, callback: (workspace) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(workspace); }, }); @@ -880,7 +880,7 @@ describe('actions/Policy', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, callback: (reports) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(reports); }, }); @@ -893,7 +893,7 @@ describe('actions/Policy', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT_ACTIONS, callback: (actions) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(actions); }, }); @@ -965,7 +965,7 @@ describe('actions/Policy', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, callback: (workspace) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(workspace); }, }); @@ -1033,7 +1033,7 @@ describe('actions/Policy', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, callback: (workspace) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(workspace); }, }); @@ -1069,7 +1069,7 @@ describe('actions/Policy', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, callback: (workspace) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(workspace); }, }); @@ -3077,7 +3077,7 @@ describe('actions/Policy', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, callback: (workspace) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(workspace); }, }); @@ -3105,7 +3105,7 @@ describe('actions/Policy', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, callback: (workspace) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(workspace); }, }); @@ -3132,7 +3132,7 @@ describe('actions/Policy', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, callback: (workspace) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(workspace); }, }); @@ -3160,7 +3160,7 @@ describe('actions/Policy', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, callback: (workspace) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(workspace); }, }); @@ -3381,7 +3381,7 @@ describe('actions/Policy', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, callback: (workspace) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(workspace); }, }); @@ -3399,7 +3399,7 @@ describe('actions/Policy', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, callback: (workspace) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(workspace); }, }); @@ -3499,7 +3499,7 @@ describe('actions/Policy', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, callback: (workspace) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(workspace); }, }); @@ -3516,7 +3516,7 @@ describe('actions/Policy', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, callback: (workspace) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(workspace); }, }); @@ -3780,7 +3780,7 @@ describe('actions/Policy', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, callback: (workspace) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(workspace); }, }); @@ -3941,7 +3941,7 @@ describe('actions/Policy', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, callback: (workspace) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(workspace); }, }); @@ -4083,7 +4083,7 @@ describe('actions/Policy', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, callback: (workspace) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(workspace); }, }); @@ -4101,7 +4101,7 @@ describe('actions/Policy', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, callback: (workspace) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(workspace); }, }); @@ -4139,7 +4139,7 @@ describe('actions/Policy', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, callback: (workspace) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(workspace); }, }); @@ -4157,7 +4157,7 @@ describe('actions/Policy', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, callback: (workspace) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(workspace); }, }); @@ -4192,7 +4192,7 @@ describe('actions/Policy', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, callback: (workspace) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(workspace); }, }); @@ -4210,7 +4210,7 @@ describe('actions/Policy', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, callback: (workspace) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(workspace); }, }); @@ -4249,7 +4249,7 @@ describe('actions/Policy', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, callback: (workspace) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(workspace); }, }); @@ -4306,7 +4306,7 @@ describe('actions/Policy', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, callback: (policy) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(policy?.pendingAction).toBeUndefined(); expect(policy?.avatarURL).toBe(fakePolicy.avatarURL); resolve(); @@ -4319,7 +4319,7 @@ describe('actions/Policy', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${fakeReport.reportID}`, callback: (report) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(report?.stateNum).toBe(fakeReport.stateNum); expect(report?.statusNum).toBe(fakeReport.statusNum); expect(report?.policyName).toBe(fakeReport.policyName); @@ -4334,7 +4334,7 @@ describe('actions/Policy', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${fakeReport.reportID}`, callback: (reportNameValuePairs) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(reportNameValuePairs?.private_isArchived).toBeUndefined(); resolve(); }, @@ -4346,7 +4346,7 @@ describe('actions/Policy', () => { const connection = Onyx.connect({ key: ONYXKEYS.REIMBURSEMENT_ACCOUNT, callback: (reimbursementAccount) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(reimbursementAccount?.errors).not.toBeUndefined(); resolve(); }, @@ -4466,7 +4466,7 @@ describe('actions/Policy', () => { const connection = Onyx.connect({ key: ONYXKEYS.NVP_ACTIVE_POLICY_ID, callback: (policyID) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(policyID); }, }); @@ -4599,7 +4599,7 @@ describe('actions/Policy', () => { const connection = Onyx.connect({ key: ONYXKEYS.LAST_ACCESSED_WORKSPACE_POLICY_ID, callback: (policyID) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(policyID); }, }); @@ -4642,7 +4642,7 @@ describe('actions/Policy', () => { const connection = Onyx.connect({ key: ONYXKEYS.LAST_ACCESSED_WORKSPACE_POLICY_ID, callback: (policyID) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(policyID); }, }); @@ -4932,7 +4932,7 @@ describe('actions/Policy', () => { key: `${ONYXKEYS.COLLECTION.POLICY_JOIN_MEMBER}${policyID}`, callback: (val) => { resolve(val); - Onyx.disconnect(connection); + connection.unsubscribe(); }, }); }); @@ -4970,7 +4970,7 @@ describe('actions/Policy', () => { key: `${ONYXKEYS.COLLECTION.POLICY_JOIN_MEMBER}${policyID}`, callback: (val) => { resolve(val); - Onyx.disconnect(connection); + connection.unsubscribe(); }, }); }); @@ -4999,7 +4999,7 @@ describe('actions/Policy', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, callback: (policy) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(policy?.maxExpenseAmountNoItemizedReceipt).toBe(expectedBackendAmount); expect(policy?.pendingFields?.maxExpenseAmountNoItemizedReceipt).toBe(CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE); resolve(); @@ -5015,7 +5015,7 @@ describe('actions/Policy', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, callback: (policy) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(policy?.pendingFields?.maxExpenseAmountNoItemizedReceipt).toBeFalsy(); expect(policy?.errorFields?.maxExpenseAmountNoItemizedReceipt).toBeFalsy(); resolve(); @@ -5038,7 +5038,7 @@ describe('actions/Policy', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, callback: (policy) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(policy?.maxExpenseAmountNoItemizedReceipt).toBe(CONST.DISABLED_MAX_EXPENSE_VALUE); expect(policy?.pendingFields?.maxExpenseAmountNoItemizedReceipt).toBe(CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE); resolve(); @@ -7906,7 +7906,7 @@ describe('actions/Policy', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transaction.transactionID}`, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value); }, }); @@ -7921,7 +7921,7 @@ describe('actions/Policy', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${iouReport.reportID}`, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value); }, }); diff --git a/tests/actions/PolicyTravelSettingsTest.ts b/tests/actions/PolicyTravelSettingsTest.ts index f9c157f575bc..071237eedba8 100644 --- a/tests/actions/PolicyTravelSettingsTest.ts +++ b/tests/actions/PolicyTravelSettingsTest.ts @@ -17,7 +17,7 @@ function getPolicy(policyID: string): Promise { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value); }, }); diff --git a/tests/actions/QueuedOnyxUpdatesTest.ts b/tests/actions/QueuedOnyxUpdatesTest.ts index de9118eedd96..c46e64b09268 100644 --- a/tests/actions/QueuedOnyxUpdatesTest.ts +++ b/tests/actions/QueuedOnyxUpdatesTest.ts @@ -78,7 +78,7 @@ async function testOnyxKeyValue(key: OnyxKey): Promise { const connection = Onyx.connect({ key, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(value).toEqual(expectedValue); resolve(); @@ -119,7 +119,7 @@ describe('actions/QueuedOnyxUpdates', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}2175919089355165`, callback: (report) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(report).toBeUndefined(); resolve(); @@ -131,7 +131,7 @@ describe('actions/QueuedOnyxUpdates', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}2175919089355165`, callback: (report) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(report).toBeUndefined(); resolve(); @@ -162,7 +162,7 @@ describe('actions/QueuedOnyxUpdates', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}2175919089355165`, callback: (report) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(report).toEqual(getOnyxUpdateValue(`${ONYXKEYS.COLLECTION.REPORT}2175919089355165`)); resolve(); @@ -174,7 +174,7 @@ describe('actions/QueuedOnyxUpdates', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}2175919089355165`, callback: (reportActions) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(reportActions).toEqual(getOnyxUpdateValue(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}2175919089355165`)); resolve(); diff --git a/tests/actions/ReimbursementAccountTest.ts b/tests/actions/ReimbursementAccountTest.ts index 68c3fcd0a49d..10928093696b 100644 --- a/tests/actions/ReimbursementAccountTest.ts +++ b/tests/actions/ReimbursementAccountTest.ts @@ -67,7 +67,7 @@ describe('ReimbursementAccount', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, callback: (policy) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expectDisconnectedAchAccount(policy?.achAccount, TEST_EMAIL); resolve(); }, @@ -97,7 +97,7 @@ describe('ReimbursementAccount', () => { const connection = Onyx.connect({ key: ONYXKEYS.BANK_ACCOUNT_LIST, callback: (bankAccountList) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(bankAccountList?.[bankAccountID]?.pendingAction).toBe(CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE); resolve(); }, @@ -125,7 +125,7 @@ describe('ReimbursementAccount', () => { const connection = Onyx.connect({ key: ONYXKEYS.BANK_ACCOUNT_LIST, callback: (bankAccountList) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(bankAccountList?.[bankAccountID]).toBeUndefined(); resolve(); }, @@ -159,7 +159,7 @@ describe('ReimbursementAccount', () => { const connection = Onyx.connect({ key: ONYXKEYS.BANK_ACCOUNT_LIST, callback: (bankAccountList) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(bankAccountList?.[bankAccountID]?.pendingAction).toBe(CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE); resolve(); }, @@ -186,7 +186,7 @@ describe('ReimbursementAccount', () => { const connection = Onyx.connect({ key: ONYXKEYS.BANK_ACCOUNT_LIST, callback: (bankAccountList) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(bankAccountList?.[bankAccountID]).toBeUndefined(); resolve(); }, @@ -212,7 +212,7 @@ describe('ReimbursementAccount', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, callback: (policy) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expectDisconnectedAchAccount(policy?.achAccount, TEST_EMAIL); resolve(); }, @@ -237,14 +237,14 @@ describe('ReimbursementAccount', () => { const reimbursementConnection = Onyx.connect({ key: ONYXKEYS.REIMBURSEMENT_ACCOUNT, callback: (reimbursementAccount) => { - Onyx.disconnect(reimbursementConnection); + reimbursementConnection.unsubscribe(); expect(reimbursementAccount).toEqual(CONST.REIMBURSEMENT_ACCOUNT.DEFAULT_DATA); }, }); const policyConnection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, callback: (policy) => { - Onyx.disconnect(policyConnection); + policyConnection.unsubscribe(); expectDisconnectedAchAccount(policy?.achAccount, TEST_EMAIL); resolve(); }, @@ -271,7 +271,7 @@ describe('ReimbursementAccount', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, callback: (policy) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expectDisconnectedAchAccount(policy?.achAccount, designatedPayer); resolve(); }, @@ -289,7 +289,7 @@ describe('ReimbursementAccount', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, callback: (policy) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expectDisconnectedAchAccount(policy?.achAccount, policyOwner); resolve(); }, diff --git a/tests/actions/ReportFieldTest.ts b/tests/actions/ReportFieldTest.ts index 1e8639df010c..64f583dcbb84 100644 --- a/tests/actions/ReportFieldTest.ts +++ b/tests/actions/ReportFieldTest.ts @@ -35,7 +35,7 @@ describe('actions/ReportField', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, callback: (workspace) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(workspace); }, }); diff --git a/tests/actions/ReportTest.ts b/tests/actions/ReportTest.ts index 511af4c91517..545c8176fa01 100644 --- a/tests/actions/ReportTest.ts +++ b/tests/actions/ReportTest.ts @@ -464,7 +464,7 @@ describe('actions/Report', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${REPORT.reportID}`, callback: (report) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(); // The report should exist but the create chat error field should be cleared. @@ -497,7 +497,7 @@ describe('actions/Report', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${REPORT.reportID}`, callback: (report) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(); // The optimistic report should be deleted (null) since it had createChat error @@ -571,7 +571,7 @@ describe('actions/Report', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${REPORT.reportID}`, callback: (report) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(); // The report should exist but the create chat error field should be cleared. @@ -1668,7 +1668,7 @@ describe('actions/Report', () => { const connection = Onyx.connect({ key: ONYXKEYS.PERSISTED_REQUESTS, callback: (persistedRequests) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(persistedRequests?.at(0)?.command).toBe(WRITE_COMMANDS.ADD_COMMENT); expect(persistedRequests?.at(1)?.command).toBeUndefined(); @@ -1683,7 +1683,7 @@ describe('actions/Report', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${REPORT_ID}`, callback: (reportActions) => { - Onyx.disconnect(connection); + connection.unsubscribe(); const reportAction = reportActionID ? reportActions?.[reportActionID] : null; expect(reportAction).not.toBeNull(); @@ -1703,7 +1703,7 @@ describe('actions/Report', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${REPORT_ID}`, callback: (reportActions) => { - Onyx.disconnect(connection); + connection.unsubscribe(); const reportAction = reportActionID ? reportActions?.[reportActionID] : undefined; expect(reportAction).toBeUndefined(); }, @@ -1813,7 +1813,7 @@ describe('actions/Report', () => { const connection = Onyx.connect({ key: ONYXKEYS.PERSISTED_REQUESTS, callback: (persistedRequests) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(persistedRequests?.at(0)?.command).toBe(WRITE_COMMANDS.UPDATE_COMMENT); resolve(); }, @@ -1935,7 +1935,7 @@ describe('actions/Report', () => { const connection = Onyx.connect({ key: ONYXKEYS.PERSISTED_REQUESTS, callback: (persistedRequests) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(persistedRequests?.at(0)?.command).toBe(WRITE_COMMANDS.ADD_ATTACHMENT); resolve(); }, @@ -1947,7 +1947,7 @@ describe('actions/Report', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${REPORT_ID}`, callback: (reportActions) => { - Onyx.disconnect(connection); + connection.unsubscribe(); const reportAction = reportActionID ? reportActions?.[reportActionID] : null; expect(reportAction).not.toBeNull(); expect(reportAction?.reportActionID).toBe(reportActionID); @@ -1965,7 +1965,7 @@ describe('actions/Report', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${REPORT_ID}`, callback: (reportActions) => { - Onyx.disconnect(connection); + connection.unsubscribe(); const reportAction = reportActionID ? reportActions?.[reportActionID] : undefined; expect(reportAction).toBeUndefined(); }, @@ -2019,7 +2019,7 @@ describe('actions/Report', () => { const connection = Onyx.connect({ key: ONYXKEYS.PERSISTED_REQUESTS, callback: (persistedRequests) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(persistedRequests?.at(0)?.command).toBe(WRITE_COMMANDS.ADD_TEXT_AND_ATTACHMENT); resolve(); }, @@ -2031,7 +2031,7 @@ describe('actions/Report', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${REPORT_ID}`, callback: (reportActions) => { - Onyx.disconnect(connection); + connection.unsubscribe(); const reportAction = reportActionID ? reportActions?.[reportActionID] : null; expect(reportAction).not.toBeNull(); expect(reportAction?.reportActionID).toBe(reportActionID); @@ -2049,7 +2049,7 @@ describe('actions/Report', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${REPORT_ID}`, callback: (reportActions) => { - Onyx.disconnect(connection); + connection.unsubscribe(); const reportAction = reportActionID ? reportActions?.[reportActionID] : undefined; expect(reportAction).toBeUndefined(); }, @@ -2080,7 +2080,7 @@ describe('actions/Report', () => { callback: (persisted) => { const relevant = (persisted ?? []).filter((r) => r?.command === WRITE_COMMANDS.ADD_ATTACHMENT || r?.command === WRITE_COMMANDS.ADD_TEXT_AND_ATTACHMENT); if (relevant.length >= 3) { - Onyx.disconnect(conn); + conn.unsubscribe(); resolve(relevant); } }, @@ -2131,7 +2131,7 @@ describe('actions/Report', () => { callback: (persisted) => { const relevant = (persisted ?? []).filter((r) => r?.command === WRITE_COMMANDS.ADD_ATTACHMENT || r?.command === WRITE_COMMANDS.ADD_TEXT_AND_ATTACHMENT); if (relevant.length >= 2) { - Onyx.disconnect(conn); + conn.unsubscribe(); resolve(relevant); } }, @@ -2181,7 +2181,7 @@ describe('actions/Report', () => { callback: (persisted) => { const relevant = (persisted ?? []).filter((r) => r?.command === WRITE_COMMANDS.ADD_ATTACHMENT); if (relevant.length >= 1) { - Onyx.disconnect(conn); + conn.unsubscribe(); resolve(relevant); } }, @@ -2419,7 +2419,7 @@ describe('actions/Report', () => { const connection = Onyx.connect({ key: ONYXKEYS.PERSISTED_REQUESTS, callback: (persistedRequests) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(persistedRequests?.at(0)?.command).toBe(WRITE_COMMANDS.ADD_COMMENT); expect(persistedRequests?.at(1)?.command).toBe(WRITE_COMMANDS.ADD_EMOJI_REACTION); expect(persistedRequests?.at(2)?.command).toBe(WRITE_COMMANDS.REMOVE_EMOJI_REACTION); @@ -2433,7 +2433,7 @@ describe('actions/Report', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${REPORT_ID}`, callback: (reportActions) => { - Onyx.disconnect(connection); + connection.unsubscribe(); const reportAction = reportActionID ? reportActions?.[reportActionID] : null; expect(reportAction).not.toBeNull(); expect(reportAction?.reportActionID).toBe(reportActionID); @@ -2451,7 +2451,7 @@ describe('actions/Report', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${REPORT_ID}`, callback: (reportActions) => { - Onyx.disconnect(connection); + connection.unsubscribe(); const reportAction = reportActionID ? reportActions?.[reportActionID] : undefined; expect(reportAction).toBeUndefined(); }, @@ -2536,7 +2536,7 @@ describe('actions/Report', () => { const connection = Onyx.connect({ key: ONYXKEYS.PERSISTED_REQUESTS, callback: (persistedRequests) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(persistedRequests?.at(0)?.command).toBe(WRITE_COMMANDS.ADD_EMOJI_REACTION); expect(persistedRequests?.at(1)?.command).toBe(WRITE_COMMANDS.REMOVE_EMOJI_REACTION); resolve(); @@ -2767,7 +2767,7 @@ describe('actions/Report', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${REPORT_ID}`, callback: (reportActions) => { - Onyx.disconnect(connection); + connection.unsubscribe(); const reportAction = reportActionID ? reportActions?.[reportActionID] : null; const message = reportAction?.message; @@ -3010,7 +3010,7 @@ describe('actions/Report', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${parentReport?.reportID}`, callback: (reportActions) => { - Onyx.disconnect(connection); + connection.unsubscribe(); const action = Object.values(reportActions ?? {}).at(0); if (!isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW)) { throw new Error('Expected the optimistic report preview action'); @@ -3028,7 +3028,7 @@ describe('actions/Report', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, callback: (reports) => { - Onyx.disconnect(connection); + connection.unsubscribe(); const createdReport = reports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`]; const parentPolicyExpenseChat = reports?.[`${ONYXKEYS.COLLECTION.REPORT}${parentReport?.reportID}`]; // assert correctness of crucial onyx data @@ -3052,7 +3052,7 @@ describe('actions/Report', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, callback: (reports) => { - Onyx.disconnect(connection); + connection.unsubscribe(); const parentPolicyExpenseChat = reports?.[`${ONYXKEYS.COLLECTION.REPORT}${parentReport?.reportID}`]; expect(parentPolicyExpenseChat?.hasOutstandingChildRequest).toBe(parentReport?.hasOutstandingChildRequest); @@ -3101,7 +3101,7 @@ describe('actions/Report', () => { if (!loadingState?.hasOnceLoadedReportActions) { return; } - Onyx.disconnect(connection); + connection.unsubscribe(); expect(loadingState.hasOnceLoadedReportActions).toBe(true); resolve(); }, @@ -3135,7 +3135,7 @@ describe('actions/Report', () => { const connection = Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, callback: (reports) => { - Onyx.disconnect(connection); + connection.unsubscribe(); const parentPolicyExpenseChat = reports?.[`${ONYXKEYS.COLLECTION.REPORT}${parentReport?.reportID}`]; expect(parentPolicyExpenseChat?.hasOutstandingChildRequest).toBe(parentReport?.hasOutstandingChildRequest); @@ -3170,7 +3170,7 @@ describe('actions/Report', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${optimisticReportData.reportID}`, callback: (report) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(report?.stateNum).toBe(CONST.REPORT.STATE_NUM.OPEN); expect(report?.statusNum).toBe(CONST.REPORT.STATUS_NUM.OPEN); @@ -3212,7 +3212,7 @@ describe('actions/Report', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.SNAPSHOT}${currentHash}`, callback: (snapshot) => { - Onyx.disconnect(connection); + connection.unsubscribe(); expect(snapshot?.data?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${parentReport?.reportID}`]).toBeTruthy(); expect(snapshot?.data?.[`${ONYXKEYS.COLLECTION.REPORT}${parentReport?.reportID}`]).toBeTruthy(); expect(snapshot?.data?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`]).toBeTruthy(); @@ -3256,7 +3256,7 @@ describe('actions/Report', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${adminsChatReportID}`, callback: (id) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(id); }, }); @@ -3731,7 +3731,7 @@ describe('actions/Report', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${report.reportID}`, callback: (reportVal) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(ReportUtils.isUnread(reportVal, undefined, undefined, undefined)); }, }); @@ -3932,7 +3932,7 @@ describe('actions/Report', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${selfDMReportID}`, callback: (val) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(val); }, }); @@ -4043,7 +4043,7 @@ describe('actions/Report', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${chatReport.reportID}`, callback: (val) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(val); }, }); @@ -4116,7 +4116,7 @@ describe('actions/Report', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${chatReport.reportID}`, callback: (val) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(val); }, }); @@ -4212,7 +4212,7 @@ describe('actions/Report', () => { key: `${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${expenseReport.reportID}`, callback: (val) => { resolve(!!val?.private_isArchived); - Onyx.disconnect(connection); + connection.unsubscribe(); }, }); }); @@ -4223,7 +4223,7 @@ describe('actions/Report', () => { key: `${ONYXKEYS.COLLECTION.SNAPSHOT}${currentHash}`, callback: (val) => { resolve(val); - Onyx.disconnect(connection); + connection.unsubscribe(); }, }); }); @@ -4275,7 +4275,7 @@ describe('actions/Report', () => { const connection = Onyx.connectWithoutView({ key: `${ONYXKEYS.COLLECTION.REPORT}${expenseReport.reportID}`, callback: (report) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(report); }, }); @@ -4348,7 +4348,7 @@ describe('actions/Report', () => { const connection = Onyx.connectWithoutView({ key: `${ONYXKEYS.COLLECTION.REPORT}${expenseReport.reportID}`, callback: (report) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(report); }, }); @@ -4364,7 +4364,7 @@ describe('actions/Report', () => { const connection = Onyx.connectWithoutView({ key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transaction.transactionID}`, callback: (txn) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(txn); }, }); @@ -4449,7 +4449,7 @@ describe('actions/Report', () => { const connection = Onyx.connectWithoutView({ key: `${ONYXKEYS.COLLECTION.REPORT}${expenseReport.reportID}`, callback: (report) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(report); }, }); @@ -4537,7 +4537,7 @@ describe('actions/Report', () => { const connection = Onyx.connectWithoutView({ key: `${ONYXKEYS.COLLECTION.REPORT}${expenseReport.reportID}`, callback: (report) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(report); }, }); @@ -4598,7 +4598,7 @@ describe('actions/Report', () => { key: `${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${expenseReport.reportID}`, callback: (val) => { resolve(!!val?.private_isArchived); - Onyx.disconnect(connection); + connection.unsubscribe(); }, }); }); @@ -4971,7 +4971,7 @@ describe('actions/Report', () => { key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReport.reportID}`, callback: (val) => { resolve(val); - Onyx.disconnect(connection); + connection.unsubscribe(); }, }); }); @@ -5302,7 +5302,7 @@ describe('actions/Report', () => { key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReport.reportID}`, callback: (val) => { resolve(val); - Onyx.disconnect(connection); + connection.unsubscribe(); }, }); }); @@ -5371,7 +5371,7 @@ describe('actions/Report', () => { key: `${ONYXKEYS.COLLECTION.POLICY}${policy.id}`, callback: (val) => { resolve(val); - Onyx.disconnect(connection); + connection.unsubscribe(); }, }); }); @@ -5427,7 +5427,7 @@ describe('actions/Report', () => { key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, callback: (val) => { resolve(val); - Onyx.disconnect(connection); + connection.unsubscribe(); }, }); }); @@ -5475,7 +5475,7 @@ describe('actions/Report', () => { key: `${ONYXKEYS.COLLECTION.REPORT}${iouReport.reportID}`, callback: (val) => { resolve(val); - Onyx.disconnect(connection); + connection.unsubscribe(); }, }); }); diff --git a/tests/actions/TravelTest.ts b/tests/actions/TravelTest.ts index d1dbb7a7396c..84754e184734 100644 --- a/tests/actions/TravelTest.ts +++ b/tests/actions/TravelTest.ts @@ -75,7 +75,7 @@ describe('actions/Travel', () => { const connection = Onyx.connect({ key: ONYXKEYS.TRAVEL_PROVISIONING, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value); }, }); diff --git a/tests/actions/UserTest.ts b/tests/actions/UserTest.ts index 79190046810d..7ece993f3681 100644 --- a/tests/actions/UserTest.ts +++ b/tests/actions/UserTest.ts @@ -49,7 +49,7 @@ describe('actions/User', () => { const connection = Onyx.connect({ key: ONYXKEYS.LOGINS, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value ?? null); }, }); @@ -81,7 +81,7 @@ describe('actions/User', () => { const connection = Onyx.connect({ key: ONYXKEYS.LOGINS, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value ?? null); }, }); @@ -125,7 +125,7 @@ describe('actions/User', () => { const connection = Onyx.connect({ key: ONYXKEYS.LOGINS, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value ?? null); }, }); @@ -164,7 +164,7 @@ describe('actions/User', () => { const connection = Onyx.connect({ key: ONYXKEYS.LOGINS, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value ?? null); }, }); @@ -327,7 +327,7 @@ describe('actions/User', () => { const connection = Onyx.connect({ key: ONYXKEYS.PENDING_CONTACT_ACTION, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value ?? null); }, }); @@ -695,7 +695,7 @@ describe('actions/User', () => { const connection = Onyx.connect({ key: ONYXKEYS.LOGINS, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value ?? null); }, }); @@ -713,7 +713,7 @@ describe('actions/User', () => { const connection = Onyx.connect({ key: ONYXKEYS.ACCOUNT, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value ?? null); }, }); @@ -726,7 +726,7 @@ describe('actions/User', () => { const connection = Onyx.connect({ key: ONYXKEYS.PENDING_CONTACT_ACTION, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value ?? null); }, }); diff --git a/tests/actions/VacationDelegateTest.ts b/tests/actions/VacationDelegateTest.ts index 9fb4c261e0c7..e4a7a6ac373d 100644 --- a/tests/actions/VacationDelegateTest.ts +++ b/tests/actions/VacationDelegateTest.ts @@ -143,7 +143,7 @@ describe('actions/VacationDelegate', () => { // When a delegate is picked await setVacationDelegate({creator: 'admin@test.com', delegate: 'delegate@test.com', currentDelegate: 'old@test.com'}); await waitForBatchedUpdates(); - Onyx.disconnect(connection); + connection.unsubscribe(); // Then the policyDiff is stored, pendingDelegate points at the pick, and the saved delegate is left unchanged const vacationDelegate = await getOnyxValue(ONYXKEYS.NVP_PRIVATE_VACATION_DELEGATE); diff --git a/tests/actions/WorkflowTest.ts b/tests/actions/WorkflowTest.ts index bed7f571639d..50f1cb15fe36 100644 --- a/tests/actions/WorkflowTest.ts +++ b/tests/actions/WorkflowTest.ts @@ -138,7 +138,7 @@ describe('actions/Workflow', () => { if (!workflow) { return; } - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(workflow); }, }); diff --git a/tests/ui/AddDomainPageTest.tsx b/tests/ui/AddDomainPageTest.tsx index a89c515da9e3..6442865cb84b 100644 --- a/tests/ui/AddDomainPageTest.tsx +++ b/tests/ui/AddDomainPageTest.tsx @@ -107,7 +107,7 @@ function getCreateDomainForm() { const connection = Onyx.connect({ key: ONYXKEYS.FORMS.CREATE_DOMAIN_FORM, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value); }, }); @@ -119,7 +119,7 @@ function getExistingDomain() { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.DOMAIN}${EXISTING_DOMAIN_ACCOUNT_ID}`, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value); }, }); diff --git a/tests/ui/ClearReportActionErrorsUITest.tsx b/tests/ui/ClearReportActionErrorsUITest.tsx index 3dc02221f470..3105c0837e61 100644 --- a/tests/ui/ClearReportActionErrorsUITest.tsx +++ b/tests/ui/ClearReportActionErrorsUITest.tsx @@ -46,7 +46,7 @@ function getReportActionsFromOnyx(reportID: string): Promise { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value ?? undefined); }, }); diff --git a/tests/ui/DistanceRequestStartPageTest.tsx b/tests/ui/DistanceRequestStartPageTest.tsx index 5067fc7285ac..1f069741aeee 100644 --- a/tests/ui/DistanceRequestStartPageTest.tsx +++ b/tests/ui/DistanceRequestStartPageTest.tsx @@ -144,7 +144,7 @@ function getDraftTransaction() { key: `${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${CONST.IOU.OPTIMISTIC_TRANSACTION_ID}`, callback: (value) => { resolve(value); - Onyx.disconnect(connection); + connection.unsubscribe(); }, }); }); diff --git a/tests/ui/EnableTravelContentTest.tsx b/tests/ui/EnableTravelContentTest.tsx index ec27564ced9b..42d793f0cd3b 100644 --- a/tests/ui/EnableTravelContentTest.tsx +++ b/tests/ui/EnableTravelContentTest.tsx @@ -97,7 +97,7 @@ function getTravelProvisioning(): Promise { const connection = Onyx.connect({ key: ONYXKEYS.TRAVEL_PROVISIONING, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value); }, }); diff --git a/tests/ui/IOURequestRedirectToStartPageTest.tsx b/tests/ui/IOURequestRedirectToStartPageTest.tsx index 567e288811a0..e0df44162b37 100644 --- a/tests/ui/IOURequestRedirectToStartPageTest.tsx +++ b/tests/ui/IOURequestRedirectToStartPageTest.tsx @@ -75,7 +75,7 @@ function getOptimisticDraft() { key: `${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${CONST.IOU.OPTIMISTIC_TRANSACTION_ID}`, callback: (value) => { resolve(value); - Onyx.disconnect(connection); + connection.unsubscribe(); }, }); }); diff --git a/tests/ui/IOURequestStartPageTest.tsx b/tests/ui/IOURequestStartPageTest.tsx index 1f6dc514090f..c821d9e56eb6 100644 --- a/tests/ui/IOURequestStartPageTest.tsx +++ b/tests/ui/IOURequestStartPageTest.tsx @@ -88,7 +88,7 @@ describe('IOURequestStartPage', () => { key: `${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${CONST.IOU.OPTIMISTIC_TRANSACTION_ID}`, callback: (val) => { resolve(val?.iouRequestType); - Onyx.disconnect(connection); + connection.unsubscribe(); }, }); }); diff --git a/tests/ui/IOURequestStepScanTest.tsx b/tests/ui/IOURequestStepScanTest.tsx index 0a6676cde985..d598ac6a5f14 100644 --- a/tests/ui/IOURequestStepScanTest.tsx +++ b/tests/ui/IOURequestStepScanTest.tsx @@ -85,7 +85,7 @@ function getTransactionsDraftOnyx(transactionID: string): Promise { resolve(val); - Onyx.disconnect(connection); + connection.unsubscribe(); }, }); }); diff --git a/tests/ui/MoneyRequestReportTransactionsNavigationTest.tsx b/tests/ui/MoneyRequestReportTransactionsNavigationTest.tsx index 5bb5c274d029..f2aff95df36e 100644 --- a/tests/ui/MoneyRequestReportTransactionsNavigationTest.tsx +++ b/tests/ui/MoneyRequestReportTransactionsNavigationTest.tsx @@ -320,7 +320,7 @@ async function getCarouselTransactionIDs(): Promise { const connection = Onyx.connectWithoutView({ key: ONYXKEYS.TRANSACTION_THREAD_NAVIGATION_TRANSACTION_IDS, callback: (ids) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(ids); }, }); diff --git a/tests/ui/RecentlyAddedSectionTest.tsx b/tests/ui/RecentlyAddedSectionTest.tsx index ea6681445723..ccb7394ecf15 100644 --- a/tests/ui/RecentlyAddedSectionTest.tsx +++ b/tests/ui/RecentlyAddedSectionTest.tsx @@ -407,7 +407,7 @@ describe('RecentlyAddedSection', () => { const connection = Onyx.connect({ key: ONYXKEYS.TRANSACTION_THREAD_NAVIGATION_TRANSACTION_IDS, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value); }, }); @@ -416,7 +416,7 @@ describe('RecentlyAddedSection', () => { const connection = Onyx.connect({ key: ONYXKEYS.TRANSACTION_THREAD_NAVIGATION_THREAD_REPORT_IDS, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value); }, }); @@ -448,7 +448,7 @@ describe('RecentlyAddedSection', () => { const connection = Onyx.connect({ key: ONYXKEYS.TRANSACTION_THREAD_NAVIGATION_TRANSACTION_IDS, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value); }, }); @@ -457,7 +457,7 @@ describe('RecentlyAddedSection', () => { const connection = Onyx.connect({ key: ONYXKEYS.TRANSACTION_THREAD_NAVIGATION_THREAD_REPORT_IDS, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value); }, }); diff --git a/tests/ui/SessionTest.tsx b/tests/ui/SessionTest.tsx index e8fab6024baa..2edff1abdd25 100644 --- a/tests/ui/SessionTest.tsx +++ b/tests/ui/SessionTest.tsx @@ -145,7 +145,7 @@ describe('Deep linking', () => { afterEach(async () => { if (lastVisitedPathConnectionID) { - Onyx.disconnect(lastVisitedPathConnectionID); + lastVisitedPathConnectionID.unsubscribe(); lastVisitedPathConnectionID = undefined; } cleanup(); @@ -425,7 +425,7 @@ describe('signInWithShortLivedAuthToken', () => { }, }); await waitForBatchedUpdates(); - Onyx.disconnect(connectionID); + connectionID.unsubscribe(); // Guard is already set even though getDeviceInfoWithID (and thus the redeem's optimisticData) has NOT resolved. expect(isAuthenticating).toBe(true); diff --git a/tests/ui/ShareSubmitScanFieldsTest.tsx b/tests/ui/ShareSubmitScanFieldsTest.tsx index c21466ed1865..92fe99e35b54 100644 --- a/tests/ui/ShareSubmitScanFieldsTest.tsx +++ b/tests/ui/ShareSubmitScanFieldsTest.tsx @@ -49,7 +49,7 @@ function getDraft(): Promise> { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${CONST.IOU.OPTIMISTIC_TRANSACTION_ID}`, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value); }, }); diff --git a/tests/ui/UnreadIndicatorsTest.tsx b/tests/ui/UnreadIndicatorsTest.tsx index 0060df9c11e9..39dbbbb24a34 100644 --- a/tests/ui/UnreadIndicatorsTest.tsx +++ b/tests/ui/UnreadIndicatorsTest.tsx @@ -500,7 +500,7 @@ describe('Unread Indicators', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${REPORT_ID}`, callback: (val) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(val); }, }); @@ -638,7 +638,7 @@ describe('Unread Indicators', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${REPORT_ID}`, callback: (val) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(val); }, }); @@ -779,7 +779,7 @@ describe('Unread Indicators', () => { }), ); - Onyx.disconnect(connection); + connection.unsubscribe(); }); it('Do not display the new line indicator when receiving a new message from another user', async () => { @@ -919,7 +919,7 @@ describe('Unread Indicators', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${REPORT_ID}`, callback: (val) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(val); }, }); @@ -973,7 +973,7 @@ describe('Unread Indicators', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${REPORT_ID}`, callback: (val) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(val); }, }); diff --git a/tests/ui/WorkspaceWorkflowsApprovalsEditPageTest.tsx b/tests/ui/WorkspaceWorkflowsApprovalsEditPageTest.tsx index 38e46d731a04..886bd48af7f5 100644 --- a/tests/ui/WorkspaceWorkflowsApprovalsEditPageTest.tsx +++ b/tests/ui/WorkspaceWorkflowsApprovalsEditPageTest.tsx @@ -168,7 +168,7 @@ describe('WorkspaceWorkflowsApprovalsEditPage', () => { key: ONYXKEYS.APPROVAL_WORKFLOW, callback: (state) => { resolve(state?.members ?? []); - Onyx.disconnect(connection); + connection.unsubscribe(); }, }); }); @@ -185,7 +185,7 @@ describe('WorkspaceWorkflowsApprovalsEditPage', () => { key: ONYXKEYS.APPROVAL_WORKFLOW, callback: (state) => { resolve(state?.availableMembers ?? []); - Onyx.disconnect(connection); + connection.unsubscribe(); }, }); }); diff --git a/tests/ui/WorkspaceWorkflowsLockedBankAccountTest.tsx b/tests/ui/WorkspaceWorkflowsLockedBankAccountTest.tsx index 7e0cca73270b..6c6ebda27147 100644 --- a/tests/ui/WorkspaceWorkflowsLockedBankAccountTest.tsx +++ b/tests/ui/WorkspaceWorkflowsLockedBankAccountTest.tsx @@ -154,7 +154,7 @@ const getInitiatingBankAccountUnlock = () => const connection = Onyx.connect({ key: ONYXKEYS.INITIATING_BANK_ACCOUNT_UNLOCK, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value); }, }); diff --git a/tests/ui/WorkspaceWorkflowsSmartLimitApprovalsTest.tsx b/tests/ui/WorkspaceWorkflowsSmartLimitApprovalsTest.tsx index 3a5c4e691bc0..a5d750d8cfb2 100644 --- a/tests/ui/WorkspaceWorkflowsSmartLimitApprovalsTest.tsx +++ b/tests/ui/WorkspaceWorkflowsSmartLimitApprovalsTest.tsx @@ -89,7 +89,7 @@ const getApprovalMode = () => const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.POLICY}${POLICY_ID}`, callback: (policy) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(policy?.approvalMode); }, }); diff --git a/tests/ui/components/IOURequestStepConfirmationPageTest.tsx b/tests/ui/components/IOURequestStepConfirmationPageTest.tsx index 6b099fb91f5a..f2a6702efdc2 100644 --- a/tests/ui/components/IOURequestStepConfirmationPageTest.tsx +++ b/tests/ui/components/IOURequestStepConfirmationPageTest.tsx @@ -616,7 +616,7 @@ describe('IOURequestStepConfirmationPageTest', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${TRANSACTION_ID}`, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value); }, }); @@ -2262,7 +2262,7 @@ describe('IOURequestStepConfirmationPageTest', () => { key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, callback: (value) => { resolve(value); - Onyx.disconnect(connection); + connection.unsubscribe(); }, }); }); @@ -2282,7 +2282,7 @@ describe('IOURequestStepConfirmationPageTest', () => { key: `${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${TRANSACTION_ID}`, callback: (value) => { resolve(value); - Onyx.disconnect(connection); + connection.unsubscribe(); }, }); }); diff --git a/tests/ui/components/ProductTrainingContextProvider.tsx b/tests/ui/components/ProductTrainingContextProvider.tsx index 88389f0a9b5d..e0de6e14640a 100644 --- a/tests/ui/components/ProductTrainingContextProvider.tsx +++ b/tests/ui/components/ProductTrainingContextProvider.tsx @@ -212,7 +212,7 @@ describe('ProductTrainingContextProvider', () => { const connection = Onyx.connect({ key: ONYXKEYS.NVP_DISMISSED_PRODUCT_TRAINING, callback: (dismissedTooltips) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(dismissedTooltips); }, }); diff --git a/tests/unit/ClearReportActionErrorsTest.ts b/tests/unit/ClearReportActionErrorsTest.ts index 47e4eb45864b..e5f8072da414 100644 --- a/tests/unit/ClearReportActionErrorsTest.ts +++ b/tests/unit/ClearReportActionErrorsTest.ts @@ -21,7 +21,7 @@ function getReportActionsFromOnyx(reportID: string): Promise { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value ?? undefined); }, }); diff --git a/tests/unit/CopyPolicySettingsNavigationTest.tsx b/tests/unit/CopyPolicySettingsNavigationTest.tsx index 17b0197b9505..fe77d56c137c 100644 --- a/tests/unit/CopyPolicySettingsNavigationTest.tsx +++ b/tests/unit/CopyPolicySettingsNavigationTest.tsx @@ -110,7 +110,7 @@ async function getCopyPolicySettings(): Promise const connection = Onyx.connect({ key: ONYXKEYS.COPY_POLICY_SETTINGS, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value ?? null); }, }); diff --git a/tests/unit/DistanceRateTest.ts b/tests/unit/DistanceRateTest.ts index f25bc3200e03..84b8aa72be29 100644 --- a/tests/unit/DistanceRateTest.ts +++ b/tests/unit/DistanceRateTest.ts @@ -253,7 +253,7 @@ describe('DistanceRate', () => { // eslint-disable-next-line rulesdir/prefer-early-return callback: (value) => { if (value !== undefined) { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value); } }, @@ -407,7 +407,7 @@ describe('DistanceRate', () => { // eslint-disable-next-line rulesdir/prefer-early-return callback: (value) => { if (value !== undefined) { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value); } }, @@ -422,7 +422,7 @@ describe('DistanceRate', () => { // eslint-disable-next-line rulesdir/prefer-early-return callback: (value) => { if (value !== undefined) { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value); } }, diff --git a/tests/unit/ExpenseAddedGrowlTest.tsx b/tests/unit/ExpenseAddedGrowlTest.tsx index bb4b75348c11..665668704dcd 100644 --- a/tests/unit/ExpenseAddedGrowlTest.tsx +++ b/tests/unit/ExpenseAddedGrowlTest.tsx @@ -166,7 +166,7 @@ describe('ExpenseAddedGrowl', () => { const connection = Onyx.connect({ key: ONYXKEYS.RAM_ONLY_EXPENSE_ADDED_GROWL_TRANSACTION_IDS, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value); }, }); diff --git a/tests/unit/MiddlewareTest.ts b/tests/unit/MiddlewareTest.ts index d6a6d79da16d..272eed8f2b0d 100644 --- a/tests/unit/MiddlewareTest.ts +++ b/tests/unit/MiddlewareTest.ts @@ -387,7 +387,7 @@ describe('Middleware', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${optimisticReportID}`, callback: (report) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(report); }, }); @@ -398,7 +398,7 @@ describe('Middleware', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${preexistingReportID}`, callback: (report) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(report); }, }); @@ -410,7 +410,7 @@ describe('Middleware', () => { const connection = Onyx.connect({ key: ONYXKEYS.PERSONAL_DETAILS_LIST, callback: (data) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(data); }, }); @@ -482,7 +482,7 @@ describe('Middleware', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${optimisticReportID}`, callback: (report) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(report); }, }); @@ -494,7 +494,7 @@ describe('Middleware', () => { const connection = Onyx.connect({ key: ONYXKEYS.PERSONAL_DETAILS_LIST, callback: (data) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(data); }, }); @@ -562,7 +562,7 @@ describe('Middleware', () => { const connection = Onyx.connect({ key: ONYXKEYS.PERSONAL_DETAILS_LIST, callback: (data) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(data); }, }); @@ -631,7 +631,7 @@ describe('Middleware', () => { const connection = Onyx.connect({ key: ONYXKEYS.PERSONAL_DETAILS_LIST, callback: (data) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(data); }, }); @@ -700,7 +700,7 @@ describe('Middleware', () => { const connection = Onyx.connect({ key: ONYXKEYS.PERSONAL_DETAILS_LIST, callback: (data) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(data); }, }); @@ -756,7 +756,7 @@ describe('Middleware', () => { const connection = Onyx.connect({ key: ONYXKEYS.PERSONAL_DETAILS_LIST, callback: (data) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(data); }, }); @@ -813,7 +813,7 @@ describe('Middleware', () => { const connection = Onyx.connect({ key: ONYXKEYS.PERSONAL_DETAILS_LIST, callback: (data) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(data); }, }); diff --git a/tests/unit/Navigation/guards/MigratedUserWelcomeModalGuard.test.ts b/tests/unit/Navigation/guards/MigratedUserWelcomeModalGuard.test.ts index bb0291812b0d..170406160538 100644 --- a/tests/unit/Navigation/guards/MigratedUserWelcomeModalGuard.test.ts +++ b/tests/unit/Navigation/guards/MigratedUserWelcomeModalGuard.test.ts @@ -479,7 +479,7 @@ describe('MigratedUserWelcomeModalGuard', () => { await clearOnyxAndSeedFullReconnect([ONYXKEYS.IS_LOADING_APP, ONYXKEYS.NVP_TRY_NEW_DOT]); await waitForBatchedUpdates(); } finally { - Onyx.disconnect(loadingAppConnection); + loadingAppConnection.unsubscribe(); } // Then the guard must not navigate using the transient post-clear state. diff --git a/tests/unit/ReportActionsUtilsTest.ts b/tests/unit/ReportActionsUtilsTest.ts index 8a4633313234..a8ebdbcef504 100644 --- a/tests/unit/ReportActionsUtilsTest.ts +++ b/tests/unit/ReportActionsUtilsTest.ts @@ -1370,7 +1370,7 @@ describe('ReportActionsUtils', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.reportID}`, callback: () => { - Onyx.disconnect(connection); + connection.unsubscribe(); const res = ReportActionsUtils.getLastVisibleAction(report.reportID); expect(res).toEqual(action2); resolve(); diff --git a/tests/unit/ReportUtilsTest.ts b/tests/unit/ReportUtilsTest.ts index f9a3a44c3097..cb42aad20c7b 100644 --- a/tests/unit/ReportUtilsTest.ts +++ b/tests/unit/ReportUtilsTest.ts @@ -5901,7 +5901,7 @@ describe('ReportUtils', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${expenseReport.reportID}`, callback: (report) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(report); }, }); @@ -5910,7 +5910,7 @@ describe('ReportUtils', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${expenseReport.reportID}`, callback: (reportActions) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(reportActions?.[expenseCreatedAction.reportActionID]); }, }); @@ -5919,7 +5919,7 @@ describe('ReportUtils', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.TRANSACTION}${expenseTransaction.transactionID}`, callback: (transaction) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(transaction); }, }); @@ -6285,7 +6285,7 @@ describe('ReportUtils', () => { const connection = Onyx.connectWithoutView({ key: `${ONYXKEYS.SESSION}`, callback: () => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(); }, }); @@ -6377,7 +6377,7 @@ describe('ReportUtils', () => { const connection = Onyx.connectWithoutView({ key: `${ONYXKEYS.SESSION}`, callback: () => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(); }, }); @@ -6424,7 +6424,7 @@ describe('ReportUtils', () => { const connection = Onyx.connectWithoutView({ key: `${ONYXKEYS.SESSION}`, callback: () => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(); }, }); diff --git a/tests/unit/ReportUtilsThreadSummaryTest.ts b/tests/unit/ReportUtilsThreadSummaryTest.ts index 6b02fc91313a..0e68672463ac 100644 --- a/tests/unit/ReportUtilsThreadSummaryTest.ts +++ b/tests/unit/ReportUtilsThreadSummaryTest.ts @@ -123,7 +123,7 @@ describe('addComment thread summary attribution', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value); }, }); diff --git a/tests/unit/SearchActionsTest.ts b/tests/unit/SearchActionsTest.ts index ebebf8088601..cb78749e99f9 100644 --- a/tests/unit/SearchActionsTest.ts +++ b/tests/unit/SearchActionsTest.ts @@ -812,7 +812,7 @@ describe('getPayOption', () => { }, }); await waitForBatchedUpdates(); - Onyx.disconnect(connection); + connection.unsubscribe(); expect(storedResults).toEqual(tags); }); @@ -851,7 +851,7 @@ describe('getPayOption', () => { }, }); await waitForBatchedUpdates(); - Onyx.disconnect(connection); + connection.unsubscribe(); expect(storedResults).toEqual([...existingTags, ...nextTags]); }); diff --git a/tests/unit/SequentialQueueTest.ts b/tests/unit/SequentialQueueTest.ts index 2dd57f31344f..d1d02f44f4e3 100644 --- a/tests/unit/SequentialQueueTest.ts +++ b/tests/unit/SequentialQueueTest.ts @@ -351,7 +351,7 @@ describe('SequentialQueue', () => { return; } - Onyx.disconnect(connectionId); + connectionId.unsubscribe(); expect(ongoingRequest).toEqual(persistedRequest); expect(ongoingRequest).toEqual(getOngoingRequest()); expect(getAll().length).toBe(0); @@ -598,7 +598,7 @@ describe('SequentialQueue - reconnect coverage collapse', () => { // The in-flight cycle owns the shared flag; its finallyData clears the spinner even under the drop. expect(isLoadingReportData).toBe(false); } finally { - Onyx.disconnect(connectionID); + connectionID.unsubscribe(); } }); @@ -737,7 +737,7 @@ describe('SequentialQueue - offline read reconciliation', () => { const connectionID = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, callback: (value) => { - Onyx.disconnect(connectionID); + connectionID.unsubscribe(); resolve(value); }, }); diff --git a/tests/unit/SplitExpenseAutoAdjustmentTest.ts b/tests/unit/SplitExpenseAutoAdjustmentTest.ts index 61b69fa85be7..c143f7004d9e 100644 --- a/tests/unit/SplitExpenseAutoAdjustmentTest.ts +++ b/tests/unit/SplitExpenseAutoAdjustmentTest.ts @@ -81,7 +81,7 @@ describe('Split Expense Auto-Adjustment', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.SPLIT_TRANSACTION_DRAFT}${ORIGINAL_TRANSACTION_ID}`, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value); }, }); @@ -121,7 +121,7 @@ describe('Split Expense Auto-Adjustment', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.SPLIT_TRANSACTION_DRAFT}${ORIGINAL_TRANSACTION_ID}`, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value); }, }); @@ -157,7 +157,7 @@ describe('Split Expense Auto-Adjustment', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.SPLIT_TRANSACTION_DRAFT}${ORIGINAL_TRANSACTION_ID}`, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value); }, }); @@ -221,7 +221,7 @@ describe('Split Expense Auto-Adjustment', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.SPLIT_TRANSACTION_DRAFT}${originalTransactionID}`, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value); }, }); @@ -254,7 +254,7 @@ describe('Split Expense Auto-Adjustment', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.SPLIT_TRANSACTION_DRAFT}${ORIGINAL_TRANSACTION_ID}`, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value); }, }); @@ -298,7 +298,7 @@ describe('Split Expense Auto-Adjustment', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.SPLIT_TRANSACTION_DRAFT}${ORIGINAL_TRANSACTION_ID}`, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value); }, }); @@ -336,7 +336,7 @@ describe('Split Expense Auto-Adjustment', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.SPLIT_TRANSACTION_DRAFT}${ORIGINAL_TRANSACTION_ID}`, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value); }, }); @@ -378,7 +378,7 @@ describe('Split Expense Auto-Adjustment', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.SPLIT_TRANSACTION_DRAFT}${ORIGINAL_TRANSACTION_ID}`, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value); }, }); @@ -422,7 +422,7 @@ describe('Split Expense Auto-Adjustment', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.SPLIT_TRANSACTION_DRAFT}${ORIGINAL_TRANSACTION_ID}`, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value); }, }); @@ -458,7 +458,7 @@ describe('Split Expense Auto-Adjustment', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.SPLIT_TRANSACTION_DRAFT}${ORIGINAL_TRANSACTION_ID}`, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value); }, }); @@ -500,7 +500,7 @@ describe('Split Expense Auto-Adjustment', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.SPLIT_TRANSACTION_DRAFT}${ORIGINAL_TRANSACTION_ID}`, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value); }, }); @@ -536,7 +536,7 @@ describe('Split Expense Auto-Adjustment', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.SPLIT_TRANSACTION_DRAFT}${ORIGINAL_TRANSACTION_ID}`, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value); }, }); @@ -568,7 +568,7 @@ describe('Split Expense Auto-Adjustment', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.SPLIT_TRANSACTION_DRAFT}${ORIGINAL_TRANSACTION_ID}`, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value); }, }); @@ -603,7 +603,7 @@ describe('Split Expense Auto-Adjustment', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.SPLIT_TRANSACTION_DRAFT}${ORIGINAL_TRANSACTION_ID}`, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value); }, }); @@ -643,7 +643,7 @@ describe('Split Expense Auto-Adjustment', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.SPLIT_TRANSACTION_DRAFT}${ORIGINAL_TRANSACTION_ID}`, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value); }, }); diff --git a/tests/unit/TransactionTest.ts b/tests/unit/TransactionTest.ts index fcbeac4e6017..8533a526a6f5 100644 --- a/tests/unit/TransactionTest.ts +++ b/tests/unit/TransactionTest.ts @@ -255,7 +255,7 @@ describe('Transaction', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${FAKE_NEW_REPORT_ID}`, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value); }, }); @@ -297,7 +297,7 @@ describe('Transaction', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${FAKE_NEW_REPORT_ID}`, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value); }, }); @@ -850,7 +850,7 @@ describe('Transaction', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${expenseReport.reportID}`, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value); }, }); @@ -903,7 +903,7 @@ describe('Transaction', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${expenseReport.reportID}`, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value); }, }); @@ -963,7 +963,7 @@ describe('Transaction', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${newExpenseReport.reportID}`, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value); }, }); @@ -1023,7 +1023,7 @@ describe('Transaction', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${newExpenseReport.reportID}`, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value); }, }); @@ -1079,7 +1079,7 @@ describe('Transaction', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${oldExpenseReport.reportID}`, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value); }, }); @@ -1136,7 +1136,7 @@ describe('Transaction', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${oldExpenseReport.reportID}`, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value); }, }); @@ -1206,7 +1206,7 @@ describe('Transaction', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${oldExpenseReport.reportID}`, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value); }, }); @@ -1490,7 +1490,7 @@ describe('Transaction', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT}${expenseReport.reportID}`, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value); }, }); @@ -1711,7 +1711,7 @@ describe('Transaction', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transaction.transactionID}`, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value); }, }); diff --git a/tests/unit/TryNewDotUtilsTest.ts b/tests/unit/TryNewDotUtilsTest.ts index 28a16406c7bf..8fc299fbefd1 100644 --- a/tests/unit/TryNewDotUtilsTest.ts +++ b/tests/unit/TryNewDotUtilsTest.ts @@ -15,7 +15,7 @@ function getTryNewDot(): Promise { const connectionID = Onyx.connect({ key: ONYXKEYS.NVP_TRY_NEW_DOT, callback: (value) => { - Onyx.disconnect(connectionID); + connectionID.unsubscribe(); resolve(value ?? null); }, }); diff --git a/tests/unit/hooks/useInsightsFilters.test.ts b/tests/unit/hooks/useInsightsFilters.test.ts index 3dfd1c26d3a6..c0c9e9853155 100644 --- a/tests/unit/hooks/useInsightsFilters.test.ts +++ b/tests/unit/hooks/useInsightsFilters.test.ts @@ -31,7 +31,7 @@ async function getStoredQuery(): Promise { const connection = Onyx.connectWithoutView({ key: ONYXKEYS.SEARCH_FILTERS, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value as Record | undefined); }, }); diff --git a/tests/unit/libs/actions/TransactionThreadNavigationTest.ts b/tests/unit/libs/actions/TransactionThreadNavigationTest.ts index b0fabc4c81f3..ee7e4dbca099 100644 --- a/tests/unit/libs/actions/TransactionThreadNavigationTest.ts +++ b/tests/unit/libs/actions/TransactionThreadNavigationTest.ts @@ -47,7 +47,7 @@ describe('TransactionThreadNavigation carousel ownership', () => { const connection = Onyx.connect({ key, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value); }, }); diff --git a/tests/utils/TestHelper.ts b/tests/utils/TestHelper.ts index 675143fec395..28464c4146fe 100644 --- a/tests/utils/TestHelper.ts +++ b/tests/utils/TestHelper.ts @@ -122,7 +122,7 @@ function getOnyxData(options: ConnectOptions) { const connectionID = Onyx.connect({ ...options, callback: (...params: ConnectionCallbackParams) => { - Onyx.disconnect(connectionID); + connectionID.unsubscribe(); options.callback?.(...params); resolve(); }, From 5a35f8b8035cf9e3b88f00bc9b9db396d6570d18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A1bio=20Henriques?= Date: Mon, 19 Oct 2026 11:10:40 +0100 Subject: [PATCH 3/6] Use newest Onyx changes --- package-lock.json | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index f59bf857404f..68c61df102a7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -126,7 +126,7 @@ "react-native-nitro-fetch": "1.6.2", "react-native-nitro-modules": "0.37.1", "react-native-nitro-sqlite": "9.8.3", - "react-native-onyx": "git+https://github.com/Expensify/react-native-onyx.git#513b3efb3c8ca2bda3e147ad064f4179464c9ee2", + "react-native-onyx": "git+https://github.com/Expensify/react-native-onyx.git#64aaf01b4310f5d743462b01fd492c1bc5e62389", "react-native-pager-view": "9.0.4", "react-native-pdf": "7.0.2", "react-native-permissions": "^5.4.0", @@ -37283,9 +37283,9 @@ } }, "node_modules/react-native-onyx": { - "version": "3.0.119", - "resolved": "git+ssh://git@github.com/Expensify/react-native-onyx.git#513b3efb3c8ca2bda3e147ad064f4179464c9ee2", - "integrity": "sha512-L3cZcTNKn1ePv2Fr5fr79MpAks+oxzSZY/V/DinHD+JWttAAJc1hLAZl4OvSk3kXwmHTFAMmuonDcQZNUQbWTg==", + "version": "3.0.120", + "resolved": "git+ssh://git@github.com/Expensify/react-native-onyx.git#64aaf01b4310f5d743462b01fd492c1bc5e62389", + "integrity": "sha512-NkakqxoLkKduxF5k1eISmsifxs6K2nPf6Nh3Y1p3K6taOw3X4JvQv9ba7onMAQ20zJBvm2QjBUCOROJO7EGsbQ==", "license": "MIT", "dependencies": { "ascii-table": "0.0.9", diff --git a/package.json b/package.json index 203129a9be5b..5d214a85b444 100644 --- a/package.json +++ b/package.json @@ -203,7 +203,7 @@ "react-native-nitro-fetch": "1.6.2", "react-native-nitro-modules": "0.37.1", "react-native-nitro-sqlite": "9.8.3", - "react-native-onyx": "git+https://github.com/Expensify/react-native-onyx.git#513b3efb3c8ca2bda3e147ad064f4179464c9ee2", + "react-native-onyx": "git+https://github.com/Expensify/react-native-onyx.git#64aaf01b4310f5d743462b01fd492c1bc5e62389", "react-native-pager-view": "9.0.4", "react-native-pdf": "7.0.2", "react-native-permissions": "^5.4.0", From 534c0cf927024fc34905be68b0fdb54d77f17a4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A1bio=20Henriques?= Date: Thu, 22 Oct 2026 08:04:51 +0100 Subject: [PATCH 4/6] Replace Onyx.disconnect usages added on main --- tests/actions/IOUTest/PayMoneyRequestTest.ts | 2 +- tests/actions/TableColumnWidthsTest.ts | 2 +- tests/ui/WorkspaceMembersTest.tsx | 2 +- tests/unit/ProactiveAppReviewModalManagerTest.tsx | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/actions/IOUTest/PayMoneyRequestTest.ts b/tests/actions/IOUTest/PayMoneyRequestTest.ts index a357d6735a77..2515b925319a 100644 --- a/tests/actions/IOUTest/PayMoneyRequestTest.ts +++ b/tests/actions/IOUTest/PayMoneyRequestTest.ts @@ -962,7 +962,7 @@ describe('actions/IOU/PayMoneyRequest', () => { const connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReport.reportID}`, callback: (reportActions) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(Object.values(reportActions ?? {}).pop()); }, }); diff --git a/tests/actions/TableColumnWidthsTest.ts b/tests/actions/TableColumnWidthsTest.ts index b96b5090847f..bece3f825c1a 100644 --- a/tests/actions/TableColumnWidthsTest.ts +++ b/tests/actions/TableColumnWidthsTest.ts @@ -14,7 +14,7 @@ function getTableColumnWidths(): Promise { const connection = Onyx.connect({ key: ONYXKEYS.TABLE_COLUMN_WIDTHS, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value); }, }); diff --git a/tests/ui/WorkspaceMembersTest.tsx b/tests/ui/WorkspaceMembersTest.tsx index 0be94fe9c8c8..9f98766c4343 100644 --- a/tests/ui/WorkspaceMembersTest.tsx +++ b/tests/ui/WorkspaceMembersTest.tsx @@ -372,7 +372,7 @@ describe('WorkspaceMembers', () => { const connection = Onyx.connect({ key: ONYXKEYS.RAM_ONLY_WORKSPACE_MEMBERS_SELECTED_FOR_ROLE_CHANGE, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value); }, }); diff --git a/tests/unit/ProactiveAppReviewModalManagerTest.tsx b/tests/unit/ProactiveAppReviewModalManagerTest.tsx index 884a44a1b87b..95e3f96e6f7e 100644 --- a/tests/unit/ProactiveAppReviewModalManagerTest.tsx +++ b/tests/unit/ProactiveAppReviewModalManagerTest.tsx @@ -176,7 +176,7 @@ describe('ProactiveAppReviewModalManager', () => { const connection = Onyx.connectWithoutView({ key: ONYXKEYS.APP_REVIEW_LAST_PROMPT, callback: (value) => { - Onyx.disconnect(connection); + connection.unsubscribe(); resolve(value); }, }); From 11138138a998e996a683f7cae39c0d40444ff98c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Musia=C5=82?= Date: Mon, 26 Oct 2026 11:07:17 +0100 Subject: [PATCH 5/6] test changes for react-native-onyx/860 --- package-lock.json | 455 ++++++++++------------- package.json | 4 +- src/setup/addUtilsToWindow.ts | 15 - src/types/modules/react-native-onyx.d.ts | 1 - 4 files changed, 198 insertions(+), 277 deletions(-) diff --git a/package-lock.json b/package-lock.json index 85291ce4c2a6..fa1cc933314d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -125,8 +125,8 @@ "react-native-localize": "^3.5.4", "react-native-nitro-fetch": "1.6.2", "react-native-nitro-modules": "0.37.1", - "react-native-nitro-sqlite": "9.8.3", - "react-native-onyx": "git+https://github.com/Expensify/react-native-onyx.git#64aaf01b4310f5d743462b01fd492c1bc5e62389", + "react-native-nitro-sqlite": "10.2.0", + "react-native-onyx": "git+https://github.com/Expensify/react-native-onyx.git#b858d5dd3aea342094c947a43b50eda2dc5774e5", "react-native-pager-view": "9.0.4", "react-native-pdf": "7.0.2", "react-native-permissions": "^5.4.0", @@ -10218,6 +10218,7 @@ }, "node_modules/@isaacs/cliui": { "version": "8.0.2", + "dev": true, "license": "ISC", "dependencies": { "string-width": "^5.1.2", @@ -10233,6 +10234,7 @@ }, "node_modules/@isaacs/cliui/node_modules/ansi-regex": { "version": "6.0.1", + "dev": true, "license": "MIT", "engines": { "node": ">=12" @@ -10243,6 +10245,7 @@ }, "node_modules/@isaacs/cliui/node_modules/ansi-styles": { "version": "6.2.1", + "dev": true, "license": "MIT", "engines": { "node": ">=12" @@ -10253,10 +10256,12 @@ }, "node_modules/@isaacs/cliui/node_modules/emoji-regex": { "version": "9.2.2", + "dev": true, "license": "MIT" }, "node_modules/@isaacs/cliui/node_modules/string-width": { "version": "5.1.2", + "dev": true, "license": "MIT", "dependencies": { "eastasianwidth": "^0.2.0", @@ -10272,6 +10277,7 @@ }, "node_modules/@isaacs/cliui/node_modules/strip-ansi": { "version": "7.1.0", + "dev": true, "license": "MIT", "dependencies": { "ansi-regex": "^6.0.1" @@ -10285,6 +10291,7 @@ }, "node_modules/@isaacs/cliui/node_modules/wrap-ansi": { "version": "8.1.0", + "dev": true, "license": "MIT", "dependencies": { "ansi-styles": "^6.1.0", @@ -13916,6 +13923,7 @@ }, "node_modules/@pkgjs/parseargs": { "version": "0.11.0", + "dev": true, "license": "MIT", "optional": true, "engines": { @@ -21265,9 +21273,9 @@ } }, "node_modules/ansis": { - "version": "3.17.0", - "resolved": "https://registry.npmjs.org/ansis/-/ansis-3.17.0.tgz", - "integrity": "sha512-0qWUglt9JEqLFr3w1I1pbrChn1grhaiAR2ocX1PP/flRmxgtwTzPFFFnfIlD6aMOLQZgSuCRlidD70lvx8yhzg==", + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/ansis/-/ansis-4.4.0.tgz", + "integrity": "sha512-9k3v7xcHwgdO/DruxGIg4HtjvlAZlcnsX/mzqUb1t3NkYnl9kK2UJ+Gq0io+vQf7iT//BD/HB/NBkUR1LWxoeA==", "license": "ISC", "engines": { "node": ">=14" @@ -21298,15 +21306,6 @@ ], "license": "MIT" }, - "node_modules/app-root-path": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/app-root-path/-/app-root-path-3.1.0.tgz", - "integrity": "sha512-biN3PwB2gUtjaYy/isrU3aNWI5w+fAfvHkSvCKeQGxhmYpwKFUxudR3Yya+KqVRHBmEDYh+/lTozYCFbmzX4nA==", - "license": "MIT", - "engines": { - "node": ">= 6.0.0" - } - }, "node_modules/appdirsjs": { "version": "1.2.7", "devOptional": true, @@ -22222,6 +22221,7 @@ }, "node_modules/balanced-match": { "version": "1.0.2", + "devOptional": true, "license": "MIT" }, "node_modules/base-64": { @@ -24516,7 +24516,9 @@ } }, "node_modules/dayjs": { - "version": "1.11.13", + "version": "1.11.23", + "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.23.tgz", + "integrity": "sha512-QDTCU0M0MxR3hQfnlDJfwekQiaanm1ubOD231u73WBckQ/fsamwRLiE2GBz6D3a/xF1NgfiDLJjXBa1hYOYTtQ==", "license": "MIT" }, "node_modules/debug": { @@ -24904,6 +24906,7 @@ }, "node_modules/eastasianwidth": { "version": "0.2.0", + "dev": true, "license": "MIT" }, "node_modules/ecdsa-sig-formatter": { @@ -27914,6 +27917,7 @@ "version": "3.3.1", "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.3.1.tgz", "integrity": "sha512-gIXjKqtFuWEgzFRJA9WCQeSJLZDjgJUOMCMzxtvFq/37KojM1BFGufqsCy0r4qSQmYLsZYMeyRqzIWOMup03sw==", + "dev": true, "license": "ISC", "dependencies": { "cross-spawn": "^7.0.6", @@ -27928,6 +27932,7 @@ }, "node_modules/foreground-child/node_modules/signal-exit": { "version": "4.1.0", + "dev": true, "license": "ISC", "engines": { "node": ">=14" @@ -28382,6 +28387,7 @@ "version": "10.5.0", "resolved": "https://registry.npmjs.org/glob/-/glob-10.5.0.tgz", "integrity": "sha512-DfXN8DfhJ7NH3Oe7cFmu3NCu1wKbkReJ8TorzSAFbSKrlNaQSKfIzqYqVY8zlbs2NLBbWpRiU52GX2PbaBVNkg==", + "dev": true, "license": "ISC", "dependencies": { "foreground-child": "^3.1.0", @@ -28430,6 +28436,7 @@ "version": "2.1.7", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.1.7.tgz", "integrity": "sha512-uZbew1NqdmPDTMJ8ah1y+b+9QEJrfkXFk3RcTQw3X0jW/xRUvFKsg1CfQdSYGdTbXZWExtU3J3ccxtnfw1Fi0g==", + "dev": true, "license": "MIT", "dependencies": { "balanced-match": "^1.0.0" @@ -28439,6 +28446,7 @@ "version": "9.0.9", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.9.tgz", "integrity": "sha512-OBwBN9AL4dqmETlpS2zasx+vTeWclWzkblfZk7KTA5j3jeOONz/tRCnZomUyvNg83wL5Zv9Ss6HMJXAgL8R2Yg==", + "dev": true, "license": "ISC", "dependencies": { "brace-expansion": "^2.0.2" @@ -30064,6 +30072,7 @@ }, "node_modules/jackspeak": { "version": "3.4.3", + "dev": true, "license": "BlueOak-1.0.0", "dependencies": { "@isaacs/cliui": "^8.0.2" @@ -35492,6 +35501,7 @@ }, "node_modules/package-json-from-dist": { "version": "1.0.0", + "dev": true, "license": "BlueOak-1.0.0" }, "node_modules/package-manager-detector": { @@ -35783,6 +35793,7 @@ }, "node_modules/path-scurry": { "version": "1.11.1", + "dev": true, "license": "BlueOak-1.0.0", "dependencies": { "lru-cache": "^10.2.0", @@ -35797,6 +35808,7 @@ }, "node_modules/path-scurry/node_modules/lru-cache": { "version": "10.2.0", + "dev": true, "license": "ISC", "engines": { "node": "14 || >=16.14" @@ -37141,188 +37153,29 @@ } }, "node_modules/react-native-nitro-sqlite": { - "version": "9.8.3", - "resolved": "https://registry.npmjs.org/react-native-nitro-sqlite/-/react-native-nitro-sqlite-9.8.3.tgz", - "integrity": "sha512-pw4ZNYNQiMiyJZr6bu0dg+IPTskoEngg1wZBD/H5bg1oyH1rJM4HfS5nVgU7jydibIMko1YhrHK+3m5AEndcDg==", + "version": "10.2.0", + "resolved": "https://registry.npmjs.org/react-native-nitro-sqlite/-/react-native-nitro-sqlite-10.2.0.tgz", + "integrity": "sha512-lB0yc4SzVNTZoe0ItyBJqOQ9qAc2SY3ku7PzFwP97e4NpZIOX0ec7p49sLK04MdWRmInt96Q7NU4rPfbNyg7Nw==", "license": "MIT", "dependencies": { - "typeorm": "0.3.27" + "typeorm": "1.1.1" }, "peerDependencies": { + "better-sqlite3": "^12.11.1", "react": ">=17.0.0", "react-native": ">=0.75.0", "react-native-nitro-modules": ">=0.35.0" - } - }, - "node_modules/react-native-nitro-sqlite/node_modules/buffer": { - "version": "6.0.3", - "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", - "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "license": "MIT", - "dependencies": { - "base64-js": "^1.3.1", - "ieee754": "^1.2.1" - } - }, - "node_modules/react-native-nitro-sqlite/node_modules/dedent": { - "version": "1.7.2", - "resolved": "https://registry.npmjs.org/dedent/-/dedent-1.7.2.tgz", - "integrity": "sha512-WzMx3mW98SN+zn3hgemf4OzdmyNhhhKz5Ay0pUfQiMQ3e1g+xmTJWp/pKdwKVXhdSkAEGIIzqeuWrL3mV/AXbA==", - "license": "MIT", - "peerDependencies": { - "babel-plugin-macros": "^3.1.0" }, "peerDependenciesMeta": { - "babel-plugin-macros": { - "optional": true - } - } - }, - "node_modules/react-native-nitro-sqlite/node_modules/dotenv": { - "version": "16.6.1", - "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.6.1.tgz", - "integrity": "sha512-uBq4egWHTcTt33a72vpSG0z3HnPuIl6NqYcTrKEg2azoEyl2hpW0zqlxysq2pK9HlDIHyHyakeYaYnSAwd8bow==", - "license": "BSD-2-Clause", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://dotenvx.com" - } - }, - "node_modules/react-native-nitro-sqlite/node_modules/typeorm": { - "version": "0.3.27", - "resolved": "https://registry.npmjs.org/typeorm/-/typeorm-0.3.27.tgz", - "integrity": "sha512-pNV1bn+1n8qEe8tUNsNdD8ejuPcMAg47u2lUGnbsajiNUr3p2Js1XLKQjBMH0yMRMDfdX8T+fIRejFmIwy9x4A==", - "license": "MIT", - "dependencies": { - "@sqltools/formatter": "^1.2.5", - "ansis": "^3.17.0", - "app-root-path": "^3.1.0", - "buffer": "^6.0.3", - "dayjs": "^1.11.13", - "debug": "^4.4.0", - "dedent": "^1.6.0", - "dotenv": "^16.4.7", - "glob": "^10.4.5", - "sha.js": "^2.4.12", - "sql-highlight": "^6.0.0", - "tslib": "^2.8.1", - "uuid": "^11.1.0", - "yargs": "^17.7.2" - }, - "bin": { - "typeorm": "cli.js", - "typeorm-ts-node-commonjs": "cli-ts-node-commonjs.js", - "typeorm-ts-node-esm": "cli-ts-node-esm.js" - }, - "engines": { - "node": ">=16.13.0" - }, - "funding": { - "url": "https://opencollective.com/typeorm" - }, - "peerDependencies": { - "@google-cloud/spanner": "^5.18.0 || ^6.0.0 || ^7.0.0", - "@sap/hana-client": "^2.14.22", - "better-sqlite3": "^8.0.0 || ^9.0.0 || ^10.0.0 || ^11.0.0 || ^12.0.0", - "ioredis": "^5.0.4", - "mongodb": "^5.8.0 || ^6.0.0", - "mssql": "^9.1.1 || ^10.0.1 || ^11.0.1", - "mysql2": "^2.2.5 || ^3.0.1", - "oracledb": "^6.3.0", - "pg": "^8.5.1", - "pg-native": "^3.0.0", - "pg-query-stream": "^4.0.0", - "redis": "^3.1.1 || ^4.0.0 || ^5.0.14", - "reflect-metadata": "^0.1.14 || ^0.2.0", - "sql.js": "^1.4.0", - "sqlite3": "^5.0.3", - "ts-node": "^10.7.0", - "typeorm-aurora-data-api-driver": "^2.0.0 || ^3.0.0" - }, - "peerDependenciesMeta": { - "@google-cloud/spanner": { - "optional": true - }, - "@sap/hana-client": { - "optional": true - }, "better-sqlite3": { "optional": true - }, - "ioredis": { - "optional": true - }, - "mongodb": { - "optional": true - }, - "mssql": { - "optional": true - }, - "mysql2": { - "optional": true - }, - "oracledb": { - "optional": true - }, - "pg": { - "optional": true - }, - "pg-native": { - "optional": true - }, - "pg-query-stream": { - "optional": true - }, - "redis": { - "optional": true - }, - "sql.js": { - "optional": true - }, - "sqlite3": { - "optional": true - }, - "ts-node": { - "optional": true - }, - "typeorm-aurora-data-api-driver": { - "optional": true } } }, - "node_modules/react-native-nitro-sqlite/node_modules/uuid": { - "version": "11.1.0", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-11.1.0.tgz", - "integrity": "sha512-0/A9rDy9P7cJ+8w1c9WD9V//9Wj15Ce2MPz8Ri6032usz+NfePxx5AcN3bN+r6ZL6jEo066/yNYB3tn4pQEx+A==", - "funding": [ - "https://github.com/sponsors/broofa", - "https://github.com/sponsors/ctavan" - ], - "license": "MIT", - "bin": { - "uuid": "dist/esm/bin/uuid" - } - }, "node_modules/react-native-onyx": { - "version": "3.0.120", - "resolved": "git+ssh://git@github.com/Expensify/react-native-onyx.git#64aaf01b4310f5d743462b01fd492c1bc5e62389", - "integrity": "sha512-NkakqxoLkKduxF5k1eISmsifxs6K2nPf6Nh3Y1p3K6taOw3X4JvQv9ba7onMAQ20zJBvm2QjBUCOROJO7EGsbQ==", + "version": "3.0.123", + "resolved": "git+ssh://git@github.com/Expensify/react-native-onyx.git#b858d5dd3aea342094c947a43b50eda2dc5774e5", + "integrity": "sha512-6tgy7bxqjFUQoy+y2C2OC0Yp6kQcxs8AeoqdZCpeKWzUyqMxBGKxSuFH0g+bVLoLl8fkMn2iDY6AAgcPbm0x1w==", "license": "MIT", "dependencies": { "ascii-table": "0.0.9", @@ -37344,7 +37197,7 @@ "react-native": ">=0.75.0", "react-native-device-info": "^10.3.0", "react-native-nitro-modules": ">=0.35.0", - "react-native-nitro-sqlite": "^9.6.0" + "react-native-nitro-sqlite": "^10.2.0" }, "peerDependenciesMeta": { "idb-keyval": { @@ -38167,8 +38020,7 @@ "version": "0.2.2", "resolved": "https://registry.npmjs.org/reflect-metadata/-/reflect-metadata-0.2.2.tgz", "integrity": "sha512-urBwgfrvVP/eAyXx4hluJivBKzuEbSQs9rKWCrCkbSxNv8mxPcUZKeuoF3Uy4mJl3Lwprp6yy5/39VWigZ4K6Q==", - "license": "Apache-2.0", - "peer": true + "license": "Apache-2.0" }, "node_modules/reflect.getprototypeof": { "version": "1.0.10", @@ -39082,46 +38934,6 @@ "node": ">=10" } }, - "node_modules/sha.js": { - "version": "2.4.12", - "resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.12.tgz", - "integrity": "sha512-8LzC5+bvI45BjpfXU8V5fdU2mfeKiQe1D1gIMn7XUlF3OTUrpdJpPPH4EMAnF0DsHHdSZqCdSss5qCmJKuiO3w==", - "license": "(MIT AND BSD-3-Clause)", - "dependencies": { - "inherits": "^2.0.4", - "safe-buffer": "^5.2.1", - "to-buffer": "^1.2.0" - }, - "bin": { - "sha.js": "bin.js" - }, - "engines": { - "node": ">= 0.10" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/sha.js/node_modules/safe-buffer": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", - "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "license": "MIT" - }, "node_modules/shallow-clone": { "version": "3.0.1", "dev": true, @@ -40555,6 +40367,7 @@ "node_modules/string-width-cjs": { "name": "string-width", "version": "4.2.3", + "dev": true, "license": "MIT", "dependencies": { "emoji-regex": "^8.0.0", @@ -40714,6 +40527,7 @@ "node_modules/strip-ansi-cjs": { "name": "strip-ansi", "version": "6.0.1", + "dev": true, "license": "MIT", "dependencies": { "ansi-regex": "^5.0.1" @@ -40724,6 +40538,7 @@ }, "node_modules/strip-ansi-cjs/node_modules/ansi-regex": { "version": "5.0.1", + "dev": true, "license": "MIT", "engines": { "node": ">=8" @@ -41446,40 +41261,6 @@ "version": "1.0.5", "license": "BSD-3-Clause" }, - "node_modules/to-buffer": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/to-buffer/-/to-buffer-1.2.2.tgz", - "integrity": "sha512-db0E3UJjcFhpDhAF4tLo03oli3pwl3dbnzXOUIlRKrp+ldk/VUxzpWYZENsw2SZiuBjHAk7DfB0VU7NKdpb6sw==", - "license": "MIT", - "dependencies": { - "isarray": "^2.0.5", - "safe-buffer": "^5.2.1", - "typed-array-buffer": "^1.0.3" - }, - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/to-buffer/node_modules/safe-buffer": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", - "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "license": "MIT" - }, "node_modules/to-regex-range": { "version": "5.0.1", "license": "MIT", @@ -41795,6 +41576,158 @@ "node": ">= 18" } }, + "node_modules/typeorm": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/typeorm/-/typeorm-1.1.1.tgz", + "integrity": "sha512-og9mG4Lwlvj6MfvYd8yRCzXy73gETtwgTKQ/ISLYvEOpJPy4IrjU/89HK4ZAFmRIbEg1hkIk04v8phTrxfgPmQ==", + "license": "MIT", + "dependencies": { + "@sqltools/formatter": "^1.2.5", + "ansis": "^4.3.1", + "dayjs": "^1.11.21", + "debug": "^4.4.3", + "dedent": "^1.7.2", + "reflect-metadata": "^0.2.2", + "sql-highlight": "^6.1.0", + "tinyglobby": "^0.2.17", + "tslib": "^2.8.1", + "yargs": "^18.0.0" + }, + "bin": { + "typeorm": "cli.js", + "typeorm-ts-node-commonjs": "cli-ts-node-commonjs.js", + "typeorm-ts-node-esm": "cli-ts-node-esm.js" + }, + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24.11.0" + }, + "funding": { + "url": "https://opencollective.com/typeorm" + }, + "peerDependencies": { + "@google-cloud/spanner": "^8.0.0", + "@sap/hana-client": "^2.14.22", + "better-sqlite3": "^12.0.0", + "ioredis": "^5.0.4", + "mongodb": "^7.0.0", + "mssql": "^12.0.0", + "mysql2": "^3.15.3", + "oracledb": "^6.3.0 || ^7.0.0", + "pg": "^8.5.1", + "pg-native": "^3.0.0", + "pg-query-stream": "^4.0.0", + "redis": "^5.0.0 || ^6.0.0", + "sql.js": "^1.4.0", + "ts-node": "^10.9.2", + "typeorm-aurora-data-api-driver": "^3.0.0" + }, + "peerDependenciesMeta": { + "@google-cloud/spanner": { + "optional": true + }, + "@sap/hana-client": { + "optional": true + }, + "better-sqlite3": { + "optional": true + }, + "ioredis": { + "optional": true + }, + "mongodb": { + "optional": true + }, + "mssql": { + "optional": true + }, + "mysql2": { + "optional": true + }, + "oracledb": { + "optional": true + }, + "pg": { + "optional": true + }, + "pg-native": { + "optional": true + }, + "pg-query-stream": { + "optional": true + }, + "redis": { + "optional": true + }, + "sql.js": { + "optional": true + }, + "ts-node": { + "optional": true + }, + "typeorm-aurora-data-api-driver": { + "optional": true + } + } + }, + "node_modules/typeorm/node_modules/dedent": { + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/dedent/-/dedent-1.7.2.tgz", + "integrity": "sha512-WzMx3mW98SN+zn3hgemf4OzdmyNhhhKz5Ay0pUfQiMQ3e1g+xmTJWp/pKdwKVXhdSkAEGIIzqeuWrL3mV/AXbA==", + "license": "MIT", + "peerDependencies": { + "babel-plugin-macros": "^3.1.0" + }, + "peerDependenciesMeta": { + "babel-plugin-macros": { + "optional": true + } + } + }, + "node_modules/typeorm/node_modules/fdir": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", + "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==", + "license": "MIT", + "engines": { + "node": ">=12.0.0" + }, + "peerDependencies": { + "picomatch": "^3 || ^4" + }, + "peerDependenciesMeta": { + "picomatch": { + "optional": true + } + } + }, + "node_modules/typeorm/node_modules/picomatch": { + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.7.tgz", + "integrity": "sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==", + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/typeorm/node_modules/tinyglobby": { + "version": "0.2.17", + "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.17.tgz", + "integrity": "sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==", + "license": "MIT", + "dependencies": { + "fdir": "^6.5.0", + "picomatch": "^4.0.4" + }, + "engines": { + "node": ">=12.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/SuperchupuDev" + } + }, "node_modules/typescript": { "version": "7.0.2", "resolved": "https://registry.npmjs.org/typescript/-/typescript-7.0.2.tgz", @@ -43040,6 +42973,7 @@ "node_modules/wrap-ansi-cjs": { "name": "wrap-ansi", "version": "7.0.0", + "dev": true, "license": "MIT", "dependencies": { "ansi-styles": "^4.0.0", @@ -43055,6 +42989,7 @@ }, "node_modules/wrap-ansi-cjs/node_modules/ansi-styles": { "version": "4.3.0", + "dev": true, "license": "MIT", "dependencies": { "color-convert": "^2.0.1" @@ -43068,6 +43003,7 @@ }, "node_modules/wrap-ansi-cjs/node_modules/color-convert": { "version": "2.0.1", + "dev": true, "license": "MIT", "dependencies": { "color-name": "~1.1.4" @@ -43078,6 +43014,7 @@ }, "node_modules/wrap-ansi-cjs/node_modules/color-name": { "version": "1.1.4", + "dev": true, "license": "MIT" }, "node_modules/wrap-ansi/node_modules/ansi-styles": { diff --git a/package.json b/package.json index 842967d1811e..8147e9ffe74f 100644 --- a/package.json +++ b/package.json @@ -202,8 +202,8 @@ "react-native-localize": "^3.5.4", "react-native-nitro-fetch": "1.6.2", "react-native-nitro-modules": "0.37.1", - "react-native-nitro-sqlite": "9.8.3", - "react-native-onyx": "git+https://github.com/Expensify/react-native-onyx.git#64aaf01b4310f5d743462b01fd492c1bc5e62389", + "react-native-nitro-sqlite": "10.2.0", + "react-native-onyx": "git+https://github.com/Expensify/react-native-onyx.git#b858d5dd3aea342094c947a43b50eda2dc5774e5", "react-native-pager-view": "9.0.4", "react-native-pdf": "7.0.2", "react-native-permissions": "^5.4.0", diff --git a/src/setup/addUtilsToWindow.ts b/src/setup/addUtilsToWindow.ts index 10e8ff2f457b..e1147d5cd66b 100644 --- a/src/setup/addUtilsToWindow.ts +++ b/src/setup/addUtilsToWindow.ts @@ -24,24 +24,9 @@ export default function addUtilsToWindow() { } window.Onyx = Onyx as typeof Onyx & { - get: (key: CollectionKeyBase) => Promise; log: (key: CollectionKeyBase) => void; }; - // We intentionally do not offer an Onyx.get API because we believe it will lead to code patterns we don't want to use in this repo, but we can offer a workaround for the sake of debugging - window.Onyx.get = function (key: CollectionKeyBase) { - return new Promise((resolve) => { - // We have opted for `connectWithoutView` here as this is a debugging utility and does not relate to any view. - const connection = Onyx.connectWithoutView({ - key, - callback: (value) => { - connection.unsubscribe(); - resolve(value); - }, - }); - }); - }; - window.Onyx.log = function (key: CollectionKeyBase) { window.Onyx.get(key).then((value) => { /* eslint-disable-next-line no-console */ diff --git a/src/types/modules/react-native-onyx.d.ts b/src/types/modules/react-native-onyx.d.ts index 73615460afd9..c091f53bce96 100644 --- a/src/types/modules/react-native-onyx.d.ts +++ b/src/types/modules/react-native-onyx.d.ts @@ -16,7 +16,6 @@ declare global { // eslint-disable-next-line @typescript-eslint/consistent-type-definitions interface Window { Onyx: typeof Onyx & { - get: (key: CollectionKeyBase) => Promise; log: (key: CollectionKeyBase) => void; }; } From b808121cf4a03d930efece9903134c7a9e0c385e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Musia=C5=82?= Date: Tue, 27 Oct 2026 18:49:16 +0100 Subject: [PATCH 6/6] bump onyx to 3.0.133 --- package-lock.json | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index d9ba92c7a3d6..93e3798055cf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -127,7 +127,7 @@ "react-native-nitro-image": "0.15.2", "react-native-nitro-modules": "0.37.1", "react-native-nitro-sqlite": "10.2.0", - "react-native-onyx": "git+https://github.com/Expensify/react-native-onyx.git#b858d5dd3aea342094c947a43b50eda2dc5774e5", + "react-native-onyx": "3.0.133", "react-native-pager-view": "9.0.4", "react-native-pdf": "7.0.2", "react-native-permissions": "^5.4.0", @@ -37667,9 +37667,9 @@ } }, "node_modules/react-native-onyx": { - "version": "3.0.123", - "resolved": "git+ssh://git@github.com/Expensify/react-native-onyx.git#b858d5dd3aea342094c947a43b50eda2dc5774e5", - "integrity": "sha512-6tgy7bxqjFUQoy+y2C2OC0Yp6kQcxs8AeoqdZCpeKWzUyqMxBGKxSuFH0g+bVLoLl8fkMn2iDY6AAgcPbm0x1w==", + "version": "3.0.133", + "resolved": "https://registry.npmjs.org/react-native-onyx/-/react-native-onyx-3.0.133.tgz", + "integrity": "sha512-0aLcDy9hTjdXqNxXoblJb6fyYa/V11RwCfvepKJ+iK/tUYt4ST2TxkwvI10QEup1fAhgSkz8FvzkSiM/JXYS/Q==", "license": "MIT", "dependencies": { "ascii-table": "0.0.9", @@ -37678,7 +37678,7 @@ "lodash.clone": "^4.5.0", "lodash.pick": "^4.4.0", "lodash.transform": "^4.6.0", - "underscore": "^1.13.6", + "underscore": "^1.13.8", "use-sync-external-store": "^1.6.0" }, "engines": { diff --git a/package.json b/package.json index c52556f0e152..5661c0504742 100644 --- a/package.json +++ b/package.json @@ -203,7 +203,7 @@ "react-native-nitro-image": "0.15.2", "react-native-nitro-modules": "0.37.1", "react-native-nitro-sqlite": "10.2.0", - "react-native-onyx": "git+https://github.com/Expensify/react-native-onyx.git#b858d5dd3aea342094c947a43b50eda2dc5774e5", + "react-native-onyx": "3.0.133", "react-native-pager-view": "9.0.4", "react-native-pdf": "7.0.2", "react-native-permissions": "^5.4.0",