@@ -1173,7 +1173,7 @@ describeSpec('Limbo Documents:', [], () => {
1173
1173
) ;
1174
1174
1175
1175
specTest (
1176
- 'Fix #8474 - Limbo resolution for documentC is removed even if documentC updates occurred earlier in the global snapshot window' ,
1176
+ 'Fix #8474 - Limbo resolution for document is removed even if document updates for the document occurred before documentDelete in the global snapshot window' ,
1177
1177
[ ] ,
1178
1178
( ) => {
1179
1179
// onSnapshot(fullQuery)
@@ -1199,7 +1199,7 @@ describeSpec('Limbo Documents:', [], () => {
1199
1199
} )
1200
1200
1201
1201
// docC was deleted, this puts docC in limbo and causes a snapshot from cache (metadata-only change)
1202
- . watchSends ( { removed : [ fullQuery ] } , docC )
1202
+ . watchRemovesDoc ( docC . key , fullQuery )
1203
1203
. watchCurrents ( fullQuery , 'resume-token-1002' )
1204
1204
. watchSnapshots ( 1002 )
1205
1205
. expectLimboDocs ( docC . key )
@@ -1221,19 +1221,19 @@ describeSpec('Limbo Documents:', [], () => {
1221
1221
. watchAcks ( filterQuery )
1222
1222
1223
1223
// Watch responds to limboQueryC - docC was deleted
1224
- . watchSends ( { affects : [ limboQueryC ] } )
1224
+ . watchDeletesDoc ( docC . key , 1009 , limboQueryC )
1225
1225
. watchCurrents ( limboQueryC , 'resume-token-1009' )
1226
1226
. watchSnapshots ( 1009 , [ limboQueryC , fullQuery ] )
1227
1227
1228
1228
// However, docC is still in limbo because there has not been a global snapshot
1229
1229
. expectLimboDocs ( docC . key )
1230
1230
1231
1231
// Rapid events of document update and delete caused by application
1232
- . watchSends ( { removed : [ filterQuery ] } , docA )
1232
+ . watchRemovesDoc ( docA . key , filterQuery )
1233
1233
. watchCurrents ( filterQuery , 'resume-token-1004' )
1234
1234
. watchSends ( { affects : [ filterQuery ] } , docC )
1235
1235
. watchCurrents ( filterQuery , 'resume-token-1005' )
1236
- . watchSends ( { removed : [ filterQuery ] } , docC )
1236
+ . watchRemovesDoc ( docC . key , filterQuery )
1237
1237
. watchSends ( { affects : [ filterQuery ] } , docA2 )
1238
1238
. watchCurrents ( filterQuery , 'resume-token-1007' )
1239
1239
@@ -1255,96 +1255,103 @@ describeSpec('Limbo Documents:', [], () => {
1255
1255
removed : [ docC ] ,
1256
1256
added : [ docA2 ]
1257
1257
} )
1258
+
1259
+ // No more expected events
1260
+ . watchSnapshots ( 1100 , [ ] )
1258
1261
) ;
1259
1262
}
1260
1263
) ;
1261
1264
1262
- specTest ( 'Fix #8474 - Watch sends deletedDoc on limbo resolution' , [ ] , ( ) => {
1263
- // onSnapshot(fullQuery)
1264
- const fullQuery = query ( 'collection' ) ;
1265
+ specTest (
1266
+ 'Fix #8474 - Limbo resolution for document is removed even if document updates for the document occurred in the global snapshot window and no document delete was received for the limbo resolution query' ,
1267
+ [ ] ,
1268
+ ( ) => {
1269
+ // onSnapshot(fullQuery)
1270
+ const fullQuery = query ( 'collection' ) ;
1265
1271
1266
- // getDocs(filterQuery)
1267
- const filterQuery = query ( 'collection' , filter ( 'included' , '==' , true ) ) ;
1272
+ // getDocs(filterQuery)
1273
+ const filterQuery = query ( 'collection' , filter ( 'included' , '==' , true ) ) ;
1268
1274
1269
- const docA = doc ( 'collection/a' , 1000 , { key : 'a' , included : false } ) ;
1270
- const docA2 = doc ( 'collection/a' , 1007 , { key : 'a' , included : true } ) ;
1271
- const docC = doc ( 'collection/c' , 1002 , { key : 'c' , included : true } ) ;
1272
- const docCDeleted = deletedDoc ( 'collection/c' , 1009 ) ;
1275
+ const docA = doc ( 'collection/a' , 1000 , { key : 'a' , included : false } ) ;
1276
+ const docA2 = doc ( 'collection/a' , 1007 , { key : 'a' , included : true } ) ;
1277
+ const docC = doc ( 'collection/c' , 1002 , { key : 'c' , included : true } ) ;
1273
1278
1274
- const limboQueryC = newQueryForPath ( docC . key . path ) ;
1279
+ const limboQueryC = newQueryForPath ( docC . key . path ) ;
1275
1280
1276
- return (
1277
- spec ( )
1278
- // onSnapshot(fullQuery) - fullQuery is listening to documents in the collection for the full test
1279
- . userListens ( fullQuery )
1280
- . watchAcksFull ( fullQuery , 1001 , docA , docC )
1281
- . expectEvents ( fullQuery , {
1282
- fromCache : false ,
1283
- added : [ docA , docC ]
1284
- } )
1281
+ return (
1282
+ spec ( )
1283
+ // onSnapshot(fullQuery) - fullQuery is listening to documents in the collection for the full test
1284
+ . userListens ( fullQuery )
1285
+ . watchAcksFull ( fullQuery , 1001 , docA , docC )
1286
+ . expectEvents ( fullQuery , {
1287
+ fromCache : false ,
1288
+ added : [ docA , docC ]
1289
+ } )
1285
1290
1286
- // docC was deleted, this puts docC in limbo and causes a snapshot from cache (metadata-only change)
1287
- . watchSends ( { removed : [ fullQuery ] } , docC )
1288
- . watchCurrents ( fullQuery , 'resume-token-1002' )
1289
- . watchSnapshots ( 1002 )
1290
- . expectLimboDocs ( docC . key )
1291
- . expectEvents ( fullQuery , {
1292
- fromCache : true
1293
- } )
1291
+ // docC was deleted, this puts docC in limbo and causes a snapshot from cache (metadata-only change)
1292
+ . watchRemovesDoc ( docC . key , fullQuery )
1293
+ . watchCurrents ( fullQuery , 'resume-token-1002' )
1294
+ . watchSnapshots ( 1002 )
1295
+ . expectLimboDocs ( docC . key )
1296
+ . expectEvents ( fullQuery , {
1297
+ fromCache : true
1298
+ } )
1294
1299
1295
- // User begins getDocs(filterQuery)
1296
- . userListensForGet ( filterQuery )
1300
+ // User begins getDocs(filterQuery)
1301
+ . userListensForGet ( filterQuery )
1297
1302
1298
- // getDocs(filterQuery) will not resolve on the snapshot from cache
1299
- . expectEvents ( filterQuery , {
1300
- fromCache : true ,
1301
- added : [ docC ]
1302
- } )
1303
+ // getDocs(filterQuery) will not resolve on the snapshot from cache
1304
+ . expectEvents ( filterQuery , {
1305
+ fromCache : true ,
1306
+ added : [ docC ]
1307
+ } )
1303
1308
1304
- // Watch acks limbo and filter queries
1305
- . watchAcks ( limboQueryC )
1306
- . watchAcks ( filterQuery )
1309
+ // Watch acks limbo and filter queries
1310
+ . watchAcks ( limboQueryC )
1311
+ . watchAcks ( filterQuery )
1307
1312
1308
- // Watch responds to limboQueryC - docC was deleted
1309
- . watchSends ( { affects : [ limboQueryC ] } , docCDeleted )
1310
- . watchCurrents ( limboQueryC , 'resume-token-1009' )
1311
- . watchSnapshots ( 1009 , [ limboQueryC , fullQuery ] )
1313
+ // Watch currents the limbo query, but did not send a document delete.
1314
+ // This is and unexpected code path, but something that is called
1315
+ // out as possible in the watch change aggregator.
1316
+ . watchCurrents ( limboQueryC , 'resume-token-1009' )
1317
+ . watchSnapshots ( 1009 , [ limboQueryC , fullQuery ] )
1312
1318
1313
- // However, docC is still in limbo because there has not been a global snapshot
1314
- . expectLimboDocs ( docC . key )
1319
+ // However, docC is still in limbo because there has not been a global snapshot
1320
+ . expectLimboDocs ( docC . key )
1315
1321
1316
- // Rapid events of document update and delete caused by application
1317
- . watchSends ( { removed : [ filterQuery ] } , docA )
1318
- . watchCurrents ( filterQuery , 'resume-token-1004' )
1319
- . watchSends ( { affects : [ filterQuery ] } , docC )
1320
- . watchCurrents ( filterQuery , 'resume-token-1005' )
1321
- . watchSends ( { removed : [ filterQuery ] } , docC )
1322
- . watchSends ( { affects : [ filterQuery ] } , docA2 )
1323
- . watchCurrents ( filterQuery , 'resume-token-1007' )
1322
+ // Rapid events of document update and delete caused by application
1323
+ . watchRemovesDoc ( docA . key , filterQuery )
1324
+ . watchCurrents ( filterQuery , 'resume-token-1004' )
1325
+ . watchSends ( { affects : [ filterQuery ] } , docC )
1326
+ . watchCurrents ( filterQuery , 'resume-token-1005' )
1327
+ . watchRemovesDoc ( docC . key , filterQuery )
1328
+ . watchSends ( { affects : [ filterQuery ] } , docA2 )
1329
+ . watchCurrents ( filterQuery , 'resume-token-1007' )
1324
1330
1325
- . watchSnapshots ( 1010 , [ fullQuery , limboQueryC ] )
1331
+ . watchSnapshots ( 1010 , [ fullQuery , limboQueryC ] )
1326
1332
1327
- // All changes are current and we get a global snapshot
1328
- . watchSnapshots ( 1010 , [ ] )
1333
+ // All changes are current and we get a global snapshot
1334
+ . watchSnapshots ( 1010 , [ ] )
1329
1335
1330
- // Now docC is out of limbo
1331
- . expectLimboDocs ( )
1332
- . expectEvents ( fullQuery , {
1333
- fromCache : false ,
1334
- modified : [ docA2 ] ,
1335
- removed : [ docC ]
1336
- } )
1337
- // Now getDocs(filterQuery) can be resolved
1338
- . expectEvents ( filterQuery , {
1339
- fromCache : false ,
1340
- removed : [ docC ] ,
1341
- added : [ docA2 ]
1342
- } )
1336
+ // Now docC is out of limbo
1337
+ . expectLimboDocs ( )
1338
+ . expectEvents ( fullQuery , {
1339
+ fromCache : false ,
1340
+ modified : [ docA2 ] ,
1341
+ removed : [ docC ]
1342
+ } )
1343
+ // Now getDocs(filterQuery) can be resolved
1344
+ . expectEvents ( filterQuery , {
1345
+ fromCache : false ,
1346
+ removed : [ docC ] ,
1347
+ added : [ docA2 ]
1348
+ } )
1343
1349
1344
- // No more expected events
1345
- . watchSnapshots ( 1100 , [ ] )
1346
- ) ;
1347
- } ) ;
1350
+ // No more expected events
1351
+ . watchSnapshots ( 1100 , [ ] )
1352
+ ) ;
1353
+ }
1354
+ ) ;
1348
1355
1349
1356
specTest (
1350
1357
'Fix #8474 - Handles code path of no ack for limbo resolution query before global snapshot' ,
@@ -1359,7 +1366,6 @@ describeSpec('Limbo Documents:', [], () => {
1359
1366
const docA = doc ( 'collection/a' , 1000 , { key : 'a' , included : false } ) ;
1360
1367
const docA2 = doc ( 'collection/a' , 1007 , { key : 'a' , included : true } ) ;
1361
1368
const docC = doc ( 'collection/c' , 1002 , { key : 'c' , included : true } ) ;
1362
- const docCDeleted = deletedDoc ( 'collection/c' , 1009 ) ;
1363
1369
1364
1370
const limboQueryC = newQueryForPath ( docC . key . path ) ;
1365
1371
@@ -1374,7 +1380,7 @@ describeSpec('Limbo Documents:', [], () => {
1374
1380
} )
1375
1381
1376
1382
// docC was deleted, this puts docC in limbo and causes a snapshot from cache (metadata-only change)
1377
- . watchSends ( { removed : [ fullQuery ] } , docC )
1383
+ . watchRemovesDoc ( docC . key , fullQuery )
1378
1384
. watchCurrents ( fullQuery , 'resume-token-1002' )
1379
1385
. watchSnapshots ( 1002 )
1380
1386
. expectLimboDocs ( docC . key )
@@ -1398,11 +1404,11 @@ describeSpec('Limbo Documents:', [], () => {
1398
1404
. expectLimboDocs ( docC . key )
1399
1405
1400
1406
// Rapid events of document update and delete caused by application
1401
- . watchSends ( { removed : [ filterQuery ] } , docA )
1407
+ . watchRemovesDoc ( docA . key , filterQuery )
1402
1408
. watchCurrents ( filterQuery , 'resume-token-1004' )
1403
1409
. watchSends ( { affects : [ filterQuery ] } , docC )
1404
1410
. watchCurrents ( filterQuery , 'resume-token-1005' )
1405
- . watchSends ( { removed : [ filterQuery ] } , docC )
1411
+ . watchRemovesDoc ( docC . key , filterQuery )
1406
1412
. watchSends ( { affects : [ filterQuery ] } , docA2 )
1407
1413
. watchCurrents ( filterQuery , 'resume-token-1007' )
1408
1414
@@ -1425,7 +1431,7 @@ describeSpec('Limbo Documents:', [], () => {
1425
1431
. watchAcks ( limboQueryC )
1426
1432
1427
1433
// Watch responds to limboQueryC - docC was deleted
1428
- . watchSends ( { affects : [ limboQueryC ] } , docCDeleted )
1434
+ . watchDeletesDoc ( docC . key , 1009 , limboQueryC )
1429
1435
. watchCurrents ( limboQueryC , 'resume-token-1009' )
1430
1436
. watchSnapshots ( 1100 , [ limboQueryC ] )
1431
1437
0 commit comments