@@ -23,6 +23,10 @@ import { Code } from '../../../src/util/error';
23
23
import { deletedDoc , doc , filter , path } from '../../util/helpers' ;
24
24
import { RpcError } from './spec_rpc_error' ;
25
25
26
+ // The IndexedDB action that the Watch stream uses to detect if IndexedDB access
27
+ // is available again.
28
+ const ASYNC_QUEUE_PROBER = 'Get last remote snapshot version' ;
29
+
26
30
describeSpec ( 'Persistence Recovery' , [ 'no-ios' , 'no-android' ] , ( ) => {
27
31
specTest (
28
32
'Write is acknowledged by primary client (with recovery)' ,
@@ -34,11 +38,7 @@ describeSpec('Persistence Recovery', ['no-ios', 'no-android'], () => {
34
38
. client ( 1 )
35
39
. expectPrimaryState ( false )
36
40
. userSets ( 'collection/a' , { v : 1 } )
37
- . failDatabaseTransactions ( {
38
- 'Locally write mutations' : true ,
39
- 'Synchronize last document change read time' : true ,
40
- 'Lookup mutation documents' : true
41
- } )
41
+ . failDatabaseTransactions ( 'Lookup mutation documents' )
42
42
. client ( 0 )
43
43
. writeAcks ( 'collection/a' , 1 , { expectUserCallback : false } )
44
44
. client ( 1 )
@@ -62,24 +62,21 @@ describeSpec('Persistence Recovery', ['no-ios', 'no-android'], () => {
62
62
[ 'multi-client' ] ,
63
63
( ) => {
64
64
const query = Query . atPath ( path ( 'collection' ) ) ;
65
+ const doc1 = doc ( 'collection/doc' , 1 , { foo : 'a' } ) ;
65
66
66
67
return client ( 0 )
67
68
. expectPrimaryState ( true )
68
69
. client ( 1 )
69
70
. expectPrimaryState ( false )
70
71
. userListens ( query )
71
- . failDatabaseTransactions ( {
72
- 'Allocate target' : true ,
73
- 'Lookup mutation documents' : true ,
74
- 'Get new document changes' : true
75
- } )
72
+ . failDatabaseTransactions ( 'Get new document changes' )
76
73
. client ( 0 )
77
74
. expectListen ( query )
78
- . watchAcksFull ( query , 1000 )
75
+ . watchAcksFull ( query , 1000 , doc1 )
79
76
. client ( 1 )
80
77
. recoverDatabase ( )
81
78
. runTimer ( TimerId . AsyncQueueRetry )
82
- . expectEvents ( query , { } ) ;
79
+ . expectEvents ( query , { added : [ doc1 ] } ) ;
83
80
}
84
81
) ;
85
82
@@ -92,10 +89,7 @@ describeSpec('Persistence Recovery', ['no-ios', 'no-android'], () => {
92
89
return (
93
90
client ( 0 )
94
91
. expectPrimaryState ( true )
95
- . failDatabaseTransactions ( {
96
- 'Allocate target' : true ,
97
- 'Get target data' : true
98
- } )
92
+ . failDatabaseTransactions ( 'Allocate target' , 'Get target data' )
99
93
. client ( 1 )
100
94
. userListens ( query )
101
95
. client ( 0 )
@@ -105,10 +99,7 @@ describeSpec('Persistence Recovery', ['no-ios', 'no-android'], () => {
105
99
. recoverDatabase ( )
106
100
. runTimer ( TimerId . AsyncQueueRetry )
107
101
. expectListen ( query )
108
- . failDatabaseTransactions ( {
109
- 'Allocate target' : true ,
110
- 'Release target' : true
111
- } )
102
+ . failDatabaseTransactions ( 'Release target' )
112
103
. client ( 1 )
113
104
. userUnlistens ( query )
114
105
. client ( 0 )
@@ -130,18 +121,12 @@ describeSpec('Persistence Recovery', ['no-ios', 'no-android'], () => {
130
121
. expectNumOutstandingWrites ( 1 )
131
122
// We fail the write if we cannot persist the local mutation (via
132
123
// 'Locally write mutations').
133
- . failDatabaseTransactions ( {
134
- 'Locally write mutations' : true
135
- } )
124
+ . failDatabaseTransactions ( 'Locally write mutations' )
136
125
. userSets ( 'collection/key2' , { bar : 'b' } )
137
126
. expectUserCallbacks ( { rejected : [ 'collection/key2' ] } )
138
127
// The write is considered successful if we can persist the local mutation
139
128
// but fail to update view assignments (via 'notifyLocalViewChanges').
140
- . failDatabaseTransactions ( {
141
- 'Locally write mutations' : false ,
142
- notifyLocalViewChanges : true ,
143
- 'Get next mutation batch' : false
144
- } )
129
+ . failDatabaseTransactions ( 'notifyLocalViewChanges' )
145
130
. userSets ( 'collection/key3' , { bar : 'b' } )
146
131
. recoverDatabase ( )
147
132
. expectNumOutstandingWrites ( 2 )
@@ -178,11 +163,7 @@ describeSpec('Persistence Recovery', ['no-ios', 'no-android'], () => {
178
163
fromCache : true ,
179
164
hasPendingWrites : true
180
165
} )
181
- . failDatabaseTransactions ( {
182
- 'Locally write mutations' : true ,
183
- notifyLocalViewChanges : true ,
184
- 'Get next mutation batch' : true
185
- } )
166
+ . failDatabaseTransactions ( 'Locally write mutations' )
186
167
. userSets ( 'collection/key2' , { foo : 'b' } )
187
168
. expectUserCallbacks ( { rejected : [ 'collection/key2' ] } )
188
169
. recoverDatabase ( )
@@ -213,12 +194,7 @@ describeSpec('Persistence Recovery', ['no-ios', 'no-android'], () => {
213
194
const doc2 = doc ( 'collection/key2' , 2 , { foo : 'b' } ) ;
214
195
return spec ( )
215
196
. userListens ( query )
216
- . failDatabaseTransactions ( {
217
- 'Locally write mutations' : false ,
218
- notifyLocalViewChanges : true ,
219
- 'Get next mutation batch' : false ,
220
- 'Set last stream token' : false
221
- } )
197
+ . failDatabaseTransactions ( 'notifyLocalViewChanges' )
222
198
. userSets ( 'collection/key1' , { foo : 'a' } )
223
199
. expectEvents ( query , {
224
200
added : [ doc1Local ] ,
@@ -228,11 +204,7 @@ describeSpec('Persistence Recovery', ['no-ios', 'no-android'], () => {
228
204
. recoverDatabase ( )
229
205
. runTimer ( TimerId . AsyncQueueRetry )
230
206
. writeAcks ( 'collection/key1' , 1 )
231
- . failDatabaseTransactions ( {
232
- 'Apply remote event' : false ,
233
- notifyLocalViewChanges : true ,
234
- 'Get last remote snapshot version' : false
235
- } )
207
+ . failDatabaseTransactions ( 'notifyLocalViewChanges' )
236
208
. watchAcksFull ( query , 1000 , doc1 , doc2 )
237
209
. expectEvents ( query , {
238
210
metadata : [ doc1 ] ,
@@ -256,11 +228,7 @@ describeSpec('Persistence Recovery', ['no-ios', 'no-android'], () => {
256
228
. expectEvents ( query , {
257
229
added : [ doc1 ]
258
230
} )
259
- . failDatabaseTransactions ( {
260
- 'Apply remote event' : false ,
261
- notifyLocalViewChanges : true ,
262
- 'Get last remote snapshot version' : false
263
- } )
231
+ . failDatabaseTransactions ( 'notifyLocalViewChanges' )
264
232
. watchSends ( { removed : [ query ] } , deletedDoc1 )
265
233
. watchSnapshots ( 2000 )
266
234
. expectEvents ( query , {
@@ -282,7 +250,7 @@ describeSpec('Persistence Recovery', ['no-ios', 'no-android'], () => {
282
250
. userListens ( query1 )
283
251
. watchAcksFull ( query1 , 1 )
284
252
. expectEvents ( query1 , { } )
285
- . failDatabaseTransactions ( { 'Allocate target' : true } )
253
+ . failDatabaseTransactions ( 'Allocate target' )
286
254
. userListens ( query2 )
287
255
. expectEvents ( query2 , { errorCode : Code . UNAVAILABLE } )
288
256
. recoverDatabase ( )
@@ -298,7 +266,7 @@ describeSpec('Persistence Recovery', ['no-ios', 'no-android'], () => {
298
266
. userListens ( query1 )
299
267
. watchAcksFull ( query1 , 1 )
300
268
. expectEvents ( query1 , { } )
301
- . failDatabaseTransactions ( { 'Allocate target' : true } )
269
+ . failDatabaseTransactions ( 'Allocate target' )
302
270
. userListens ( query2 )
303
271
. expectEvents ( query2 , { errorCode : Code . UNAVAILABLE } )
304
272
. recoverDatabase ( )
@@ -320,12 +288,9 @@ describeSpec('Persistence Recovery', ['no-ios', 'no-android'], () => {
320
288
added : [ doc1 ]
321
289
} )
322
290
. watchSends ( { affects : [ query ] } , doc2 )
323
- . failDatabaseTransactions ( {
324
- 'Get last remote snapshot version' : true ,
325
- 'Release target' : true
326
- } )
291
+ . failDatabaseTransactions ( 'Get last remote snapshot version' )
327
292
. watchSnapshots ( 1500 )
328
- // `failDatabase ()` causes us to go offline.
293
+ // `failDatabaseTransactions ()` causes us to go offline.
329
294
. expectActiveTargets ( )
330
295
. expectEvents ( query , { fromCache : true } )
331
296
. recoverDatabase ( )
@@ -357,15 +322,12 @@ describeSpec('Persistence Recovery', ['no-ios', 'no-android'], () => {
357
322
. expectEvents ( doc2Query , {
358
323
added : [ doc2 ]
359
324
} )
360
- . failDatabaseTransactions ( {
361
- 'Get last remote snapshot version' : true ,
362
- 'Release target' : true
363
- } )
325
+ . failDatabaseTransactions ( 'Release target' , ASYNC_QUEUE_PROBER )
364
326
. watchRemoves (
365
327
doc1Query ,
366
328
new RpcError ( Code . PERMISSION_DENIED , 'Simulated target error' )
367
329
)
368
- // `failDatabase ()` causes us to go offline.
330
+ // `failDatabaseTransactions ()` causes us to go offline.
369
331
. expectActiveTargets ( )
370
332
. expectEvents ( doc1Query , { fromCache : true } )
371
333
. expectEvents ( doc2Query , { fromCache : true } )
@@ -416,7 +378,7 @@ describeSpec('Persistence Recovery', ['no-ios', 'no-android'], () => {
416
378
} )
417
379
. watchAcksFull ( filteredQuery , 2000 )
418
380
. expectLimboDocs ( doc1a . key )
419
- . failDatabaseTransactions ( { 'Get last remote snapshot version' : true } )
381
+ . failDatabaseTransactions ( 'Get last remote snapshot version' )
420
382
. watchAcksFull ( limboQuery , 3000 , doc1b )
421
383
. expectActiveTargets ( )
422
384
. recoverDatabase ( )
@@ -459,10 +421,7 @@ describeSpec('Persistence Recovery', ['no-ios', 'no-android'], () => {
459
421
} )
460
422
. watchAcksFull ( filteredQuery , 2000 )
461
423
. expectLimboDocs ( doc1 . key )
462
- . failDatabaseTransactions ( {
463
- 'Apply remote event' : true ,
464
- 'Get last remote snapshot version' : true
465
- } )
424
+ . failDatabaseTransactions ( 'Apply remote event' , ASYNC_QUEUE_PROBER )
466
425
. watchRemoves (
467
426
limboQuery ,
468
427
new RpcError ( Code . PERMISSION_DENIED , 'Test error' )
0 commit comments