firebase / firebase/firebase-tools
Add Firestore indexes to local emulator
- Dominant language
- TypeScript
- Stars
- 4.5k
- Forks
- 1.3k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 84
Description
### [REQUIRED] Environment info
**firebase-tools:**
7.15.0
**Platform:**
Ubuntu 18.04.4
### [REQUIRED] Test case
I'm trying to test [our Firestore indexes](https://tutorbook.app/docs/tutorial-Storage.html), but they seem to always be working (regardless of the indexing settings included in `firestore.indexes.json`). Below is the [test case in question](https://github.com/tutorbookapp/tutorbook/blob/develop/firebase/test/test.js#L382):
```javascript
const FILTERS = {
'grade': ['==', TUTOR.grade],
'gender': ['==', TUTOR.gender],
'location': ['==', TUTOR.location],
'type': ['==', TUTOR.type],
'payments.type': ['==', TUTOR.payments.type],
'config.showProfile': ['==', true],
};
const SORTERS = [
'avgRating',
'numRatings',
];
describe('Tutorbook\'s Database Indexing', () => {
const db = authedApp({
uid: PUPIL.uid,
email: PUPIL.email,
access: PUPIL.access,
});
const filterCombos = combinations(Object.keys(FILTERS));
return Promise.all(filterCombos.map(filters => it('lets users filter ' +
'profiles by ' + filters.join(', '), () => {
var query = db.collection('users')
.where('access', 'array-contains-any', PUPIL.access);
filters.map(filter => query =
query.where(filter, FILTERS[filter][0], FILTERS[filter][1]));
return Promise.all(SORTERS.map(sorter =>
firebase.assertSucceeds(query.orderBy(sorter).get())));
})));
});
```
### [REQUIRED] Steps to reproduce
Just try testing any type of composite or collection group query that would (normally) require an index. It will work on the emulator suite regardless of the existence of the required index (but it won't work in production without the index).
### [REQUIRED] Expected behavior
These tests should fail unless there are Firestore indexes (specified in `firestore.indexes.json`) that support the composite indexes tested.
### [REQUIRED] Actual behavior
All the tests succeed (even though they shouldn't).
Contributor guide
Assessment
This issue has not been assessed yet.