Skip to content

Commit fcb842c

Browse files
committed
revert changes from RUT to be implemented later
1 parent b41fcde commit fcb842c

File tree

8 files changed

+147420
-16
lines changed

8 files changed

+147420
-16
lines changed

.changeset/real-dolls-type.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
---
2-
'@firebase/rules-unit-testing': minor
32
'@firebase/auth-compat': minor
43
'@firebase/firestore': minor
54
'@firebase/functions': minor
@@ -8,4 +7,5 @@
87
'firebase': minor
98
---
109

11-
Replaced node-fetch v2.6.7 dependency with the latest version of undici (v5.26.5) in Node.js SDK builds.
10+
Replaced node-fetch v2.6.7 dependency with the latest version of undici (v5.26.5) in Node.js SDK
11+
builds for auth, firestore, functions and storage.

.yarn/releases/yarn-1.22.11.cjs

+147,406
Large diffs are not rendered by default.

packages/rules-unit-testing/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@
5454
"url": "https://github.com/firebase/firebase-js-sdk/issues"
5555
},
5656
"dependencies": {
57-
"undici": "5.26.5",
5857
"node-fetch": "2.6.7",
5958
"@types/node-fetch": "2.6.4"
6059
}

packages/rules-unit-testing/src/impl/discovery.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export async function discoverEmulators(
3838

3939
const emulators: DiscoveredEmulators = {};
4040

41-
const data = (await res.json()) as any;
41+
const data = await res.json();
4242

4343
if (data.database) {
4444
emulators.database = {

packages/rules-unit-testing/src/impl/rules.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
import { HostAndPort } from '../public_types';
1919
import { makeUrl } from './url';
20-
import { fetch as undiciFetch } from 'undici';
20+
import fetch from 'node-fetch';
2121

2222
/**
2323
* @private
@@ -29,7 +29,7 @@ export async function loadDatabaseRules(
2929
): Promise<void> {
3030
const url = makeUrl(hostAndPort, '/.settings/rules.json');
3131
url.searchParams.append('ns', databaseName);
32-
const resp = await undiciFetch(url, {
32+
const resp = await fetch(url, {
3333
method: 'PUT',
3434
headers: { Authorization: 'Bearer owner' },
3535
body: rules
@@ -48,7 +48,7 @@ export async function loadFirestoreRules(
4848
projectId: string,
4949
rules: string
5050
): Promise<void> {
51-
const resp = await undiciFetch(
51+
const resp = await fetch(
5252
makeUrl(hostAndPort, `/emulator/v1/projects/${projectId}:securityRules`),
5353
{
5454
method: 'PUT',
@@ -72,7 +72,7 @@ export async function loadStorageRules(
7272
hostAndPort: HostAndPort,
7373
rules: string
7474
): Promise<void> {
75-
const resp = await undiciFetch(makeUrl(hostAndPort, '/internal/setRules'), {
75+
const resp = await fetch(makeUrl(hostAndPort, '/internal/setRules'), {
7676
method: 'PUT',
7777
headers: {
7878
'Content-Type': 'application/json'

packages/rules-unit-testing/src/impl/test_environment.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* limitations under the License.
1616
*/
1717

18-
import { fetch as undiciFetch } from 'undici';
18+
import fetch from 'node-fetch';
1919
import firebase from 'firebase/compat/app';
2020
import 'firebase/compat/firestore';
2121
import 'firebase/compat/database';
@@ -106,7 +106,7 @@ export class RulesTestEnvironmentImpl implements RulesTestEnvironment {
106106
this.checkNotDestroyed();
107107
assertEmulatorRunning(this.emulators, 'firestore');
108108

109-
const resp = await undiciFetch(
109+
const resp = await fetch(
110110
makeUrl(
111111
this.emulators.firestore,
112112
`/emulator/v1/projects/${this.projectId}/databases/(default)/documents`

packages/rules-unit-testing/src/util.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import {
2121
} from './impl/discovery';
2222
import { fixHostname, makeUrl } from './impl/url';
2323
import { HostAndPort } from './public_types';
24-
import { fetch as undiciFetch } from 'undici';
24+
import fetch from 'node-fetch';
2525

2626
/**
2727
* Run a setup function with background Cloud Functions triggers disabled. This can be used to
@@ -79,13 +79,12 @@ export async function withFunctionTriggersDisabled<TResult>(
7979
hub.host = fixHostname(hub.host);
8080
makeUrl(hub, '/functions/disableBackgroundTriggers');
8181
// Disable background triggers
82-
const disableRes = await undiciFetch(
82+
const disableRes = await fetch(
8383
makeUrl(hub, '/functions/disableBackgroundTriggers'),
8484
{
8585
method: 'PUT'
8686
}
8787
);
88-
8988
if (!disableRes.ok) {
9089
throw new Error(
9190
`HTTP Error ${disableRes.status} when disabling functions triggers, are you using firebase-tools 8.13.0 or higher?`
@@ -98,7 +97,7 @@ export async function withFunctionTriggersDisabled<TResult>(
9897
result = await maybeFn();
9998
} finally {
10099
// Re-enable background triggers
101-
const enableRes = await undiciFetch(
100+
const enableRes = await fetch(
102101
makeUrl(hub, '/functions/enableBackgroundTriggers'),
103102
{
104103
method: 'PUT'

packages/rules-unit-testing/test/util.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ describe('assertFails()', () => {
165165

166166
describe('withFunctionTriggersDisabled()', () => {
167167
it('disabling function triggers does not throw, returns value', async function () {
168-
const fetchSpy = sinon.spy(require('undici'), 'fetch');
168+
const fetchSpy = sinon.spy(require('node-fetch'), 'default');
169169

170170
const res = await withFunctionTriggersDisabled(() => {
171171
return Promise.resolve(1234);
@@ -176,7 +176,7 @@ describe('withFunctionTriggersDisabled()', () => {
176176
});
177177

178178
it('disabling function triggers always re-enables, event when the function throws', async function () {
179-
const fetchSpy = sinon.spy(require('undici'), 'fetch');
179+
const fetchSpy = sinon.spy(require('node-fetch'), 'default');
180180

181181
const res = withFunctionTriggersDisabled(() => {
182182
throw new Error('I throw!');

0 commit comments

Comments
 (0)