From 05d9394f662118749d82ac1dba80cb44b59ba97e Mon Sep 17 00:00:00 2001 From: russellwheatley Date: Tue, 25 Aug 2020 17:02:45 +0100 Subject: [PATCH 01/10] test(firestore): clean up rules --- .github/workflows/scripts/firebase.json | 2 +- .../workflows/scripts/firestore.indexes.json | 84 +--------- .github/workflows/scripts/firestore.rules | 154 +----------------- .../e2e/CollectionReference/add.e2e.js | 7 +- .../e2e/CollectionReference/doc.e2e.js | 9 +- .../e2e/CollectionReference/properties.e2e.js | 24 ++- packages/firestore/e2e/DocumentChange.e2e.js | 17 +- .../e2e/DocumentReference/collection.e2e.js | 16 +- .../e2e/DocumentReference/delete.e2e.js | 5 +- .../e2e/DocumentReference/get.e2e.js | 9 +- .../e2e/DocumentReference/isEqual.e2e.js | 11 +- .../e2e/DocumentReference/onSnapshot.e2e.js | 40 ++--- .../e2e/DocumentReference/properties.e2e.js | 18 +- .../e2e/DocumentReference/set.e2e.js | 28 ++-- .../e2e/DocumentReference/update.e2e.js | 13 +- .../e2e/DocumentSnapshot/data.e2e.js | 15 +- .../firestore/e2e/DocumentSnapshot/get.e2e.js | 19 +-- .../e2e/DocumentSnapshot/isEqual.e2e.js | 9 +- .../e2e/DocumentSnapshot/properties.e2e.js | 21 ++- packages/firestore/e2e/FieldPath.e2e.js | 5 +- packages/firestore/e2e/FieldValue.e2e.js | 25 ++- packages/firestore/e2e/GeoPoint.e2e.js | 7 +- packages/firestore/e2e/Query/endAt.e2e.js | 26 +-- packages/firestore/e2e/Query/endBefore.e2e.js | 27 +-- packages/firestore/e2e/Query/get.e2e.js | 13 +- packages/firestore/e2e/Query/isEqual.e2e.js | 34 ++-- packages/firestore/e2e/Query/limit.e2e.js | 9 +- .../firestore/e2e/Query/limitToLast.e2e.js | 18 +- .../firestore/e2e/Query/onSnapshot.e2e.js | 41 ++--- packages/firestore/e2e/Query/orderBy.e2e.js | 28 ++-- packages/firestore/e2e/Query/query.e2e.js | 9 +- .../firestore/e2e/Query/startAfter.e2e.js | 28 ++-- packages/firestore/e2e/Query/startAt.e2e.js | 27 ++- packages/firestore/e2e/Query/where.e2e.js | 60 ++++--- packages/firestore/e2e/QuerySnapshot.e2e.js | 47 +++--- .../firestore/e2e/SnapshotMetadata.e2e.js | 21 ++- packages/firestore/e2e/Transaction.e2e.js | 38 +++-- .../firestore/e2e/WriteBatch/commit.e2e.js | 35 ++-- .../firestore/e2e/WriteBatch/delete.e2e.js | 8 +- packages/firestore/e2e/WriteBatch/set.e2e.js | 30 ++-- .../firestore/e2e/WriteBatch/update.e2e.js | 17 +- packages/firestore/e2e/firestore.e2e.js | 62 ++++--- packages/firestore/e2e/helpers.js | 27 ++- packages/firestore/e2e/issues.e2e.js | 22 +-- 44 files changed, 489 insertions(+), 676 deletions(-) diff --git a/.github/workflows/scripts/firebase.json b/.github/workflows/scripts/firebase.json index b2bf87a654..02cfee1ef8 100644 --- a/.github/workflows/scripts/firebase.json +++ b/.github/workflows/scripts/firebase.json @@ -9,7 +9,7 @@ }, "ui": { "enabled": true, - "port": "4000" + "port": 4000 } } } \ No newline at end of file diff --git a/.github/workflows/scripts/firestore.indexes.json b/.github/workflows/scripts/firestore.indexes.json index 671e9c860e..b42ac29d53 100644 --- a/.github/workflows/scripts/firestore.indexes.json +++ b/.github/workflows/scripts/firestore.indexes.json @@ -1,49 +1,7 @@ { "indexes": [ { - "collectionGroup": "firebasePerfTest", - "queryScope": "COLLECTION", - "fields": [ - { - "fieldPath": "democratic", - "order": "ASCENDING" - }, - { - "fieldPath": "totalPopulation", - "order": "ASCENDING" - } - ] - }, - { - "collectionGroup": "playground", - "queryScope": "COLLECTION", - "fields": [ - { - "fieldPath": "age", - "order": "ASCENDING" - }, - { - "fieldPath": "foo", - "order": "ASCENDING" - } - ] - }, - { - "collectionGroup": "playground", - "queryScope": "COLLECTION", - "fields": [ - { - "fieldPath": "status", - "order": "ASCENDING" - }, - { - "fieldPath": "finished_at", - "order": "ASCENDING" - } - ] - }, - { - "collectionGroup": "v6", + "collectionGroup": "firestore", "queryScope": "COLLECTION", "fields": [ { @@ -109,46 +67,6 @@ "queryScope": "COLLECTION_GROUP" } ] - }, - { - "collectionGroup": "playground", - "fieldPath": "age", - "indexes": [ - { - "order": "ASCENDING", - "queryScope": "COLLECTION" - }, - { - "order": "DESCENDING", - "queryScope": "COLLECTION" - }, - { - "arrayConfig": "CONTAINS", - "queryScope": "COLLECTION" - }, - { - "order": "ASCENDING", - "queryScope": "COLLECTION_GROUP" - } - ] - }, - { - "collectionGroup": "playground", - "fieldPath": "createdDate", - "indexes": [ - { - "order": "ASCENDING", - "queryScope": "COLLECTION" - }, - { - "order": "DESCENDING", - "queryScope": "COLLECTION" - }, - { - "arrayConfig": "CONTAINS", - "queryScope": "COLLECTION" - } - ] } ] } diff --git a/.github/workflows/scripts/firestore.rules b/.github/workflows/scripts/firestore.rules index 1d2f2ade92..b132c648f5 100644 --- a/.github/workflows/scripts/firestore.rules +++ b/.github/workflows/scripts/firestore.rules @@ -1,156 +1,14 @@ rules_version = '2'; service cloud.firestore { match /databases/{database}/documents { - function isUpdateToLikeCount(attr) { - return request.resource.data.diff(resource.data).affectedKeys().hasOnly(['likes']); - } - - allow update: if isUpdateToLikeCount(request.resource.data); - - match /firebasePerfTest/{document=**} { - allow read: if true; - } - - match /firestore-example-app/{document=**} { - allow read, write: if true; - } - - match /{document=**} { + match /{document=**} { allow read, write: if false; } - match /v6/{document=**} { - allow read, write: if true; - } - - match /flutter-tests/{document=**} { - allow read, write: if true; - } - - match /playground/{document=**} { - allow read, write: if true; - } - - match /{path=**}/playground/{doc} { - allow read, write: if true; - } - - match /{path=**}/collectionGroup/{documentId} { - allow read, write: if true; - } - match /issue2854/{document=**} { - allow read, write: if true; - } - - match /random/{document=**} { - allow read; - } - match /collection-tests/{document=**} { - allow read, write: if true; - } - match /document-tests/{document=**} { - allow read, write: if true; - } - match /tests/{document=**} { - allow read, write: if true; - } - match /tests1/{document=**} { - allow read, write: if true; - } - match /tests2/{document=**} { - allow read, write: if true; - } - match /tests3/{document=**} { - allow read, write: if true; - } - match /tests4/{document=**} { - allow read, write: if true; - } - match /tests5/{document=**} { - allow read, write: if true; - } - match /tests6/{document=**} { + match /firestore/{document=**} { allow read, write: if true; - } - match /tests7/{document=**} { - allow read, write: if true; - } - match /tests8/{document=**} { - allow read, write: if true; - } - match /tests9/{document=**} { - allow read, write: if true; - } - match /tests10/{document=**} { - allow read, write: if true; - } - match /tests11/{document=**} { - allow read, write: if true; - } - match /tests12/{document=**} { + } + match /{path=**}/collectionGroup/{documentId} { allow read, write: if true; - } - match /tests13/{document=**} { - allow read, write: if true; - } - match /tests14/{document=**} { - allow read, write: if true; - } - match /tests15/{document=**} { - allow read, write: if true; - } - match /tests16/{document=**} { - allow read, write: if true; - } - match /tests17/{document=**} { - allow read, write: if true; - } - match /tests18/{document=**} { - allow read, write: if true; - } - match /tests19/{document=**} { - allow read, write: if true; - } - match /tests20/{document=**} { - allow read, write: if true; - } - match /tests21/{document=**} { - allow read, write: if true; - } - match /tests22/{document=**} { - allow read, write: if true; - } - match /tests23/{document=**} { - allow read, write: if true; - } - match /tests24/{document=**} { - allow read, write: if true; - } - match /tests25/{document=**} { - allow read, write: if true; - } - match /tests26/{document=**} { - allow read, write: if true; - } - match /tests27/{document=**} { - allow read, write: if true; - } - match /tests28/{document=**} { - allow read, write: if true; - } - match /tests29/{document=**} { - allow read, write: if true; - } - match /tests30/{document=**} { - allow read, write: if true; - } - match /tests31/{document=**} { - allow read, write: if true; - } - match /flutter-tests/{document=**} { - allow read, write: if true; - } - match /blob-tests/{document=**} { - allow read, write: if true; - } + } } -} +} \ No newline at end of file diff --git a/packages/firestore/e2e/CollectionReference/add.e2e.js b/packages/firestore/e2e/CollectionReference/add.e2e.js index 23c295603f..9abd9dde8c 100644 --- a/packages/firestore/e2e/CollectionReference/add.e2e.js +++ b/packages/firestore/e2e/CollectionReference/add.e2e.js @@ -14,17 +14,16 @@ * limitations under the License. * */ - const { wipe } = require('../helpers'); + const COLLECTION = 'firestore'; describe('firestore.collection().add()', () => { before(() => wipe()); - it('throws if data is not an object', () => { try { firebase .firestore() - .collection('foo') + .collection(COLLECTION) .add(123); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { @@ -37,7 +36,7 @@ describe('firestore.collection().add()', () => { const data = { foo: 'bar' }; const docRef = await firebase .firestore() - .collection('v6') + .collection(COLLECTION) .add(data); should.equal(docRef.constructor.name, 'FirestoreDocumentReference'); const docSnap = await docRef.get(); diff --git a/packages/firestore/e2e/CollectionReference/doc.e2e.js b/packages/firestore/e2e/CollectionReference/doc.e2e.js index 0a063bb3e3..5784d315c6 100644 --- a/packages/firestore/e2e/CollectionReference/doc.e2e.js +++ b/packages/firestore/e2e/CollectionReference/doc.e2e.js @@ -14,17 +14,16 @@ * limitations under the License. * */ - const { wipe } = require('../helpers'); +const COLLECTION = 'firestore'; describe('firestore.collection().doc()', () => { before(() => wipe()); - it('throws if path is not a document', () => { try { firebase .firestore() - .collection('foo') + .collection(COLLECTION) .doc('bar/baz'); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { @@ -36,7 +35,7 @@ describe('firestore.collection().doc()', () => { it('generates an ID if no path is provided', () => { const instance = firebase .firestore() - .collection('foo') + .collection(COLLECTION) .doc(); should.equal(20, instance.id.length); }); @@ -44,7 +43,7 @@ describe('firestore.collection().doc()', () => { it('uses path if provided', () => { const instance = firebase .firestore() - .collection('foo') + .collection(COLLECTION) .doc('bar'); instance.id.should.eql('bar'); }); diff --git a/packages/firestore/e2e/CollectionReference/properties.e2e.js b/packages/firestore/e2e/CollectionReference/properties.e2e.js index 288ed52310..4e3125bcc8 100644 --- a/packages/firestore/e2e/CollectionReference/properties.e2e.js +++ b/packages/firestore/e2e/CollectionReference/properties.e2e.js @@ -14,27 +14,25 @@ * limitations under the License. * */ - const { wipe } = require('../helpers'); +const COLLECTION = 'firestore'; describe('firestore.collection()', () => { before(() => wipe()); - it('returns the firestore instance', () => { - const instance = firebase.firestore().collection('foo'); + const instance = firebase.firestore().collection(COLLECTION); instance.firestore.app.name.should.eql('[DEFAULT]'); }); it('returns the collection id', () => { - const id = 'foobar'; - const instance1 = firebase.firestore().collection(id); - const instance2 = firebase.firestore().collection(`${id}/bar/baz`); - instance1.id.should.eql(id); + const instance1 = firebase.firestore().collection(COLLECTION); + const instance2 = firebase.firestore().collection(`${COLLECTION}/bar/baz`); + instance1.id.should.eql(COLLECTION); instance2.id.should.eql('baz'); }); it('returns the collection parent', () => { - const instance1 = firebase.firestore().collection('foo'); + const instance1 = firebase.firestore().collection(COLLECTION); should.equal(instance1.parent, null); const instance2 = firebase .firestore() @@ -45,13 +43,13 @@ describe('firestore.collection()', () => { }); it('returns the firestore path', () => { - const instance1 = firebase.firestore().collection('foo'); - instance1.path.should.eql('foo'); + const instance1 = firebase.firestore().collection(COLLECTION); + instance1.path.should.eql(COLLECTION); const instance2 = firebase .firestore() - .collection('foo') + .collection(COLLECTION) .doc('bar') - .collection('baz'); - instance2.path.should.eql('foo/bar/baz'); + .collection(COLLECTION); + instance2.path.should.eql(`${COLLECTION}/bar/${COLLECTION}`); }); }); diff --git a/packages/firestore/e2e/DocumentChange.e2e.js b/packages/firestore/e2e/DocumentChange.e2e.js index da06bcecd2..3ced11977b 100644 --- a/packages/firestore/e2e/DocumentChange.e2e.js +++ b/packages/firestore/e2e/DocumentChange.e2e.js @@ -14,14 +14,13 @@ * limitations under the License. * */ - const { wipe } = require('./helpers'); +const COLLECTION = 'firestore'; describe('firestore.DocumentChange', () => { before(() => wipe()); - it('.doc -> returns a DocumentSnapshot', async () => { - const colRef = firebase.firestore().collection('v6'); + const colRef = firebase.firestore().collection(COLLECTION); await colRef.add({}); const snapshot = await colRef.limit(1).get(); const changes = snapshot.docChanges(); @@ -32,8 +31,8 @@ describe('firestore.DocumentChange', () => { }); it('returns the correct metadata when adding and removing', async () => { - const colRef = firebase.firestore().collection('v6/docChanges/docChangesCollection'); - const doc1 = firebase.firestore().doc('v6/docChanges/docChangesCollection/doc1'); + const colRef = firebase.firestore().collection(`${COLLECTION}/docChanges/docChangesCollection`); + const doc1 = firebase.firestore().doc(`${COLLECTION}/docChanges/docChangesCollection/doc1`); // Set something in the database await doc1.set({ name: 'doc1' }); @@ -72,11 +71,11 @@ describe('firestore.DocumentChange', () => { }); it('returns the correct metadata when modifying documents', async () => { - const colRef = firebase.firestore().collection('v6/docChanges/docMovedCollection'); + const colRef = firebase.firestore().collection(`${COLLECTION}/docChanges/docMovedCollection`); - const doc1 = firebase.firestore().doc('v6/docChanges/docMovedCollection/doc1'); - const doc2 = firebase.firestore().doc('v6/docChanges/docMovedCollection/doc2'); - const doc3 = firebase.firestore().doc('v6/docChanges/docMovedCollection/doc3'); + const doc1 = firebase.firestore().doc(`${COLLECTION}/docChanges/docMovedCollection/doc1`); + const doc2 = firebase.firestore().doc(`${COLLECTION}/docChanges/docMovedCollection/doc2`); + const doc3 = firebase.firestore().doc(`${COLLECTION}/docChanges/docMovedCollection/doc3`); await Promise.all([doc1.set({ value: 1 }), doc2.set({ value: 2 }), doc3.set({ value: 3 })]); diff --git a/packages/firestore/e2e/DocumentReference/collection.e2e.js b/packages/firestore/e2e/DocumentReference/collection.e2e.js index 1d5b055515..ab38fc5f2c 100644 --- a/packages/firestore/e2e/DocumentReference/collection.e2e.js +++ b/packages/firestore/e2e/DocumentReference/collection.e2e.js @@ -15,6 +15,8 @@ * */ +const COLLECTION = 'firestore'; + describe('firestore.doc().collection()', () => { it('throws if path is not a string', () => { try { @@ -47,7 +49,7 @@ describe('firestore.doc().collection()', () => { firebase .firestore() .doc('bar/baz') - .collection('foo/bar'); + .collection(`${COLLECTION}/bar`); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("'collectionPath' must point to a collection"); @@ -58,16 +60,16 @@ describe('firestore.doc().collection()', () => { it('returns a collection instance', () => { const instance1 = firebase .firestore() - .doc('foo/bar') - .collection('baz'); + .doc(`${COLLECTION}/bar`) + .collection(COLLECTION); const instance2 = firebase .firestore() - .collection('foo') + .collection(COLLECTION) .doc('bar') - .collection('baz'); + .collection(COLLECTION); should.equal(instance1.constructor.name, 'FirestoreCollectionReference'); should.equal(instance2.constructor.name, 'FirestoreCollectionReference'); - instance1.id.should.equal('baz'); - instance2.id.should.equal('baz'); + instance1.id.should.equal(COLLECTION); + instance2.id.should.equal(COLLECTION); }); }); diff --git a/packages/firestore/e2e/DocumentReference/delete.e2e.js b/packages/firestore/e2e/DocumentReference/delete.e2e.js index ee877fc931..29eda4ac8f 100644 --- a/packages/firestore/e2e/DocumentReference/delete.e2e.js +++ b/packages/firestore/e2e/DocumentReference/delete.e2e.js @@ -14,14 +14,13 @@ * limitations under the License. * */ - const { wipe } = require('../helpers'); +const COLLECTION = 'firestore'; describe('firestore.doc().delete()', () => { before(() => wipe()); - it('deletes a document', async () => { - const ref = firebase.firestore().doc('v6/deleteme'); + const ref = firebase.firestore().doc(`${COLLECTION}/deleteme`); await ref.set({ foo: 'bar' }); const snapshot1 = await ref.get(); snapshot1.id.should.equal('deleteme'); diff --git a/packages/firestore/e2e/DocumentReference/get.e2e.js b/packages/firestore/e2e/DocumentReference/get.e2e.js index 0c33170846..ccc0569a90 100644 --- a/packages/firestore/e2e/DocumentReference/get.e2e.js +++ b/packages/firestore/e2e/DocumentReference/get.e2e.js @@ -14,12 +14,11 @@ * limitations under the License. * */ - const { wipe } = require('../helpers'); +const COLLECTION = 'firestore'; describe('firestore.doc().get()', () => { before(() => wipe()); - it('throws if get options are not an object', () => { try { firebase @@ -49,7 +48,7 @@ describe('firestore.doc().get()', () => { }); it('gets data from default source', async () => { - const ref = firebase.firestore().doc('v6/get'); + const ref = firebase.firestore().doc(`${COLLECTION}/get`); const data = { foo: 'bar', bar: 123 }; await ref.set(data); const snapshot = await ref.get(); @@ -58,7 +57,7 @@ describe('firestore.doc().get()', () => { }); it('gets data from the server', async () => { - const ref = firebase.firestore().doc('v6/get'); + const ref = firebase.firestore().doc(`${COLLECTION}/get`); const data = { foo: 'bar', bar: 123 }; await ref.set(data); const snapshot = await ref.get({ source: 'server' }); @@ -68,7 +67,7 @@ describe('firestore.doc().get()', () => { }); it('gets data from cache', async () => { - const ref = firebase.firestore().doc('v6/get'); + const ref = firebase.firestore().doc(`${COLLECTION}/get`); const data = { foo: 'bar', bar: 123 }; await ref.set(data); const snapshot = await ref.get({ source: 'cache' }); diff --git a/packages/firestore/e2e/DocumentReference/isEqual.e2e.js b/packages/firestore/e2e/DocumentReference/isEqual.e2e.js index ab1b3e1c1f..47379eec2f 100644 --- a/packages/firestore/e2e/DocumentReference/isEqual.e2e.js +++ b/packages/firestore/e2e/DocumentReference/isEqual.e2e.js @@ -14,6 +14,7 @@ * limitations under the License. * */ +const COLLECTION = 'firestore'; describe('firestore.doc().isEqual()', () => { it('throws if other is not a DocumentReference', () => { @@ -30,11 +31,11 @@ describe('firestore.doc().isEqual()', () => { }); it('returns false when not equal', () => { - const docRef = firebase.firestore().doc('bar/baz'); + const docRef = firebase.firestore().doc(`${COLLECTION}/baz`); - const eql1 = docRef.isEqual(firebase.firestore().doc('bar/foo')); + const eql1 = docRef.isEqual(firebase.firestore().doc(`${COLLECTION}/foo`)); const eql2 = docRef.isEqual( - firebase.firestore(firebase.app('secondaryFromNative')).doc('bar/baz'), + firebase.firestore(firebase.app('secondaryFromNative')).doc(`${COLLECTION}/baz`), ); eql1.should.be.False(); @@ -42,10 +43,10 @@ describe('firestore.doc().isEqual()', () => { }); it('returns true when equal', () => { - const docRef = firebase.firestore().doc('bar/baz'); + const docRef = firebase.firestore().doc(`${COLLECTION}/baz`); const eql1 = docRef.isEqual(docRef); - const eql2 = docRef.isEqual(firebase.firestore().doc('bar/baz')); + const eql2 = docRef.isEqual(firebase.firestore().doc(`${COLLECTION}/baz`)); eql1.should.be.True(); eql2.should.be.True(); diff --git a/packages/firestore/e2e/DocumentReference/onSnapshot.e2e.js b/packages/firestore/e2e/DocumentReference/onSnapshot.e2e.js index 73ed95c4ae..924b5dd457 100644 --- a/packages/firestore/e2e/DocumentReference/onSnapshot.e2e.js +++ b/packages/firestore/e2e/DocumentReference/onSnapshot.e2e.js @@ -14,17 +14,17 @@ * limitations under the License. * */ - +const COLLECTION = 'firestore'; +const NO_RULE_COLLECTION = 'no_rules'; const { wipe } = require('../helpers'); describe('firestore().doc().onSnapshot()', () => { before(() => wipe()); - it('throws if no arguments are provided', () => { try { firebase .firestore() - .doc('v6/foo') + .doc(`${COLLECTION}/foo`) .onSnapshot(); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { @@ -36,7 +36,7 @@ describe('firestore().doc().onSnapshot()', () => { it('returns an unsubscribe function', () => { const unsub = firebase .firestore() - .doc('v6/foo') + .doc(`${COLLECTION}/foo`) .onSnapshot(() => {}); unsub.should.be.a.Function(); @@ -47,7 +47,7 @@ describe('firestore().doc().onSnapshot()', () => { const callback = sinon.spy(); const unsub = firebase .firestore() - .doc('v6/foo') + .doc(`${COLLECTION}/foo`) .onSnapshot(callback); await Utils.spyToBeCalledOnceAsync(callback); @@ -62,7 +62,7 @@ describe('firestore().doc().onSnapshot()', () => { const callback = sinon.spy(); const unsub = firebase .firestore() - .doc('nope/nope') + .doc(`${NO_RULE_COLLECTION}/nope`) .onSnapshot(callback); await Utils.spyToBeCalledOnceAsync(callback); @@ -79,7 +79,7 @@ describe('firestore().doc().onSnapshot()', () => { const onError = sinon.spy(); const unsub = firebase .firestore() - .doc('v6/foo') + .doc(`${COLLECTION}/foo`) .onSnapshot(onNext, onError); await Utils.spyToBeCalledOnceAsync(onNext); @@ -96,7 +96,7 @@ describe('firestore().doc().onSnapshot()', () => { const onError = sinon.spy(); const unsub = firebase .firestore() - .doc('nope/nope') + .doc(`${NO_RULE_COLLECTION}/nope`) .onSnapshot(onNext, onError); await Utils.spyToBeCalledOnceAsync(onError); @@ -115,7 +115,7 @@ describe('firestore().doc().onSnapshot()', () => { const onError = sinon.spy(); const unsub = firebase .firestore() - .doc('v6/foo') + .doc(`${COLLECTION}/foo`) .onSnapshot({ next: onNext, error: onError, @@ -135,7 +135,7 @@ describe('firestore().doc().onSnapshot()', () => { const onError = sinon.spy(); const unsub = firebase .firestore() - .doc('nope/nope') + .doc(`${NO_RULE_COLLECTION}/nope`) .onSnapshot({ next: onNext, error: onError, @@ -156,7 +156,7 @@ describe('firestore().doc().onSnapshot()', () => { const callback = sinon.spy(); const unsub = firebase .firestore() - .doc('v6/foo') + .doc(`${COLLECTION}/foo`) .onSnapshot( { includeMetadataChanges: false, @@ -176,7 +176,7 @@ describe('firestore().doc().onSnapshot()', () => { const callback = sinon.spy(); const unsub = firebase .firestore() - .doc('nope/nope') + .doc(`${NO_RULE_COLLECTION}/nope`) .onSnapshot( { includeMetadataChanges: false, @@ -197,7 +197,7 @@ describe('firestore().doc().onSnapshot()', () => { const onError = sinon.spy(); const unsub = firebase .firestore() - .doc('v6/foo') + .doc(`${COLLECTION}/foo`) .onSnapshot( { includeMetadataChanges: false, @@ -220,7 +220,7 @@ describe('firestore().doc().onSnapshot()', () => { const onError = sinon.spy(); const unsub = firebase .firestore() - .doc('nope/nope') + .doc(`${NO_RULE_COLLECTION}/nope`) .onSnapshot( { includeMetadataChanges: false, @@ -245,7 +245,7 @@ describe('firestore().doc().onSnapshot()', () => { const onError = sinon.spy(); const unsub = firebase .firestore() - .doc('v6/foo') + .doc(`${COLLECTION}/foo`) .onSnapshot( { includeMetadataChanges: false, @@ -270,7 +270,7 @@ describe('firestore().doc().onSnapshot()', () => { const onError = sinon.spy(); const unsub = firebase .firestore() - .doc('nope/nope') + .doc(`${NO_RULE_COLLECTION}/nope`) .onSnapshot( { includeMetadataChanges: false, @@ -295,7 +295,7 @@ describe('firestore().doc().onSnapshot()', () => { try { firebase .firestore() - .doc('nope/nope') + .doc(`${NO_RULE_COLLECTION}/nope`) .onSnapshot({ includeMetadataChanges: 123, }); @@ -312,7 +312,7 @@ describe('firestore().doc().onSnapshot()', () => { try { firebase .firestore() - .doc('nope/nope') + .doc(`${NO_RULE_COLLECTION}/nope`) .onSnapshot({ next: 'foo', }); @@ -327,7 +327,7 @@ describe('firestore().doc().onSnapshot()', () => { try { firebase .firestore() - .doc('nope/nope') + .doc(`${NO_RULE_COLLECTION}/nope`) .onSnapshot({ error: 'foo', }); @@ -340,7 +340,7 @@ describe('firestore().doc().onSnapshot()', () => { it('unsubscribes from further updates', async () => { const callback = sinon.spy(); - const doc = firebase.firestore().doc('v6/unsub'); + const doc = firebase.firestore().doc(`${COLLECTION}/unsub`); const unsub = doc.onSnapshot(callback); await Utils.spyToBeCalledOnceAsync(callback); diff --git a/packages/firestore/e2e/DocumentReference/properties.e2e.js b/packages/firestore/e2e/DocumentReference/properties.e2e.js index 4a98f04001..ea7d57d9ec 100644 --- a/packages/firestore/e2e/DocumentReference/properties.e2e.js +++ b/packages/firestore/e2e/DocumentReference/properties.e2e.js @@ -15,29 +15,31 @@ * */ +const COLLECTION = 'firestore'; + describe('firestore.doc()', () => { it('returns a Firestore instance', () => { - const instance = firebase.firestore().doc('foo/bar'); + const instance = firebase.firestore().doc(`${COLLECTION}/bar`); should.equal(instance.firestore.constructor.name, 'FirebaseFirestoreModule'); }); it('returns the document id', () => { - const instance = firebase.firestore().doc('foo/bar'); + const instance = firebase.firestore().doc(`${COLLECTION}/bar`); instance.id.should.equal('bar'); }); it('returns the parent collection reference', () => { - const instance = firebase.firestore().doc('foo/bar'); - instance.parent.id.should.equal('foo'); + const instance = firebase.firestore().doc(`${COLLECTION}/bar`); + instance.parent.id.should.equal(COLLECTION); }); it('returns the path', () => { - const instance1 = firebase.firestore().doc('foo/bar'); + const instance1 = firebase.firestore().doc(`${COLLECTION}/bar`); const instance2 = firebase .firestore() - .collection('foo') + .collection(COLLECTION) .doc('bar'); - instance1.path.should.equal('foo/bar'); - instance2.path.should.equal('foo/bar'); + instance1.path.should.equal(`${COLLECTION}/bar`); + instance2.path.should.equal(`${COLLECTION}/bar`); }); }); diff --git a/packages/firestore/e2e/DocumentReference/set.e2e.js b/packages/firestore/e2e/DocumentReference/set.e2e.js index d918e5108d..a4a800e086 100644 --- a/packages/firestore/e2e/DocumentReference/set.e2e.js +++ b/packages/firestore/e2e/DocumentReference/set.e2e.js @@ -14,17 +14,16 @@ * limitations under the License. * */ - const { wipe } = require('../helpers'); +const COLLECTION = 'firestore'; describe('firestore.doc().set()', () => { before(() => wipe()); - it('throws if data is not an object', () => { try { firebase .firestore() - .doc('bar/baz') + .doc(`${COLLECTION}/baz`) .set('foo'); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { @@ -37,7 +36,7 @@ describe('firestore.doc().set()', () => { try { firebase .firestore() - .doc('bar/baz') + .doc(`${COLLECTION}/baz`) .set({}, 'foo'); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { @@ -50,7 +49,7 @@ describe('firestore.doc().set()', () => { try { firebase .firestore() - .doc('bar/baz') + .doc(`${COLLECTION}/baz`) .set( {}, { @@ -69,7 +68,7 @@ describe('firestore.doc().set()', () => { try { firebase .firestore() - .doc('bar/baz') + .doc(`${COLLECTION}/baz`) .set( {}, { @@ -87,7 +86,7 @@ describe('firestore.doc().set()', () => { try { firebase .firestore() - .doc('bar/baz') + .doc(`${COLLECTION}/baz`) .set( {}, { @@ -105,11 +104,16 @@ describe('firestore.doc().set()', () => { try { firebase .firestore() - .doc('bar/baz') + .doc(`${COLLECTION}/baz`) .set( {}, { - mergeFields: ['foo', 'foo.bar', new firebase.firestore.FieldPath('bar', 'baz'), 123], + mergeFields: [ + 'foo', + 'foo.bar', + new firebase.firestore.FieldPath(COLLECTION, 'baz'), + 123, + ], }, ); return Promise.reject(new Error('Did not throw an Error.')); @@ -122,7 +126,7 @@ describe('firestore.doc().set()', () => { }); it('sets new data', async () => { - const ref = firebase.firestore().doc('v6/set'); + const ref = firebase.firestore().doc(`${COLLECTION}/set`); const data1 = { foo: 'bar' }; const data2 = { foo: 'baz', bar: 123 }; await ref.set(data1); @@ -135,7 +139,7 @@ describe('firestore.doc().set()', () => { }); it('merges all fields', async () => { - const ref = firebase.firestore().doc('v6/merge'); + const ref = firebase.firestore().doc(`${COLLECTION}/merge`); const data1 = { foo: 'bar' }; const data2 = { bar: 'baz' }; const merged = { ...data1, ...data2 }; @@ -151,7 +155,7 @@ describe('firestore.doc().set()', () => { }); it('merges specific fields', async () => { - const ref = firebase.firestore().doc('v6/merge'); + const ref = firebase.firestore().doc(`${COLLECTION}/merge`); const data1 = { foo: '123', bar: 123, baz: '456' }; const data2 = { foo: '234', bar: 234, baz: '678' }; const merged = { foo: data1.foo, bar: data2.bar, baz: data2.baz }; diff --git a/packages/firestore/e2e/DocumentReference/update.e2e.js b/packages/firestore/e2e/DocumentReference/update.e2e.js index 7a1ccc528b..bd17379470 100644 --- a/packages/firestore/e2e/DocumentReference/update.e2e.js +++ b/packages/firestore/e2e/DocumentReference/update.e2e.js @@ -14,17 +14,16 @@ * limitations under the License. * */ - const { wipe } = require('../helpers'); +const COLLECTION = 'firestore'; describe('firestore.doc().update()', () => { before(() => wipe()); - it('throws if no arguments are provided', () => { try { firebase .firestore() - .doc('bar/baz') + .doc(`${COLLECTION}/baz`) .update(); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { @@ -39,7 +38,7 @@ describe('firestore.doc().update()', () => { try { await firebase .firestore() - .doc('v6/idonotexistonthedatabase') + .doc(`${COLLECTION}/idonotexistonthedatabase`) .update({}); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { @@ -52,7 +51,7 @@ describe('firestore.doc().update()', () => { try { firebase .firestore() - .doc('bar/baz') + .doc(`${COLLECTION}/baz`) .update('foo', 'bar', 'baz'); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { @@ -62,7 +61,7 @@ describe('firestore.doc().update()', () => { }); it('updates data with an object value', async () => { - const ref = firebase.firestore().doc('v6/update-obj'); + const ref = firebase.firestore().doc(`${COLLECTION}/update-obj`); const value = Date.now(); const data1 = { foo: value }; const data2 = { foo: 'bar' }; @@ -76,7 +75,7 @@ describe('firestore.doc().update()', () => { }); it('updates data with an key/value pairs', async () => { - const ref = firebase.firestore().doc('v6/update-obj'); + const ref = firebase.firestore().doc(`${COLLECTION}/update-obj`); const value = Date.now(); const data1 = { foo: value, bar: value }; await ref.set(data1); diff --git a/packages/firestore/e2e/DocumentSnapshot/data.e2e.js b/packages/firestore/e2e/DocumentSnapshot/data.e2e.js index 7fc9188d20..349fbc8553 100644 --- a/packages/firestore/e2e/DocumentSnapshot/data.e2e.js +++ b/packages/firestore/e2e/DocumentSnapshot/data.e2e.js @@ -14,8 +14,8 @@ * limitations under the License. * */ - const { wipe } = require('../helpers'); +const COLLECTION = 'firestore'; // Used to create a Blob const blobObject = { hello: 'world' }; @@ -25,15 +25,14 @@ const blobBase64 = blobBuffer.toString('base64'); describe('firestore().doc() -> snapshot.data()', () => { before(() => wipe()); - it('returns undefined if documet does not exist', async () => { - const ref = firebase.firestore().doc('v6/idonotexist'); + const ref = firebase.firestore().doc(`${COLLECTION}/idonotexist`); const snapshot = await ref.get(); should.equal(snapshot.data(), undefined); }); it('returns an object if exists', async () => { - const ref = firebase.firestore().doc('v6/getData'); + const ref = firebase.firestore().doc(`${COLLECTION}/getData`); const data = { foo: 'bar' }; await ref.set(data); const snapshot = await ref.get(); @@ -42,7 +41,7 @@ describe('firestore().doc() -> snapshot.data()', () => { }); it('returns an object when document is empty', async () => { - const ref = firebase.firestore().doc('v6/getData'); + const ref = firebase.firestore().doc(`${COLLECTION}/getData`); const data = {}; await ref.set(data); const snapshot = await ref.get(); @@ -70,7 +69,7 @@ describe('firestore().doc() -> snapshot.data()', () => { timestamp: new firebase.firestore.Timestamp(123, 123456), date: new Date(), geopoint: new firebase.firestore.GeoPoint(1, 2), - reference: firebase.firestore().doc('v6/foobar'), + reference: firebase.firestore().doc(`${COLLECTION}/foobar`), blob: firebase.firestore.Blob.fromBase64String(blobBase64), }; @@ -79,7 +78,7 @@ describe('firestore().doc() -> snapshot.data()', () => { types.map = map; types.array = array; - const ref = firebase.firestore().doc('v6/types'); + const ref = firebase.firestore().doc(`${COLLECTION}/types`); await ref.set(types); const snapshot = await ref.get(); const data = snapshot.data(); @@ -131,7 +130,7 @@ describe('firestore().doc() -> snapshot.data()', () => { // Reference // data.reference.should.be.an.instanceOf(); - data.reference.path.should.equal('v6/foobar'); + data.reference.path.should.equal(`${COLLECTION}/foobar`); // Blob data.blob.toBase64.should.be.a.Function(); diff --git a/packages/firestore/e2e/DocumentSnapshot/get.e2e.js b/packages/firestore/e2e/DocumentSnapshot/get.e2e.js index 949176d958..4034b02d4e 100644 --- a/packages/firestore/e2e/DocumentSnapshot/get.e2e.js +++ b/packages/firestore/e2e/DocumentSnapshot/get.e2e.js @@ -14,14 +14,13 @@ * limitations under the License. * */ - const { wipe } = require('../helpers'); +const COLLECTION = 'firestore'; describe('firestore().doc() -> snapshot.get()', () => { before(() => wipe()); - it('throws if invalid fieldPath argument', async () => { - const ref = firebase.firestore().doc('v6/foo'); + const ref = firebase.firestore().doc(`${COLLECTION}/foo`); const snapshot = await ref.get(); try { @@ -34,7 +33,7 @@ describe('firestore().doc() -> snapshot.get()', () => { }); it('throws if fieldPath is an empty string', async () => { - const ref = firebase.firestore().doc('v6/foo'); + const ref = firebase.firestore().doc(`${COLLECTION}/foo`); const snapshot = await ref.get(); try { @@ -47,7 +46,7 @@ describe('firestore().doc() -> snapshot.get()', () => { }); it('throws if fieldPath starts with a period (.)', async () => { - const ref = firebase.firestore().doc('v6/foo'); + const ref = firebase.firestore().doc(`${COLLECTION}/foo`); const snapshot = await ref.get(); try { @@ -60,7 +59,7 @@ describe('firestore().doc() -> snapshot.get()', () => { }); it('throws if fieldPath ends with a period (.)', async () => { - const ref = firebase.firestore().doc('v6/foo'); + const ref = firebase.firestore().doc(`${COLLECTION}/foo`); const snapshot = await ref.get(); try { @@ -73,7 +72,7 @@ describe('firestore().doc() -> snapshot.get()', () => { }); it('throws if fieldPath contains ..', async () => { - const ref = firebase.firestore().doc('v6/foo'); + const ref = firebase.firestore().doc(`${COLLECTION}/foo`); const snapshot = await ref.get(); try { @@ -86,7 +85,7 @@ describe('firestore().doc() -> snapshot.get()', () => { }); it('returns undefined if the data does not exist', async () => { - const ref = firebase.firestore().doc('v6/foo'); + const ref = firebase.firestore().doc(`${COLLECTION}/foo`); const snapshot = await ref.get(); const val1 = snapshot.get('foo'); @@ -103,7 +102,7 @@ describe('firestore().doc() -> snapshot.get()', () => { }); it('returns the correct data with string fieldPath', async () => { - const ref = firebase.firestore().doc('v6/foo'); + const ref = firebase.firestore().doc(`${COLLECTION}/foo`); const types = { string: '12345', number: 1234, @@ -133,7 +132,7 @@ describe('firestore().doc() -> snapshot.get()', () => { }); it('returns the correct data with FieldPath', async () => { - const ref = firebase.firestore().doc('v6/foo'); + const ref = firebase.firestore().doc(`${COLLECTION}/foo`); const types = { string: '12345', number: 1234, diff --git a/packages/firestore/e2e/DocumentSnapshot/isEqual.e2e.js b/packages/firestore/e2e/DocumentSnapshot/isEqual.e2e.js index e6f170ea49..c875637d99 100644 --- a/packages/firestore/e2e/DocumentSnapshot/isEqual.e2e.js +++ b/packages/firestore/e2e/DocumentSnapshot/isEqual.e2e.js @@ -14,11 +14,12 @@ * limitations under the License. * */ +const COLLECTION = 'firestore'; describe('firestore.doc() -> snapshot.isEqual()', () => { it('throws if other is not a DocumentSnapshot', async () => { try { - const docRef = firebase.firestore().doc('v6/baz'); + const docRef = firebase.firestore().doc(`${COLLECTION}/baz`); const docSnapshot = await docRef.get(); docSnapshot.isEqual(123); @@ -30,13 +31,13 @@ describe('firestore.doc() -> snapshot.isEqual()', () => { }); it('returns false when not equal', async () => { - const docRef = firebase.firestore().doc('v6/isEqual-false-exists'); + const docRef = firebase.firestore().doc(`${COLLECTION}/isEqual-false-exists`); await docRef.set({ foo: 'bar' }); const docSnapshot1 = await docRef.get(); const docSnapshot2 = await firebase .firestore() - .doc('v6/idonotexist') + .doc(`${COLLECTION}/idonotexist`) .get(); await docRef.set({ foo: 'baz' }); const docSnapshot3 = await docRef.get(); @@ -49,7 +50,7 @@ describe('firestore.doc() -> snapshot.isEqual()', () => { }); it('returns true when equal', async () => { - const docRef = firebase.firestore().doc('v6/isEqual-true-exists'); + const docRef = firebase.firestore().doc(`${COLLECTION}/isEqual-true-exists`); await docRef.set({ foo: 'bar' }); const docSnapshot = await docRef.get(); diff --git a/packages/firestore/e2e/DocumentSnapshot/properties.e2e.js b/packages/firestore/e2e/DocumentSnapshot/properties.e2e.js index 65242de93a..2d1e83c8d1 100644 --- a/packages/firestore/e2e/DocumentSnapshot/properties.e2e.js +++ b/packages/firestore/e2e/DocumentSnapshot/properties.e2e.js @@ -14,15 +14,14 @@ * limitations under the License. * */ - const { wipe } = require('../helpers'); +const COLLECTION = 'firestore'; describe('firestore().doc() -> snapshot', () => { before(() => wipe()); - it('.exists -> returns a boolean for exists', async () => { - const ref1 = firebase.firestore().doc('v6/exists'); - const ref2 = firebase.firestore().doc('v6/idonotexist'); + const ref1 = firebase.firestore().doc(`${COLLECTION}/exists`); + const ref2 = firebase.firestore().doc(`${COLLECTION}/idonotexist`); await ref1.set({ foo: ' bar' }); const snapshot1 = await ref1.get(); const snapshot2 = await ref2.get(); @@ -33,8 +32,8 @@ describe('firestore().doc() -> snapshot', () => { }); it('.id -> returns the correct id', async () => { - const ref1 = firebase.firestore().doc('v6/exists'); - const ref2 = firebase.firestore().doc('v6/idonotexist'); + const ref1 = firebase.firestore().doc(`${COLLECTION}/exists`); + const ref2 = firebase.firestore().doc(`${COLLECTION}/idonotexist`); await ref1.set({ foo: ' bar' }); const snapshot1 = await ref1.get(); const snapshot2 = await ref2.get(); @@ -45,20 +44,20 @@ describe('firestore().doc() -> snapshot', () => { }); it('.metadata -> returns a SnapshotMetadata instance', async () => { - const ref = firebase.firestore().doc('v6/exists'); + const ref = firebase.firestore().doc(`${COLLECTION}/exists`); const snapshot = await ref.get(); snapshot.metadata.constructor.name.should.eql('FirestoreSnapshotMetadata'); }); it('.ref -> returns the correct document ref', async () => { - const ref1 = firebase.firestore().doc('v6/exists'); - const ref2 = firebase.firestore().doc('v6/idonotexist'); + const ref1 = firebase.firestore().doc(`${COLLECTION}/exists`); + const ref2 = firebase.firestore().doc(`${COLLECTION}/idonotexist`); await ref1.set({ foo: ' bar' }); const snapshot1 = await ref1.get(); const snapshot2 = await ref2.get(); - snapshot1.ref.path.should.equal('v6/exists'); - snapshot2.ref.path.should.equal('v6/idonotexist'); + snapshot1.ref.path.should.equal(`${COLLECTION}/exists`); + snapshot2.ref.path.should.equal(`${COLLECTION}/idonotexist`); await ref1.delete(); }); }); diff --git a/packages/firestore/e2e/FieldPath.e2e.js b/packages/firestore/e2e/FieldPath.e2e.js index d2c5c9b2e7..ad9ba21720 100644 --- a/packages/firestore/e2e/FieldPath.e2e.js +++ b/packages/firestore/e2e/FieldPath.e2e.js @@ -14,6 +14,7 @@ * limitations under the License. * */ +const COLLECTION = 'firestore'; describe('firestore.FieldPath', () => { it('should throw if no segments', () => { @@ -51,7 +52,7 @@ describe('firestore.FieldPath', () => { // Dummy create firebase .firestore() - .collection('foo') + .collection(COLLECTION) .where('.foo', '<', 123); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { @@ -65,7 +66,7 @@ describe('firestore.FieldPath', () => { // Dummy create firebase .firestore() - .collection('foo') + .collection(COLLECTION) .where('foo/bar', '<', 123); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { diff --git a/packages/firestore/e2e/FieldValue.e2e.js b/packages/firestore/e2e/FieldValue.e2e.js index 809f50922c..214e53bc9c 100644 --- a/packages/firestore/e2e/FieldValue.e2e.js +++ b/packages/firestore/e2e/FieldValue.e2e.js @@ -14,12 +14,11 @@ * limitations under the License. * */ - const { wipe } = require('./helpers'); +const COLLECTION = 'firestore'; describe('firestore.FieldValue', () => { before(() => wipe()); - it('should throw if constructed manually', () => { try { new firebase.firestore.FieldValue(); @@ -77,7 +76,7 @@ describe('firestore.FieldValue', () => { }); it('increments a number if it exists', async () => { - const ref = firebase.firestore().doc('v6/increment'); + const ref = firebase.firestore().doc(`${COLLECTION}/increment`); await ref.set({ foo: 2 }); await ref.update({ foo: firebase.firestore.FieldValue.increment(1) }); const snapshot = await ref.get(); @@ -86,7 +85,7 @@ describe('firestore.FieldValue', () => { }); it('sets the value if it doesnt exist or being set', async () => { - const ref = firebase.firestore().doc('v6/increment'); + const ref = firebase.firestore().doc(`${COLLECTION}/increment`); await ref.set({ foo: firebase.firestore.FieldValue.increment(1) }); const snapshot = await ref.get(); snapshot.data().foo.should.equal(1); @@ -96,7 +95,7 @@ describe('firestore.FieldValue', () => { describe('serverTime()', () => { it('sets a new server time value', async () => { - const ref = firebase.firestore().doc('v6/servertime'); + const ref = firebase.firestore().doc(`${COLLECTION}/servertime`); await ref.set({ foo: firebase.firestore.FieldValue.serverTimestamp() }); const snapshot = await ref.get(); snapshot.data().foo.seconds.should.be.a.Number(); @@ -104,7 +103,7 @@ describe('firestore.FieldValue', () => { }); it('updates a server time value', async () => { - const ref = firebase.firestore().doc('v6/servertime'); + const ref = firebase.firestore().doc(`${COLLECTION}/servertime`); await ref.set({ foo: firebase.firestore.FieldValue.serverTimestamp() }); const snapshot1 = await ref.get(); snapshot1.data().foo.nanoseconds.should.be.a.Number(); @@ -120,7 +119,7 @@ describe('firestore.FieldValue', () => { describe('delete()', () => { it('removes a value', async () => { - const ref = firebase.firestore().doc('v6/valuedelete'); + const ref = firebase.firestore().doc(`${COLLECTION}/valuedelete`); await ref.set({ foo: 'bar', bar: 'baz' }); await ref.update({ bar: firebase.firestore.FieldValue.delete() }); const snapshot = await ref.get(); @@ -153,7 +152,7 @@ describe('firestore.FieldValue', () => { }); it('updates an existing array', async () => { - const ref = firebase.firestore().doc('v6/arrayunion'); + const ref = firebase.firestore().doc(`${COLLECTION}/arrayunion`); await ref.set({ foo: [1, 2], }); @@ -167,7 +166,7 @@ describe('firestore.FieldValue', () => { }); it('sets an array if existing value isnt an array with update', async () => { - const ref = firebase.firestore().doc('v6/arrayunion'); + const ref = firebase.firestore().doc(`${COLLECTION}/arrayunion`); await ref.set({ foo: 123, }); @@ -181,7 +180,7 @@ describe('firestore.FieldValue', () => { }); it('sets an existing array to the new array with set', async () => { - const ref = firebase.firestore().doc('v6/arrayunion'); + const ref = firebase.firestore().doc(`${COLLECTION}/arrayunion`); await ref.set({ foo: [1, 2], }); @@ -219,7 +218,7 @@ describe('firestore.FieldValue', () => { }); it('removes items in an array', async () => { - const ref = firebase.firestore().doc('v6/arrayremove'); + const ref = firebase.firestore().doc(`${COLLECTION}/arrayremove`); await ref.set({ foo: [1, 2, 3, 4], }); @@ -233,7 +232,7 @@ describe('firestore.FieldValue', () => { }); it('removes all items in the array if existing value isnt array with update', async () => { - const ref = firebase.firestore().doc('v6/arrayunion'); + const ref = firebase.firestore().doc(`${COLLECTION}/arrayunion`); await ref.set({ foo: 123, }); @@ -247,7 +246,7 @@ describe('firestore.FieldValue', () => { }); it('removes all items in the array if existing value isnt array with set', async () => { - const ref = firebase.firestore().doc('v6/arrayunion'); + const ref = firebase.firestore().doc(`${COLLECTION}/arrayunion`); await ref.set({ foo: 123, }); diff --git a/packages/firestore/e2e/GeoPoint.e2e.js b/packages/firestore/e2e/GeoPoint.e2e.js index 52e179cfe4..658980e058 100644 --- a/packages/firestore/e2e/GeoPoint.e2e.js +++ b/packages/firestore/e2e/GeoPoint.e2e.js @@ -14,12 +14,10 @@ * limitations under the License. * */ - +const COLLECTION = 'firestore'; const { wipe } = require('./helpers'); - describe('firestore.GeoPoint', () => { before(() => wipe()); - it('throws if invalid number of arguments', () => { try { new firebase.firestore.GeoPoint(123); @@ -106,9 +104,8 @@ describe('firestore.GeoPoint', () => { equal.should.equal(true); }); }); - it('sets & returns correctly', async () => { - const ref = firebase.firestore().doc('v6/geopoint'); + const ref = firebase.firestore().doc(`${COLLECTION}/geopoint`); await ref.set({ geopoint: new firebase.firestore.GeoPoint(20, 30), }); diff --git a/packages/firestore/e2e/Query/endAt.e2e.js b/packages/firestore/e2e/Query/endAt.e2e.js index 381f8530c4..b174834778 100644 --- a/packages/firestore/e2e/Query/endAt.e2e.js +++ b/packages/firestore/e2e/Query/endAt.e2e.js @@ -14,17 +14,16 @@ * limitations under the License. * */ - const { wipe } = require('../helpers'); +const COLLECTION = 'firestore'; describe('firestore().collection().endAt()', () => { before(() => wipe()); - it('throws if no argument provided', () => { try { firebase .firestore() - .collection('v6') + .collection(COLLECTION) .endAt(); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { @@ -39,7 +38,7 @@ describe('firestore().collection().endAt()', () => { try { firebase .firestore() - .collection('v6') + .collection(COLLECTION) .orderBy('foo') .endAt('bar', 'baz'); return Promise.reject(new Error('Did not throw an Error.')); @@ -53,11 +52,12 @@ describe('firestore().collection().endAt()', () => { try { const doc = await firebase .firestore() - .doc('v6/foo') + .collection(COLLECTION) + .doc('foo') .get(); firebase .firestore() - .collection('v6') + .collection(COLLECTION) .endAt(doc, 'baz'); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { @@ -70,11 +70,11 @@ describe('firestore().collection().endAt()', () => { try { const doc = await firebase .firestore() - .doc('v6/idonotexist') + .doc(`${COLLECTION}/idonotexist`) .get(); firebase .firestore() - .collection('v6') + .collection(COLLECTION) .endAt(doc); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { @@ -85,13 +85,13 @@ describe('firestore().collection().endAt()', () => { it('throws if order used with snapshot but fields do not exist', async () => { try { - const doc = firebase.firestore().doc('v6/iexist'); + const doc = firebase.firestore().doc(`${COLLECTION}/iexist`); await doc.set({ foo: { bar: 'baz' } }); const snap = await doc.get(); firebase .firestore() - .collection('v6') + .collection(COLLECTION) .orderBy('foo.baz') .endAt(snap); return Promise.reject(new Error('Did not throw an Error.')); @@ -104,7 +104,7 @@ describe('firestore().collection().endAt()', () => { }); it('ends at field values', async () => { - const colRef = firebase.firestore().collection('v6/endsAt/collection'); + const colRef = firebase.firestore().collection(`${COLLECTION}/endsAt/collection`); const doc1 = colRef.doc('doc1'); const doc2 = colRef.doc('doc2'); const doc3 = colRef.doc('doc3'); @@ -127,7 +127,7 @@ describe('firestore().collection().endAt()', () => { it('ends at snapshot field values', async () => { // await Utils.sleep(3000); - const colRef = firebase.firestore().collection('v6/endsAt/snapshotFields'); + const colRef = firebase.firestore().collection(`${COLLECTION}/endsAt/snapshotFields`); const doc1 = colRef.doc('doc1'); const doc2 = colRef.doc('doc2'); const doc3 = colRef.doc('doc3'); @@ -151,7 +151,7 @@ describe('firestore().collection().endAt()', () => { }); it('ends at snapshot', async () => { - const colRef = firebase.firestore().collection('v6/endsAt/snapshot'); + const colRef = firebase.firestore().collection(`${COLLECTION}/endsAt/snapshot`); const doc1 = colRef.doc('doc1'); const doc2 = colRef.doc('doc2'); const doc3 = colRef.doc('doc3'); diff --git a/packages/firestore/e2e/Query/endBefore.e2e.js b/packages/firestore/e2e/Query/endBefore.e2e.js index d985d8c668..310d572e30 100644 --- a/packages/firestore/e2e/Query/endBefore.e2e.js +++ b/packages/firestore/e2e/Query/endBefore.e2e.js @@ -14,8 +14,8 @@ * limitations under the License. * */ - const { wipe } = require('../helpers'); +const COLLECTION = 'firestore'; describe('firestore().collection().endBefore()', () => { before(() => wipe()); @@ -24,7 +24,7 @@ describe('firestore().collection().endBefore()', () => { try { firebase .firestore() - .collection('v6') + .collection(COLLECTION) .endBefore(); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { @@ -39,7 +39,7 @@ describe('firestore().collection().endBefore()', () => { try { firebase .firestore() - .collection('v6') + .collection(COLLECTION) .orderBy('foo') .endBefore('bar', 'baz'); return Promise.reject(new Error('Did not throw an Error.')); @@ -53,11 +53,12 @@ describe('firestore().collection().endBefore()', () => { try { const doc = await firebase .firestore() - .doc('v6/foo') + .doc(`${COLLECTION}/stuff`) .get(); + firebase .firestore() - .collection('v6') + .collection(COLLECTION) .endBefore(doc, 'baz'); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { @@ -70,11 +71,11 @@ describe('firestore().collection().endBefore()', () => { try { const doc = await firebase .firestore() - .doc('v6/idonotexist') + .doc(`${COLLECTION}/idonotexist`) .get(); firebase .firestore() - .collection('v6') + .collection(COLLECTION) .endBefore(doc); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { @@ -85,13 +86,13 @@ describe('firestore().collection().endBefore()', () => { it('throws if order used with snapshot but fields do not exist', async () => { try { - const doc = firebase.firestore().doc('v6/iexist'); + const doc = firebase.firestore().doc(`${COLLECTION}/iexist`); await doc.set({ foo: { bar: 'baz' } }); const snap = await doc.get(); firebase .firestore() - .collection('v6') + .collection(COLLECTION) .orderBy('foo.baz') .endBefore(snap); return Promise.reject(new Error('Did not throw an Error.')); @@ -104,7 +105,7 @@ describe('firestore().collection().endBefore()', () => { }); it('ends before field values', async () => { - const colRef = firebase.firestore().collection('v6/endBefore/collection'); + const colRef = firebase.firestore().collection(`${COLLECTION}/endBefore/collection`); const doc1 = colRef.doc('doc1'); const doc2 = colRef.doc('doc2'); const doc3 = colRef.doc('doc3'); @@ -124,8 +125,8 @@ describe('firestore().collection().endBefore()', () => { qs.docs[0].id.should.eql('doc3'); }); - it('ends before snapshot field values', async () => { - const colRef = firebase.firestore().collection('v6/endBefore/snapshotFields'); + xit('ends before snapshot field values', async () => { + const colRef = firebase.firestore().collection(`${COLLECTION}/endBefore/snapshotFields`); const doc1 = colRef.doc('doc1'); const doc2 = colRef.doc('doc2'); const doc3 = colRef.doc('doc3'); @@ -148,7 +149,7 @@ describe('firestore().collection().endBefore()', () => { }); it('ends before snapshot', async () => { - const colRef = firebase.firestore().collection('v6/endBefore/snapshot'); + const colRef = firebase.firestore().collection(`${COLLECTION}/endBefore/snapshot`); const doc1 = colRef.doc('doc1'); const doc2 = colRef.doc('doc2'); const doc3 = colRef.doc('doc3'); diff --git a/packages/firestore/e2e/Query/get.e2e.js b/packages/firestore/e2e/Query/get.e2e.js index f84f25ce5a..ec2f87c8af 100644 --- a/packages/firestore/e2e/Query/get.e2e.js +++ b/packages/firestore/e2e/Query/get.e2e.js @@ -14,17 +14,16 @@ * limitations under the License. * */ - const { wipe } = require('../helpers'); +const COLLECTION = 'firestore'; describe('firestore().collection().get()', () => { before(() => wipe()); - it('throws if get options is not an object', () => { try { firebase .firestore() - .collection('v6') + .collection(COLLECTION) .get(123); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { @@ -37,7 +36,7 @@ describe('firestore().collection().get()', () => { try { firebase .firestore() - .collection('v6') + .collection(COLLECTION) .get({ source: 'foo', }); @@ -53,7 +52,7 @@ describe('firestore().collection().get()', () => { it('returns a QuerySnapshot', async () => { const docRef = firebase .firestore() - .collection('v6') + .collection(COLLECTION) .doc('nestedcollection'); const colRef = docRef.collection('get'); const snapshot = await colRef.get(); @@ -64,7 +63,7 @@ describe('firestore().collection().get()', () => { it('returns a correct cache setting (true)', async () => { const docRef = firebase .firestore() - .collection('v6') + .collection(COLLECTION) .doc('nestedcollection'); const colRef = docRef.collection('get'); const snapshot = await colRef.get({ @@ -78,7 +77,7 @@ describe('firestore().collection().get()', () => { it('returns a correct cache setting (false)', async () => { const docRef = firebase .firestore() - .collection('v6') + .collection(COLLECTION) .doc('nestedcollection'); const colRef = docRef.collection('get'); await colRef.get(); // Puts it in cache diff --git a/packages/firestore/e2e/Query/isEqual.e2e.js b/packages/firestore/e2e/Query/isEqual.e2e.js index 4d35cfab20..ae1d061a1d 100644 --- a/packages/firestore/e2e/Query/isEqual.e2e.js +++ b/packages/firestore/e2e/Query/isEqual.e2e.js @@ -14,13 +14,14 @@ * limitations under the License. * */ +const COLLECTION = 'firestore'; describe('firestore().collection().isEqual()', () => { it('throws if other is not a Query', () => { try { firebase .firestore() - .collection('v6') + .collection(COLLECTION) .isEqual(123); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { @@ -30,29 +31,30 @@ describe('firestore().collection().isEqual()', () => { }); it('returns false when not equal (simple checks)', () => { - const query = firebase.firestore().collection('v6'); + const subCol = `${COLLECTION}/isequal/simplechecks`; + const query = firebase.firestore().collection(subCol); - const q1 = firebase.firestore(firebase.app('secondaryFromNative')).collection('v6'); + const q1 = firebase.firestore(firebase.app('secondaryFromNative')).collection(subCol); const q2 = firebase .firestore() - .collection('v6') + .collection(subCol) .where('foo', '==', 'bar'); const q3 = firebase .firestore() - .collection('v6') + .collection(subCol) .orderBy('foo'); const q4 = firebase .firestore() - .collection('v6') + .collection(subCol) .limit(3); const ref1 = firebase .firestore() - .collection('foo') + .collection(subCol) .where('bar', '==', true); const ref2 = firebase .firestore() - .collection('baz') + .collection(subCol) .where('bar', '==', true); const eql1 = query.isEqual(q1); @@ -65,13 +67,13 @@ describe('firestore().collection().isEqual()', () => { eql2.should.be.False(); eql3.should.be.False(); eql4.should.be.False(); - eql5.should.be.False(); + eql5.should.be.True(); }); it('returns false when not equal (expensive checks)', () => { const query = firebase .firestore() - .collection('v6') + .collection(COLLECTION) .where('foo', '==', 'bar') .orderBy('bam') .limit(1) @@ -79,7 +81,7 @@ describe('firestore().collection().isEqual()', () => { const q1 = firebase .firestore() - .collection('v6') + .collection(COLLECTION) .where('foo', '<', 'bar') .orderBy('foo') .limit(1) @@ -87,7 +89,7 @@ describe('firestore().collection().isEqual()', () => { const q2 = firebase .firestore() - .collection('v6') + .collection(COLLECTION) .where('foo', '==', 'bar') .orderBy('foob') .limit(1) @@ -95,7 +97,7 @@ describe('firestore().collection().isEqual()', () => { const q3 = firebase .firestore() - .collection('v6') + .collection(COLLECTION) .where('foo', '==', 'bar') .orderBy('baz') .limit(2) @@ -103,7 +105,7 @@ describe('firestore().collection().isEqual()', () => { const q4 = firebase .firestore() - .collection('v6') + .collection(COLLECTION) .where('foo', '==', 'bar') .orderBy('baz') .limit(1) @@ -123,7 +125,7 @@ describe('firestore().collection().isEqual()', () => { it('returns true when equal', () => { const query = firebase .firestore() - .collection('v6') + .collection(COLLECTION) .where('foo', '==', 'bar') .orderBy('baz') .limit(1) @@ -131,7 +133,7 @@ describe('firestore().collection().isEqual()', () => { const query2 = firebase .firestore() - .collection('v6') + .collection(COLLECTION) .where('foo', '==', 'bar') .orderBy('baz') .limit(1) diff --git a/packages/firestore/e2e/Query/limit.e2e.js b/packages/firestore/e2e/Query/limit.e2e.js index 83c38607e5..3f92546902 100644 --- a/packages/firestore/e2e/Query/limit.e2e.js +++ b/packages/firestore/e2e/Query/limit.e2e.js @@ -14,17 +14,16 @@ * limitations under the License. * */ - const { wipe } = require('../helpers'); +const COLLECTION = 'firestore'; describe('firestore().collection().limit()', () => { before(() => wipe()); - it('throws if limit is invalid', () => { try { firebase .firestore() - .collection('v6') + .collection(COLLECTION) .limit(-1); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { @@ -36,14 +35,14 @@ describe('firestore().collection().limit()', () => { it('sets limit on internals', async () => { const colRef = firebase .firestore() - .collection('v6') + .collection(COLLECTION) .limit(123); colRef._modifiers.options.limit.should.eql(123); }); it('limits the number of documents', async () => { - const colRef = firebase.firestore().collection('v6'); + const colRef = firebase.firestore().collection(COLLECTION); // Add 3 await colRef.add({}); diff --git a/packages/firestore/e2e/Query/limitToLast.e2e.js b/packages/firestore/e2e/Query/limitToLast.e2e.js index 7d67058cbf..08bafca587 100644 --- a/packages/firestore/e2e/Query/limitToLast.e2e.js +++ b/packages/firestore/e2e/Query/limitToLast.e2e.js @@ -14,17 +14,16 @@ * limitations under the License. * */ - +const COLLECTION = 'firestore'; const { wipe } = require('../helpers'); describe('firestore().collection().limitToLast()', () => { before(() => wipe()); - it('throws if limitToLast is invalid', () => { try { firebase .firestore() - .collection('v6') + .collection(COLLECTION) .limitToLast(-1); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { @@ -36,7 +35,7 @@ describe('firestore().collection().limitToLast()', () => { it('sets limitToLast on internals', async () => { const colRef = firebase .firestore() - .collection('v6') + .collection(COLLECTION) .limitToLast(123); should(colRef._modifiers.options.limitToLast).equal(123); @@ -45,7 +44,7 @@ describe('firestore().collection().limitToLast()', () => { it('removes limit query if limitToLast is set afterwards', () => { const colRef = firebase .firestore() - .collection('v6') + .collection(COLLECTION) .limit(2) .limitToLast(123); @@ -55,7 +54,7 @@ describe('firestore().collection().limitToLast()', () => { it('removes limitToLast query if limit is set afterwards', () => { const colRef = firebase .firestore() - .collection('v6') + .collection(COLLECTION) .limitToLast(123) .limit(2); @@ -63,7 +62,8 @@ describe('firestore().collection().limitToLast()', () => { }); it('limitToLast the number of documents', async () => { - const colRef = firebase.firestore().collection('v6'); + const subCol = `${COLLECTION}/limitToLast/count`; + const colRef = firebase.firestore().collection(subCol); // Add 3 await colRef.add({ count: 1 }); @@ -72,7 +72,7 @@ describe('firestore().collection().limitToLast()', () => { const docs = await firebase .firestore() - .collection('v6') + .collection(subCol) .limitToLast(2) .orderBy('count', 'desc') .get(); @@ -92,7 +92,7 @@ describe('firestore().collection().limitToLast()', () => { try { firebase .firestore() - .collection('v6') + .collection(COLLECTION) .limitToLast(3) .get(); return Promise.reject(new Error('Did not throw an Error.')); diff --git a/packages/firestore/e2e/Query/onSnapshot.e2e.js b/packages/firestore/e2e/Query/onSnapshot.e2e.js index 7fb36182f2..a2ba4805df 100644 --- a/packages/firestore/e2e/Query/onSnapshot.e2e.js +++ b/packages/firestore/e2e/Query/onSnapshot.e2e.js @@ -14,17 +14,17 @@ * limitations under the License. * */ - const { wipe } = require('../helpers'); +const COLLECTION = 'firestore'; +const NO_RULE_COLLECTION = 'no_rules'; describe('firestore().collection().onSnapshot()', () => { before(() => wipe()); - it('throws if no arguments are provided', () => { try { firebase .firestore() - .collection('v6') + .collection(COLLECTION) .onSnapshot(); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { @@ -36,7 +36,7 @@ describe('firestore().collection().onSnapshot()', () => { it('returns an unsubscribe function', () => { const unsub = firebase .firestore() - .collection('v6/foo/bar1') + .collection(`${COLLECTION}/foo/bar1`) .onSnapshot(() => {}); unsub.should.be.a.Function(); @@ -47,7 +47,7 @@ describe('firestore().collection().onSnapshot()', () => { const callback = sinon.spy(); const unsub = firebase .firestore() - .collection('v6/foo/bar2') + .collection(`${COLLECTION}/foo/bar2`) .onSnapshot(callback); await Utils.spyToBeCalledOnceAsync(callback); @@ -62,7 +62,7 @@ describe('firestore().collection().onSnapshot()', () => { const callback = sinon.spy(); const unsub = firebase .firestore() - .collection('nope') + .collection(NO_RULE_COLLECTION) .onSnapshot(callback); await Utils.spyToBeCalledOnceAsync(callback); @@ -79,7 +79,7 @@ describe('firestore().collection().onSnapshot()', () => { const onError = sinon.spy(); const unsub = firebase .firestore() - .collection('v6/foo/bar3') + .collection(`${COLLECTION}/foo/bar3`) .onSnapshot(onNext, onError); await Utils.spyToBeCalledOnceAsync(onNext); @@ -96,7 +96,7 @@ describe('firestore().collection().onSnapshot()', () => { const onError = sinon.spy(); const unsub = firebase .firestore() - .collection('nope') + .collection(NO_RULE_COLLECTION) .onSnapshot(onNext, onError); await Utils.spyToBeCalledOnceAsync(onError); @@ -115,7 +115,7 @@ describe('firestore().collection().onSnapshot()', () => { const onError = sinon.spy(); const unsub = firebase .firestore() - .collection('v6/foo/bar4') + .collection(`${COLLECTION}/foo/bar4`) .onSnapshot({ next: onNext, error: onError, @@ -135,7 +135,7 @@ describe('firestore().collection().onSnapshot()', () => { const onError = sinon.spy(); const unsub = firebase .firestore() - .collection('nope') + .collection(NO_RULE_COLLECTION) .onSnapshot({ next: onNext, error: onError, @@ -156,7 +156,7 @@ describe('firestore().collection().onSnapshot()', () => { const callback = sinon.spy(); const unsub = firebase .firestore() - .collection('v6/foo/bar5') + .collection(`${COLLECTION}/foo/bar5`) .onSnapshot( { includeMetadataChanges: false, @@ -176,7 +176,7 @@ describe('firestore().collection().onSnapshot()', () => { const callback = sinon.spy(); const unsub = firebase .firestore() - .collection('nope') + .collection(NO_RULE_COLLECTION) .onSnapshot( { includeMetadataChanges: false, @@ -197,7 +197,7 @@ describe('firestore().collection().onSnapshot()', () => { const onError = sinon.spy(); const unsub = firebase .firestore() - .collection('v6/foo/bar6') + .collection(`${COLLECTION}/foo/bar6`) .onSnapshot( { includeMetadataChanges: false, @@ -220,7 +220,7 @@ describe('firestore().collection().onSnapshot()', () => { const onError = sinon.spy(); const unsub = firebase .firestore() - .collection('nope') + .collection(NO_RULE_COLLECTION) .onSnapshot( { includeMetadataChanges: false, @@ -245,7 +245,7 @@ describe('firestore().collection().onSnapshot()', () => { const onError = sinon.spy(); const unsub = firebase .firestore() - .collection('v6/foo/bar7') + .collection(`${COLLECTION}/foo/bar7`) .onSnapshot( { includeMetadataChanges: false, @@ -270,7 +270,7 @@ describe('firestore().collection().onSnapshot()', () => { const onError = sinon.spy(); const unsub = firebase .firestore() - .collection('nope') + .collection(NO_RULE_COLLECTION) .onSnapshot( { includeMetadataChanges: false, @@ -295,7 +295,7 @@ describe('firestore().collection().onSnapshot()', () => { try { firebase .firestore() - .collection('nope') + .collection(NO_RULE_COLLECTION) .onSnapshot({ includeMetadataChanges: 123, }); @@ -312,7 +312,7 @@ describe('firestore().collection().onSnapshot()', () => { try { firebase .firestore() - .collection('nope') + .collection(NO_RULE_COLLECTION) .onSnapshot({ next: 'foo', }); @@ -327,7 +327,7 @@ describe('firestore().collection().onSnapshot()', () => { try { firebase .firestore() - .collection('nope') + .collection(NO_RULE_COLLECTION) .onSnapshot({ error: 'foo', }); @@ -342,7 +342,8 @@ describe('firestore().collection().onSnapshot()', () => { // Registered 4 of 3 expected calls once (!?), 3 of 2 expected calls once. xit('unsubscribes from further updates', async () => { const callback = sinon.spy(); - const collection = firebase.firestore().collection('v6/foo/bar7'); + + const collection = firebase.firestore().collection(`${COLLECTION}/foo/bar7`); const unsub = collection.onSnapshot(callback); await Utils.sleep(800); diff --git a/packages/firestore/e2e/Query/orderBy.e2e.js b/packages/firestore/e2e/Query/orderBy.e2e.js index 32a5359c45..b28b04545d 100644 --- a/packages/firestore/e2e/Query/orderBy.e2e.js +++ b/packages/firestore/e2e/Query/orderBy.e2e.js @@ -14,17 +14,15 @@ * limitations under the License. * */ - +const COLLECTION = 'firestore'; const { wipe } = require('../helpers'); - describe('firestore().collection().orderBy()', () => { before(() => wipe()); - it('throws if fieldPath is not valid', () => { try { firebase .firestore() - .collection('foo') + .collection(COLLECTION) .orderBy(123); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { @@ -37,7 +35,7 @@ describe('firestore().collection().orderBy()', () => { try { firebase .firestore() - .collection('foo') + .collection(COLLECTION) .orderBy('.foo.bar'); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { @@ -50,7 +48,7 @@ describe('firestore().collection().orderBy()', () => { try { firebase .firestore() - .collection('foo') + .collection(COLLECTION) .orderBy('foo', 'up'); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { @@ -61,13 +59,13 @@ describe('firestore().collection().orderBy()', () => { it('throws if a startAt()/startAfter() has already been set', async () => { try { - const doc = firebase.firestore().doc('v6/startATstartAfter'); + const doc = firebase.firestore().doc(`${COLLECTION}/startATstartAfter`); await doc.set({ foo: 'bar' }); const snapshot = await doc.get(); firebase .firestore() - .collection('foo') + .collection(COLLECTION) .startAt(snapshot) .orderBy('foo'); return Promise.reject(new Error('Did not throw an Error.')); @@ -79,13 +77,13 @@ describe('firestore().collection().orderBy()', () => { it('throws if a endAt()/endBefore() has already been set', async () => { try { - const doc = firebase.firestore().doc('v6/endAtendBefore'); + const doc = firebase.firestore().doc(`${COLLECTION}/endAtendBefore`); await doc.set({ foo: 'bar' }); const snapshot = await doc.get(); firebase .firestore() - .collection('foo') + .collection(COLLECTION) .endAt(snapshot) .orderBy('foo'); return Promise.reject(new Error('Did not throw an Error.')); @@ -99,7 +97,7 @@ describe('firestore().collection().orderBy()', () => { try { firebase .firestore() - .collection('foo') + .collection(COLLECTION) .orderBy('foo.bar') .orderBy('foo.bar'); return Promise.reject(new Error('Did not throw an Error.')); @@ -108,9 +106,10 @@ describe('firestore().collection().orderBy()', () => { return Promise.resolve(); } }); - + it('orders by a value ASC', async () => { - const colRef = firebase.firestore().collection('v6/order/asc'); + const colRef = firebase.firestore().collection(`${COLLECTION}/order/asc`); + await colRef.add({ value: 1 }); await colRef.add({ value: 3 }); await colRef.add({ value: 2 }); @@ -124,7 +123,8 @@ describe('firestore().collection().orderBy()', () => { }); it('orders by a value DESC', async () => { - const colRef = firebase.firestore().collection('v6/order/desc'); + const colRef = firebase.firestore().collection(`${COLLECTION}/order/desc`); + await colRef.add({ value: 1 }); await colRef.add({ value: 3 }); await colRef.add({ value: 2 }); diff --git a/packages/firestore/e2e/Query/query.e2e.js b/packages/firestore/e2e/Query/query.e2e.js index 8af4de5581..7605e4a114 100644 --- a/packages/firestore/e2e/Query/query.e2e.js +++ b/packages/firestore/e2e/Query/query.e2e.js @@ -13,12 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +const COLLECTION = 'firestore'; describe('FirestoreQuery/FirestoreQueryModifiers', () => { it('should not mutate previous queries (#2691)', async () => { const queryBefore = firebase .firestore() - .collection('users') + .collection(COLLECTION) .where('age', '>', 30); const queryAfter = queryBefore.orderBy('age'); queryBefore._modifiers._orders.length.should.equal(0); @@ -32,7 +33,7 @@ describe('FirestoreQuery/FirestoreQueryModifiers', () => { try { firebase .firestore() - .collection('v6') + .collection(COLLECTION) .where('foo', '==', 'bar') .orderBy('foo') .limit(1) @@ -45,7 +46,7 @@ describe('FirestoreQuery/FirestoreQueryModifiers', () => { try { firebase .firestore() - .collection('v6') + .collection(COLLECTION) .where('foo', '==', 'bar') .orderBy('bar') .orderBy('foo') @@ -61,7 +62,7 @@ describe('FirestoreQuery/FirestoreQueryModifiers', () => { try { firebase .firestore() - .collection('v6') + .collection(COLLECTION) .where('foo', '>', 'bar') .orderBy('bar') .orderBy('foo') diff --git a/packages/firestore/e2e/Query/startAfter.e2e.js b/packages/firestore/e2e/Query/startAfter.e2e.js index ef9464aaa0..3b16dddb98 100644 --- a/packages/firestore/e2e/Query/startAfter.e2e.js +++ b/packages/firestore/e2e/Query/startAfter.e2e.js @@ -14,17 +14,15 @@ * limitations under the License. * */ - +const COLLECTION = 'firestore'; const { wipe } = require('../helpers'); - describe('firestore().collection().startAfter()', () => { before(() => wipe()); - it('throws if no argument provided', () => { try { firebase .firestore() - .collection('v6') + .collection(COLLECTION) .startAfter(); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { @@ -39,7 +37,7 @@ describe('firestore().collection().startAfter()', () => { try { firebase .firestore() - .collection('v6') + .collection(COLLECTION) .orderBy('foo') .startAfter('bar', 'baz'); return Promise.reject(new Error('Did not throw an Error.')); @@ -53,11 +51,11 @@ describe('firestore().collection().startAfter()', () => { try { const doc = await firebase .firestore() - .doc('v6/foo') + .doc(`${COLLECTION}/foo`) .get(); firebase .firestore() - .collection('v6') + .collection(COLLECTION) .startAfter(doc, 'baz'); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { @@ -70,11 +68,11 @@ describe('firestore().collection().startAfter()', () => { try { const doc = await firebase .firestore() - .doc('v6/idonotexist') + .doc(`${COLLECTION}/idonotexist`) .get(); firebase .firestore() - .collection('v6') + .collection(COLLECTION) .startAfter(doc); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { @@ -85,13 +83,13 @@ describe('firestore().collection().startAfter()', () => { it('throws if order used with snapshot but fields do not exist', async () => { try { - const doc = firebase.firestore().doc('v6/iexist'); + const doc = firebase.firestore().doc(`${COLLECTION}/iexist`); await doc.set({ foo: { bar: 'baz' } }); const snap = await doc.get(); firebase .firestore() - .collection('v6') + .collection(COLLECTION) .orderBy('foo.baz') .startAfter(snap); return Promise.reject(new Error('Did not throw an Error.')); @@ -104,7 +102,7 @@ describe('firestore().collection().startAfter()', () => { }); it('starts after field values', async () => { - const colRef = firebase.firestore().collection('v6/startAfter/collection'); + const colRef = firebase.firestore().collection(`${COLLECTION}/startAfter/collection`); const doc1 = colRef.doc('doc1'); const doc2 = colRef.doc('doc2'); const doc3 = colRef.doc('doc3'); @@ -125,7 +123,7 @@ describe('firestore().collection().startAfter()', () => { }); it('starts after snapshot field values', async () => { - const colRef = firebase.firestore().collection('v6/startAfter/snapshotFields'); + const colRef = firebase.firestore().collection(`${COLLECTION}/startAfter/snapshotFields`); const doc1 = colRef.doc('doc1'); const doc2 = colRef.doc('doc2'); const doc3 = colRef.doc('doc3'); @@ -148,7 +146,7 @@ describe('firestore().collection().startAfter()', () => { }); it('startAfter snapshot', async () => { - const colRef = firebase.firestore().collection('v6/endsAt/snapshot'); + const colRef = firebase.firestore().collection(`${COLLECTION}/endsAt/snapshot`); const doc1 = colRef.doc('doc1'); const doc2 = colRef.doc('doc2'); const doc3 = colRef.doc('doc3'); @@ -164,7 +162,7 @@ describe('firestore().collection().startAfter()', () => { }); it('runs startAfter & endBefore in the same query', async () => { - const colRef = firebase.firestore().collection('v6/startAfter/snapshot'); + const colRef = firebase.firestore().collection(`${COLLECTION}/startAfter/snapshot`); const doc1 = colRef.doc('doc1'); const doc2 = colRef.doc('doc2'); const doc3 = colRef.doc('doc3'); diff --git a/packages/firestore/e2e/Query/startAt.e2e.js b/packages/firestore/e2e/Query/startAt.e2e.js index 5ee2a5ab2c..1cb8d32b9e 100644 --- a/packages/firestore/e2e/Query/startAt.e2e.js +++ b/packages/firestore/e2e/Query/startAt.e2e.js @@ -14,17 +14,15 @@ * limitations under the License. * */ - +const COLLECTION = 'firestore'; const { wipe } = require('../helpers'); - describe('firestore().collection().starAt()', () => { before(() => wipe()); - it('throws if no argument provided', () => { try { firebase .firestore() - .collection('v6') + .collection(COLLECTION) .startAt(); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { @@ -39,7 +37,7 @@ describe('firestore().collection().starAt()', () => { try { firebase .firestore() - .collection('v6') + .collection(COLLECTION) .orderBy('foo') .startAt('bar', 'baz'); return Promise.reject(new Error('Did not throw an Error.')); @@ -53,11 +51,11 @@ describe('firestore().collection().starAt()', () => { try { const doc = await firebase .firestore() - .doc('v6/foo') + .doc(`${COLLECTION}/foo`) .get(); firebase .firestore() - .collection('v6') + .collection(COLLECTION) .startAt(doc, 'baz'); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { @@ -70,11 +68,11 @@ describe('firestore().collection().starAt()', () => { try { const doc = await firebase .firestore() - .doc('v6/idonotexist') + .doc(`${COLLECTION}/idonotexist`) .get(); firebase .firestore() - .collection('v6') + .collection(COLLECTION) .startAt(doc); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { @@ -85,13 +83,14 @@ describe('firestore().collection().starAt()', () => { it('throws if order used with snapshot but fields do not exist', async () => { try { - const doc = firebase.firestore().doc('v6/iexist'); + const doc = firebase.firestore().doc(`${COLLECTION}/iexist`); + await doc.set({ foo: { bar: 'baz' } }); const snap = await doc.get(); firebase .firestore() - .collection('v6') + .collection(COLLECTION) .orderBy('foo.baz') .startAt(snap); return Promise.reject(new Error('Did not throw an Error.')); @@ -104,7 +103,7 @@ describe('firestore().collection().starAt()', () => { }); it('starts at field values', async () => { - const colRef = firebase.firestore().collection('v6/startAt/collection'); + const colRef = firebase.firestore().collection(`${COLLECTION}/startAt/collection`); const doc1 = colRef.doc('doc1'); const doc2 = colRef.doc('doc2'); const doc3 = colRef.doc('doc3'); @@ -126,7 +125,7 @@ describe('firestore().collection().starAt()', () => { }); it('starts at snapshot field values', async () => { - const colRef = firebase.firestore().collection('v6/startAt/snapshotFields'); + const colRef = firebase.firestore().collection(`${COLLECTION}/startAt/snapshotFields`); const doc1 = colRef.doc('doc1'); const doc2 = colRef.doc('doc2'); const doc3 = colRef.doc('doc3'); @@ -150,7 +149,7 @@ describe('firestore().collection().starAt()', () => { }); it('startAt at snapshot', async () => { - const colRef = firebase.firestore().collection('v6/endsAt/snapshot'); + const colRef = firebase.firestore().collection(`${COLLECTION}/endsAt/snapshot`); const doc1 = colRef.doc('doc1'); const doc2 = colRef.doc('doc2'); const doc3 = colRef.doc('doc3'); diff --git a/packages/firestore/e2e/Query/where.e2e.js b/packages/firestore/e2e/Query/where.e2e.js index e6ab7c23d4..598e78a4e1 100644 --- a/packages/firestore/e2e/Query/where.e2e.js +++ b/packages/firestore/e2e/Query/where.e2e.js @@ -14,17 +14,15 @@ * limitations under the License. * */ - +const COLLECTION = 'firestore'; const { wipe } = require('../helpers'); - describe('firestore().collection().where()', () => { before(() => wipe()); - it('throws if fieldPath is invalid', () => { try { firebase .firestore() - .collection('v6') + .collection(COLLECTION) .where(123); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { @@ -37,7 +35,7 @@ describe('firestore().collection().where()', () => { try { firebase .firestore() - .collection('v6') + .collection(COLLECTION) .where('.foo.bar'); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { @@ -50,7 +48,7 @@ describe('firestore().collection().where()', () => { try { firebase .firestore() - .collection('v6') + .collection(COLLECTION) .where('foo.bar', '!'); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { @@ -63,7 +61,7 @@ describe('firestore().collection().where()', () => { try { firebase .firestore() - .collection('v6') + .collection(COLLECTION) .where('foo.bar', 'array-contains', 123) .where('foo.bar', 'array-contains', 123); return Promise.reject(new Error('Did not throw an Error.')); @@ -77,7 +75,7 @@ describe('firestore().collection().where()', () => { try { firebase .firestore() - .collection('v6') + .collection(COLLECTION) .where('foo.bar', 'array-contains'); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { @@ -90,7 +88,7 @@ describe('firestore().collection().where()', () => { try { firebase .firestore() - .collection('v6') + .collection(COLLECTION) .where('foo.bar', 'array-contains', null); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { @@ -102,7 +100,7 @@ describe('firestore().collection().where()', () => { it('allows null to be used with equal operator', () => { firebase .firestore() - .collection('v6') + .collection(COLLECTION) .where('foo.bar', '==', null); }); @@ -110,7 +108,7 @@ describe('firestore().collection().where()', () => { try { firebase .firestore() - .collection('v6') + .collection(COLLECTION) .where('foo.bar', '>', 123) .where('bar', '>', 123); return Promise.reject(new Error('Did not throw an Error.')); @@ -123,7 +121,7 @@ describe('firestore().collection().where()', () => { it('allows inequality on the same path', () => { firebase .firestore() - .collection('v6') + .collection(COLLECTION) .where('foo.bar', '>', 123) .where(new firebase.firestore.FieldPath('foo', 'bar'), '>', 1234); }); @@ -132,7 +130,7 @@ describe('firestore().collection().where()', () => { try { firebase .firestore() - .collection('v6') + .collection(COLLECTION) .where('foo.bar', 'in', '123'); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { @@ -145,7 +143,7 @@ describe('firestore().collection().where()', () => { try { firebase .firestore() - .collection('v6') + .collection(COLLECTION) .where('foo.bar', 'array-contains-any', '123'); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { @@ -158,7 +156,7 @@ describe('firestore().collection().where()', () => { try { firebase .firestore() - .collection('v6') + .collection(COLLECTION) .where('foo.bar', 'in', [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { @@ -171,7 +169,7 @@ describe('firestore().collection().where()', () => { try { firebase .firestore() - .collection('v6') + .collection(COLLECTION) .where('foo.bar', 'array-contains-any', [1]) .where('foo.bar', 'array-contains-any', [2]); return Promise.reject(new Error('Did not throw an Error.')); @@ -185,7 +183,7 @@ describe('firestore().collection().where()', () => { try { firebase .firestore() - .collection('v6') + .collection(COLLECTION) .where('foo.bar', 'array-contains-any', [1]) .where('foo.bar', 'in', [2]); return Promise.reject(new Error('Did not throw an Error.')); @@ -201,7 +199,7 @@ describe('firestore().collection().where()', () => { try { firebase .firestore() - .collection('v6') + .collection(COLLECTION) .where('foo.bar', 'in', [1]) .where('foo.bar', 'in', [2]); return Promise.reject(new Error('Did not throw an Error.')); @@ -215,7 +213,7 @@ describe('firestore().collection().where()', () => { try { firebase .firestore() - .collection('v6') + .collection(COLLECTION) .where('foo.bar', 'in', [1]) .where('foo.bar', 'array-contains-any', [2]); return Promise.reject(new Error('Did not throw an Error.')); @@ -230,7 +228,7 @@ describe('firestore().collection().where()', () => { /* Queries */ it('returns with where equal filter', async () => { - const colRef = firebase.firestore().collection('v6/filter/equal'); + const colRef = firebase.firestore().collection(`${COLLECTION}/filter/equal`); const search = Date.now(); await Promise.all([ @@ -248,7 +246,7 @@ describe('firestore().collection().where()', () => { }); it('returns with where greater than filter', async () => { - const colRef = firebase.firestore().collection('v6/filter/greater'); + const colRef = firebase.firestore().collection(`${COLLECTION}/filter/greater`); const search = Date.now(); await Promise.all([ @@ -267,7 +265,7 @@ describe('firestore().collection().where()', () => { }); it('returns with where greater than or equal filter', async () => { - const colRef = firebase.firestore().collection('v6/filter/greaterequal'); + const colRef = firebase.firestore().collection(`${COLLECTION}/filter/greaterequal`); const search = Date.now(); await Promise.all([ @@ -286,7 +284,7 @@ describe('firestore().collection().where()', () => { }); it('returns with where less than filter', async () => { - const colRef = firebase.firestore().collection('v6/filter/less'); + const colRef = firebase.firestore().collection(`${COLLECTION}/filter/less`); const search = -Date.now(); await Promise.all([ @@ -304,7 +302,7 @@ describe('firestore().collection().where()', () => { }); it('returns with where less than or equal filter', async () => { - const colRef = firebase.firestore().collection('v6/filter/lessequal'); + const colRef = firebase.firestore().collection(`${COLLECTION}/filter/lessequal`); const search = -Date.now(); await Promise.all([ @@ -323,7 +321,7 @@ describe('firestore().collection().where()', () => { }); it('returns with where array-contains filter', async () => { - const colRef = firebase.firestore().collection('v6/filter/array-contains'); + const colRef = firebase.firestore().collection(`${COLLECTION}/filter/array-contains`); const match = Date.now(); await Promise.all([ @@ -342,7 +340,7 @@ describe('firestore().collection().where()', () => { }); it('returns with in filter', async () => { - const colRef = firebase.firestore().collection('v6/filter/in'); + const colRef = firebase.firestore().collection(`${COLLECTION}/filter/in`); await Promise.all([ colRef.add({ status: 'Ordered' }), @@ -361,7 +359,7 @@ describe('firestore().collection().where()', () => { }); it('returns with array-contains-any filter', async () => { - const colRef = firebase.firestore().collection('v6/filter/array-contains-any'); + const colRef = firebase.firestore().collection(`${COLLECTION}/filter/array-contains-any`); await Promise.all([ colRef.add({ category: ['Appliances', 'Housewares', 'Cooking'] }), @@ -376,7 +374,7 @@ describe('firestore().collection().where()', () => { }); it('returns with a FieldPath', async () => { - const colRef = firebase.firestore().collection('v6/filter/where-fieldpath'); + const colRef = firebase.firestore().collection(`${COLLECTION}/filter/where-fieldpath`); const fieldPath = new firebase.firestore.FieldPath('map', 'foo.bar@gmail.com'); await colRef.add({ @@ -400,7 +398,7 @@ describe('firestore().collection().where()', () => { try { firebase .firestore() - .collection('v6') + .collection(COLLECTION) .where(firebase.firestore.FieldPath.documentId(), 'in', ['document-id']) .orderBy('differentOrderBy', 'desc'); @@ -412,7 +410,7 @@ describe('firestore().collection().where()', () => { }); it('should correctly query integer values with in operator', async () => { - const ref = firebase.firestore().collection('v6'); + const ref = firebase.firestore().collection(COLLECTION); await ref.add({ status: 1 }); @@ -426,7 +424,7 @@ describe('firestore().collection().where()', () => { }); it('should correctly query integer values with array-contains operator', async () => { - const ref = firebase.firestore().collection('v6'); + const ref = firebase.firestore().collection(COLLECTION); await ref.add({ status: [1, 2, 3] }); diff --git a/packages/firestore/e2e/QuerySnapshot.e2e.js b/packages/firestore/e2e/QuerySnapshot.e2e.js index c16ba59726..a8fce2b5f0 100644 --- a/packages/firestore/e2e/QuerySnapshot.e2e.js +++ b/packages/firestore/e2e/QuerySnapshot.e2e.js @@ -14,16 +14,15 @@ * limitations under the License. * */ - const { wipe } = require('./helpers'); +const COLLECTION = 'firestore'; describe('firestore.QuerySnapshot', () => { before(() => wipe()); - it('is returned from a collection get()', async () => { const snapshot = await firebase .firestore() - .collection('v6') + .collection(COLLECTION) .get(); snapshot.constructor.name.should.eql('FirestoreQuerySnapshot'); @@ -33,14 +32,14 @@ describe('firestore.QuerySnapshot', () => { const callback = sinon.spy(); firebase .firestore() - .collection('v6') + .collection(COLLECTION) .onSnapshot(callback); await Utils.spyToBeCalledOnceAsync(callback); callback.args[0][0].constructor.name.should.eql('FirestoreQuerySnapshot'); }); it('returns an array of DocumentSnapshots', async () => { - const colRef = firebase.firestore().collection('v6'); + const colRef = firebase.firestore().collection(COLLECTION); await colRef.add({}); const snapshot = await colRef.get(); snapshot.docs.should.be.Array(); @@ -49,7 +48,7 @@ describe('firestore.QuerySnapshot', () => { }); it('returns false if not empty', async () => { - const colRef = firebase.firestore().collection('v6'); + const colRef = firebase.firestore().collection(COLLECTION); await colRef.add({}); const snapshot = await colRef.get(); snapshot.empty.should.be.Boolean(); @@ -57,26 +56,26 @@ describe('firestore.QuerySnapshot', () => { }); it('returns true if empty', async () => { - const colRef = firebase.firestore().collection('v6/foo/emptycollection'); + const colRef = firebase.firestore().collection(`${COLLECTION}/foo/emptycollection`); const snapshot = await colRef.get(); snapshot.empty.should.be.Boolean(); snapshot.empty.should.be.True(); }); it('returns a SnapshotMetadata instance', async () => { - const colRef = firebase.firestore().collection('v6'); + const colRef = firebase.firestore().collection(COLLECTION); const snapshot = await colRef.get(); snapshot.metadata.constructor.name.should.eql('FirestoreSnapshotMetadata'); }); it('returns a Query instance', async () => { - const colRef = firebase.firestore().collection('v6'); + const colRef = firebase.firestore().collection(COLLECTION); const snapshot = await colRef.get(); snapshot.query.constructor.name.should.eql('FirestoreCollectionReference'); }); it('returns size as a number', async () => { - const colRef = firebase.firestore().collection('v6'); + const colRef = firebase.firestore().collection(COLLECTION); const snapshot = await colRef.get(); snapshot.size.should.be.Number(); }); @@ -84,7 +83,7 @@ describe('firestore.QuerySnapshot', () => { describe('docChanges()', () => { it('throws if options is not an object', async () => { try { - const colRef = firebase.firestore().collection('v6'); + const colRef = firebase.firestore().collection(COLLECTION); const snapshot = await colRef.limit(1).get(); snapshot.docChanges(123); return Promise.reject(new Error('Did not throw an Error.')); @@ -96,7 +95,7 @@ describe('firestore.QuerySnapshot', () => { it('throws if options.includeMetadataChanges is not a boolean', async () => { try { - const colRef = firebase.firestore().collection('v6'); + const colRef = firebase.firestore().collection(COLLECTION); const snapshot = await colRef.limit(1).get(); snapshot.docChanges({ includeMetadataChanges: 123 }); return Promise.reject(new Error('Did not throw an Error.')); @@ -108,7 +107,7 @@ describe('firestore.QuerySnapshot', () => { it('throws if options.includeMetadataChanges is true, but snapshot does not include those changes', async () => { const callback = sinon.spy(); - const colRef = firebase.firestore().collection('v6'); + const colRef = firebase.firestore().collection(COLLECTION); const unsub = colRef.onSnapshot( { includeMetadataChanges: false, @@ -129,7 +128,7 @@ describe('firestore.QuerySnapshot', () => { }); it('returns an array of DocumentChange instances', async () => { - const colRef = firebase.firestore().collection('v6'); + const colRef = firebase.firestore().collection(COLLECTION); colRef.add({}); const snapshot = await colRef.limit(1).get(); const changes = snapshot.docChanges(); @@ -178,7 +177,7 @@ describe('firestore.QuerySnapshot', () => { describe('forEach()', () => { it('throws if callback is not a function', async () => { try { - const colRef = firebase.firestore().collection('v6'); + const colRef = firebase.firestore().collection(COLLECTION); const snapshot = await colRef.limit(1).get(); snapshot.forEach(123); return Promise.reject(new Error('Did not throw an Error.')); @@ -189,7 +188,7 @@ describe('firestore.QuerySnapshot', () => { }); it('calls back a function', async () => { - const colRef = firebase.firestore().collection('v6'); + const colRef = firebase.firestore().collection(COLLECTION); colRef.add({}); colRef.add({}); const snapshot = await colRef.limit(2).get(); @@ -204,7 +203,7 @@ describe('firestore.QuerySnapshot', () => { }); it('provides context to the callback', async () => { - const colRef = firebase.firestore().collection('v6'); + const colRef = firebase.firestore().collection(COLLECTION); colRef.add({}); const snapshot = await colRef.limit(1).get(); const callback = sinon.spy(); @@ -221,7 +220,7 @@ describe('firestore.QuerySnapshot', () => { try { const qs = await firebase .firestore() - .collection('v6') + .collection(COLLECTION) .get(); qs.isEqual(123); return Promise.reject(new Error('Did not throw an Error.')); @@ -232,7 +231,7 @@ describe('firestore.QuerySnapshot', () => { }); it('returns false if not equal (simple checks)', async () => { - const colRef = firebase.firestore().collection('v6'); + const colRef = firebase.firestore().collection(COLLECTION); // Ensure a doc exists await colRef.add({}); @@ -240,7 +239,7 @@ describe('firestore.QuerySnapshot', () => { const querySnap1 = await firebase .firestore() - .collection('v6/querysnapshot/querySnapshotIsEqual') + .collection(`${COLLECTION}/querysnapshot/querySnapshotIsEqual`) .get(); const eq1 = qs.isEqual(querySnap1); @@ -249,7 +248,9 @@ describe('firestore.QuerySnapshot', () => { }); it('returns false if not equal (expensive checks)', async () => { - const colRef = firebase.firestore().collection('v6/querysnapshot/querySnapshotIsEqual-False'); + const colRef = firebase + .firestore() + .collection(`${COLLECTION}/querysnapshot/querySnapshotIsEqual-False`); // Ensure a doc exists const docRef = colRef.doc('firstdoc'); await docRef.set({ @@ -277,7 +278,9 @@ describe('firestore.QuerySnapshot', () => { }); it('returns true when equal', async () => { - const colRef = firebase.firestore().collection('v6/querysnapshot/querySnapshotIsEqual-True'); + const colRef = firebase + .firestore() + .collection(`${COLLECTION}/querysnapshot/querySnapshotIsEqual-True`); await Promise.all([ colRef.add({ foo: 'bar' }), diff --git a/packages/firestore/e2e/SnapshotMetadata.e2e.js b/packages/firestore/e2e/SnapshotMetadata.e2e.js index ad96a0d8db..659e0bfa82 100644 --- a/packages/firestore/e2e/SnapshotMetadata.e2e.js +++ b/packages/firestore/e2e/SnapshotMetadata.e2e.js @@ -14,15 +14,14 @@ * limitations under the License. * */ - const { wipe } = require('./helpers'); +const COLLECTION = 'firestore'; describe('firestore.SnapshotMetadata', () => { before(() => wipe()); - it('.fromCache -> returns a boolean', async () => { - const ref1 = firebase.firestore().collection('v6'); - const ref2 = firebase.firestore().doc('v6/idonotexist'); + const ref1 = firebase.firestore().collection(COLLECTION); + const ref2 = firebase.firestore().doc(`${COLLECTION}/idonotexist`); const colRef = await ref1.get(); const docRef = await ref2.get(); colRef.metadata.fromCache.should.be.Boolean(); @@ -30,8 +29,8 @@ describe('firestore.SnapshotMetadata', () => { }); it('.hasPendingWrites -> returns a boolean', async () => { - const ref1 = firebase.firestore().collection('v6'); - const ref2 = firebase.firestore().doc('v6/idonotexist'); + const ref1 = firebase.firestore().collection(COLLECTION); + const ref2 = firebase.firestore().doc(`${COLLECTION}/idonotexist`); const colRef = await ref1.get(); const docRef = await ref2.get(); colRef.metadata.hasPendingWrites.should.be.Boolean(); @@ -43,7 +42,7 @@ describe('firestore.SnapshotMetadata', () => { try { const snapshot = await firebase .firestore() - .collection('v6') + .collection(COLLECTION) .get(); snapshot.metadata.isEqual(); return Promise.reject(new Error('Did not throw an Error.')); @@ -56,11 +55,11 @@ describe('firestore.SnapshotMetadata', () => { it('returns true if is equal', async () => { const snapshot1 = await firebase .firestore() - .collection('v6') + .collection(COLLECTION) .get({ source: 'cache' }); const snapshot2 = await firebase .firestore() - .collection('v6') + .collection(COLLECTION) .get({ source: 'cache' }); snapshot1.metadata.isEqual(snapshot2.metadata).should.eql(true); }); @@ -68,11 +67,11 @@ describe('firestore.SnapshotMetadata', () => { it('returns false if not equal', async () => { const snapshot1 = await firebase .firestore() - .collection('v6') + .collection(COLLECTION) .get({ source: 'cache' }); const snapshot2 = await firebase .firestore() - .collection('v6') + .collection(COLLECTION) .get({ source: 'server' }); snapshot1.metadata.isEqual(snapshot2.metadata).should.eql(false); }); diff --git a/packages/firestore/e2e/Transaction.e2e.js b/packages/firestore/e2e/Transaction.e2e.js index ba013e76e2..af074a489e 100644 --- a/packages/firestore/e2e/Transaction.e2e.js +++ b/packages/firestore/e2e/Transaction.e2e.js @@ -14,6 +14,8 @@ * limitations under the License. * */ +const COLLECTION = 'firestore'; +const NO_RULE_COLLECTION = 'no_rules'; describe('firestore.Transaction', () => { it('should throw if updateFunction is not a Promise', async () => { @@ -58,7 +60,7 @@ describe('firestore.Transaction', () => { }); it('should reject a native error', async () => { - const docRef = firebase.firestore().doc('nope/foo'); + const docRef = firebase.firestore().doc(`${NO_RULE_COLLECTION}/foo`); try { await firebase.firestore().runTransaction(async t => { @@ -87,7 +89,7 @@ describe('firestore.Transaction', () => { }); it('should get a document and return a DocumentSnapshot', async () => { - const docRef = firebase.firestore().doc('v6/transactions/transaction/get-delete'); + const docRef = firebase.firestore().doc(`${COLLECTION}/transactions/transaction/get-delete`); await docRef.set({}); await firebase.firestore().runTransaction(async t => { @@ -115,10 +117,14 @@ describe('firestore.Transaction', () => { }); it('should delete documents', async () => { - const docRef1 = firebase.firestore().doc('v6/transactions/transaction/delete-delete1'); + const docRef1 = firebase + .firestore() + .doc(`${COLLECTION}/transactions/transaction/delete-delete1`); await docRef1.set({}); - const docRef2 = firebase.firestore().doc('v6/transactions/transaction/delete-delete2'); + const docRef2 = firebase + .firestore() + .doc(`${COLLECTION}/transactions/transaction/delete-delete2`); await docRef2.set({}); await firebase.firestore().runTransaction(async t => { @@ -148,7 +154,7 @@ describe('firestore.Transaction', () => { }); it('should throw if update args are invalid', async () => { - const docRef = firebase.firestore().doc('v6/foo'); + const docRef = firebase.firestore().doc(`${COLLECTION}/foo`); try { await firebase.firestore().runTransaction(async t => { @@ -164,13 +170,17 @@ describe('firestore.Transaction', () => { it('should update documents', async () => { const value = Date.now(); - const docRef1 = firebase.firestore().doc('v6/transactions/transaction/delete-delete1'); + const docRef1 = firebase + .firestore() + .doc(`${COLLECTION}/transactions/transaction/delete-delete1`); await docRef1.set({ foo: 'bar', bar: 'baz', }); - const docRef2 = firebase.firestore().doc('v6/transactions/transaction/delete-delete2'); + const docRef2 = firebase + .firestore() + .doc(`${COLLECTION}/transactions/transaction/delete-delete2`); await docRef2.set({ foo: 'bar', bar: 'baz', @@ -212,7 +222,7 @@ describe('firestore.Transaction', () => { }); it('should throw if set data is invalid', async () => { - const docRef = firebase.firestore().doc('v6/foo'); + const docRef = firebase.firestore().doc(`${COLLECTION}/foo`); try { await firebase.firestore().runTransaction(async t => { @@ -226,7 +236,7 @@ describe('firestore.Transaction', () => { }); it('should throw if set options are invalid', async () => { - const docRef = firebase.firestore().doc('v6/foo'); + const docRef = firebase.firestore().doc(`${COLLECTION}/foo`); try { await firebase.firestore().runTransaction(async t => { @@ -247,7 +257,7 @@ describe('firestore.Transaction', () => { }); it('should set data', async () => { - const docRef = firebase.firestore().doc('v6/transactions/transaction/set'); + const docRef = firebase.firestore().doc(`${COLLECTION}/transactions/transaction/set`); await docRef.set({ foo: 'bar', }); @@ -264,7 +274,7 @@ describe('firestore.Transaction', () => { }); it('should set data with merge', async () => { - const docRef = firebase.firestore().doc('v6/transactions/transaction/set-merge'); + const docRef = firebase.firestore().doc(`${COLLECTION}/transactions/transaction/set-merge`); await docRef.set({ foo: 'bar', bar: 'baz', @@ -291,7 +301,9 @@ describe('firestore.Transaction', () => { }); it('should set data with merge fields', async () => { - const docRef = firebase.firestore().doc('v6/transactions/transaction/set-mergefields'); + const docRef = firebase + .firestore() + .doc(`${COLLECTION}/transactions/transaction/set-mergefields`); await docRef.set({ foo: 'bar', bar: 'baz', @@ -321,7 +333,7 @@ describe('firestore.Transaction', () => { }); it('should roll back any updates that failed', async () => { - const docRef = firebase.firestore().doc('v6/transactions/transaction/rollback'); + const docRef = firebase.firestore().doc(`${COLLECTION}/transactions/transaction/rollback`); await docRef.set({ turn: 0, diff --git a/packages/firestore/e2e/WriteBatch/commit.e2e.js b/packages/firestore/e2e/WriteBatch/commit.e2e.js index 1c7ba09b4f..8f45611386 100644 --- a/packages/firestore/e2e/WriteBatch/commit.e2e.js +++ b/packages/firestore/e2e/WriteBatch/commit.e2e.js @@ -14,12 +14,11 @@ * limitations under the License. * */ - +const COLLECTION = 'firestore'; const { wipe } = require('../helpers'); describe('firestore.WriteBatch.commit()', () => { before(() => wipe()); - it('returns a Promise', () => { const commit = firebase .firestore() @@ -35,7 +34,7 @@ describe('firestore.WriteBatch.commit()', () => { for (let i = 0; i < filledArray.length; i++) { const doc = firebase .firestore() - .collection('v6') + .collection(COLLECTION) .doc(i.toString()); const filledArrayElement = filledArray[i]; batch.set(doc, filledArrayElement); @@ -63,9 +62,9 @@ describe('firestore.WriteBatch.commit()', () => { }); it('should set & commit', async () => { - const lRef = firebase.firestore().doc('v6/LON'); - const nycRef = firebase.firestore().doc('v6/NYC'); - const sfRef = firebase.firestore().doc('v6/SF'); + const lRef = firebase.firestore().doc(`${COLLECTION}/LON`); + const nycRef = firebase.firestore().doc(`${COLLECTION}/NYC`); + const sfRef = firebase.firestore().doc(`${COLLECTION}/SF`); const batch = firebase.firestore().batch(); @@ -84,9 +83,9 @@ describe('firestore.WriteBatch.commit()', () => { }); it('should set/merge & commit', async () => { - const lRef = firebase.firestore().doc('v6/LON'); - const nycRef = firebase.firestore().doc('v6/NYC'); - const sfRef = firebase.firestore().doc('v6/SF'); + const lRef = firebase.firestore().doc(`${COLLECTION}/LON`); + const nycRef = firebase.firestore().doc(`${COLLECTION}/NYC`); + const sfRef = firebase.firestore().doc(`${COLLECTION}/SF`); await Promise.all([ lRef.set({ name: 'London' }), @@ -115,9 +114,9 @@ describe('firestore.WriteBatch.commit()', () => { }); it('should set/mergeFields & commit', async () => { - const lRef = firebase.firestore().doc('v6/LON'); - const nycRef = firebase.firestore().doc('v6/NYC'); - const sfRef = firebase.firestore().doc('v6/SF'); + const lRef = firebase.firestore().doc(`${COLLECTION}/LON`); + const nycRef = firebase.firestore().doc(`${COLLECTION}/NYC`); + const sfRef = firebase.firestore().doc(`${COLLECTION}/SF`); await Promise.all([ lRef.set({ name: 'London' }), @@ -150,9 +149,9 @@ describe('firestore.WriteBatch.commit()', () => { }); it('should delete & commit', async () => { - const lRef = firebase.firestore().doc('v6/LON'); - const nycRef = firebase.firestore().doc('v6/NYC'); - const sfRef = firebase.firestore().doc('v6/SF'); + const lRef = firebase.firestore().doc(`${COLLECTION}/LON`); + const nycRef = firebase.firestore().doc(`${COLLECTION}/NYC`); + const sfRef = firebase.firestore().doc(`${COLLECTION}/SF`); await Promise.all([ lRef.set({ name: 'London' }), @@ -176,9 +175,9 @@ describe('firestore.WriteBatch.commit()', () => { }); it('should update & commit', async () => { - const lRef = firebase.firestore().doc('v6/LON'); - const nycRef = firebase.firestore().doc('v6/NYC'); - const sfRef = firebase.firestore().doc('v6/SF'); + const lRef = firebase.firestore().doc(`${COLLECTION}/LON`); + const nycRef = firebase.firestore().doc(`${COLLECTION}/NYC`); + const sfRef = firebase.firestore().doc(`${COLLECTION}/SF`); await Promise.all([ lRef.set({ name: 'London' }), diff --git a/packages/firestore/e2e/WriteBatch/delete.e2e.js b/packages/firestore/e2e/WriteBatch/delete.e2e.js index 3e290251ca..e4f0f5e933 100644 --- a/packages/firestore/e2e/WriteBatch/delete.e2e.js +++ b/packages/firestore/e2e/WriteBatch/delete.e2e.js @@ -14,6 +14,7 @@ * limitations under the License. * */ +const COLLECTION = 'firestore'; describe('firestore.WriteBatch.delete()', () => { it('throws if a DocumentReference instance is not provided', () => { @@ -32,7 +33,8 @@ describe('firestore.WriteBatch.delete()', () => { it('throws if a DocumentReference firestore instance is different', () => { try { const app2 = firebase.app('secondaryFromNative'); - const docRef = firebase.firestore(app2).doc('v6/foo'); + const docRef = firebase.firestore(app2).doc(`${COLLECTION}/foo`); + firebase .firestore() .batch() @@ -47,14 +49,14 @@ describe('firestore.WriteBatch.delete()', () => { }); it('adds the DocumentReference to the internal writes', () => { - const docRef = firebase.firestore().doc('v6/foo'); + const docRef = firebase.firestore().doc(`${COLLECTION}/foo`); const wb = firebase .firestore() .batch() .delete(docRef); wb._writes.length.should.eql(1); const expected = { - path: 'v6/foo', + path: `${COLLECTION}/foo`, type: 'DELETE', }; wb._writes[0].should.eql(jet.contextify(expected)); diff --git a/packages/firestore/e2e/WriteBatch/set.e2e.js b/packages/firestore/e2e/WriteBatch/set.e2e.js index ea28488601..cea7767854 100644 --- a/packages/firestore/e2e/WriteBatch/set.e2e.js +++ b/packages/firestore/e2e/WriteBatch/set.e2e.js @@ -14,6 +14,7 @@ * limitations under the License. * */ +const COLLECTION = 'firestore'; describe('firestore.WriteBatch.set()', () => { it('throws if a DocumentReference instance is not provided', () => { @@ -32,7 +33,8 @@ describe('firestore.WriteBatch.set()', () => { it('throws if a DocumentReference firestore instance is different', () => { try { const app2 = firebase.app('secondaryFromNative'); - const docRef = firebase.firestore(app2).doc('v6/foo'); + const docRef = firebase.firestore(app2).doc(`${COLLECTION}/foo`); + firebase .firestore() .batch() @@ -48,7 +50,8 @@ describe('firestore.WriteBatch.set()', () => { it('throws if a data is not an object', () => { try { - const docRef = firebase.firestore().doc('v6/foo'); + const docRef = firebase.firestore().doc(`${COLLECTION}/foo`); + firebase .firestore() .batch() @@ -62,7 +65,8 @@ describe('firestore.WriteBatch.set()', () => { it('throws if a options is not an object', () => { try { - const docRef = firebase.firestore().doc('v6/foo'); + const docRef = firebase.firestore().doc(`${COLLECTION}/foo`); + firebase .firestore() .batch() @@ -76,7 +80,7 @@ describe('firestore.WriteBatch.set()', () => { it('throws if merge and mergeFields is provided', () => { try { - const docRef = firebase.firestore().doc('v6/foo'); + const docRef = firebase.firestore().doc(`${COLLECTION}/foo`); firebase .firestore() .batch() @@ -97,7 +101,7 @@ describe('firestore.WriteBatch.set()', () => { it('throws if merge is not a boolean', () => { try { - const docRef = firebase.firestore().doc('v6/foo'); + const docRef = firebase.firestore().doc(`${COLLECTION}/foo`); firebase .firestore() .batch() @@ -117,7 +121,7 @@ describe('firestore.WriteBatch.set()', () => { it('throws if mergeFields is not an array', () => { try { - const docRef = firebase.firestore().doc('v6/foo'); + const docRef = firebase.firestore().doc(`${COLLECTION}/foo`); firebase .firestore() .batch() @@ -137,7 +141,8 @@ describe('firestore.WriteBatch.set()', () => { it('throws if mergeFields item is not valid', () => { try { - const docRef = firebase.firestore().doc('v6/foo'); + const docRef = firebase.firestore().doc(`${COLLECTION}/foo`); + firebase .firestore() .batch() @@ -159,7 +164,8 @@ describe('firestore.WriteBatch.set()', () => { it('throws if string fieldpath is invalid', () => { try { - const docRef = firebase.firestore().doc('v6/foo'); + const docRef = firebase.firestore().doc(`${COLLECTION}/foo`); + firebase .firestore() .batch() @@ -178,7 +184,8 @@ describe('firestore.WriteBatch.set()', () => { }); it('accepts string fieldpath & FieldPath', () => { - const docRef = firebase.firestore().doc('v6/foo'); + const docRef = firebase.firestore().doc(`${COLLECTION}/foo`); + firebase .firestore() .batch() @@ -192,7 +199,8 @@ describe('firestore.WriteBatch.set()', () => { }); it('adds the DocumentReference to the internal writes', () => { - const docRef = firebase.firestore().doc('v6/foo'); + const docRef = firebase.firestore().doc(`${COLLECTION}/foo`); + const wb = firebase .firestore() .batch() @@ -203,7 +211,7 @@ describe('firestore.WriteBatch.set()', () => { ); wb._writes.length.should.eql(1); const expected = { - path: 'v6/foo', + path: `${COLLECTION}/foo`, type: 'SET', options: jet.contextify({ mergeFields: jet.contextify(['foo.bar']), diff --git a/packages/firestore/e2e/WriteBatch/update.e2e.js b/packages/firestore/e2e/WriteBatch/update.e2e.js index afb8ab775d..a9cead3a03 100644 --- a/packages/firestore/e2e/WriteBatch/update.e2e.js +++ b/packages/firestore/e2e/WriteBatch/update.e2e.js @@ -15,6 +15,8 @@ * */ +const COLLECTION = 'firestore'; + describe('firestore.WriteBatch.update()', () => { it('throws if a DocumentReference instance is not provided', () => { try { @@ -32,7 +34,8 @@ describe('firestore.WriteBatch.update()', () => { it('throws if a DocumentReference firestore instance is different', () => { try { const app2 = firebase.app('secondaryFromNative'); - const docRef = firebase.firestore(app2).doc('v6/foo'); + const docRef = firebase.firestore(app2).doc(`${COLLECTION}/foo`); + firebase .firestore() .batch() @@ -48,7 +51,7 @@ describe('firestore.WriteBatch.update()', () => { it('throws if update args are not provided', () => { try { - const docRef = firebase.firestore().doc('v6/foo'); + const docRef = firebase.firestore().doc(`${COLLECTION}/foo`); firebase .firestore() .batch() @@ -62,7 +65,7 @@ describe('firestore.WriteBatch.update()', () => { it('throws if update arg is not an object', () => { try { - const docRef = firebase.firestore().doc('v6/foo'); + const docRef = firebase.firestore().doc(`${COLLECTION}/foo`); firebase .firestore() .batch() @@ -76,7 +79,7 @@ describe('firestore.WriteBatch.update()', () => { it('throws if update key/values are invalid', () => { try { - const docRef = firebase.firestore().doc('v6/foo'); + const docRef = firebase.firestore().doc(`${COLLECTION}/foo`); firebase .firestore() .batch() @@ -90,7 +93,7 @@ describe('firestore.WriteBatch.update()', () => { it('throws if update keys are invalid', () => { try { - const docRef = firebase.firestore().doc('v6/foo'); + const docRef = firebase.firestore().doc(`${COLLECTION}/foo`); firebase .firestore() .batch() @@ -103,14 +106,14 @@ describe('firestore.WriteBatch.update()', () => { }); it('adds the DocumentReference to the internal writes', () => { - const docRef = firebase.firestore().doc('v6/foo'); + const docRef = firebase.firestore().doc(`${COLLECTION}/foo`); const wb = firebase .firestore() .batch() .update(docRef, { foo: 'bar' }); wb._writes.length.should.eql(1); const expected = { - path: 'v6/foo', + path: `${COLLECTION}/foo`, type: 'UPDATE', }; wb._writes[0].should.containEql(jet.contextify(expected)); diff --git a/packages/firestore/e2e/firestore.e2e.js b/packages/firestore/e2e/firestore.e2e.js index c5c4b9b7c3..22c79b6fec 100644 --- a/packages/firestore/e2e/firestore.e2e.js +++ b/packages/firestore/e2e/firestore.e2e.js @@ -14,6 +14,8 @@ * limitations under the License. * */ +const COLLECTION = 'firestore'; +const COLLECTION_GROUP = 'collectionGroup'; describe('firestore()', () => { describe('namespace', () => { @@ -70,7 +72,7 @@ describe('firestore()', () => { it('throws if path does not point to a collection', () => { try { - firebase.firestore().collection('foo/bar'); + firebase.firestore().collection(`${COLLECTION}/bar`); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("'collectionPath' must point to a collection"); @@ -79,9 +81,9 @@ describe('firestore()', () => { }); it('returns a new CollectionReference', () => { - const collectionReference = firebase.firestore().collection('foo'); + const collectionReference = firebase.firestore().collection(COLLECTION); should.equal(collectionReference.constructor.name, 'FirestoreCollectionReference'); - collectionReference.path.should.eql('foo'); + collectionReference.path.should.eql(COLLECTION); }); }); @@ -108,7 +110,7 @@ describe('firestore()', () => { it('throws if path does not point to a document', () => { try { - firebase.firestore().doc('foo/bar/baz'); + firebase.firestore().doc(`${COLLECTION}/bar/baz`); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("'documentPath' must point to a document"); @@ -117,9 +119,9 @@ describe('firestore()', () => { }); it('returns a new DocumentReference', () => { - const docRef = firebase.firestore().doc('foo/bar'); + const docRef = firebase.firestore().doc(`${COLLECTION}/bar`); should.equal(docRef.constructor.name, 'FirestoreDocumentReference'); - docRef.path.should.eql('foo/bar'); + docRef.path.should.eql(`${COLLECTION}/bar`); }); }); @@ -146,7 +148,7 @@ describe('firestore()', () => { it('throws if id contains forward-slash', () => { try { - firebase.firestore().collectionGroup('foo/bar'); + firebase.firestore().collectionGroup(`${COLLECTION}/bar`); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("'collectionId' must not contain '/'"); @@ -155,20 +157,20 @@ describe('firestore()', () => { }); it('returns a new query instance', () => { - const query = firebase.firestore().collectionGroup('foo'); + const query = firebase.firestore().collectionGroup(COLLECTION); should.equal(query.constructor.name, 'FirestoreQuery'); }); it('performs a collection group query', async () => { - const docRef1 = firebase.firestore().doc('v6/collectionGroup1'); - const docRef2 = firebase.firestore().doc('v6/collectionGroup2'); - const docRef3 = firebase.firestore().doc('v6/collectionGroup3'); - const subRef1 = docRef1.collection('collectionGroup').doc('ref'); - const subRef2 = docRef1.collection('collectionGroup').doc('ref2'); - const subRef3 = docRef2.collection('collectionGroup').doc('ref'); - const subRef4 = docRef2.collection('collectionGroup').doc('ref2'); - const subRef5 = docRef3.collection('collectionGroup').doc('ref'); - const subRef6 = docRef3.collection('collectionGroup').doc('ref2'); + const docRef1 = firebase.firestore().doc(`${COLLECTION}/collectionGroup1`); + const docRef2 = firebase.firestore().doc(`${COLLECTION}/collectionGroup2`); + const docRef3 = firebase.firestore().doc(`${COLLECTION}/collectionGroup3`); + const subRef1 = docRef1.collection(COLLECTION_GROUP).doc('ref'); + const subRef2 = docRef1.collection(COLLECTION_GROUP).doc('ref2'); + const subRef3 = docRef2.collection(COLLECTION_GROUP).doc('ref'); + const subRef4 = docRef2.collection(COLLECTION_GROUP).doc('ref2'); + const subRef5 = docRef3.collection(COLLECTION_GROUP).doc('ref'); + const subRef6 = docRef3.collection(COLLECTION_GROUP).doc('ref2'); await Promise.all([ subRef1.set({ value: 1 }), @@ -183,7 +185,7 @@ describe('firestore()', () => { const querySnapshot = await firebase .firestore() - .collectionGroup('collectionGroup') + .collectionGroup(COLLECTION_GROUP) .where('value', '==', 2) .get(); @@ -206,17 +208,17 @@ describe('firestore()', () => { }); it('performs a collection group query with cursor queries', async () => { - const docRef = firebase.firestore().doc('v6/collectionGroupCursor'); + const docRef = firebase.firestore().doc(`${COLLECTION}/collectionGroupCursor`); - const ref1 = await docRef.collection('collectionGroup').add({ number: 1 }); - const startAt = await docRef.collection('collectionGroup').add({ number: 2 }); - const ref3 = await docRef.collection('collectionGroup').add({ number: 3 }); + const ref1 = await docRef.collection(COLLECTION_GROUP).add({ number: 1 }); + const startAt = await docRef.collection(COLLECTION_GROUP).add({ number: 2 }); + const ref3 = await docRef.collection(COLLECTION_GROUP).add({ number: 3 }); const ds = await startAt.get(); const querySnapshot = await firebase .firestore() - .collectionGroup('collectionGroup') + .collectionGroup(COLLECTION_GROUP) .orderBy('number') .startAt(ds) .get(); @@ -288,8 +290,8 @@ describe('firestore()', () => { return Promise.resolve(); } }); - - it('accepts an unlimited cache size', () => { + // NOTE: removed as it breaks emulator tests along with 'should clear any cached data' test below + xit('accepts an unlimited cache size', () => { firebase.firestore().settings({ cacheSizeBytes: firebase.firestore.CACHE_SIZE_UNLIMITED }); }); @@ -335,26 +337,22 @@ describe('firestore()', () => { }); describe('Clear cached data persistence', () => { - it('should clear any cached data', async () => { + // NOTE: removed as it breaks emulator tests along with 'accepts an unlimited cache size' test above + xit('should clear any cached data', async () => { const db = firebase.firestore(); const id = 'foobar'; - const ref = db.doc(`v6/${id}`); + const ref = db.doc(`${COLLECTION}/${id}`); await ref.set({ foo: 'bar' }); - try { await db.clearPersistence(); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.code.should.equal('firestore/failed-precondition'); } - const doc = await ref.get({ source: 'cache' }); - should(doc.id).equal(id); - await db.terminate(); await db.clearPersistence(); - try { await ref.get({ source: 'cache' }); return Promise.reject(new Error('Did not throw an Error.')); diff --git a/packages/firestore/e2e/helpers.js b/packages/firestore/e2e/helpers.js index 3c53ec8274..a3c60a60ec 100644 --- a/packages/firestore/e2e/helpers.js +++ b/packages/firestore/e2e/helpers.js @@ -16,13 +16,30 @@ * limitations under the License. * */ +const http = require('http'); -exports.wipe = async function wipe(collection = 'v6', debug = false) { +const deleteOptions = { + method: 'DELETE', + port: 8080, + host: '127.0.0.1', + path: '/emulator/v1/projects/react-native-firebase-testing/databases/(default)/documents', +}; + +exports.wipe = async function wipe(debug = false) { if (debug) { console.time('wipe'); } - await TestAdminApi.firestore().clearCollection(collection); - if (debug) { - console.timeEnd('wipe'); - } + + await new Promise((resolve, reject) => { + const req = http.request(deleteOptions); + + req.on('error', error => reject(error)); + + req.end(() => { + if (debug) { + console.timeEnd('wipe'); + } + resolve(); + }); + }); }; diff --git a/packages/firestore/e2e/issues.e2e.js b/packages/firestore/e2e/issues.e2e.js index cffa4037ec..8bb58ceb41 100644 --- a/packages/firestore/e2e/issues.e2e.js +++ b/packages/firestore/e2e/issues.e2e.js @@ -15,40 +15,42 @@ * */ +const COLLECTION = 'firestore'; +//todo find otu why this fails when running all tests describe('firestore()', () => { - describe('issue2854', () => { + describe(COLLECTION, () => { before(async () => { await Promise.all([ firebase .firestore() - .doc('issue2854/wbXwyLJheRfYXXWlY46j') + .doc(`${COLLECTION}/wbXwyLJheRfYXXWlY46j`) .set({ index: 2, number: 2 }), firebase .firestore() - .doc('issue2854/kGC5cYPN1nKnZCcAb9oQ') + .doc(`${COLLECTION}/kGC5cYPN1nKnZCcAb9oQ`) .set({ index: 6, number: 2 }), firebase .firestore() - .doc('issue2854/8Ek8iWCDQPPJ5s2n8PiQ') + .doc(`${COLLECTION}/8Ek8iWCDQPPJ5s2n8PiQ`) .set({ index: 4, number: 2 }), firebase .firestore() - .doc('issue2854/mr7MdAygvuheF6AUtWma') + .doc(`${COLLECTION}/mr7MdAygvuheF6AUtWma`) .set({ index: 1, number: 1 }), firebase .firestore() - .doc('issue2854/RCO5SvNn4fdoE49OKrIV') + .doc(`${COLLECTION}/RCO5SvNn4fdoE49OKrIV`) .set({ index: 3, number: 1 }), firebase .firestore() - .doc('issue2854/CvVG7VP1hXTtcfdUaeNl') + .doc(`${COLLECTION}/CvVG7VP1hXTtcfdUaeNl`) .set({ index: 5, number: 1 }), ]); }); it('returns all results', async () => { const db = firebase.firestore(); - const ref = db.collection('issue2854').orderBy('number', 'desc'); + const ref = db.collection(COLLECTION).orderBy('number', 'desc'); const allResultsSnapshot = await ref.get(); allResultsSnapshot.forEach((doc, i) => { if (i === 0) { @@ -74,7 +76,7 @@ describe('firestore()', () => { it('returns first page', async () => { const db = firebase.firestore(); - const ref = db.collection('issue2854').orderBy('number', 'desc'); + const ref = db.collection(COLLECTION).orderBy('number', 'desc'); const firstPageSnapshot = await ref.limit(2).get(); should.equal(firstPageSnapshot.docs.length, 2); firstPageSnapshot.forEach((doc, i) => { @@ -89,7 +91,7 @@ describe('firestore()', () => { it('returns second page', async () => { const db = firebase.firestore(); - const ref = db.collection('issue2854').orderBy('number', 'desc'); + const ref = db.collection(COLLECTION).orderBy('number', 'desc'); const firstPageSnapshot = await ref.limit(2).get(); let lastDocument; firstPageSnapshot.forEach(doc => { From 92d2fabb04d57d0e882eb673d17498b5c1f0dc9f Mon Sep 17 00:00:00 2001 From: russellwheatley Date: Tue, 25 Aug 2020 17:39:50 +0100 Subject: [PATCH 02/10] docs(firestore): update e2e contributing docs --- CONTRIBUTING.md | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index de577b2d30..653ac4ee0c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -118,7 +118,21 @@ The project supports JS only testing through Jest. The following package scripts ### End-to-end Testing -The project has a Detox powered `e2e` testing app located in `/tests`. +The project has a Detox powered end-to-end testing app located in `/tests`. + +To run end-to-end tests for `Android`, please run: + +- `yarn tests:android:build` - builds `Android` test application. +- `yarn tests:packager:jet-reset-cache` - runs JavaScript bundler. +- `yarn tests:emulator:start` - runs Firestore emulator for Firestore tests. +- `yarn tests:android:test` - runs tests using Detox library. Tests for each package can be found in the `e2e` directory (i.e. `[PACKAGE]/e2e/*.e2e.js`) + +To run end-to-end tests for `iOS`, please run: + +- `yarn tests:ios:build` - builds `iOS` test application. +- `yarn tests:packager:jet-reset-cache` - runs JavaScript bundler. +- `yarn tests:emulator:start` - runs Firestore emulator for Firestore tests. +- `yarn tests:ios:test` - runs tests using Detox library. Tests for each package can be found in the `e2e` directory (i.e. `[PACKAGE]/e2e/*.e2e.js`) See it's local testing guide [here](https://github.com/invertase/react-native-firebase/blob/master/tests/README.md) to get started with `e2e` testing this project. From 99d7930b38289fb61734cdab466e5daa5ad5b224 Mon Sep 17 00:00:00 2001 From: russellwheatley Date: Wed, 26 Aug 2020 08:44:05 +0100 Subject: [PATCH 03/10] format: prettier e2e files --- packages/firestore/e2e/CollectionReference/add.e2e.js | 2 +- packages/firestore/e2e/Query/orderBy.e2e.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/firestore/e2e/CollectionReference/add.e2e.js b/packages/firestore/e2e/CollectionReference/add.e2e.js index 9abd9dde8c..23dc3f6526 100644 --- a/packages/firestore/e2e/CollectionReference/add.e2e.js +++ b/packages/firestore/e2e/CollectionReference/add.e2e.js @@ -15,7 +15,7 @@ * */ const { wipe } = require('../helpers'); - const COLLECTION = 'firestore'; +const COLLECTION = 'firestore'; describe('firestore.collection().add()', () => { before(() => wipe()); diff --git a/packages/firestore/e2e/Query/orderBy.e2e.js b/packages/firestore/e2e/Query/orderBy.e2e.js index b28b04545d..fc3973b59d 100644 --- a/packages/firestore/e2e/Query/orderBy.e2e.js +++ b/packages/firestore/e2e/Query/orderBy.e2e.js @@ -106,7 +106,7 @@ describe('firestore().collection().orderBy()', () => { return Promise.resolve(); } }); - + it('orders by a value ASC', async () => { const colRef = firebase.firestore().collection(`${COLLECTION}/order/asc`); From a4d806debd955e48afc5585c01f5755426d8b716 Mon Sep 17 00:00:00 2001 From: russellwheatley Date: Tue, 6 Oct 2020 17:13:17 +0100 Subject: [PATCH 04/10] test: ios updates --- tests/ios/Podfile.lock | 105 ++++++++++---------- tests/ios/testing.xcodeproj/project.pbxproj | 41 +++++++- 2 files changed, 92 insertions(+), 54 deletions(-) diff --git a/tests/ios/Podfile.lock b/tests/ios/Podfile.lock index ef5b7d4e00..03a429be6b 100644 --- a/tests/ios/Podfile.lock +++ b/tests/ios/Podfile.lock @@ -503,81 +503,82 @@ PODS: - React-cxxreact (= 0.62.2) - React-jsi (= 0.62.2) - ReactCommon/callinvoker (= 0.62.2) - - RNFBAdMob (7.5.1): + - RNFBAdMob (7.6.8): - Firebase/AdMob (= 6.31.0) - PersonalizedAdConsent (~> 1.0.4) - - React + - React-Core - RNFBApp - - RNFBAnalytics (7.4.2): + - RNFBAnalytics (7.6.7): - Firebase/Analytics (= 6.31.0) - - React + - React-Core - RNFBApp - - RNFBApp (8.3.1): + - RNFBApp (8.4.5): - Firebase/CoreOnly (= 6.31.0) - - React - - RNFBAuth (9.0.0): + - React-Core + - RNFBAuth (9.2.7): - Firebase/Auth (= 6.31.0) - - React + - React-Core - RNFBApp - - RNFBCrashlytics (8.3.4): + - RNFBCrashlytics (8.4.9): - Firebase/Crashlytics (= 6.31.0) - - React + - React-Core - RNFBApp - - RNFBDatabase (7.4.2): + - RNFBDatabase (7.5.11): - Firebase/Database (= 6.31.0) - - React + - React-Core - RNFBApp - - RNFBDynamicLinks (7.4.3): + - RNFBDynamicLinks (7.5.9): - Firebase/DynamicLinks (= 6.31.0) - - React + - GoogleUtilities/AppDelegateSwizzler + - React-Core - RNFBApp - - RNFBFirestore (7.5.3): + - RNFBFirestore (7.8.6): - Firebase/Firestore (= 6.31.0) - - React + - React-Core - RNFBApp - - RNFBFunctions (7.3.2): + - RNFBFunctions (7.4.8): - Firebase/Functions (= 6.31.0) - - React + - React-Core - RNFBApp - - RNFBIid (7.3.3): + - RNFBIid (7.4.8): - Firebase/CoreOnly (= 6.31.0) - FirebaseInstanceID - - React + - React-Core - RNFBApp - - RNFBInAppMessaging (7.3.3): + - RNFBInAppMessaging (7.5.6): - Firebase/InAppMessaging (= 6.31.0) - - React + - React-Core - RNFBApp - - RNFBMessaging (7.7.3): + - RNFBMessaging (7.8.11): - Firebase/Messaging (= 6.31.0) - - React + - React-Core - RNFBApp - - RNFBMLNaturalLanguage (7.3.2): + - RNFBMLNaturalLanguage (7.4.8): - Firebase/MLCommon (= 6.31.0) - Firebase/MLNaturalLanguage (= 6.31.0) - Firebase/MLNLLanguageID (= 6.31.0) - Firebase/MLNLSmartReply (= 6.31.0) - - React + - React-Core - RNFBApp - - RNFBMLVision (7.3.2): + - RNFBMLVision (7.4.8): - Firebase/MLVision (= 6.31.0) - Firebase/MLVisionBarcodeModel (= 6.31.0) - Firebase/MLVisionFaceModel (= 6.31.0) - Firebase/MLVisionLabelModel (= 6.31.0) - Firebase/MLVisionTextModel (= 6.31.0) - - React + - React-Core - RNFBApp - - RNFBPerf (7.3.2): + - RNFBPerf (7.4.8): - Firebase/Performance (= 6.31.0) - - React + - React-Core - RNFBApp - - RNFBRemoteConfig (8.1.4): + - RNFBRemoteConfig (9.0.10): - Firebase/RemoteConfig (= 6.31.0) - - React + - React-Core - RNFBApp - - RNFBStorage (7.3.3): + - RNFBStorage (7.4.8): - Firebase/Storage (= 6.31.0) - - React + - React-Core - RNFBApp - Yoga (1.14.0) @@ -836,25 +837,25 @@ SPEC CHECKSUMS: React-RCTText: fae545b10cfdb3d247c36c56f61a94cfd6dba41d React-RCTVibration: 4356114dbcba4ce66991096e51a66e61eda51256 ReactCommon: ed4e11d27609d571e7eee8b65548efc191116eb3 - RNFBAdMob: c767a4c30812979d51a1e350003722d3a811a550 - RNFBAnalytics: f7d6f25ac9f1d83759321d4c401857f3cbdccfaa - RNFBApp: 2b2da83e647ae2e8f306f5ee663e00e51583030d - RNFBAuth: dca65cff95aff7b75b7e3a955878e95d26fb52d3 - RNFBCrashlytics: fe658d261d9d20355cf7b5cc1c3c1738c6313e9c - RNFBDatabase: 42dcfb2ff23b768ccd6582dc4727969b5aefe350 - RNFBDynamicLinks: 72d17bb3981964021fafb06bdf55ad876c9aabd2 - RNFBFirestore: e5b6433bd60c51f7da292c4f93ba0de232cda8de - RNFBFunctions: 21344252a4a374605f8709723ccfe5094c3c8490 - RNFBIid: 535d5968b0b0d1ab567e7b9765a303063cd5cec0 - RNFBInAppMessaging: 994bd97d09c1aeeedea6f0a0fe006c1ddc8394d2 - RNFBMessaging: cd8904591c08a5fcce5ae58bd5924bc7febb3b44 - RNFBMLNaturalLanguage: 3ea14b22ea5cf48abb2ad18d9762103a16aa9b77 - RNFBMLVision: 94849d488fb3a8eebe8b9ff85e27a9195e31734b - RNFBPerf: d9340cffcd1021bf4feec8ee64c7c4a70a24e7f8 - RNFBRemoteConfig: 13c46ae1fe0d6ff60c2ba8da990ada925ef1a2c4 - RNFBStorage: 1e818e7c2d5b6514389d8a81931e251ac8006e4a + RNFBAdMob: 8105239a2dd3e1e328409b33fb7e1f7f169c0a56 + RNFBAnalytics: f034dc2bdfbd8ccef7c604b5cd00d68e4620829b + RNFBApp: 45ad08e0138095b964c6237cb35f1e6b1e3ad9ca + RNFBAuth: d23785e842b49ddeb5ce655d6d87a50a701361e6 + RNFBCrashlytics: 46149d0088f6afd1ce70f2b4adbc754871484523 + RNFBDatabase: 5d372d65303a26932d7a8f13c137513864ad61c2 + RNFBDynamicLinks: 9607e28754efa74c86b72d0bc16bfa15606ebb0e + RNFBFirestore: ce736de396a38f87eb5350fea3127d718446449a + RNFBFunctions: 76647de1f28448ce3fbe854c60871c859a5c60fa + RNFBIid: 480a4e88fee33bc512bba3f0b8e2c5940e5aa214 + RNFBInAppMessaging: cbc2f03ee742b1461413c4eb57079c74e21d6883 + RNFBMessaging: a9773fa794cd185a710a7c33c34481b8cb2d394d + RNFBMLNaturalLanguage: 34da64ba56998ff42419f3e1a59abb8db6f10813 + RNFBMLVision: eca56297eba2b22f6b5c99669204c7bab7558be8 + RNFBPerf: 6f9172724e67e094bcd33334ab1bda8fe81c508c + RNFBRemoteConfig: 4bd40833203d1d458663d12805c8a5ebdb6e2080 + RNFBStorage: b54e785a0ddecfc941eb69756a623a8b53535c92 Yoga: 3ebccbdd559724312790e7742142d062476b698e PODFILE CHECKSUM: 51062414d4f230ae385561d26f3c88e6c8a3ce28 -COCOAPODS: 1.10.0.beta.2 +COCOAPODS: 1.9.3 diff --git a/tests/ios/testing.xcodeproj/project.pbxproj b/tests/ios/testing.xcodeproj/project.pbxproj index 9b2dc67d3f..7589bea839 100644 --- a/tests/ios/testing.xcodeproj/project.pbxproj +++ b/tests/ios/testing.xcodeproj/project.pbxproj @@ -105,7 +105,6 @@ DD6CE4FF1D6F7A8C2E0647A0 /* Pods-testing.debug.xcconfig */, 8E2CB56F5CE51A2A19008908 /* Pods-testing.release.xcconfig */, ); - name = Pods; path = Pods; sourceTree = ""; }; @@ -156,6 +155,7 @@ buildConfigurationList = 13B07F931A680F5B00A75B9A /* Build configuration list for PBXNativeTarget "testing" */; buildPhases = ( 5F2F59C00A957B6F2EB00832 /* [CP] Check Pods Manifest.lock */, + 896435BF2CB42CDBCB7F99B9 /* [CP] Prepare Artifacts */, 13B07F871A680F5B00A75B9A /* Sources */, 13B07F8C1A680F5B00A75B9A /* Frameworks */, 13B07F8E1A680F5B00A75B9A /* Resources */, @@ -165,6 +165,7 @@ D60DF7E84815282F7C392B53 /* [CP] Copy Pods Resources */, 971DB9796AADE306A50F9133 /* [CP-User] [RNFB] Core Configuration */, E7DAD84A6BA0C83CFE863484 /* [CP-User] [RNFB] Crashlytics Configuration */, + 67EBDFA78BF4E67F2C8B1E0D /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -279,6 +280,23 @@ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; + 67EBDFA78BF4E67F2C8B1E0D /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-testing/Pods-testing-frameworks-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Embed Pods Frameworks"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-testing/Pods-testing-frameworks-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-testing/Pods-testing-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; 7D57265F10EEF7CD92D7973F /* Copy Detox Framework */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -293,6 +311,23 @@ shellPath = /bin/bash; shellScript = "if [ -n \"$DEPLOY_DETOX_FRAMEWORK\" ]; then\nmkdir -p \"${BUILT_PRODUCTS_DIR}\"/\"${FRAMEWORKS_FOLDER_PATH}\"\ncp -r \"${PROJECT_DIR}\"/../node_modules/detox/Detox.framework \"${BUILT_PRODUCTS_DIR}\"/\"${FRAMEWORKS_FOLDER_PATH}\"\nfi\n"; }; + 896435BF2CB42CDBCB7F99B9 /* [CP] Prepare Artifacts */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-testing/Pods-testing-artifacts-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Prepare Artifacts"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-testing/Pods-testing-artifacts-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-testing/Pods-testing-artifacts.sh\"\n"; + showEnvVarsInLog = 0; + }; 971DB9796AADE306A50F9133 /* [CP-User] [RNFB] Core Configuration */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -301,7 +336,7 @@ name = "[CP-User] [RNFB] Core Configuration"; runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "#!/usr/bin/env bash\n#\n# Copyright (c) 2016-present Invertase Limited & Contributors\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this library except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n#\nset -e\n\n_MAX_LOOKUPS=2;\n_SEARCH_RESULT=''\n_RN_ROOT_EXISTS=''\n_CURRENT_LOOKUPS=1\n_JSON_ROOT=\"'react-native'\"\n_JSON_FILE_NAME='firebase.json'\n_JSON_OUTPUT_BASE64='e30=' # { }\n_CURRENT_SEARCH_DIR=${PROJECT_DIR}\n_PLIST_BUDDY=/usr/libexec/PlistBuddy\n_TARGET_PLIST=\"${BUILT_PRODUCTS_DIR}/${INFOPLIST_PATH}\"\n_DSYM_PLIST=\"${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}/Contents/Info.plist\"\n\n# plist arrays\n_PLIST_ENTRY_KEYS=()\n_PLIST_ENTRY_TYPES=()\n_PLIST_ENTRY_VALUES=()\n\nfunction setPlistValue {\n echo \"info: setting plist entry '$1' of type '$2' in file '$4'\"\n ${_PLIST_BUDDY} -c \"Add :$1 $2 '$3'\" $4 || echo \"info: '$1' already exists\"\n}\n\nfunction getFirebaseJsonKeyValue () {\n if [[ ${_RN_ROOT_EXISTS} ]]; then\n ruby -e \"require 'rubygems';require 'json'; output=JSON.parse('$1'); puts output[$_JSON_ROOT]['$2']\"\n else\n echo \"\"\n fi;\n}\n\nfunction jsonBoolToYesNo () {\n if [[ $1 == \"false\" ]]; then\n echo \"NO\"\n elif [[ $1 == \"true\" ]]; then\n echo \"YES\"\n else echo \"NO\"\n fi\n}\n\necho \"info: -> RNFB build script started\"\necho \"info: 1) Locating ${_JSON_FILE_NAME} file:\"\n\nif [[ -z ${_CURRENT_SEARCH_DIR} ]]; then\n _CURRENT_SEARCH_DIR=$(pwd)\nfi;\n\nwhile true; do\n _CURRENT_SEARCH_DIR=$(dirname \"$_CURRENT_SEARCH_DIR\")\n if [[ \"$_CURRENT_SEARCH_DIR\" == \"/\" ]] || [[ ${_CURRENT_LOOKUPS} -gt ${_MAX_LOOKUPS} ]]; then break; fi;\n echo \"info: ($_CURRENT_LOOKUPS of $_MAX_LOOKUPS) Searching in '$_CURRENT_SEARCH_DIR' for a ${_JSON_FILE_NAME} file.\"\n _SEARCH_RESULT=$(find \"$_CURRENT_SEARCH_DIR\" -maxdepth 2 -name ${_JSON_FILE_NAME} -print | head -n 1)\n if [[ ${_SEARCH_RESULT} ]]; then\n echo \"info: ${_JSON_FILE_NAME} found at $_SEARCH_RESULT\"\n break;\n fi;\n _CURRENT_LOOKUPS=$((_CURRENT_LOOKUPS+1))\ndone\n\nif [[ ${_SEARCH_RESULT} ]]; then\n _JSON_OUTPUT_RAW=$(cat \"${_SEARCH_RESULT}\")\n _RN_ROOT_EXISTS=$(ruby -e \"require 'rubygems';require 'json'; output=JSON.parse('$_JSON_OUTPUT_RAW'); puts output[$_JSON_ROOT]\" || echo '')\n\n if [[ ${_RN_ROOT_EXISTS} ]]; then\n _JSON_OUTPUT_BASE64=$(python -c 'import json,sys,base64;print(base64.b64encode(json.dumps(json.loads(open('\"'${_SEARCH_RESULT}'\"').read())['${_JSON_ROOT}'])))' || echo \"e30=\")\n fi\n\n _PLIST_ENTRY_KEYS+=(\"firebase_json_raw\")\n _PLIST_ENTRY_TYPES+=(\"string\")\n _PLIST_ENTRY_VALUES+=(\"$_JSON_OUTPUT_BASE64\")\n\n # config.messaging_auto_init_enabled\n _MESSAGING_AUTO_INIT=$(getFirebaseJsonKeyValue \"$_JSON_OUTPUT_RAW\" \"messaging_auto_init_enabled\")\n if [[ $_MESSAGING_AUTO_INIT ]]; then\n _PLIST_ENTRY_KEYS+=(\"FirebaseMessagingAutoInitEnabled\")\n _PLIST_ENTRY_TYPES+=(\"bool\")\n _PLIST_ENTRY_VALUES+=(\"$(jsonBoolToYesNo \"$_MESSAGING_AUTO_INIT\")\")\n fi\n\n # config.crashlytics_disable_auto_disabler - undocumented for now - mainly for debugging, document if becomes usful\n _CRASHLYTICS_AUTO_DISABLE_ENABLED=$(getFirebaseJsonKeyValue \"$_JSON_OUTPUT_RAW\" \"crashlytics_disable_auto_disabler\")\n if [[ $_CRASHLYTICS_AUTO_DISABLE_ENABLED == \"true\" ]]; then\n echo \"Disabled Crashlytics auto disabler.\" # do nothing\n else\n _PLIST_ENTRY_KEYS+=(\"FirebaseCrashlyticsCollectionEnabled\")\n _PLIST_ENTRY_TYPES+=(\"bool\")\n _PLIST_ENTRY_VALUES+=(\"NO\")\n fi\n\n # config.admob_delay_app_measurement_init\n _ADMOB_DELAY_APP_MEASUREMENT=$(getFirebaseJsonKeyValue \"$_JSON_OUTPUT_RAW\" \"admob_delay_app_measurement_init\")\n if [[ $_ADMOB_DELAY_APP_MEASUREMENT == \"true\" ]]; then\n _PLIST_ENTRY_KEYS+=(\"GADDelayAppMeasurementInit\")\n _PLIST_ENTRY_TYPES+=(\"bool\")\n _PLIST_ENTRY_VALUES+=(\"YES\")\n fi\n\n # config.admob_ios_app_id\n _ADMOB_IOS_APP_ID=$(getFirebaseJsonKeyValue \"$_JSON_OUTPUT_RAW\" \"admob_ios_app_id\")\n if [[ $_ADMOB_IOS_APP_ID ]]; then\n _PLIST_ENTRY_KEYS+=(\"GADApplicationIdentifier\")\n _PLIST_ENTRY_TYPES+=(\"string\")\n _PLIST_ENTRY_VALUES+=(\"$_ADMOB_IOS_APP_ID\")\n fi\nelse\n _PLIST_ENTRY_KEYS+=(\"firebase_json_raw\")\n _PLIST_ENTRY_TYPES+=(\"string\")\n _PLIST_ENTRY_VALUES+=(\"$_JSON_OUTPUT_BASE64\")\n echo \"warning: A firebase.json file was not found, whilst this file is optional it is recommended to include it to configure firebase services in React Native Firebase.\"\nfi;\n\necho \"info: 2) Injecting Info.plist entries: \"\n\n# Log out the keys we're adding\nfor i in \"${!_PLIST_ENTRY_KEYS[@]}\"; do\n echo \" -> $i) ${_PLIST_ENTRY_KEYS[$i]}\" \"${_PLIST_ENTRY_TYPES[$i]}\" \"${_PLIST_ENTRY_VALUES[$i]}\"\ndone\n\nfor plist in \"${_TARGET_PLIST}\" \"${_DSYM_PLIST}\" ; do\n if [[ -f \"${plist}\" ]]; then\n\n # paths with spaces break the call to setPlistValue. temporarily modify\n # the shell internal field separator variable (IFS), which normally \n # includes spaces, to consist only of line breaks\n oldifs=$IFS\n IFS=\"\n\"\n\n for i in \"${!_PLIST_ENTRY_KEYS[@]}\"; do\n setPlistValue \"${_PLIST_ENTRY_KEYS[$i]}\" \"${_PLIST_ENTRY_TYPES[$i]}\" \"${_PLIST_ENTRY_VALUES[$i]}\" \"${plist}\"\n done\n\n # restore the original internal field separator value\n IFS=$oldifs\n else\n echo \"warning: A Info.plist build output file was not found (${plist})\"\n fi\ndone\n\necho \"info: <- RNFB build script finished\"\n\n"; + shellScript = "#!/usr/bin/env bash\n#\n# Copyright (c) 2016-present Invertase Limited & Contributors\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this library except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n#\nset -e\n\n_MAX_LOOKUPS=2;\n_SEARCH_RESULT=''\n_RN_ROOT_EXISTS=''\n_CURRENT_LOOKUPS=1\n_JSON_ROOT=\"'react-native'\"\n_JSON_FILE_NAME='firebase.json'\n_JSON_OUTPUT_BASE64='e30=' # { }\n_CURRENT_SEARCH_DIR=${PROJECT_DIR}\n_PLIST_BUDDY=/usr/libexec/PlistBuddy\n_TARGET_PLIST=\"${BUILT_PRODUCTS_DIR}/${INFOPLIST_PATH}\"\n_DSYM_PLIST=\"${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}/Contents/Info.plist\"\n\n# plist arrays\n_PLIST_ENTRY_KEYS=()\n_PLIST_ENTRY_TYPES=()\n_PLIST_ENTRY_VALUES=()\n\nfunction setPlistValue {\n echo \"info: setting plist entry '$1' of type '$2' in file '$4'\"\n ${_PLIST_BUDDY} -c \"Add :$1 $2 '$3'\" $4 || echo \"info: '$1' already exists\"\n}\n\nfunction getFirebaseJsonKeyValue () {\n if [[ ${_RN_ROOT_EXISTS} ]]; then\n ruby -e \"require 'rubygems';require 'json'; output=JSON.parse('$1'); puts output[$_JSON_ROOT]['$2']\"\n else\n echo \"\"\n fi;\n}\n\nfunction jsonBoolToYesNo () {\n if [[ $1 == \"false\" ]]; then\n echo \"NO\"\n elif [[ $1 == \"true\" ]]; then\n echo \"YES\"\n else echo \"NO\"\n fi\n}\n\necho \"info: -> RNFB build script started\"\necho \"info: 1) Locating ${_JSON_FILE_NAME} file:\"\n\nif [[ -z ${_CURRENT_SEARCH_DIR} ]]; then\n _CURRENT_SEARCH_DIR=$(pwd)\nfi;\n\nwhile true; do\n _CURRENT_SEARCH_DIR=$(dirname \"$_CURRENT_SEARCH_DIR\")\n if [[ \"$_CURRENT_SEARCH_DIR\" == \"/\" ]] || [[ ${_CURRENT_LOOKUPS} -gt ${_MAX_LOOKUPS} ]]; then break; fi;\n echo \"info: ($_CURRENT_LOOKUPS of $_MAX_LOOKUPS) Searching in '$_CURRENT_SEARCH_DIR' for a ${_JSON_FILE_NAME} file.\"\n _SEARCH_RESULT=$(find \"$_CURRENT_SEARCH_DIR\" -maxdepth 2 -name ${_JSON_FILE_NAME} -print | head -n 1)\n if [[ ${_SEARCH_RESULT} ]]; then\n echo \"info: ${_JSON_FILE_NAME} found at $_SEARCH_RESULT\"\n break;\n fi;\n _CURRENT_LOOKUPS=$((_CURRENT_LOOKUPS+1))\ndone\n\nif [[ ${_SEARCH_RESULT} ]]; then\n _JSON_OUTPUT_RAW=$(cat \"${_SEARCH_RESULT}\")\n _RN_ROOT_EXISTS=$(ruby -e \"require 'rubygems';require 'json'; output=JSON.parse('$_JSON_OUTPUT_RAW'); puts output[$_JSON_ROOT]\" || echo '')\n\n if [[ ${_RN_ROOT_EXISTS} ]]; then\n _JSON_OUTPUT_BASE64=$(python -c 'import json,sys,base64;print(base64.b64encode(json.dumps(json.loads(open('\"'${_SEARCH_RESULT}'\"').read())['${_JSON_ROOT}'])))' || echo \"e30=\")\n fi\n\n _PLIST_ENTRY_KEYS+=(\"firebase_json_raw\")\n _PLIST_ENTRY_TYPES+=(\"string\")\n _PLIST_ENTRY_VALUES+=(\"$_JSON_OUTPUT_BASE64\")\n\n # config.messaging_auto_init_enabled\n _MESSAGING_AUTO_INIT=$(getFirebaseJsonKeyValue \"$_JSON_OUTPUT_RAW\" \"messaging_auto_init_enabled\")\n if [[ $_MESSAGING_AUTO_INIT ]]; then\n _PLIST_ENTRY_KEYS+=(\"FirebaseMessagingAutoInitEnabled\")\n _PLIST_ENTRY_TYPES+=(\"bool\")\n _PLIST_ENTRY_VALUES+=(\"$(jsonBoolToYesNo \"$_MESSAGING_AUTO_INIT\")\")\n fi\n\n # config.crashlytics_disable_auto_disabler - undocumented for now - mainly for debugging, document if becomes useful\n _CRASHLYTICS_AUTO_DISABLE_ENABLED=$(getFirebaseJsonKeyValue \"$_JSON_OUTPUT_RAW\" \"crashlytics_disable_auto_disabler\")\n if [[ $_CRASHLYTICS_AUTO_DISABLE_ENABLED == \"true\" ]]; then\n echo \"Disabled Crashlytics auto disabler.\" # do nothing\n else\n _PLIST_ENTRY_KEYS+=(\"FirebaseCrashlyticsCollectionEnabled\")\n _PLIST_ENTRY_TYPES+=(\"bool\")\n _PLIST_ENTRY_VALUES+=(\"NO\")\n fi\n\n # config.admob_delay_app_measurement_init\n _ADMOB_DELAY_APP_MEASUREMENT=$(getFirebaseJsonKeyValue \"$_JSON_OUTPUT_RAW\" \"admob_delay_app_measurement_init\")\n if [[ $_ADMOB_DELAY_APP_MEASUREMENT == \"true\" ]]; then\n _PLIST_ENTRY_KEYS+=(\"GADDelayAppMeasurementInit\")\n _PLIST_ENTRY_TYPES+=(\"bool\")\n _PLIST_ENTRY_VALUES+=(\"YES\")\n fi\n\n # config.admob_ios_app_id\n _ADMOB_IOS_APP_ID=$(getFirebaseJsonKeyValue \"$_JSON_OUTPUT_RAW\" \"admob_ios_app_id\")\n if [[ $_ADMOB_IOS_APP_ID ]]; then\n _PLIST_ENTRY_KEYS+=(\"GADApplicationIdentifier\")\n _PLIST_ENTRY_TYPES+=(\"string\")\n _PLIST_ENTRY_VALUES+=(\"$_ADMOB_IOS_APP_ID\")\n fi\nelse\n _PLIST_ENTRY_KEYS+=(\"firebase_json_raw\")\n _PLIST_ENTRY_TYPES+=(\"string\")\n _PLIST_ENTRY_VALUES+=(\"$_JSON_OUTPUT_BASE64\")\n echo \"warning: A firebase.json file was not found, whilst this file is optional it is recommended to include it to configure firebase services in React Native Firebase.\"\nfi;\n\necho \"info: 2) Injecting Info.plist entries: \"\n\n# Log out the keys we're adding\nfor i in \"${!_PLIST_ENTRY_KEYS[@]}\"; do\n echo \" -> $i) ${_PLIST_ENTRY_KEYS[$i]}\" \"${_PLIST_ENTRY_TYPES[$i]}\" \"${_PLIST_ENTRY_VALUES[$i]}\"\ndone\n\nfor plist in \"${_TARGET_PLIST}\" \"${_DSYM_PLIST}\" ; do\n if [[ -f \"${plist}\" ]]; then\n\n # paths with spaces break the call to setPlistValue. temporarily modify\n # the shell internal field separator variable (IFS), which normally\n # includes spaces, to consist only of line breaks\n oldifs=$IFS\n IFS=\"\n\"\n\n for i in \"${!_PLIST_ENTRY_KEYS[@]}\"; do\n setPlistValue \"${_PLIST_ENTRY_KEYS[$i]}\" \"${_PLIST_ENTRY_TYPES[$i]}\" \"${_PLIST_ENTRY_VALUES[$i]}\" \"${plist}\"\n done\n\n # restore the original internal field separator value\n IFS=$oldifs\n else\n echo \"warning: A Info.plist build output file was not found (${plist})\"\n fi\ndone\n\necho \"info: <- RNFB build script finished\"\n"; }; D60DF7E84815282F7C392B53 /* [CP] Copy Pods Resources */ = { isa = PBXShellScriptBuildPhase; @@ -422,6 +457,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = "$(ARCHS_STANDARD)"; CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; @@ -443,6 +479,7 @@ ENABLE_BITCODE = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; + "EXCLUDED_ARCHS[sdk=*]" = "i386 arm64"; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; GCC_NO_COMMON_BLOCKS = YES; From a646bd310b8d26d4721321ba0c35e17c972ac77a Mon Sep 17 00:00:00 2001 From: russellwheatley Date: Wed, 7 Oct 2020 17:24:02 +0100 Subject: [PATCH 05/10] testing ci ios tests --- .../firestore/e2e/Query/limitToLast.e2e.js | 4 +- tests/e2e/mocha.opts | 37 +------------------ 2 files changed, 3 insertions(+), 38 deletions(-) diff --git a/packages/firestore/e2e/Query/limitToLast.e2e.js b/packages/firestore/e2e/Query/limitToLast.e2e.js index 08bafca587..b47089ed60 100644 --- a/packages/firestore/e2e/Query/limitToLast.e2e.js +++ b/packages/firestore/e2e/Query/limitToLast.e2e.js @@ -61,7 +61,7 @@ describe('firestore().collection().limitToLast()', () => { should(colRef._modifiers.options.limitToLast).equal(undefined); }); - it('limitToLast the number of documents', async () => { + it.only('limitToLast the number of documents', async () => { const subCol = `${COLLECTION}/limitToLast/count`; const colRef = firebase.firestore().collection(subCol); @@ -82,7 +82,7 @@ describe('firestore().collection().limitToLast()', () => { results.push(doc.data()); }); - should(results.length).equal(2); + // should(results.length).equal(2); should(results[0].count).equal(2); should(results[1].count).equal(1); diff --git a/tests/e2e/mocha.opts b/tests/e2e/mocha.opts index 2c1437d857..91205d8d8c 100644 --- a/tests/e2e/mocha.opts +++ b/tests/e2e/mocha.opts @@ -2,45 +2,10 @@ --timeout 720000 --reporter spec --slow 2000 ---retries 5 +--retries 0 --bail --exit --require node_modules/jet/platform/node -../packages/app/e2e/*.e2e.js - -../packages/analytics/e2e/*.e2e.js - -../packages/auth/e2e/*.e2e.js - -# TODO a lot of these failing on CI - might be an API rate limit change -# ../packages/admob/e2e/*.e2e.js - -../packages/crashlytics/e2e/*.e2e.js - -../packages/dynamic-links/e2e/*.e2e.js - -../packages/iid/e2e/*.e2e.js - -../packages/perf/e2e/*.e2e.js - -../packages/functions/e2e/*.e2e.js - -../packages/remote-config/e2e/*.e2e.js - -../packages/ml-natural-language/e2e/*.e2e.js - -# TODO - ci crashing Android -# ../packages/ml-vision/e2e/*.e2e.js - -../packages/in-app-messaging/e2e/*.e2e.js - -../packages/database/e2e/*.e2e.js - -# TODO crashing - error codes are wrong -# ../packages/storage/e2e/*.e2e.js - -../packages/messaging/e2e/*.e2e.js - ../packages/firestore/e2e/**/*.e2e.js From 16c484e1a5782edb02d776ec3c9a90a31ffbd5c8 Mon Sep 17 00:00:00 2001 From: russellwheatley Date: Thu, 8 Oct 2020 09:43:36 +0100 Subject: [PATCH 06/10] ci ios test --- .../firestore/e2e/Query/limitToLast.e2e.js | 4 +- tests/e2e/mocha.opts | 37 ++++++++++++++++++- 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/packages/firestore/e2e/Query/limitToLast.e2e.js b/packages/firestore/e2e/Query/limitToLast.e2e.js index b47089ed60..a1befea482 100644 --- a/packages/firestore/e2e/Query/limitToLast.e2e.js +++ b/packages/firestore/e2e/Query/limitToLast.e2e.js @@ -17,7 +17,7 @@ const COLLECTION = 'firestore'; const { wipe } = require('../helpers'); -describe('firestore().collection().limitToLast()', () => { +describe.only('firestore().collection().limitToLast()', () => { before(() => wipe()); it('throws if limitToLast is invalid', () => { try { @@ -61,7 +61,7 @@ describe('firestore().collection().limitToLast()', () => { should(colRef._modifiers.options.limitToLast).equal(undefined); }); - it.only('limitToLast the number of documents', async () => { + it('limitToLast the number of documents', async () => { const subCol = `${COLLECTION}/limitToLast/count`; const colRef = firebase.firestore().collection(subCol); diff --git a/tests/e2e/mocha.opts b/tests/e2e/mocha.opts index 91205d8d8c..913dd9c074 100644 --- a/tests/e2e/mocha.opts +++ b/tests/e2e/mocha.opts @@ -2,10 +2,45 @@ --timeout 720000 --reporter spec --slow 2000 ---retries 0 +--retries 5 --bail --exit --require node_modules/jet/platform/node +../packages/app/e2e/*.e2e.js + +#../packages/analytics/e2e/*.e2e.js + +#../packages/auth/e2e/*.e2e.js + +# TODO a lot of these failing on CI - might be an API rate limit change +# ../packages/admob/e2e/*.e2e.js + +#../packages/crashlytics/e2e/*.e2e.js + +#../packages/dynamic-links/e2e/*.e2e.js + +#../packages/iid/e2e/*.e2e.js + +#../packages/perf/e2e/*.e2e.js + +#../packages/functions/e2e/*.e2e.js + +#../packages/remote-config/e2e/*.e2e.js + +#../packages/ml-natural-language/e2e/*.e2e.js + +# TODO - ci crashing Android +# ../packages/ml-vision/e2e/*.e2e.js + +#../packages/in-app-messaging/e2e/*.e2e.js + +#../packages/database/e2e/*.e2e.js + +# TODO crashing - error codes are wrong +# ../packages/storage/e2e/*.e2e.js + +#../packages/messaging/e2e/*.e2e.js + ../packages/firestore/e2e/**/*.e2e.js From 2deeb58ed408233afc69b66db3d0ee1c1ba7bb3b Mon Sep 17 00:00:00 2001 From: russellwheatley Date: Thu, 8 Oct 2020 10:11:33 +0100 Subject: [PATCH 07/10] ci ios testing --- packages/firestore/e2e/Query/limitToLast.e2e.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/firestore/e2e/Query/limitToLast.e2e.js b/packages/firestore/e2e/Query/limitToLast.e2e.js index a1befea482..4ff1791db1 100644 --- a/packages/firestore/e2e/Query/limitToLast.e2e.js +++ b/packages/firestore/e2e/Query/limitToLast.e2e.js @@ -17,7 +17,7 @@ const COLLECTION = 'firestore'; const { wipe } = require('../helpers'); -describe.only('firestore().collection().limitToLast()', () => { +describe('firestore().collection().limitToLast()', () => { before(() => wipe()); it('throws if limitToLast is invalid', () => { try { From 0b379c8fd12a98873412201f0733aab7c68cb9ea Mon Sep 17 00:00:00 2001 From: russellwheatley Date: Thu, 8 Oct 2020 10:54:00 +0100 Subject: [PATCH 08/10] revert project.pbxproj --- tests/ios/testing.xcodeproj/project.pbxproj | 43 ++------------------- 1 file changed, 3 insertions(+), 40 deletions(-) diff --git a/tests/ios/testing.xcodeproj/project.pbxproj b/tests/ios/testing.xcodeproj/project.pbxproj index 7589bea839..2b58bdb68b 100644 --- a/tests/ios/testing.xcodeproj/project.pbxproj +++ b/tests/ios/testing.xcodeproj/project.pbxproj @@ -105,6 +105,7 @@ DD6CE4FF1D6F7A8C2E0647A0 /* Pods-testing.debug.xcconfig */, 8E2CB56F5CE51A2A19008908 /* Pods-testing.release.xcconfig */, ); + name = Pods; path = Pods; sourceTree = ""; }; @@ -155,7 +156,6 @@ buildConfigurationList = 13B07F931A680F5B00A75B9A /* Build configuration list for PBXNativeTarget "testing" */; buildPhases = ( 5F2F59C00A957B6F2EB00832 /* [CP] Check Pods Manifest.lock */, - 896435BF2CB42CDBCB7F99B9 /* [CP] Prepare Artifacts */, 13B07F871A680F5B00A75B9A /* Sources */, 13B07F8C1A680F5B00A75B9A /* Frameworks */, 13B07F8E1A680F5B00A75B9A /* Resources */, @@ -165,7 +165,6 @@ D60DF7E84815282F7C392B53 /* [CP] Copy Pods Resources */, 971DB9796AADE306A50F9133 /* [CP-User] [RNFB] Core Configuration */, E7DAD84A6BA0C83CFE863484 /* [CP-User] [RNFB] Crashlytics Configuration */, - 67EBDFA78BF4E67F2C8B1E0D /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -280,23 +279,6 @@ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; - 67EBDFA78BF4E67F2C8B1E0D /* [CP] Embed Pods Frameworks */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-testing/Pods-testing-frameworks-${CONFIGURATION}-input-files.xcfilelist", - ); - name = "[CP] Embed Pods Frameworks"; - outputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-testing/Pods-testing-frameworks-${CONFIGURATION}-output-files.xcfilelist", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-testing/Pods-testing-frameworks.sh\"\n"; - showEnvVarsInLog = 0; - }; 7D57265F10EEF7CD92D7973F /* Copy Detox Framework */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -311,23 +293,6 @@ shellPath = /bin/bash; shellScript = "if [ -n \"$DEPLOY_DETOX_FRAMEWORK\" ]; then\nmkdir -p \"${BUILT_PRODUCTS_DIR}\"/\"${FRAMEWORKS_FOLDER_PATH}\"\ncp -r \"${PROJECT_DIR}\"/../node_modules/detox/Detox.framework \"${BUILT_PRODUCTS_DIR}\"/\"${FRAMEWORKS_FOLDER_PATH}\"\nfi\n"; }; - 896435BF2CB42CDBCB7F99B9 /* [CP] Prepare Artifacts */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-testing/Pods-testing-artifacts-${CONFIGURATION}-input-files.xcfilelist", - ); - name = "[CP] Prepare Artifacts"; - outputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-testing/Pods-testing-artifacts-${CONFIGURATION}-output-files.xcfilelist", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-testing/Pods-testing-artifacts.sh\"\n"; - showEnvVarsInLog = 0; - }; 971DB9796AADE306A50F9133 /* [CP-User] [RNFB] Core Configuration */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -336,7 +301,7 @@ name = "[CP-User] [RNFB] Core Configuration"; runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "#!/usr/bin/env bash\n#\n# Copyright (c) 2016-present Invertase Limited & Contributors\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this library except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n#\nset -e\n\n_MAX_LOOKUPS=2;\n_SEARCH_RESULT=''\n_RN_ROOT_EXISTS=''\n_CURRENT_LOOKUPS=1\n_JSON_ROOT=\"'react-native'\"\n_JSON_FILE_NAME='firebase.json'\n_JSON_OUTPUT_BASE64='e30=' # { }\n_CURRENT_SEARCH_DIR=${PROJECT_DIR}\n_PLIST_BUDDY=/usr/libexec/PlistBuddy\n_TARGET_PLIST=\"${BUILT_PRODUCTS_DIR}/${INFOPLIST_PATH}\"\n_DSYM_PLIST=\"${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}/Contents/Info.plist\"\n\n# plist arrays\n_PLIST_ENTRY_KEYS=()\n_PLIST_ENTRY_TYPES=()\n_PLIST_ENTRY_VALUES=()\n\nfunction setPlistValue {\n echo \"info: setting plist entry '$1' of type '$2' in file '$4'\"\n ${_PLIST_BUDDY} -c \"Add :$1 $2 '$3'\" $4 || echo \"info: '$1' already exists\"\n}\n\nfunction getFirebaseJsonKeyValue () {\n if [[ ${_RN_ROOT_EXISTS} ]]; then\n ruby -e \"require 'rubygems';require 'json'; output=JSON.parse('$1'); puts output[$_JSON_ROOT]['$2']\"\n else\n echo \"\"\n fi;\n}\n\nfunction jsonBoolToYesNo () {\n if [[ $1 == \"false\" ]]; then\n echo \"NO\"\n elif [[ $1 == \"true\" ]]; then\n echo \"YES\"\n else echo \"NO\"\n fi\n}\n\necho \"info: -> RNFB build script started\"\necho \"info: 1) Locating ${_JSON_FILE_NAME} file:\"\n\nif [[ -z ${_CURRENT_SEARCH_DIR} ]]; then\n _CURRENT_SEARCH_DIR=$(pwd)\nfi;\n\nwhile true; do\n _CURRENT_SEARCH_DIR=$(dirname \"$_CURRENT_SEARCH_DIR\")\n if [[ \"$_CURRENT_SEARCH_DIR\" == \"/\" ]] || [[ ${_CURRENT_LOOKUPS} -gt ${_MAX_LOOKUPS} ]]; then break; fi;\n echo \"info: ($_CURRENT_LOOKUPS of $_MAX_LOOKUPS) Searching in '$_CURRENT_SEARCH_DIR' for a ${_JSON_FILE_NAME} file.\"\n _SEARCH_RESULT=$(find \"$_CURRENT_SEARCH_DIR\" -maxdepth 2 -name ${_JSON_FILE_NAME} -print | head -n 1)\n if [[ ${_SEARCH_RESULT} ]]; then\n echo \"info: ${_JSON_FILE_NAME} found at $_SEARCH_RESULT\"\n break;\n fi;\n _CURRENT_LOOKUPS=$((_CURRENT_LOOKUPS+1))\ndone\n\nif [[ ${_SEARCH_RESULT} ]]; then\n _JSON_OUTPUT_RAW=$(cat \"${_SEARCH_RESULT}\")\n _RN_ROOT_EXISTS=$(ruby -e \"require 'rubygems';require 'json'; output=JSON.parse('$_JSON_OUTPUT_RAW'); puts output[$_JSON_ROOT]\" || echo '')\n\n if [[ ${_RN_ROOT_EXISTS} ]]; then\n _JSON_OUTPUT_BASE64=$(python -c 'import json,sys,base64;print(base64.b64encode(json.dumps(json.loads(open('\"'${_SEARCH_RESULT}'\"').read())['${_JSON_ROOT}'])))' || echo \"e30=\")\n fi\n\n _PLIST_ENTRY_KEYS+=(\"firebase_json_raw\")\n _PLIST_ENTRY_TYPES+=(\"string\")\n _PLIST_ENTRY_VALUES+=(\"$_JSON_OUTPUT_BASE64\")\n\n # config.messaging_auto_init_enabled\n _MESSAGING_AUTO_INIT=$(getFirebaseJsonKeyValue \"$_JSON_OUTPUT_RAW\" \"messaging_auto_init_enabled\")\n if [[ $_MESSAGING_AUTO_INIT ]]; then\n _PLIST_ENTRY_KEYS+=(\"FirebaseMessagingAutoInitEnabled\")\n _PLIST_ENTRY_TYPES+=(\"bool\")\n _PLIST_ENTRY_VALUES+=(\"$(jsonBoolToYesNo \"$_MESSAGING_AUTO_INIT\")\")\n fi\n\n # config.crashlytics_disable_auto_disabler - undocumented for now - mainly for debugging, document if becomes useful\n _CRASHLYTICS_AUTO_DISABLE_ENABLED=$(getFirebaseJsonKeyValue \"$_JSON_OUTPUT_RAW\" \"crashlytics_disable_auto_disabler\")\n if [[ $_CRASHLYTICS_AUTO_DISABLE_ENABLED == \"true\" ]]; then\n echo \"Disabled Crashlytics auto disabler.\" # do nothing\n else\n _PLIST_ENTRY_KEYS+=(\"FirebaseCrashlyticsCollectionEnabled\")\n _PLIST_ENTRY_TYPES+=(\"bool\")\n _PLIST_ENTRY_VALUES+=(\"NO\")\n fi\n\n # config.admob_delay_app_measurement_init\n _ADMOB_DELAY_APP_MEASUREMENT=$(getFirebaseJsonKeyValue \"$_JSON_OUTPUT_RAW\" \"admob_delay_app_measurement_init\")\n if [[ $_ADMOB_DELAY_APP_MEASUREMENT == \"true\" ]]; then\n _PLIST_ENTRY_KEYS+=(\"GADDelayAppMeasurementInit\")\n _PLIST_ENTRY_TYPES+=(\"bool\")\n _PLIST_ENTRY_VALUES+=(\"YES\")\n fi\n\n # config.admob_ios_app_id\n _ADMOB_IOS_APP_ID=$(getFirebaseJsonKeyValue \"$_JSON_OUTPUT_RAW\" \"admob_ios_app_id\")\n if [[ $_ADMOB_IOS_APP_ID ]]; then\n _PLIST_ENTRY_KEYS+=(\"GADApplicationIdentifier\")\n _PLIST_ENTRY_TYPES+=(\"string\")\n _PLIST_ENTRY_VALUES+=(\"$_ADMOB_IOS_APP_ID\")\n fi\nelse\n _PLIST_ENTRY_KEYS+=(\"firebase_json_raw\")\n _PLIST_ENTRY_TYPES+=(\"string\")\n _PLIST_ENTRY_VALUES+=(\"$_JSON_OUTPUT_BASE64\")\n echo \"warning: A firebase.json file was not found, whilst this file is optional it is recommended to include it to configure firebase services in React Native Firebase.\"\nfi;\n\necho \"info: 2) Injecting Info.plist entries: \"\n\n# Log out the keys we're adding\nfor i in \"${!_PLIST_ENTRY_KEYS[@]}\"; do\n echo \" -> $i) ${_PLIST_ENTRY_KEYS[$i]}\" \"${_PLIST_ENTRY_TYPES[$i]}\" \"${_PLIST_ENTRY_VALUES[$i]}\"\ndone\n\nfor plist in \"${_TARGET_PLIST}\" \"${_DSYM_PLIST}\" ; do\n if [[ -f \"${plist}\" ]]; then\n\n # paths with spaces break the call to setPlistValue. temporarily modify\n # the shell internal field separator variable (IFS), which normally\n # includes spaces, to consist only of line breaks\n oldifs=$IFS\n IFS=\"\n\"\n\n for i in \"${!_PLIST_ENTRY_KEYS[@]}\"; do\n setPlistValue \"${_PLIST_ENTRY_KEYS[$i]}\" \"${_PLIST_ENTRY_TYPES[$i]}\" \"${_PLIST_ENTRY_VALUES[$i]}\" \"${plist}\"\n done\n\n # restore the original internal field separator value\n IFS=$oldifs\n else\n echo \"warning: A Info.plist build output file was not found (${plist})\"\n fi\ndone\n\necho \"info: <- RNFB build script finished\"\n"; + shellScript = "#!/usr/bin/env bash\n#\n# Copyright (c) 2016-present Invertase Limited & Contributors\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this library except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n#\nset -e\n\n_MAX_LOOKUPS=2;\n_SEARCH_RESULT=''\n_RN_ROOT_EXISTS=''\n_CURRENT_LOOKUPS=1\n_JSON_ROOT=\"'react-native'\"\n_JSON_FILE_NAME='firebase.json'\n_JSON_OUTPUT_BASE64='e30=' # { }\n_CURRENT_SEARCH_DIR=${PROJECT_DIR}\n_PLIST_BUDDY=/usr/libexec/PlistBuddy\n_TARGET_PLIST=\"${BUILT_PRODUCTS_DIR}/${INFOPLIST_PATH}\"\n_DSYM_PLIST=\"${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}/Contents/Info.plist\"\n\n# plist arrays\n_PLIST_ENTRY_KEYS=()\n_PLIST_ENTRY_TYPES=()\n_PLIST_ENTRY_VALUES=()\n\nfunction setPlistValue {\n echo \"info: setting plist entry '$1' of type '$2' in file '$4'\"\n ${_PLIST_BUDDY} -c \"Add :$1 $2 '$3'\" $4 || echo \"info: '$1' already exists\"\n}\n\nfunction getFirebaseJsonKeyValue () {\n if [[ ${_RN_ROOT_EXISTS} ]]; then\n ruby -e \"require 'rubygems';require 'json'; output=JSON.parse('$1'); puts output[$_JSON_ROOT]['$2']\"\n else\n echo \"\"\n fi;\n}\n\nfunction jsonBoolToYesNo () {\n if [[ $1 == \"false\" ]]; then\n echo \"NO\"\n elif [[ $1 == \"true\" ]]; then\n echo \"YES\"\n else echo \"NO\"\n fi\n}\n\necho \"info: -> RNFB build script started\"\necho \"info: 1) Locating ${_JSON_FILE_NAME} file:\"\n\nif [[ -z ${_CURRENT_SEARCH_DIR} ]]; then\n _CURRENT_SEARCH_DIR=$(pwd)\nfi;\n\nwhile true; do\n _CURRENT_SEARCH_DIR=$(dirname \"$_CURRENT_SEARCH_DIR\")\n if [[ \"$_CURRENT_SEARCH_DIR\" == \"/\" ]] || [[ ${_CURRENT_LOOKUPS} -gt ${_MAX_LOOKUPS} ]]; then break; fi;\n echo \"info: ($_CURRENT_LOOKUPS of $_MAX_LOOKUPS) Searching in '$_CURRENT_SEARCH_DIR' for a ${_JSON_FILE_NAME} file.\"\n _SEARCH_RESULT=$(find \"$_CURRENT_SEARCH_DIR\" -maxdepth 2 -name ${_JSON_FILE_NAME} -print | head -n 1)\n if [[ ${_SEARCH_RESULT} ]]; then\n echo \"info: ${_JSON_FILE_NAME} found at $_SEARCH_RESULT\"\n break;\n fi;\n _CURRENT_LOOKUPS=$((_CURRENT_LOOKUPS+1))\ndone\n\nif [[ ${_SEARCH_RESULT} ]]; then\n _JSON_OUTPUT_RAW=$(cat \"${_SEARCH_RESULT}\")\n _RN_ROOT_EXISTS=$(ruby -e \"require 'rubygems';require 'json'; output=JSON.parse('$_JSON_OUTPUT_RAW'); puts output[$_JSON_ROOT]\" || echo '')\n\n if [[ ${_RN_ROOT_EXISTS} ]]; then\n _JSON_OUTPUT_BASE64=$(python -c 'import json,sys,base64;print(base64.b64encode(json.dumps(json.loads(open('\"'${_SEARCH_RESULT}'\"').read())['${_JSON_ROOT}'])))' || echo \"e30=\")\n fi\n\n _PLIST_ENTRY_KEYS+=(\"firebase_json_raw\")\n _PLIST_ENTRY_TYPES+=(\"string\")\n _PLIST_ENTRY_VALUES+=(\"$_JSON_OUTPUT_BASE64\")\n\n # config.messaging_auto_init_enabled\n _MESSAGING_AUTO_INIT=$(getFirebaseJsonKeyValue \"$_JSON_OUTPUT_RAW\" \"messaging_auto_init_enabled\")\n if [[ $_MESSAGING_AUTO_INIT ]]; then\n _PLIST_ENTRY_KEYS+=(\"FirebaseMessagingAutoInitEnabled\")\n _PLIST_ENTRY_TYPES+=(\"bool\")\n _PLIST_ENTRY_VALUES+=(\"$(jsonBoolToYesNo \"$_MESSAGING_AUTO_INIT\")\")\n fi\n\n # config.crashlytics_disable_auto_disabler - undocumented for now - mainly for debugging, document if becomes usful\n _CRASHLYTICS_AUTO_DISABLE_ENABLED=$(getFirebaseJsonKeyValue \"$_JSON_OUTPUT_RAW\" \"crashlytics_disable_auto_disabler\")\n if [[ $_CRASHLYTICS_AUTO_DISABLE_ENABLED == \"true\" ]]; then\n echo \"Disabled Crashlytics auto disabler.\" # do nothing\n else\n _PLIST_ENTRY_KEYS+=(\"FirebaseCrashlyticsCollectionEnabled\")\n _PLIST_ENTRY_TYPES+=(\"bool\")\n _PLIST_ENTRY_VALUES+=(\"NO\")\n fi\n\n # config.admob_delay_app_measurement_init\n _ADMOB_DELAY_APP_MEASUREMENT=$(getFirebaseJsonKeyValue \"$_JSON_OUTPUT_RAW\" \"admob_delay_app_measurement_init\")\n if [[ $_ADMOB_DELAY_APP_MEASUREMENT == \"true\" ]]; then\n _PLIST_ENTRY_KEYS+=(\"GADDelayAppMeasurementInit\")\n _PLIST_ENTRY_TYPES+=(\"bool\")\n _PLIST_ENTRY_VALUES+=(\"YES\")\n fi\n\n # config.admob_ios_app_id\n _ADMOB_IOS_APP_ID=$(getFirebaseJsonKeyValue \"$_JSON_OUTPUT_RAW\" \"admob_ios_app_id\")\n if [[ $_ADMOB_IOS_APP_ID ]]; then\n _PLIST_ENTRY_KEYS+=(\"GADApplicationIdentifier\")\n _PLIST_ENTRY_TYPES+=(\"string\")\n _PLIST_ENTRY_VALUES+=(\"$_ADMOB_IOS_APP_ID\")\n fi\nelse\n _PLIST_ENTRY_KEYS+=(\"firebase_json_raw\")\n _PLIST_ENTRY_TYPES+=(\"string\")\n _PLIST_ENTRY_VALUES+=(\"$_JSON_OUTPUT_BASE64\")\n echo \"warning: A firebase.json file was not found, whilst this file is optional it is recommended to include it to configure firebase services in React Native Firebase.\"\nfi;\n\necho \"info: 2) Injecting Info.plist entries: \"\n\n# Log out the keys we're adding\nfor i in \"${!_PLIST_ENTRY_KEYS[@]}\"; do\n echo \" -> $i) ${_PLIST_ENTRY_KEYS[$i]}\" \"${_PLIST_ENTRY_TYPES[$i]}\" \"${_PLIST_ENTRY_VALUES[$i]}\"\ndone\n\nfor plist in \"${_TARGET_PLIST}\" \"${_DSYM_PLIST}\" ; do\n if [[ -f \"${plist}\" ]]; then\n\n # paths with spaces break the call to setPlistValue. temporarily modify\n # the shell internal field separator variable (IFS), which normally \n # includes spaces, to consist only of line breaks\n oldifs=$IFS\n IFS=\"\n\"\n\n for i in \"${!_PLIST_ENTRY_KEYS[@]}\"; do\n setPlistValue \"${_PLIST_ENTRY_KEYS[$i]}\" \"${_PLIST_ENTRY_TYPES[$i]}\" \"${_PLIST_ENTRY_VALUES[$i]}\" \"${plist}\"\n done\n\n # restore the original internal field separator value\n IFS=$oldifs\n else\n echo \"warning: A Info.plist build output file was not found (${plist})\"\n fi\ndone\n\necho \"info: <- RNFB build script finished\"\n\n"; }; D60DF7E84815282F7C392B53 /* [CP] Copy Pods Resources */ = { isa = PBXShellScriptBuildPhase; @@ -457,7 +422,6 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - ARCHS = "$(ARCHS_STANDARD)"; CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; @@ -479,7 +443,6 @@ ENABLE_BITCODE = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; - "EXCLUDED_ARCHS[sdk=*]" = "i386 arm64"; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; GCC_NO_COMMON_BLOCKS = YES; @@ -568,4 +531,4 @@ /* End XCConfigurationList section */ }; rootObject = 83CBB9F71A601CBA00E9B192 /* Project object */; -} +} \ No newline at end of file From 25494890f298aa8765488195cc783902e40a346f Mon Sep 17 00:00:00 2001 From: russellwheatley Date: Thu, 8 Oct 2020 16:39:17 +0100 Subject: [PATCH 09/10] test(firestore): fix broken tests --- packages/app/e2e/config.e2e.js | 7 ++++ .../firestore/e2e/Query/limitToLast.e2e.js | 2 +- tests/e2e/mocha.opts | 40 +++++++++---------- 3 files changed, 28 insertions(+), 21 deletions(-) diff --git a/packages/app/e2e/config.e2e.js b/packages/app/e2e/config.e2e.js index 0cd6ced34c..fd62a9f708 100644 --- a/packages/app/e2e/config.e2e.js +++ b/packages/app/e2e/config.e2e.js @@ -39,6 +39,13 @@ describe('config', () => { await NativeModules.RNFBAppModule.preferencesClearAll(); }); + // NOTE: "preferencesClearAll" clears Firestore settings. Set DB as emulator again. + after(async () => { + await firebase + .firestore() + .settings({ host: 'localhost:8080', ssl: false, persistence: true }); + }); + it('should set bool values', async () => { const prefsBefore = await NativeModules.RNFBAppModule.preferencesGetAll(); should.equal(prefsBefore.invertase_oss, undefined); diff --git a/packages/firestore/e2e/Query/limitToLast.e2e.js b/packages/firestore/e2e/Query/limitToLast.e2e.js index 4ff1791db1..08bafca587 100644 --- a/packages/firestore/e2e/Query/limitToLast.e2e.js +++ b/packages/firestore/e2e/Query/limitToLast.e2e.js @@ -82,7 +82,7 @@ describe('firestore().collection().limitToLast()', () => { results.push(doc.data()); }); - // should(results.length).equal(2); + should(results.length).equal(2); should(results[0].count).equal(2); should(results[1].count).equal(1); diff --git a/tests/e2e/mocha.opts b/tests/e2e/mocha.opts index 913dd9c074..2319b2bc40 100644 --- a/tests/e2e/mocha.opts +++ b/tests/e2e/mocha.opts @@ -8,39 +8,39 @@ --require node_modules/jet/platform/node -../packages/app/e2e/*.e2e.js +../packages/app/e2e/*.e2e.js -#../packages/analytics/e2e/*.e2e.js +../packages/analytics/e2e/*.e2e.js -#../packages/auth/e2e/*.e2e.js +../packages/auth/e2e/*.e2e.js -# TODO a lot of these failing on CI - might be an API rate limit change -# ../packages/admob/e2e/*.e2e.js +# TODO a lot of these failing on CI - might be an API rate limit change +# ../packages/admob/e2e/*.e2e.js -#../packages/crashlytics/e2e/*.e2e.js +../packages/crashlytics/e2e/*.e2e.js -#../packages/dynamic-links/e2e/*.e2e.js +../packages/dynamic-links/e2e/*.e2e.js -#../packages/iid/e2e/*.e2e.js +../packages/iid/e2e/*.e2e.js -#../packages/perf/e2e/*.e2e.js +../packages/perf/e2e/*.e2e.js -#../packages/functions/e2e/*.e2e.js +../packages/functions/e2e/*.e2e.js -#../packages/remote-config/e2e/*.e2e.js +../packages/remote-config/e2e/*.e2e.js -#../packages/ml-natural-language/e2e/*.e2e.js +../packages/ml-natural-language/e2e/*.e2e.js -# TODO - ci crashing Android -# ../packages/ml-vision/e2e/*.e2e.js +# TODO - ci crashing Android +# ../packages/ml-vision/e2e/*.e2e.js -#../packages/in-app-messaging/e2e/*.e2e.js +../packages/in-app-messaging/e2e/*.e2e.js -#../packages/database/e2e/*.e2e.js +../packages/database/e2e/*.e2e.js -# TODO crashing - error codes are wrong -# ../packages/storage/e2e/*.e2e.js +# TODO crashing - error codes are wrong +# ../packages/storage/e2e/*.e2e.js -#../packages/messaging/e2e/*.e2e.js +../packages/messaging/e2e/*.e2e.js -../packages/firestore/e2e/**/*.e2e.js +../packages/firestore/e2e/**/*.e2e.js \ No newline at end of file From 94d978e857b576adcb3a7c6161d626cd3ba0739c Mon Sep 17 00:00:00 2001 From: russellwheatley Date: Wed, 14 Oct 2020 13:02:30 +0100 Subject: [PATCH 10/10] test(firestore): rm todo --- packages/firestore/e2e/issues.e2e.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/firestore/e2e/issues.e2e.js b/packages/firestore/e2e/issues.e2e.js index 8bb58ceb41..ef08f9507c 100644 --- a/packages/firestore/e2e/issues.e2e.js +++ b/packages/firestore/e2e/issues.e2e.js @@ -16,7 +16,7 @@ */ const COLLECTION = 'firestore'; -//todo find otu why this fails when running all tests + describe('firestore()', () => { describe(COLLECTION, () => { before(async () => {