diff --git a/src/libs/actions/OnyxUpdates.ts b/src/libs/actions/OnyxUpdates.ts index d2a78eb4a2bb..a09159993ad8 100644 --- a/src/libs/actions/OnyxUpdates.ts +++ b/src/libs/actions/OnyxUpdates.ts @@ -190,5 +190,5 @@ function doesClientNeedToBeUpdated({previousUpdateID, clientLastUpdateID}: DoesC } // eslint-disable-next-line import/prefer-default-export -export {apply, doesClientNeedToBeUpdated, saveUpdateInformation}; +export {apply, doesClientNeedToBeUpdated, saveUpdateInformation, applyHTTPSOnyxUpdates as INTERNAL_DO_NOT_USE_applyHTTPSOnyxUpdates}; export type {DoesClientNeedToBeUpdatedParams as ManualOnyxUpdateCheckIds}; diff --git a/src/libs/actions/__mocks__/OnyxUpdates.ts b/src/libs/actions/__mocks__/OnyxUpdates.ts index 0c7a9df4f6ab..3e4cb10d7f9e 100644 --- a/src/libs/actions/__mocks__/OnyxUpdates.ts +++ b/src/libs/actions/__mocks__/OnyxUpdates.ts @@ -6,7 +6,7 @@ import type {OnyxUpdatesFromServer, Response} from '@src/types/onyx'; jest.mock('@libs/actions/OnyxUpdateManager/utils/applyUpdates'); const OnyxUpdatesImplementation = jest.requireActual('@libs/actions/OnyxUpdates'); -const {doesClientNeedToBeUpdated, saveUpdateInformation} = OnyxUpdatesImplementation; +const {doesClientNeedToBeUpdated, saveUpdateInformation, INTERNAL_DO_NOT_USE_applyHTTPSOnyxUpdates: applyHTTPSOnyxUpdates} = OnyxUpdatesImplementation; type OnyxUpdatesMock = typeof OnyxUpdatesImport & { apply: jest.Mock, [OnyxUpdatesFromServer]>; @@ -18,9 +18,13 @@ Onyx.connect({ callback: (val) => (lastUpdateIDAppliedToClient = val), }); -const apply = jest.fn(({lastUpdateID}: OnyxUpdatesFromServer): Promise | undefined => { +const apply = jest.fn(({lastUpdateID, request, response}: OnyxUpdatesFromServer): Promise | undefined => { if (lastUpdateID && (lastUpdateIDAppliedToClient === undefined || Number(lastUpdateID) > lastUpdateIDAppliedToClient)) { - Onyx.set(ONYXKEYS.ONYX_UPDATES_LAST_UPDATE_ID_APPLIED_TO_CLIENT, Number(lastUpdateID)); + Onyx.merge(ONYXKEYS.ONYX_UPDATES_LAST_UPDATE_ID_APPLIED_TO_CLIENT, Number(lastUpdateID)); + } + + if (request && response) { + return applyHTTPSOnyxUpdates(request, response).then(() => undefined); } return Promise.resolve(); diff --git a/tests/actions/OnyxUpdateManagerTest.ts b/tests/actions/OnyxUpdateManagerTest.ts index 3039d1999a79..7366c13fa8b3 100644 --- a/tests/actions/OnyxUpdateManagerTest.ts +++ b/tests/actions/OnyxUpdateManagerTest.ts @@ -17,10 +17,11 @@ import ONYXKEYS from '@src/ONYXKEYS'; import type * as OnyxTypes from '@src/types/onyx'; import OnyxUpdateMockUtils from '../utils/OnyxUpdateMockUtils'; -jest.mock('@libs/actions/App'); -jest.mock('@libs/actions/OnyxUpdateManager/utils'); -jest.mock('@libs/actions/OnyxUpdateManager/utils/applyUpdates', () => { - const ApplyUpdatesImplementation = jest.requireActual('@libs/actions/OnyxUpdateManager/utils/applyUpdates'); +jest.mock('@userActions/OnyxUpdates'); +jest.mock('@userActions/App'); +jest.mock('@userActions/OnyxUpdateManager/utils'); +jest.mock('@userActions/OnyxUpdateManager/utils/applyUpdates', () => { + const ApplyUpdatesImplementation = jest.requireActual('@userActions/OnyxUpdateManager/utils/applyUpdates'); return { applyUpdates: jest.fn((updates: DeferredUpdatesDictionary) => ApplyUpdatesImplementation.applyUpdates(updates)),