Skip to content

Commit de204ad

Browse files
Merge master into release
2 parents 47895fe + ca1b0c8 commit de204ad

35 files changed

+1017
-163
lines changed

.changeset/good-bears-obey.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@firebase/database": patch
3+
---
4+
5+
Included experimental support for Deno

.changeset/happy-eels-confess.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@firebase/auth": patch
3+
---
4+
5+
Fix proactive refresh logic in Auth when RTDB/Firestore/Storage are in use

.changeset/smart-plants-sparkle.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@firebase/firestore': patch
3+
---
4+
5+
Fix FAILED_PRECONDITION when writing to a deleted document in a transaction (#5871)
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Deploy Project Config
2+
3+
on: pull_request
4+
5+
# Detects if any project config files (rules or functions) have changed,
6+
# and deploys them to the test project used for CI if so.
7+
# Run this in its own workflow instead of as a step before each test
8+
# workflow to avoid too many deploys, possibly causing race conditions.
9+
# Since the build step of each test workflow takes a long time, this
10+
# this should finish before the tests begin running.
11+
12+
jobs:
13+
test:
14+
name: Deploy Firebase Project Rules and Functions
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout Repo
19+
uses: actions/checkout@master
20+
with:
21+
# This makes Actions fetch all Git history so run-changed script can diff properly.
22+
fetch-depth: 0
23+
- name: Set up Node (14)
24+
uses: actions/setup-node@v2
25+
with:
26+
node-version: 14.x
27+
- name: Yarn install
28+
run: yarn
29+
- name: Deploy project config if needed
30+
run: yarn ts-node scripts/ci-test/deploy-if-needed.ts
31+
env:
32+
FIREBASE_CLI_TOKEN: ${{secrets.FIREBASE_CLI_TOKEN}}

.github/workflows/test-changed-auth.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,6 @@ jobs:
6363
- name: build
6464
run: yarn build:changed auth
6565
- name: Run tests on auth changed packages
66-
run: xvfb-run yarn --cwd packages/auth test:browser:unit
67-
env:
68-
BROWSERS: 'Firefox'
69-
- name: Run tests on auth-compat changed packages
70-
run: xvfb-run yarn --cwd packages/auth-compat test:browser:unit
66+
run: xvfb-run yarn test:changed auth
7167
env:
7268
BROWSERS: 'Firefox'

.github/workflows/test-changed-firestore.yml

Lines changed: 56 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,62 @@ name: Test Firestore
33
on: pull_request
44

55
jobs:
6-
test:
7-
name: Test Firestore If Changed
6+
test-chrome:
7+
name: Test Firestore on Chrome and Node If Changed
88
runs-on: ubuntu-latest
99

1010
steps:
11-
- name: Checkout Repo
12-
uses: actions/checkout@master
13-
with:
14-
# This makes Actions fetch all Git history so run-changed script can diff properly.
15-
fetch-depth: 0
16-
- name: Set up Node (14)
17-
uses: actions/setup-node@v2
18-
with:
19-
node-version: 14.x
20-
- name: install Chrome stable
21-
run: |
22-
sudo apt-get update
23-
sudo apt-get install google-chrome-stable
24-
- name: Bump Node memory limit
25-
run: echo "NODE_OPTIONS=--max_old_space_size=4096" >> $GITHUB_ENV
26-
- name: Test setup and yarn install
27-
run: |
28-
cp config/ci.config.json config/project.json
29-
yarn
30-
- name: build
31-
run: yarn build:changed firestore
32-
- name: Run tests if firestore or its dependencies has changed
33-
run: yarn test:changed firestore
11+
- name: Checkout Repo
12+
uses: actions/checkout@master
13+
with:
14+
# This makes Actions fetch all Git history so run-changed script can diff properly.
15+
fetch-depth: 0
16+
- name: Set up Node (14)
17+
uses: actions/setup-node@v2
18+
with:
19+
node-version: 14.x
20+
- name: install Chrome stable
21+
run: |
22+
sudo apt-get update
23+
sudo apt-get install google-chrome-stable
24+
- name: Bump Node memory limit
25+
run: echo "NODE_OPTIONS=--max_old_space_size=4096" >> $GITHUB_ENV
26+
- name: Test setup and yarn install
27+
run: |
28+
cp config/ci.config.json config/project.json
29+
yarn
30+
- name: build
31+
run: yarn build:changed firestore
32+
- name: Run tests if firestore or its dependencies has changed
33+
run: yarn test:changed firestore
34+
35+
test-firefox:
36+
name: Test Firestore on Firefox If Changed
37+
runs-on: ubuntu-latest
38+
39+
steps:
40+
- name: install Firefox stable
41+
run: |
42+
sudo apt-get update
43+
sudo apt-get install firefox
44+
- name: Checkout Repo
45+
uses: actions/checkout@master
46+
with:
47+
# This makes Actions fetch all Git history so run-changed script can diff properly.
48+
fetch-depth: 0
49+
- name: Set up Node (14)
50+
uses: actions/setup-node@v2
51+
with:
52+
node-version: 14.x
53+
- name: Bump Node memory limit
54+
run: echo "NODE_OPTIONS=--max_old_space_size=4096" >> $GITHUB_ENV
55+
- name: Test setup and yarn install
56+
run: |
57+
cp config/ci.config.json config/project.json
58+
yarn
59+
- name: build
60+
run: yarn build:changed firestore
61+
- name: Run tests if firestore or its dependencies has changed
62+
run: xvfb-run yarn test:changed firestore
63+
env:
64+
BROWSERS: 'Firefox'

common/api-review/firestore-lite.api.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,10 @@ export function getDoc<T>(reference: DocumentReference<T>): Promise<DocumentSnap
176176
export function getDocs<T>(query: Query<T>): Promise<QuerySnapshot<T>>;
177177

178178
// @public
179-
export function getFirestore(app?: FirebaseApp): Firestore;
179+
export function getFirestore(): Firestore;
180+
181+
// @public
182+
export function getFirestore(app: FirebaseApp): Firestore;
180183

181184
// @public
182185
export function increment(n: number): FieldValue;

common/api-review/firestore.api.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,13 +228,16 @@ export function getDocsFromCache<T>(query: Query<T>): Promise<QuerySnapshot<T>>;
228228
export function getDocsFromServer<T>(query: Query<T>): Promise<QuerySnapshot<T>>;
229229

230230
// @public
231-
export function getFirestore(app?: FirebaseApp): Firestore;
231+
export function getFirestore(): Firestore;
232+
233+
// @public
234+
export function getFirestore(app: FirebaseApp): Firestore;
232235

233236
// @public
234237
export function increment(n: number): FieldValue;
235238

236239
// @public
237-
export function initializeFirestore(app: FirebaseApp, settings: FirestoreSettings): Firestore;
240+
export function initializeFirestore(app: FirebaseApp, settings: FirestoreSettings, databaseId?: string): Firestore;
238241

239242
// @public
240243
export function limit(limit: number): QueryConstraint;

integration/firestore/firebase_export.ts

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,25 @@ import {
2727

2828
let appCount = 0;
2929

30+
export function newTestApp(projectId: string, appName?: string): FirebaseApp {
31+
if (appName === undefined) {
32+
appName = 'test-app-' + appCount++;
33+
}
34+
return initializeApp(
35+
{
36+
apiKey: 'fake-api-key',
37+
projectId
38+
},
39+
appName
40+
);
41+
}
42+
3043
export function newTestFirestore(
31-
projectId: string,
32-
nameOrApp?: string | FirebaseApp,
33-
settings?: FirestoreSettings
44+
app: FirebaseApp,
45+
settings?: FirestoreSettings,
46+
dbName?: string
3447
): Firestore {
35-
if (nameOrApp === undefined) {
36-
nameOrApp = 'test-app-' + appCount++;
37-
}
38-
const app =
39-
typeof nameOrApp === 'string'
40-
? initializeApp({ apiKey: 'fake-api-key', projectId }, nameOrApp)
41-
: nameOrApp;
42-
return initializeFirestore(app, settings || {});
48+
return initializeFirestore(app, settings || {}, dbName);
4349
}
4450

4551
export * from '@firebase/firestore';

packages/auth/src/core/auth/auth_impl.test.ts

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,65 @@ describe('core/auth/auth_impl', () => {
306306
});
307307
});
308308

309+
context('with Proactive Refresh', () => {
310+
let oldUser: UserInternal;
311+
312+
beforeEach(() => {
313+
oldUser = testUser(auth, 'old-user-uid');
314+
315+
for (const u of [user, oldUser]) {
316+
sinon.spy(u, '_startProactiveRefresh');
317+
sinon.spy(u, '_stopProactiveRefresh');
318+
}
319+
});
320+
321+
it('null -> user: does not turn on if not enabled', async () => {
322+
await auth._updateCurrentUser(null);
323+
await auth._updateCurrentUser(user);
324+
325+
expect(user._startProactiveRefresh).not.to.have.been.called;
326+
});
327+
328+
it('null -> user: turns on if enabled', async () => {
329+
await auth._updateCurrentUser(null);
330+
auth._startProactiveRefresh();
331+
await auth._updateCurrentUser(user);
332+
333+
expect(user._startProactiveRefresh).to.have.been.called;
334+
});
335+
336+
it('user -> user: does not turn on if not enabled', async () => {
337+
await auth._updateCurrentUser(oldUser);
338+
await auth._updateCurrentUser(user);
339+
340+
expect(user._startProactiveRefresh).not.to.have.been.called;
341+
});
342+
343+
it('user -> user: turns on if enabled', async () => {
344+
auth._startProactiveRefresh();
345+
await auth._updateCurrentUser(oldUser);
346+
await auth._updateCurrentUser(user);
347+
348+
expect(oldUser._stopProactiveRefresh).to.have.been.called;
349+
expect(user._startProactiveRefresh).to.have.been.called;
350+
});
351+
352+
it('calling start on auth triggers user to start', async () => {
353+
await auth._updateCurrentUser(user);
354+
auth._startProactiveRefresh();
355+
356+
expect(user._startProactiveRefresh).to.have.been.calledOnce;
357+
});
358+
359+
it('calling stop stops the refresh on the current user', async () => {
360+
auth._startProactiveRefresh();
361+
await auth._updateCurrentUser(user);
362+
auth._stopProactiveRefresh();
363+
364+
expect(user._stopProactiveRefresh).to.have.been.called;
365+
});
366+
});
367+
309368
it('onAuthStateChange works for multiple listeners', async () => {
310369
const cb1 = sinon.spy();
311370
const cb2 = sinon.spy();

0 commit comments

Comments
 (0)