Skip to content

Commit 74004ff

Browse files
committed
test(firestore): Enable forceIndex tests
Enables the `forceIndex` tests. They set the `forceIndex` option to `"primary"` and simply assert that the snapshot contains an expected number of documents, and that the stage option has the `forceIndex` set as expected. Question: Is there a better way to validate that the request correctly used the index specified by `forceIndex`?
1 parent 87d5cc1 commit 74004ff

2 files changed

Lines changed: 28 additions & 16 deletions

File tree

packages/firestore/test/integration/api/pipeline.test.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6011,27 +6011,33 @@ apiDescribe.skipClassic('Pipelines', persistence => {
60116011

60126012
describe('stage options', () => {
60136013
describe('forceIndex', () => {
6014-
// SKIP: requires pre-existing index
6015-
// eslint-disable-next-line no-restricted-properties
6016-
it.skip('Collection Stage', async () => {
6014+
it('Collection Stage', async () => {
60176015
const snapshot = await execute(
60186016
firestore.pipeline().collection({
60196017
collection: randomCol,
6020-
forceIndex: 'unknown'
6018+
forceIndex: 'primary'
60216019
})
60226020
);
6021+
expect(
6022+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
6023+
(snapshot as any)._pipeline.stages[0].optionsProto.force_index
6024+
.stringValue
6025+
).equal('primary');
60236026
expect(snapshot.results.length).to.equal(10);
60246027
});
60256028

6026-
// SKIP: requires pre-existing index
6027-
// eslint-disable-next-line no-restricted-properties
6028-
it.skip('CollectionGroup Stage', async () => {
6029+
it('CollectionGroup Stage', async () => {
60296030
const snapshot = await execute(
60306031
firestore.pipeline().collectionGroup({
60316032
collectionId: randomCol.id,
6032-
forceIndex: 'unknown'
6033+
forceIndex: 'primary'
60336034
})
60346035
);
6036+
expect(
6037+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
6038+
(snapshot as any)._pipeline.stages[0].optionsProto.force_index
6039+
.stringValue
6040+
).equal('primary');
60356041
expect(snapshot.results.length).to.equal(10);
60366042
});
60376043
});

packages/firestore/test/lite/pipeline.test.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5883,27 +5883,33 @@ describe.skipClassic('Firestore Pipelines', () => {
58835883

58845884
describe('stage options', () => {
58855885
describe('forceIndex', () => {
5886-
// SKIP: requires pre-existing index
5887-
// eslint-disable-next-line no-restricted-properties
5888-
it.skip('Collection Stage', async () => {
5886+
it('Collection Stage', async () => {
58895887
const snapshot = await execute(
58905888
firestore.pipeline().collection({
58915889
collection: randomCol,
5892-
forceIndex: 'unknown'
5890+
forceIndex: 'primary'
58935891
})
58945892
);
5893+
expect(
5894+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
5895+
(snapshot as any)._pipeline.stages[0].optionsProto.force_index
5896+
.stringValue
5897+
).equal('primary');
58955898
expect(snapshot.results.length).to.equal(10);
58965899
});
58975900

5898-
// SKIP: requires pre-existing index
5899-
// eslint-disable-next-line no-restricted-properties
5900-
it.skip('CollectionGroup Stage', async () => {
5901+
it('CollectionGroup Stage', async () => {
59015902
const snapshot = await execute(
59025903
firestore.pipeline().collectionGroup({
59035904
collectionId: randomCol.id,
5904-
forceIndex: 'unknown'
5905+
forceIndex: 'primary'
59055906
})
59065907
);
5908+
expect(
5909+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
5910+
(snapshot as any)._pipeline.stages[0].optionsProto.force_index
5911+
.stringValue
5912+
).equal('primary');
59075913
expect(snapshot.results.length).to.equal(10);
59085914
});
59095915
});

0 commit comments

Comments
 (0)