Skip to content

Commit 65f18fb

Browse files
MichaelVerdonmikehardy
authored andcommitted
chore(remote-config): deprecations for next major release
1 parent eb1d1b6 commit 65f18fb

File tree

4 files changed

+242
-22
lines changed

4 files changed

+242
-22
lines changed

packages/app/lib/common/index.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,28 @@ const mapOfDeprecationReplacements = {
337337
nanoseconds: NO_REPLACEMENT,
338338
},
339339
},
340+
remoteConfig: {
341+
default: {
342+
activate: 'activate()',
343+
ensureInitialized: 'ensureInitialized()',
344+
fetchAndActivate: 'fetchAndActivate()',
345+
getAll: 'getAll()',
346+
getBoolean: 'getBoolean()',
347+
getNumber: 'getNumber()',
348+
getString: 'getString()',
349+
getValue: 'getValue()',
350+
reset: 'reset()',
351+
setConfigSettings: 'setConfigSettings()',
352+
fetch: 'fetch()',
353+
setDefaults: 'setDefaults()',
354+
setDefaultsFromResource: 'setDefaultsFromResource()',
355+
onConfigUpdated: 'onConfigUpdated()',
356+
},
357+
statics: {
358+
LastFetchStatus: 'LastFetchStatus',
359+
ValueSource: 'ValueSource',
360+
},
361+
},
340362
storage: {
341363
default: {
342364
useEmulator: 'connectStorageEmulator()',
@@ -503,6 +525,9 @@ export function createDeprecationProxy(instance) {
503525
) {
504526
deprecationConsoleWarning('firestore', prop, 'statics', false);
505527
}
528+
if (prop === 'LastFetchStatus' || prop === 'ValueSource') {
529+
deprecationConsoleWarning('remoteConfig', prop, 'statics', false);
530+
}
506531
if (prop === 'CustomProvider') {
507532
deprecationConsoleWarning('appCheck', prop, 'statics', false);
508533
}

packages/remote-config/__tests__/remote-config.test.ts

Lines changed: 186 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*
1616
*/
17-
import { afterAll, beforeAll, describe, expect, it } from '@jest/globals';
17+
import { afterAll, beforeAll, describe, expect, it, beforeEach, jest } from '@jest/globals';
1818

1919
import {
2020
firebase,
@@ -44,6 +44,14 @@ import {
4444
ValueSource,
4545
} from '../lib';
4646

47+
import {
48+
createCheckV9Deprecation,
49+
CheckV9DeprecationFunction,
50+
} from '../../app/lib/common/unitTestUtils';
51+
52+
// @ts-ignore test
53+
import FirebaseModule from '../../app/lib/internal/FirebaseModule';
54+
4755
describe('remoteConfig()', function () {
4856
describe('namespace', function () {
4957
beforeAll(async function () {
@@ -246,5 +254,182 @@ describe('remoteConfig()', function () {
246254
expect(ValueSource.REMOTE).toBeDefined();
247255
expect(ValueSource.STATIC).toBeDefined();
248256
});
257+
258+
describe('test `console.warn` is called for RNFB v8 API & not called for v9 API', function () {
259+
let remoteConfigV9Deprecation: CheckV9DeprecationFunction;
260+
let staticsV9Deprecation: CheckV9DeprecationFunction;
261+
262+
beforeEach(function () {
263+
remoteConfigV9Deprecation = createCheckV9Deprecation(['remoteConfig']);
264+
265+
staticsV9Deprecation = createCheckV9Deprecation(['remoteConfig', 'statics']);
266+
267+
// @ts-ignore test
268+
jest.spyOn(FirebaseModule.prototype, 'native', 'get').mockImplementation(() => {
269+
return new Proxy(
270+
{},
271+
{
272+
get: () =>
273+
jest.fn().mockResolvedValue({
274+
result: true,
275+
constants: {
276+
lastFetchTime: Date.now(),
277+
lastFetchStatus: 'success',
278+
fetchTimeout: 60,
279+
minimumFetchInterval: 12,
280+
values: {},
281+
},
282+
} as never),
283+
},
284+
);
285+
});
286+
});
287+
288+
describe('remoteConfig functions', function () {
289+
it('activate()', function () {
290+
const remoteConfig = getRemoteConfig();
291+
remoteConfigV9Deprecation(
292+
() => activate(remoteConfig),
293+
() => remoteConfig.activate(),
294+
'activate',
295+
);
296+
});
297+
298+
it('ensureInitialized()', function () {
299+
const remoteConfig = getRemoteConfig();
300+
remoteConfigV9Deprecation(
301+
() => ensureInitialized(remoteConfig),
302+
() => remoteConfig.ensureInitialized(),
303+
'ensureInitialized',
304+
);
305+
});
306+
307+
it('fetchAndActivate()', function () {
308+
const remoteConfig = getRemoteConfig();
309+
remoteConfigV9Deprecation(
310+
() => fetchAndActivate(remoteConfig),
311+
() => remoteConfig.fetchAndActivate(),
312+
'fetchAndActivate',
313+
);
314+
});
315+
316+
it('getAll()', function () {
317+
const remoteConfig = getRemoteConfig();
318+
remoteConfigV9Deprecation(
319+
() => getAll(remoteConfig),
320+
() => remoteConfig.getAll(),
321+
'getAll',
322+
);
323+
});
324+
325+
it('getBoolean()', function () {
326+
const remoteConfig = getRemoteConfig();
327+
remoteConfigV9Deprecation(
328+
() => getBoolean(remoteConfig, 'foo'),
329+
() => remoteConfig.getBoolean('foo'),
330+
'getBoolean',
331+
);
332+
});
333+
334+
it('getNumber()', function () {
335+
const remoteConfig = getRemoteConfig();
336+
remoteConfigV9Deprecation(
337+
() => getNumber(remoteConfig, 'foo'),
338+
() => remoteConfig.getNumber('foo'),
339+
'getNumber',
340+
);
341+
});
342+
343+
it('getString()', function () {
344+
const remoteConfig = getRemoteConfig();
345+
remoteConfigV9Deprecation(
346+
() => getString(remoteConfig, 'foo'),
347+
() => remoteConfig.getString('foo'),
348+
'getString',
349+
);
350+
});
351+
352+
it('getValue()', function () {
353+
const remoteConfig = getRemoteConfig();
354+
remoteConfigV9Deprecation(
355+
() => getValue(remoteConfig, 'foo'),
356+
() => remoteConfig.getValue('foo'),
357+
'getValue',
358+
);
359+
});
360+
361+
it('reset()', function () {
362+
const remoteConfig = getRemoteConfig();
363+
remoteConfigV9Deprecation(
364+
() => reset(remoteConfig),
365+
() => remoteConfig.reset(),
366+
'reset',
367+
);
368+
});
369+
370+
it('setConfigSettings()', function () {
371+
const remoteConfig = getRemoteConfig();
372+
remoteConfigV9Deprecation(
373+
() => setConfigSettings(remoteConfig, { minimumFetchIntervalMillis: 12 }),
374+
() => remoteConfig.setConfigSettings({ minimumFetchIntervalMillis: 12 }),
375+
'setConfigSettings',
376+
);
377+
});
378+
379+
it('fetch()', function () {
380+
const remoteConfig = getRemoteConfig();
381+
remoteConfigV9Deprecation(
382+
() => fetch(remoteConfig, 12),
383+
() => remoteConfig.fetch(12),
384+
'fetch',
385+
);
386+
});
387+
388+
it('setDefaults()', function () {
389+
const remoteConfig = getRemoteConfig();
390+
remoteConfigV9Deprecation(
391+
() => setDefaults(remoteConfig, { foo: 'bar' }),
392+
() => remoteConfig.setDefaults({ foo: 'bar' }),
393+
'setDefaults',
394+
);
395+
});
396+
397+
it('setDefaultsFromResource()', function () {
398+
const remoteConfig = getRemoteConfig();
399+
remoteConfigV9Deprecation(
400+
() => setDefaultsFromResource(remoteConfig, 'foo'),
401+
() => remoteConfig.setDefaultsFromResource('foo'),
402+
'setDefaultsFromResource',
403+
);
404+
});
405+
406+
it('onConfigUpdated()', function () {
407+
const remoteConfig = getRemoteConfig();
408+
remoteConfigV9Deprecation(
409+
() => onConfigUpdated(remoteConfig, () => {}),
410+
() => remoteConfig.onConfigUpdated(() => {}),
411+
'onConfigUpdated',
412+
);
413+
});
414+
});
415+
416+
describe('statics', function () {
417+
it('LastFetchStatus', function () {
418+
staticsV9Deprecation(
419+
() => LastFetchStatus.FAILURE,
420+
() => firebase.remoteConfig.LastFetchStatus.FAILURE,
421+
'LastFetchStatus',
422+
);
423+
});
424+
425+
it('ValueSource', function () {
426+
staticsV9Deprecation(
427+
() => ValueSource.DEFAULT,
428+
() => firebase.remoteConfig.ValueSource.DEFAULT,
429+
'ValueSource',
430+
);
431+
});
432+
});
433+
});
249434
});
250435
});

packages/remote-config/e2e/config.e2e.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ describe('remoteConfig()', function () {
379379

380380
describe('fetch()', function () {
381381
it('with expiration provided', async function () {
382-
const { getRemoteConfig, ensureInitialized, fetch } = remoteConfigModular;
382+
const { getRemoteConfig, ensureInitialized, fetch, LastFetchStatus } = remoteConfigModular;
383383
const date = Date.now() - 30000;
384384
const remoteConfig = getRemoteConfig();
385385
await ensureInitialized(remoteConfig);
@@ -390,7 +390,7 @@ describe('remoteConfig()', function () {
390390
}
391391

392392
await fetch(remoteConfig, 0);
393-
remoteConfig.lastFetchStatus.should.equal(firebase.remoteConfig.LastFetchStatus.SUCCESS);
393+
remoteConfig.lastFetchStatus.should.equal(LastFetchStatus.SUCCESS);
394394
should.equal(getRemoteConfig().fetchTimeMillis >= date, true);
395395
});
396396

0 commit comments

Comments
 (0)