Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/scripts/firebase.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
"ui": {
"enabled": true,
"port": "4000"
"port": 4000
}
}
}
84 changes: 1 addition & 83 deletions .github/workflows/scripts/firestore.indexes.json
Original file line number Diff line number Diff line change
@@ -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": [
{
Expand Down Expand Up @@ -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"
}
]
}
]
}
154 changes: 6 additions & 148 deletions .github/workflows/scripts/firestore.rules
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
}
}
16 changes: 15 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
7 changes: 7 additions & 0 deletions packages/app/e2e/config.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 3 additions & 4 deletions packages/firestore/e2e/CollectionReference/add.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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();
Expand Down
9 changes: 4 additions & 5 deletions packages/firestore/e2e/CollectionReference/doc.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -36,15 +35,15 @@ 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);
});

it('uses path if provided', () => {
const instance = firebase
.firestore()
.collection('foo')
.collection(COLLECTION)
.doc('bar');
instance.id.should.eql('bar');
});
Expand Down
Loading