Skip to content

Commit ac4bf09

Browse files
committed
Update integration tests. Minified tests fail.
1 parent 830d948 commit ac4bf09

File tree

4 files changed

+43
-23
lines changed

4 files changed

+43
-23
lines changed

integration/firestore/firebase_export.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,16 @@ const Timestamp = firebase.firestore.Timestamp;
5555
const GeoPoint = firebase.firestore.GeoPoint;
5656
const FieldValue = firebase.firestore.FieldValue;
5757
const Blob = firebase.firestore.Blob;
58+
const loadBundle = firebase.firestore.loadBundle;
59+
const namedQuery = firebase.firestore.namedQuery;
5860

59-
export { Firestore, FieldValue, FieldPath, Timestamp, Blob, GeoPoint };
61+
export {
62+
Firestore,
63+
FieldValue,
64+
FieldPath,
65+
Timestamp,
66+
Blob,
67+
GeoPoint,
68+
loadBundle,
69+
namedQuery
70+
};

integration/firestore/firebase_export_memory.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,16 @@ const Timestamp = firebase.firestore.Timestamp;
5555
const GeoPoint = firebase.firestore.GeoPoint;
5656
const FieldValue = firebase.firestore.FieldValue;
5757
const Blob = firebase.firestore.Blob;
58+
const loadBundle = firebase.firestore.loadBundle;
59+
const namedQuery = firebase.firestore.namedQuery;
5860

59-
export { Firestore, FieldValue, FieldPath, Timestamp, Blob, GeoPoint };
61+
export {
62+
Firestore,
63+
FieldValue,
64+
FieldPath,
65+
Timestamp,
66+
Blob,
67+
GeoPoint,
68+
loadBundle,
69+
namedQuery
70+
};

packages/firestore/register-module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ declare module '@firebase/app-types' {
3636
Transaction: typeof types.Transaction;
3737
WriteBatch: typeof types.WriteBatch;
3838
setLogLevel: typeof types.setLogLevel;
39+
loadBundle: typeof types.loadBundle;
40+
namedQuery: typeof types.namedQuery;
3941
};
4042
}
4143
interface FirebaseApp {

packages/firestore/test/integration/api/bundle.test.ts

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@ import {
2424
withTestDb
2525
} from '../util/helpers';
2626
import { EventsAccumulator } from '../util/events_accumulator';
27+
import * as firebaseExport from '../util/firebase_export';
2728

28-
// TODO(b/162594908): Move this to api/ instead of api_internal.
29+
const loadBundle = firebaseExport.loadBundle;
30+
const namedQuery = firebaseExport.namedQuery;
2931

3032
export const encoder = new TextEncoder();
3133

@@ -95,10 +97,7 @@ apiDescribe('Bundles', (persistence: boolean) => {
9597
return withTestDb(persistence, async db => {
9698
const progressEvents: firestore.LoadBundleTaskProgress[] = [];
9799
let completeCalled = false;
98-
const task: firestore.LoadBundleTask = firestore.loadBundle(
99-
db,
100-
bundleString(db)
101-
);
100+
const task: firestore.LoadBundleTask = loadBundle(db, bundleString(db));
102101
task.onProgress(
103102
progress => {
104103
progressEvents.push(progress);
@@ -127,12 +126,12 @@ apiDescribe('Bundles', (persistence: boolean) => {
127126
let snap = await db.collection('coll-1').get({ source: 'cache' });
128127
verifySnapEqualsTestDocs(snap);
129128

130-
snap = await (await firestore.namedQuery(db, 'limit'))!.get({
129+
snap = await (await namedQuery(db, 'limit'))!.get({
131130
source: 'cache'
132131
});
133132
expect(toDataArray(snap)).to.deep.equal([{ k: 'b', bar: 2 }]);
134133

135-
snap = await (await firestore.namedQuery(db, 'limit-to-last'))!.get({
134+
snap = await (await namedQuery(db, 'limit-to-last'))!.get({
136135
source: 'cache'
137136
});
138137
expect(toDataArray(snap)).to.deep.equal([{ k: 'a', bar: 1 }]);
@@ -141,7 +140,7 @@ apiDescribe('Bundles', (persistence: boolean) => {
141140

142141
it('load with documents and queries with promise interface', () => {
143142
return withTestDb(persistence, async db => {
144-
const fulfillProgress: firestore.LoadBundleTaskProgress = await firestore.loadBundle(
143+
const fulfillProgress: firestore.LoadBundleTaskProgress = await loadBundle(
145144
db,
146145
bundleString(db)
147146
);
@@ -157,11 +156,11 @@ apiDescribe('Bundles', (persistence: boolean) => {
157156

158157
it('load for a second time skips', () => {
159158
return withTestDb(persistence, async db => {
160-
await firestore.loadBundle(db, bundleString(db));
159+
await loadBundle(db, bundleString(db));
161160

162161
let completeCalled = false;
163162
const progressEvents: firestore.LoadBundleTaskProgress[] = [];
164-
const task: firestore.LoadBundleTask = firestore.loadBundle(
163+
const task: firestore.LoadBundleTask = loadBundle(
165164
db,
166165
encoder.encode(bundleString(db))
167166
);
@@ -198,7 +197,7 @@ apiDescribe('Bundles', (persistence: boolean) => {
198197
db.collection('coll-1').onSnapshot(accumulator.storeEvent);
199198
await accumulator.awaitEvent();
200199

201-
const progress = await firestore.loadBundle(
200+
const progress = await loadBundle(
202201
db,
203202
// Testing passing in non-string bundles.
204203
encoder.encode(bundleString(db))
@@ -210,17 +209,17 @@ apiDescribe('Bundles', (persistence: boolean) => {
210209
// cache can only be tested in spec tests.
211210
await accumulator.assertNoAdditionalEvents();
212211

213-
let snap = await (await firestore.namedQuery(db, 'limit'))!.get();
212+
let snap = await (await namedQuery(db, 'limit'))!.get();
214213
expect(toDataArray(snap)).to.deep.equal([{ k: 'b', bar: 0 }]);
215214

216-
snap = await (await firestore.namedQuery(db, 'limit-to-last'))!.get();
215+
snap = await (await namedQuery(db, 'limit-to-last'))!.get();
217216
expect(toDataArray(snap)).to.deep.equal([{ k: 'a', bar: 0 }]);
218217
});
219218
});
220219

221220
it('loaded documents should not be GC-ed right away', () => {
222221
return withTestDb(persistence, async db => {
223-
const fulfillProgress: firestore.LoadBundleTaskProgress = await firestore.loadBundle(
222+
const fulfillProgress: firestore.LoadBundleTaskProgress = await loadBundle(
224223
db,
225224
bundleString(db)
226225
);
@@ -242,15 +241,12 @@ apiDescribe('Bundles', (persistence: boolean) => {
242241
it('load with documents from other projects fails', () => {
243242
return withTestDb(persistence, async db => {
244243
return withAlternateTestDb(persistence, async otherDb => {
245-
await expect(
246-
firestore.loadBundle(otherDb, bundleString(db))
247-
).to.be.rejectedWith('Tried to deserialize key from different project');
244+
await expect(loadBundle(otherDb, bundleString(db))).to.be.rejectedWith(
245+
'Tried to deserialize key from different project'
246+
);
248247

249248
// Verify otherDb still functions, despite loaded a problematic bundle.
250-
const finalProgress = await firestore.loadBundle(
251-
otherDb,
252-
bundleString(otherDb)
253-
);
249+
const finalProgress = await loadBundle(otherDb, bundleString(otherDb));
254250
verifySuccessProgress(finalProgress);
255251

256252
// Read from cache. These documents do not exist in backend, so they can

0 commit comments

Comments
 (0)