From 7ed3a1f1e2f7f7dbc08dbc6f4ff35446767a334f Mon Sep 17 00:00:00 2001 From: MichaelVerdon Date: Wed, 25 Jun 2025 10:17:49 +0100 Subject: [PATCH] chore(installations): deprecations for v8 API ahead of future major release --- packages/app/lib/common/index.js | 27 +++++---- .../__tests__/installations.test.ts | 58 ++++++++++++++++++- packages/installations/lib/modular/index.js | 8 +-- 3 files changed, 78 insertions(+), 15 deletions(-) diff --git a/packages/app/lib/common/index.js b/packages/app/lib/common/index.js index 5da3b8ed2a..d4ff6fb134 100644 --- a/packages/app/lib/common/index.js +++ b/packages/app/lib/common/index.js @@ -345,6 +345,23 @@ const mapOfDeprecationReplacements = { nanoseconds: NO_REPLACEMENT, }, }, + functions: { + default: { + useEmulator: 'connectFirestoreEmulator()', + httpsCallable: 'httpsCallable()', + httpsCallableFromUrl: 'httpsCallableFromUrl()', + }, + statics: { + HttpsErrorCode: 'HttpsErrorCode', + }, + }, + installations: { + default: { + delete: 'deleteInstallations()', + getId: 'getId()', + getToken: 'getToken()', + }, + }, messaging: { default: { isAutoInitEnabled: 'isAutoInitEnabled()', @@ -437,16 +454,6 @@ const mapOfDeprecationReplacements = { TaskState: 'TaskState', }, }, - functions: { - default: { - useEmulator: 'connectFirestoreEmulator()', - httpsCallable: 'httpsCallable()', - httpsCallableFromUrl: 'httpsCallableFromUrl()', - }, - statics: { - HttpsErrorCode: 'HttpsErrorCode', - }, - }, }; const modularDeprecationMessage = diff --git a/packages/installations/__tests__/installations.test.ts b/packages/installations/__tests__/installations.test.ts index 5e06cf3a6b..8c76b1cd84 100644 --- a/packages/installations/__tests__/installations.test.ts +++ b/packages/installations/__tests__/installations.test.ts @@ -1,4 +1,4 @@ -import { afterAll, beforeAll, describe, expect, it } from '@jest/globals'; +import { afterAll, beforeAll, describe, expect, it, beforeEach, jest } from '@jest/globals'; import { firebase, @@ -9,6 +9,14 @@ import { onIdChange, } from '../lib'; +import { + createCheckV9Deprecation, + CheckV9DeprecationFunction, +} from '../../app/lib/common/unitTestUtils'; + +// @ts-ignore test +import FirebaseModule from '../../app/lib/internal/FirebaseModule'; + describe('installations()', function () { describe('namespace', function () { beforeAll(async function () { @@ -76,4 +84,52 @@ describe('installations()', function () { }); }); }); + + describe('test `console.warn` is called for RNFB v8 API & not called for v9 API', function () { + let installationsV9Deprecation: CheckV9DeprecationFunction; + + beforeEach(function () { + installationsV9Deprecation = createCheckV9Deprecation(['installations']); + + // @ts-ignore test + jest.spyOn(FirebaseModule.prototype, 'native', 'get').mockImplementation(() => { + return new Proxy( + {}, + { + get: () => + jest.fn().mockResolvedValue({ + constants: {}, + } as never), + }, + ); + }); + }); + + it('delete', function () { + const installations = getInstallations(); + installationsV9Deprecation( + () => deleteInstallations(installations), + () => installations.delete(), + 'delete', + ); + }); + + it('getId', function () { + const installations = getInstallations(); + installationsV9Deprecation( + () => getId(installations), + () => installations.getId(), + 'getId', + ); + }); + + it('getToken', function () { + const installations = getInstallations(); + installationsV9Deprecation( + () => getToken(installations), + () => installations.getToken(), + 'getToken', + ); + }); + }); }); diff --git a/packages/installations/lib/modular/index.js b/packages/installations/lib/modular/index.js index 0bd0854cd4..ea17cffa60 100644 --- a/packages/installations/lib/modular/index.js +++ b/packages/installations/lib/modular/index.js @@ -16,7 +16,7 @@ */ import { getApp } from '@react-native-firebase/app'; - +import { MODULAR_DEPRECATION_ARG } from '@react-native-firebase/app/lib/common'; /** * @typedef {import('..').FirebaseInstallationsTypes.Module} FirebaseInstallation */ @@ -33,7 +33,7 @@ export function getInstallations(app) { * @returns {Promise} */ export function deleteInstallations(installations) { - return installations.delete(); + return installations.delete.call(installations, MODULAR_DEPRECATION_ARG); } /** @@ -41,7 +41,7 @@ export function deleteInstallations(installations) { * @returns {Promise} */ export function getId(installations) { - return installations.getId(); + return installations.getId.call(installations, MODULAR_DEPRECATION_ARG); } /** @@ -50,7 +50,7 @@ export function getId(installations) { * @returns {Promise} */ export function getToken(installations, forceRefresh) { - return installations.getToken(forceRefresh); + return installations.getToken.call(installations, forceRefresh, MODULAR_DEPRECATION_ARG); } /**