@@ -38,14 +38,8 @@ import { DocumentKey } from '../../../src/model/document_key';
38
38
import { DocumentSet } from '../../../src/model/document_set' ;
39
39
import { assert } from '../../../src/util/assert' ;
40
40
import { testMemoryEagerPersistence } from './persistence_test_helpers' ;
41
- import {
42
- doc ,
43
- filter ,
44
- key ,
45
- orderBy ,
46
- path ,
47
- queryData as testQueryData
48
- } from '../../util/helpers' ;
41
+ import { doc , filter , key , orderBy , path , version } from '../../util/helpers' ;
42
+ import { ListenSequence } from '../../../src/core/listen_sequence' ;
49
43
50
44
const TEST_TARGET_ID = 1 ;
51
45
@@ -183,13 +177,7 @@ describe('IndexFreeQueryEngine', () => {
183
177
const query = Query . atPath ( path ( 'coll' ) ) . addFilter (
184
178
filter ( 'matches' , '==' , true )
185
179
) ;
186
- const queryData = testQueryData (
187
- 2 ,
188
- QueryPurpose . Listen ,
189
- 'coll' ,
190
- 10 ,
191
- /* hasLimboFreeSnapshot= */ true
192
- ) ;
180
+ const queryData = testQueryData ( query , /* hasLimboFreeSnapshot= */ true ) ;
193
181
194
182
await addDocument ( MATCHING_DOC_A , MATCHING_DOC_B ) ;
195
183
await persistQueryMapping ( MATCHING_DOC_A . key , MATCHING_DOC_B . key ) ;
@@ -203,13 +191,7 @@ describe('IndexFreeQueryEngine', () => {
203
191
const query = Query . atPath ( path ( 'coll' ) ) . addFilter (
204
192
filter ( 'matches' , '==' , true )
205
193
) ;
206
- const queryData = testQueryData (
207
- 2 ,
208
- QueryPurpose . Listen ,
209
- 'coll' ,
210
- 10 ,
211
- /* hasLimboFreeSnapshot= */ true
212
- ) ;
194
+ const queryData = testQueryData ( query , /* hasLimboFreeSnapshot= */ true ) ;
213
195
214
196
await addDocument ( MATCHING_DOC_A , MATCHING_DOC_B ) ;
215
197
await persistQueryMapping ( MATCHING_DOC_A . key , MATCHING_DOC_B . key ) ;
@@ -226,13 +208,7 @@ describe('IndexFreeQueryEngine', () => {
226
208
const query = Query . atPath ( path ( 'coll' ) ) . addFilter (
227
209
filter ( 'matches' , '==' , true )
228
210
) ;
229
- const queryData = testQueryData (
230
- 2 ,
231
- QueryPurpose . Listen ,
232
- 'coll' ,
233
- 10 ,
234
- /* hasLimboFreeSnapshot= */ true
235
- ) ;
211
+ const queryData = testQueryData ( query , /* hasLimboFreeSnapshot= */ true ) ;
236
212
237
213
await addDocument ( MATCHING_DOC_A , MATCHING_DOC_B ) ;
238
214
await persistQueryMapping ( MATCHING_DOC_A . key , MATCHING_DOC_B . key ) ;
@@ -251,13 +227,7 @@ describe('IndexFreeQueryEngine', () => {
251
227
const query = Query . atPath ( path ( 'coll' ) ) . addFilter (
252
228
filter ( 'matches' , '==' , true )
253
229
) ;
254
- const queryData = testQueryData (
255
- 2 ,
256
- QueryPurpose . Listen ,
257
- 'coll' ,
258
- 10 ,
259
- /* hasLimboFreeSnapshot= */ false
260
- ) ;
230
+ const queryData = testQueryData ( query , /* hasLimboFreeSnapshot= */ false ) ;
261
231
262
232
const docs = await expectFullCollectionQuery ( ( ) =>
263
233
runQuery ( query , queryData )
@@ -267,13 +237,7 @@ describe('IndexFreeQueryEngine', () => {
267
237
268
238
it ( 'does not use initial results for unfiltered collection query' , async ( ) => {
269
239
const query = Query . atPath ( path ( 'coll' ) ) ;
270
- const queryData = testQueryData (
271
- 2 ,
272
- QueryPurpose . Listen ,
273
- 'coll' ,
274
- 10 ,
275
- /* hasLimboFreeSnapshot= */ true
276
- ) ;
240
+ const queryData = testQueryData ( query , /* hasLimboFreeSnapshot= */ true ) ;
277
241
278
242
const docs = await expectFullCollectionQuery ( ( ) =>
279
243
runQuery ( query , queryData )
@@ -294,13 +258,7 @@ describe('IndexFreeQueryEngine', () => {
294
258
295
259
await addDocument ( MATCHING_DOC_B ) ;
296
260
297
- const queryData = testQueryData (
298
- 2 ,
299
- QueryPurpose . Listen ,
300
- 'coll' ,
301
- 10 ,
302
- /* hasLimboFreeSnapshot= */ true
303
- ) ;
261
+ const queryData = testQueryData ( query , /* hasLimboFreeSnapshot= */ true ) ;
304
262
const docs = await expectFullCollectionQuery ( ( ) =>
305
263
runQuery ( query , queryData )
306
264
) ;
@@ -319,13 +277,7 @@ describe('IndexFreeQueryEngine', () => {
319
277
await addDocument ( PENDING_MATCHING_DOC_A ) ;
320
278
await persistQueryMapping ( PENDING_MATCHING_DOC_A . key ) ;
321
279
322
- const queryData = testQueryData (
323
- 2 ,
324
- QueryPurpose . Listen ,
325
- 'coll' ,
326
- 10 ,
327
- /* hasLimboFreeSnapshot= */ true
328
- ) ;
280
+ const queryData = testQueryData ( query , /* hasLimboFreeSnapshot= */ true ) ;
329
281
330
282
await addDocument ( MATCHING_DOC_B ) ;
331
283
@@ -347,13 +299,7 @@ describe('IndexFreeQueryEngine', () => {
347
299
await addDocument ( UPDATED_DOC_A ) ;
348
300
await persistQueryMapping ( UPDATED_DOC_A . key ) ;
349
301
350
- const queryData = testQueryData (
351
- 2 ,
352
- QueryPurpose . Listen ,
353
- 'coll' ,
354
- 10 ,
355
- /* hasLimboFreeSnapshot= */ true
356
- ) ;
302
+ const queryData = testQueryData ( query , /* hasLimboFreeSnapshot= */ true ) ;
357
303
358
304
await addDocument ( MATCHING_DOC_B ) ;
359
305
@@ -372,13 +318,7 @@ describe('IndexFreeQueryEngine', () => {
372
318
await addDocument ( doc ( 'coll/b' , 1 , { order : 3 } ) ) ;
373
319
await persistQueryMapping ( key ( 'coll/a' ) , key ( 'coll/b' ) ) ;
374
320
375
- const queryData = testQueryData (
376
- 2 ,
377
- QueryPurpose . Listen ,
378
- 'coll' ,
379
- 10 ,
380
- /* hasLimboFreeSnapshot= */ true
381
- ) ;
321
+ const queryData = testQueryData ( query , /* hasLimboFreeSnapshot= */ true ) ;
382
322
383
323
// Update "coll/a" but make sure it still sorts before "coll/b"
384
324
await addDocument (
@@ -412,3 +352,14 @@ function verifyResult(
412
352
'Result count does not match'
413
353
) ;
414
354
}
355
+
356
+ function testQueryData ( query : Query , hasLimboFreeSnapshot : boolean ) : QueryData {
357
+ return new QueryData (
358
+ query ,
359
+ TEST_TARGET_ID ,
360
+ QueryPurpose . Listen ,
361
+ ListenSequence . INVALID ,
362
+ version ( 10 ) ,
363
+ hasLimboFreeSnapshot ? version ( 10 ) : SnapshotVersion . MIN
364
+ ) ;
365
+ }
0 commit comments