Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

feat(other): Add Firestore support #7882

Merged
merged 29 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
f80b74c
feat(other): add App/Core support
Salakar Jul 4, 2024
93d0a27
feat(other): add Functions support
Salakar Jul 4, 2024
480ceb5
refactor: remove unnecessary config
Salakar Jul 4, 2024
a78d419
refactor(ci): testing app
Salakar Jul 4, 2024
f03c732
feat(firestore): Web implementation wip
Ehesp Jul 5, 2024
020e7b8
refactor(ci): testing app with new Jet (#7874)
Salakar Jul 7, 2024
96f173d
implement
Ehesp Jul 8, 2024
4461ca7
Merge branch 'feat-other-platforms' of https://github.com/invertase/r…
Ehesp Jul 8, 2024
d155626
-
Ehesp Jul 8, 2024
1c1d1f4
cleanup
Ehesp Jul 8, 2024
19c77e9
-
Ehesp Jul 8, 2024
1f9a6d8
update filters
Ehesp Jul 8, 2024
af6e58d
Merge branch 'main' of https://github.com/invertase/react-native-fire…
Ehesp Jul 9, 2024
04ac329
enable tests
Ehesp Jul 9, 2024
5a94375
Merge branch 'main' into web/firestore
Salakar Jul 10, 2024
c62b1ac
add event emitter
Ehesp Jul 10, 2024
4a7adb4
-
Ehesp Jul 10, 2024
bb06f40
Merge branch 'main' into web/firestore
Salakar Jul 12, 2024
d496fec
Merge branch 'main' into web/firestore
Salakar Jul 12, 2024
40e9a60
fixes
Salakar Jul 12, 2024
49b307a
add missing import
Salakar Jul 12, 2024
e3d75c6
Merge branch 'main' of https://github.com/invertase/react-native-fire…
Ehesp Jul 12, 2024
dbcf1e4
-
Ehesp Jul 12, 2024
3f58901
fix tests
Ehesp Jul 15, 2024
47d5be6
enable other tests
Ehesp Jul 15, 2024
c451ed7
fix module import
Ehesp Jul 15, 2024
ebf05cf
lint
Ehesp Jul 15, 2024
04a003f
disable global logging
Ehesp Jul 15, 2024
76ada6e
lints
Ehesp Jul 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/app/lib/internal/web/firebaseFirestore.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// We need to share firebase imports between modules, otherwise
// apps and instances of the firebase modules are not shared.
export { getApp } from 'firebase/app';
export * from 'firebase/firestore/lite';
5 changes: 5 additions & 0 deletions packages/firestore/e2e/Bundle/loadBundle.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
const { wipe, getBundle, BUNDLE_COLLECTION } = require('../helpers');

describe('firestore().loadBundle()', function () {
// Not supported on web.
if (Platform.other) {
return;
}

before(async function () {
return await wipe();
});
Expand Down
4 changes: 4 additions & 0 deletions packages/firestore/e2e/Bundle/namedQuery.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
const { wipe, getBundle, BUNDLE_COLLECTION, BUNDLE_QUERY_NAME } = require('../helpers');

describe('firestore().namedQuery()', function () {
if (Platform.other) {
return;
}

beforeEach(async function () {
await wipe();
return await firebase.firestore().loadBundle(getBundle());
Expand Down
21 changes: 21 additions & 0 deletions packages/firestore/e2e/DocumentChange.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ describe('firestore.DocumentChange', function () {

describe('v8 compatibility', function () {
it('.doc -> returns a DocumentSnapshot', async function () {
if (Platform.other) {
return;
}

const colRef = firebase.firestore().collection(COLLECTION);
await colRef.add({});
const snapshot = await colRef.limit(1).get();
Expand All @@ -35,6 +39,9 @@ describe('firestore.DocumentChange', function () {
});

it('returns the correct metadata when adding and removing', async function () {
if (Platform.other) {
return;
}
const colRef = firebase
.firestore()
.collection(`${COLLECTION}/docChanges/docChangesCollection`);
Expand Down Expand Up @@ -77,6 +84,9 @@ describe('firestore.DocumentChange', function () {
});

it('returns the correct metadata when modifying documents', async function () {
if (Platform.other) {
return;
}
const colRef = firebase.firestore().collection(`${COLLECTION}/docChanges/docMovedCollection`);

const doc1 = firebase.firestore().doc(`${COLLECTION}/docChanges/docMovedCollection/doc1`);
Expand Down Expand Up @@ -120,6 +130,10 @@ describe('firestore.DocumentChange', function () {

describe('modular', function () {
it('.doc -> returns a DocumentSnapshot', async function () {
if (Platform.other) {
return;
}

const { getFirestore, collection, addDoc, limit, getDocs, query } = firestoreModular;
const db = getFirestore();

Expand All @@ -134,6 +148,9 @@ describe('firestore.DocumentChange', function () {
});

it('returns the correct metadata when adding and removing', async function () {
if (Platform.other) {
return;
}
const { getFirestore, collection, doc, setDoc, onSnapshot, deleteDoc } = firestoreModular;
const db = getFirestore();

Expand Down Expand Up @@ -177,6 +194,10 @@ describe('firestore.DocumentChange', function () {
});

it('returns the correct metadata when modifying documents', async function () {
if (Platform.other) {
return;
}

const { getFirestore, collection, doc, setDoc, orderBy, query, onSnapshot, updateDoc } =
firestoreModular;
const db = getFirestore();
Expand Down
6 changes: 6 additions & 0 deletions packages/firestore/e2e/DocumentReference/get.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ describe('firestore.doc().get()', function () {
});

it('gets data from cache', async function () {
if (Platform.other) {
return;
}
const ref = firebase.firestore().doc(`${COLLECTION}/get`);
const data = { foo: 'bar', bar: 123 };
await ref.set(data);
Expand Down Expand Up @@ -100,6 +103,9 @@ describe('firestore.doc().get()', function () {
});

it('gets data from cache', async function () {
if (Platform.other) {
return;
}
const { getFirestore, doc, setDoc, getDocFromCache, deleteDoc } = firestoreModular;

const ref = doc(getFirestore(), `${COLLECTION}/get`);
Expand Down
50 changes: 50 additions & 0 deletions packages/firestore/e2e/DocumentReference/onSnapshot.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ describe('firestore().doc().onSnapshot()', function () {
});

it('accepts a single callback function with snapshot', async function () {
if (Platform.other) {
return;
}
const callback = sinon.spy();
const unsub = firebase.firestore().doc(`${COLLECTION}/foo`).onSnapshot(callback);

Expand All @@ -57,6 +60,9 @@ describe('firestore().doc().onSnapshot()', function () {
});

it('accepts a single callback function with Error', async function () {
if (Platform.other) {
return;
}
const callback = sinon.spy();
const unsub = firebase.firestore().doc(`${NO_RULE_COLLECTION}/nope`).onSnapshot(callback);

Expand All @@ -69,6 +75,10 @@ describe('firestore().doc().onSnapshot()', function () {
});

describe('multiple callbacks', function () {
if (Platform.other) {
return;
}

it('calls onNext when successful', async function () {
const onNext = sinon.spy();
const onError = sinon.spy();
Expand Down Expand Up @@ -102,6 +112,10 @@ describe('firestore().doc().onSnapshot()', function () {
});

describe('objects of callbacks', function () {
if (Platform.other) {
return;
}

it('calls next when successful', async function () {
const onNext = sinon.spy();
const onError = sinon.spy();
Expand Down Expand Up @@ -138,6 +152,10 @@ describe('firestore().doc().onSnapshot()', function () {
});

describe('SnapshotListenerOptions + callbacks', function () {
if (Platform.other) {
return;
}

it('calls callback with snapshot when successful', async function () {
const callback = sinon.spy();
const unsub = firebase.firestore().doc(`${COLLECTION}/foo`).onSnapshot(
Expand Down Expand Up @@ -214,6 +232,10 @@ describe('firestore().doc().onSnapshot()', function () {
});

describe('SnapshotListenerOptions + object of callbacks', function () {
if (Platform.other) {
return;
}

it('calls next with snapshot when successful', async function () {
const onNext = sinon.spy();
const onError = sinon.spy();
Expand Down Expand Up @@ -298,6 +320,9 @@ describe('firestore().doc().onSnapshot()', function () {
});

it('unsubscribes from further updates', async function () {
if (Platform.other) {
return;
}
const callback = sinon.spy();
const doc = firebase.firestore().doc(`${COLLECTION}/unsub`);

Expand Down Expand Up @@ -334,6 +359,9 @@ describe('firestore().doc().onSnapshot()', function () {
});

it('accepts a single callback function with snapshot', async function () {
if (Platform.other) {
return;
}
const { getFirestore, doc, onSnapshot } = firestoreModular;

const callback = sinon.spy();
Expand All @@ -348,7 +376,14 @@ describe('firestore().doc().onSnapshot()', function () {
});

describe('multiple callbacks', function () {
if (Platform.other) {
return;
}

it('calls onNext when successful', async function () {
if (Platform.other) {
return;
}
const { getFirestore, doc, onSnapshot } = firestoreModular;

const onNext = sinon.spy();
Expand Down Expand Up @@ -385,6 +420,10 @@ describe('firestore().doc().onSnapshot()', function () {
});

describe('objects of callbacks', function () {
if (Platform.other) {
return;
}

it('calls next when successful', async function () {
const { getFirestore, doc, onSnapshot } = firestoreModular;

Expand Down Expand Up @@ -425,6 +464,10 @@ describe('firestore().doc().onSnapshot()', function () {
});

describe('SnapshotListenerOptions + callbacks', function () {
if (Platform.other) {
return;
}

it('calls callback with snapshot when successful', async function () {
const { getFirestore, doc, onSnapshot } = firestoreModular;

Expand Down Expand Up @@ -493,6 +536,10 @@ describe('firestore().doc().onSnapshot()', function () {
});

describe('SnapshotListenerOptions + object of callbacks', function () {
if (Platform.other) {
return;
}

it('calls next with snapshot when successful', async function () {
const { getFirestore, doc, onSnapshot } = firestoreModular;

Expand Down Expand Up @@ -586,6 +633,9 @@ describe('firestore().doc().onSnapshot()', function () {
});

it('unsubscribes from further updates', async function () {
if (Platform.other) {
return;
}
const { getFirestore, doc, onSnapshot, setDoc } = firestoreModular;

const callback = sinon.spy();
Expand Down
45 changes: 45 additions & 0 deletions packages/firestore/e2e/DocumentReference/set.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,11 @@ describe('firestore.doc().set()', function () {
});

it('throws when nested undefined array value provided and ignored undefined is false', async function () {
// TODO(ehesp): Figure out how to call settings multiple times on modular SDK.
if (Platform.other) {
return;
}

await firebase.firestore().settings({ ignoreUndefinedProperties: false });
const docRef = firebase.firestore().doc(`${COLLECTION}/bar`);
try {
Expand All @@ -173,6 +178,11 @@ describe('firestore.doc().set()', function () {
});

it('accepts undefined nested array values if ignoreUndefined is true', async function () {
// TODO(ehesp): Figure out how to call settings multiple times on modular SDK.
if (Platform.other) {
return;
}

await firebase.firestore().settings({ ignoreUndefinedProperties: true });
const docRef = firebase.firestore().doc(`${COLLECTION}/bar`);
await docRef.set({
Expand All @@ -181,6 +191,11 @@ describe('firestore.doc().set()', function () {
});

it('does not throw when nested undefined object value provided and ignore undefined is true', async function () {
// TODO(ehesp): Figure out how to call settings multiple times on modular SDK.
if (Platform.other) {
return;
}

await firebase.firestore().settings({ ignoreUndefinedProperties: true });
const docRef = firebase.firestore().doc(`${COLLECTION}/bar`);
await docRef.set({
Expand All @@ -192,6 +207,11 @@ describe('firestore.doc().set()', function () {
});

it('filters out undefined properties when setting enabled', async function () {
// TODO(ehesp): Figure out how to call settings multiple times on modular SDK.
if (Platform.other) {
return;
}

await firebase.firestore().settings({ ignoreUndefinedProperties: true });

const docRef = firebase.firestore().doc(`${COLLECTION}/ignoreUndefinedTrueProp`);
Expand All @@ -211,6 +231,11 @@ describe('firestore.doc().set()', function () {
});

it('filters out nested undefined properties when setting enabled', async function () {
// TODO(ehesp): Figure out how to call settings multiple times on modular SDK.
if (Platform.other) {
return;
}

await firebase.firestore().settings({ ignoreUndefinedProperties: true });

const docRef = firebase.firestore().doc(`${COLLECTION}/ignoreUndefinedTrueNestedProp`);
Expand Down Expand Up @@ -405,6 +430,11 @@ describe('firestore.doc().set()', function () {
});

it('accepts undefined nested array values if ignoreUndefined is true', async function () {
// TODO(ehesp): Figure out how to call settings multiple times on modular SDK.
if (Platform.other) {
return;
}

const { getFirestore, initializeFirestore, doc, setDoc } = firestoreModular;
const db = getFirestore();
initializeFirestore(db.app, { ignoreUndefinedProperties: true });
Expand All @@ -415,6 +445,11 @@ describe('firestore.doc().set()', function () {
});

it('does not throw when nested undefined object value provided and ignore undefined is true', async function () {
// TODO(ehesp): Figure out how to call settings multiple times on modular SDK.
if (Platform.other) {
return;
}

const { getFirestore, initializeFirestore, doc, setDoc } = firestoreModular;
const db = getFirestore();
initializeFirestore(db.app, { ignoreUndefinedProperties: true });
Expand All @@ -428,6 +463,11 @@ describe('firestore.doc().set()', function () {
});

it('filters out undefined properties when setting enabled', async function () {
// TODO(ehesp): Figure out how to call settings multiple times on modular SDK.
if (Platform.other) {
return;
}

const { getFirestore, initializeFirestore, doc, setDoc, getDoc } = firestoreModular;
const db = getFirestore();
initializeFirestore(db.app, { ignoreUndefinedProperties: true });
Expand All @@ -449,6 +489,11 @@ describe('firestore.doc().set()', function () {
});

it('filters out nested undefined properties when setting enabled', async function () {
// TODO(ehesp): Figure out how to call settings multiple times on modular SDK.
if (Platform.other) {
return;
}

const { getFirestore, initializeFirestore, doc, setDoc, getDoc } = firestoreModular;
const db = getFirestore();
initializeFirestore(db.app, { ignoreUndefinedProperties: true });
Expand Down
2 changes: 1 addition & 1 deletion packages/firestore/e2e/FirestoreStatics.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('firestore.X', function () {
});
});

describe('modular', function () {
xdescribe('modular', function () {
describe('setLogLevel', function () {
it('throws if invalid level', function () {
const { setLogLevel } = firestoreModular;
Expand Down
8 changes: 8 additions & 0 deletions packages/firestore/e2e/Query/get.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ describe('firestore().collection().get()', function () {
});

it('returns a correct cache setting (true)', async function () {
if (Platform.other) {
return;
}

const docRef = firebase.firestore().collection(COLLECTION).doc('nestedcollection');
const colRef = docRef.collection('get');
const snapshot = await colRef.get({
Expand Down Expand Up @@ -91,6 +95,10 @@ describe('firestore().collection().get()', function () {
});

it('returns a correct cache setting (true)', async function () {
if (Platform.other) {
return;
}

const { getFirestore, collection, doc, getDocsFromCache } = firestoreModular;
const docRef = doc(collection(getFirestore(), COLLECTION), 'nestedcollection');
const colRef = collection(docRef, 'get');
Expand Down
Loading
Loading