Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(firestore): V9 modular APIs #7235

Merged
merged 68 commits into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
ed13768
feat(firestore): add implementation for getFirestore and tests
exaby73 Jun 16, 2023
0acb60e
firestore queries - work in progress
exaby73 Jun 19, 2023
0c1f179
add modular API tests to firestore.e2e.js
exaby73 Jun 22, 2023
15bb556
add modular API tests for Bytes
exaby73 Jun 23, 2023
c67d0a0
add modular API tests for DocumentChange.e2e.js
exaby73 Jun 23, 2023
d727f08
add modular API tests for FieldPath.e2e.js
exaby73 Jun 26, 2023
33de1c5
add modular API tests for FieldValue.e2e.js
exaby73 Jun 28, 2023
0475c22
add modular API tests for FirestoreStatics.e2e.js
exaby73 Jun 28, 2023
48b9674
update docs for FieldPath and FieldValue
exaby73 Jun 28, 2023
210718f
add modular API tests for GeoPoint.e2e.js
exaby73 Jun 28, 2023
91e799c
add startAfter to query.js
exaby73 Jul 3, 2023
d2e4d55
add modular API tests for issues.e2e.js
exaby73 Jul 3, 2023
91a173f
add modular API tests for QuerySnapshot.e2e.js
exaby73 Jul 4, 2023
aaf79fc
add modular API tests for SnapshotMetadata.e2e.js
exaby73 Jul 4, 2023
7643c73
add modular API tests for Timestamp.e2e.js
exaby73 Jul 4, 2023
ac7b746
add modular API tests for Transaction.e2e.js
exaby73 Jul 4, 2023
b6fdc62
add modular API tests for count.e2e.js
exaby73 Jul 7, 2023
1ce6f79
add modular API tests for loadBundle.e2e.js
exaby73 Jul 7, 2023
c24dc9e
add modular API tests for namedQuery.e2e.js and fix onSnapshot making…
exaby73 Jul 7, 2023
80919fb
add modular API tests for add.e2e.js and remove .only in namedQuery.e…
exaby73 Jul 7, 2023
7beebcc
add modular API tests for doc.e2e.js
exaby73 Jul 7, 2023
939fa7a
add modular API tests for properties.e2e.js
exaby73 Jul 7, 2023
1701d84
add modular API tests for collection.e2e.js
exaby73 Jul 7, 2023
652eea1
add modular API tests for delete.e2e.js
exaby73 Jul 7, 2023
43c9960
add modular API tests for get.e2e.js
exaby73 Jul 7, 2023
47ba9f4
add modular API tests for isEqual.e2e.js
exaby73 Jul 7, 2023
55fe44c
add modular API tests for onSnapshot.e2e.js and skip a few tests that…
exaby73 Jul 7, 2023
2b23c33
add modular API tests for properties.e2e.js
exaby73 Jul 7, 2023
bfb7e86
add modular API tests for set.e2e.js
exaby73 Jul 7, 2023
754bc60
add modular API tests for update.e2e.js
exaby73 Jul 7, 2023
c3262c1
add modular API tests for data.e2e.js
exaby73 Jul 7, 2023
29303a1
add modular API tests for get.e2e.js
exaby73 Jul 10, 2023
f35e232
add modular API tests for isEqual.e2e.js
exaby73 Jul 10, 2023
b00dc13
add modular API tests for properties.e2e.js
exaby73 Jul 10, 2023
c7fa10e
add modular API tests for endAt.e2e.js
exaby73 Jul 10, 2023
65e5d55
remove .only
exaby73 Jul 10, 2023
e7ed7b5
add modular API tests for endBefore.e2e.js
exaby73 Jul 10, 2023
b34fabc
add modular tests for get.e2e.js
exaby73 Jul 10, 2023
c8b37d4
add modular API tests for isEqual.e2e.js
exaby73 Jul 10, 2023
def9d98
add modular API tests for limit.e2e.js
exaby73 Jul 10, 2023
9b7b644
add modular API tests for limitToLast.e2e.js
exaby73 Jul 10, 2023
1efd5ef
add modular API tests for onSnapshot.e2e.js
exaby73 Jul 10, 2023
003bb07
add modular API test for orderBy.e2e.js
exaby73 Jul 10, 2023
ecdc6c3
add modular API test for query.e2e.js
exaby73 Jul 10, 2023
13de27e
add modular API test for startAfter.e2e.js
exaby73 Jul 10, 2023
ada8364
add modular API test for startAt.e2e.js
exaby73 Jul 11, 2023
943f113
add modular API tests for where.and.filter.e2e.js
exaby73 Jul 13, 2023
53708fc
fix: flaky tests in where.and.filter.e2e.js
exaby73 Jul 13, 2023
6e55240
add modular API tests for where.e2e.js
exaby73 Jul 13, 2023
bc9596a
delete where.filter.e2e.js since Filter is not part of the modular API
exaby73 Jul 13, 2023
3902382
add modular API tests for commit.e2e.js
exaby73 Jul 13, 2023
9cdb0b4
add modular API tests for delete.e2e.js
exaby73 Jul 13, 2023
35f9215
add modular API tests for set.e2e.js
exaby73 Jul 13, 2023
0f019a7
skip flaky test
exaby73 Jul 14, 2023
3881796
remove only in delete tests
exaby73 Jul 14, 2023
096625a
add modular API tests for update.e2e.js
exaby73 Jul 14, 2023
39b3e0f
fix(firestore): linting errors
exaby73 Jul 14, 2023
bc39238
fix: add back where.filter.e2e.js
exaby73 Sep 18, 2023
4505597
feat(firestore): add modular tests for where.or.filter.e2e.js
exaby73 Sep 18, 2023
5fbb3c4
fix(firestore): remove duplicate getFirestore TS declaration
exaby73 Sep 18, 2023
f39cc45
fix(firestore): issues e2e, use modular js functions in modular tests
exaby73 Sep 18, 2023
4f524dd
add comment for 2nd database
exaby73 Sep 19, 2023
dda993d
remove .only in issues.e2e.js
exaby73 Sep 19, 2023
57a00ca
extract jsdoc imports
exaby73 Sep 19, 2023
aafa467
removed unused variables
exaby73 Sep 19, 2023
52cdaa7
change collection path for failing modular test
exaby73 Sep 19, 2023
daa4279
remove console log
exaby73 Sep 19, 2023
ac4a698
test(firestore): re-enable modular where-in test via stable ordering
mikehardy Sep 20, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
159 changes: 107 additions & 52 deletions packages/firestore/e2e/Aggregate/count.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,62 +21,117 @@ describe('firestore().collection().count()', function () {
return wipe();
});

it('throws if no argument provided', function () {
try {
firebase.firestore().collection(COLLECTION).startAt();
return Promise.reject(new Error('Did not throw an Error.'));
} catch (error) {
error.message.should.containEql(
'Expected a DocumentSnapshot or list of field values but got undefined',
);
return Promise.resolve();
}
});
describe('v8 compatibility', function () {
it('throws if no argument provided', function () {
try {
firebase.firestore().collection(COLLECTION).startAt();
return Promise.reject(new Error('Did not throw an Error.'));
} catch (error) {
error.message.should.containEql(
'Expected a DocumentSnapshot or list of field values but got undefined',
);
return Promise.resolve();
}
});

it('gets count of collection reference - unfiltered', async function () {
const colRef = firebase.firestore().collection(`${COLLECTION}/count/collection`);
it('gets count of collection reference - unfiltered', async function () {
const colRef = firebase.firestore().collection(`${COLLECTION}/count/collection`);

const doc1 = colRef.doc('doc1');
const doc2 = colRef.doc('doc2');
const doc3 = colRef.doc('doc3');
await Promise.all([
doc1.set({ foo: 1, bar: { value: 1 } }),
doc2.set({ foo: 2, bar: { value: 2 } }),
doc3.set({ foo: 3, bar: { value: 3 } }),
]);
const doc1 = colRef.doc('doc1');
const doc2 = colRef.doc('doc2');
const doc3 = colRef.doc('doc3');
await Promise.all([
doc1.set({ foo: 1, bar: { value: 1 } }),
doc2.set({ foo: 2, bar: { value: 2 } }),
doc3.set({ foo: 3, bar: { value: 3 } }),
]);

const qs = await colRef.count().get();
qs.data().count.should.eql(3);
});
it('gets countFromServer of collection reference - unfiltered', async function () {
const colRef = firebase.firestore().collection(`${COLLECTION}/count/collection`);

const doc1 = colRef.doc('doc1');
const doc2 = colRef.doc('doc2');
const doc3 = colRef.doc('doc3');
await Promise.all([
doc1.set({ foo: 1, bar: { value: 1 } }),
doc2.set({ foo: 2, bar: { value: 2 } }),
doc3.set({ foo: 3, bar: { value: 3 } }),
]);

const qs = await colRef.countFromServer().get();
qs.data().count.should.eql(3);
const qs = await colRef.count().get();
qs.data().count.should.eql(3);
});
it('gets countFromServer of collection reference - unfiltered', async function () {
const colRef = firebase.firestore().collection(`${COLLECTION}/count/collection`);

const doc1 = colRef.doc('doc1');
const doc2 = colRef.doc('doc2');
const doc3 = colRef.doc('doc3');
await Promise.all([
doc1.set({ foo: 1, bar: { value: 1 } }),
doc2.set({ foo: 2, bar: { value: 2 } }),
doc3.set({ foo: 3, bar: { value: 3 } }),
]);

const qs = await colRef.countFromServer().get();
qs.data().count.should.eql(3);
});
it('gets correct count of collection reference - where equal', async function () {
const colRef = firebase.firestore().collection(`${COLLECTION}/count/collection`);

const doc1 = colRef.doc('doc1');
const doc2 = colRef.doc('doc2');
const doc3 = colRef.doc('doc3');
await Promise.all([
doc1.set({ foo: 1, bar: { value: 1 } }),
doc2.set({ foo: 2, bar: { value: 2 } }),
doc3.set({ foo: 3, bar: { value: 3 } }),
]);

const qs = await colRef.where('foo', '==', 3).count().get();
qs.data().count.should.eql(1);
});
});
it('gets correct count of collection reference - where equal', async function () {
const colRef = firebase.firestore().collection(`${COLLECTION}/count/collection`);

const doc1 = colRef.doc('doc1');
const doc2 = colRef.doc('doc2');
const doc3 = colRef.doc('doc3');
await Promise.all([
doc1.set({ foo: 1, bar: { value: 1 } }),
doc2.set({ foo: 2, bar: { value: 2 } }),
doc3.set({ foo: 3, bar: { value: 3 } }),
]);

const qs = await colRef.where('foo', '==', 3).count().get();
qs.data().count.should.eql(1);

describe('modular', function () {
it('throws if no argument provided', function () {
const { getFirestore, collection, startAt, query } = firestoreModular;

try {
query(collection(getFirestore(), COLLECTION), startAt());
return Promise.reject(new Error('Did not throw an Error.'));
} catch (error) {
error.message.should.containEql(
'Expected a DocumentSnapshot or list of field values but got undefined',
);
return Promise.resolve();
}
});

it('gets countFromServer of collection reference - unfiltered', async function () {
const { getFirestore, collection, doc, setDoc, getCountFromServer } = firestoreModular;

const colRef = collection(getFirestore(), `${COLLECTION}/count/collection`);

const doc1 = doc(colRef, 'doc1');
const doc2 = doc(colRef, 'doc2');
const doc3 = doc(colRef, 'doc3');
await Promise.all([
setDoc(doc1, { foo: 1, bar: { value: 1 } }),
setDoc(doc2, { foo: 2, bar: { value: 2 } }),
setDoc(doc3, { foo: 3, bar: { value: 3 } }),
]);

const qs = await getCountFromServer(colRef);
qs.data().count.should.eql(3);
});

it('gets correct count of collection reference - where equal', async function () {
const { getFirestore, collection, doc, setDoc, query, where, getCountFromServer } =
firestoreModular;

const colRef = collection(getFirestore(), `${COLLECTION}/count/collection`);

const doc1 = doc(colRef, 'doc1');
const doc2 = doc(colRef, 'doc2');
const doc3 = doc(colRef, 'doc3');
await Promise.all([
setDoc(doc1, { foo: 1, bar: { value: 1 } }),
setDoc(doc2, { foo: 2, bar: { value: 2 } }),
setDoc(doc3, { foo: 3, bar: { value: 3 } }),
]);

const qs = await getCountFromServer(query(colRef, where('foo', '==', 3)));
qs.data().count.should.eql(1);
});
});

// TODO
Expand Down
76 changes: 55 additions & 21 deletions packages/firestore/e2e/Bundle/loadBundle.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,62 @@ describe('firestore().loadBundle()', function () {
return await wipe();
});

it('loads the bundle contents', async function () {
const bundle = getBundle();
const progress = await firebase.firestore().loadBundle(bundle);
const query = firebase.firestore().collection(BUNDLE_COLLECTION);
const snapshot = await query.get({ source: 'cache' });

progress.taskState.should.eql('Success');
progress.documentsLoaded.should.eql(6);
snapshot.size.should.eql(6);
describe('v8 compatibility', function () {
it('loads the bundle contents', async function () {
const bundle = getBundle();
const progress = await firebase.firestore().loadBundle(bundle);
const query = firebase.firestore().collection(BUNDLE_COLLECTION);
const snapshot = await query.get({ source: 'cache' });

progress.taskState.should.eql('Success');
progress.documentsLoaded.should.eql(6);
snapshot.size.should.eql(6);
});

it('throws if invalid bundle', async function () {
try {
await firebase.firestore().loadBundle('not-a-bundle');
return Promise.reject(new Error('Did not throw an Error.'));
} catch (error) {
/*
* Due to inconsistent error throws between Android and iOS Firebase SDK,
* it is not able to test a specific error message.
* Android SDK throws 'invalid-arguments', while iOS SDK throws 'unknown'
*/
return Promise.resolve();
}
});
});

it('throws if invalid bundle', async function () {
try {
await firebase.firestore().loadBundle('not-a-bundle');
return Promise.reject(new Error('Did not throw an Error.'));
} catch (error) {
/*
* Due to inconsistent error throws between Android and iOS Firebase SDK,
* it is not able to test a specific error message.
* Android SDK throws 'invalid-arguments', while iOS SDK throws 'unknown'
*/
return Promise.resolve();
}
describe('modular', function () {
it('loads the bundle contents', async function () {
const { getFirestore, loadBundle, collection, getDocsFromCache } = firestoreModular;
const db = getFirestore();

const bundle = getBundle();
const progress = await loadBundle(db, bundle);
const query = collection(db, BUNDLE_COLLECTION);
const snapshot = await getDocsFromCache(query);

progress.taskState.should.eql('Success');
progress.documentsLoaded.should.eql(6);
snapshot.size.should.eql(6);
});

it('throws if invalid bundle', async function () {
const { getFirestore, loadBundle } = firestoreModular;

try {
await loadBundle(getFirestore(), 'not-a-bundle');
return Promise.reject(new Error('Did not throw an Error.'));
} catch (error) {
/*
* Due to inconsistent error throws between Android and iOS Firebase SDK,
* it is not able to test a specific error message.
* Android SDK throws 'invalid-arguments', while iOS SDK throws 'unknown'
*/
return Promise.resolve();
}
});
});
});
Loading
Loading