@@ -67,31 +67,36 @@ function bundleWithDocument(testDoc: TestBundleDocument): string {
67
67
describeSpec ( 'Bundles:' , [ 'no-ios' , 'no-android' ] , ( ) => {
68
68
specTest ( 'Newer docs from bundles should overwrite cache' , [ ] , ( ) => {
69
69
const query1 = Query . atPath ( path ( 'collection' ) ) ;
70
- const docA = doc ( 'collection/a' , 1000 , { key : 'a' } ) ;
71
- const docAChanged = doc ( 'collection/a' , 2999 , { key : 'b' } ) ;
70
+ const docA = doc ( 'collection/a' , 1000 , { value : 'a' } ) ;
71
+ const docAChanged = doc ( 'collection/a' , 2999 , { value : 'b' } ) ;
72
72
73
73
const bundleString = bundleWithDocument ( {
74
74
key : docA . key ,
75
75
readTime : 3000 ,
76
76
createTime : 1999 ,
77
77
updateTime : 2999 ,
78
- content : { key : 'b' }
78
+ content : { value : 'b' }
79
79
} ) ;
80
80
81
- return spec ( )
82
- . userListens ( query1 )
83
- . watchAcksFull ( query1 , 1000 , docA )
84
- . expectEvents ( query1 , { added : [ docA ] } )
85
- . loadBundle ( bundleString )
86
- . expectEvents ( query1 , { modified : [ docAChanged ] } ) ;
81
+ return (
82
+ spec ( )
83
+ . userListens ( query1 )
84
+ . watchAcksFull ( query1 , 1000 , docA )
85
+ . expectEvents ( query1 , { added : [ docA ] } )
86
+ // TODO(b/160876443): This currently raises snapshots with
87
+ // `fromCache=false` if users already listen to some queries and bundles
88
+ // has newer version.
89
+ . loadBundle ( bundleString )
90
+ . expectEvents ( query1 , { modified : [ docAChanged ] } )
91
+ ) ;
87
92
} ) ;
88
93
89
94
specTest (
90
- 'Newer deleted docs from bundles should delete cache docs' ,
95
+ 'Newer deleted docs from bundles should delete cached docs' ,
91
96
[ ] ,
92
97
( ) => {
93
98
const query1 = Query . atPath ( path ( 'collection' ) ) ;
94
- const docA = doc ( 'collection/a' , 1000 , { key : 'a' } ) ;
99
+ const docA = doc ( 'collection/a' , 1000 , { value : 'a' } ) ;
95
100
96
101
const bundleString = bundleWithDocument ( {
97
102
key : docA . key ,
@@ -109,7 +114,7 @@ describeSpec('Bundles:', ['no-ios', 'no-android'], () => {
109
114
110
115
specTest ( 'Older deleted docs from bundles should do nothing' , [ ] , ( ) => {
111
116
const query1 = Query . atPath ( path ( 'collection' ) ) ;
112
- const docA = doc ( 'collection/a' , 1000 , { key : 'a' } ) ;
117
+ const docA = doc ( 'collection/a' , 1000 , { value : 'a' } ) ;
113
118
114
119
const bundleString = bundleWithDocument ( {
115
120
key : docA . key ,
@@ -131,22 +136,22 @@ describeSpec('Bundles:', ['no-ios', 'no-android'], () => {
131
136
[ ] ,
132
137
( ) => {
133
138
const query = Query . atPath ( path ( 'collection' ) ) ;
134
- const docA = doc ( 'collection/a' , 250 , { key : 'a' } ) ;
139
+ const docA = doc ( 'collection/a' , 250 , { value : 'a' } ) ;
135
140
136
141
const bundleBeforeMutationAck = bundleWithDocument ( {
137
142
key : docA . key ,
138
143
readTime : 500 ,
139
144
createTime : 250 ,
140
145
updateTime : 500 ,
141
- content : { key : 'b' }
146
+ content : { value : 'b' }
142
147
} ) ;
143
148
144
149
const bundleAfterMutationAck = bundleWithDocument ( {
145
150
key : docA . key ,
146
151
readTime : 1001 ,
147
152
createTime : 250 ,
148
153
updateTime : 1001 ,
149
- content : { key : 'fromBundle' }
154
+ content : { value : 'fromBundle' }
150
155
} ) ;
151
156
return (
152
157
spec ( )
@@ -156,29 +161,29 @@ describeSpec('Bundles:', ['no-ios', 'no-android'], () => {
156
161
. userListens ( query )
157
162
. watchAcksFull ( query , 250 , docA )
158
163
. expectEvents ( query , {
159
- added : [ doc ( 'collection/a' , 250 , { key : 'a' } ) ]
164
+ added : [ doc ( 'collection/a' , 250 , { value : 'a' } ) ]
160
165
} )
161
- . userPatches ( 'collection/a' , { key : 'patched' } )
166
+ . userPatches ( 'collection/a' , { value : 'patched' } )
162
167
. expectEvents ( query , {
163
168
modified : [
164
169
doc (
165
170
'collection/a' ,
166
171
250 ,
167
- { key : 'patched' } ,
172
+ { value : 'patched' } ,
168
173
{ hasLocalMutations : true }
169
174
)
170
175
] ,
171
176
hasPendingWrites : true
172
177
} )
173
178
. writeAcks ( 'collection/a' , 1000 )
174
- // loading bundleBeforeMutationAck will not raise snapshots, because it is before
175
- // the acknowledged mutation.
179
+ // loading bundleBeforeMutationAck will not raise snapshots, because its
180
+ // snapshot version is older than the acknowledged mutation.
176
181
. loadBundle ( bundleBeforeMutationAck )
177
182
// loading bundleAfterMutationAck will raise a snapshot, because it is after
178
183
// the acknowledged mutation.
179
184
. loadBundle ( bundleAfterMutationAck )
180
185
. expectEvents ( query , {
181
- modified : [ doc ( 'collection/a' , 1001 , { key : 'fromBundle' } ) ]
186
+ modified : [ doc ( 'collection/a' , 1001 , { value : 'fromBundle' } ) ]
182
187
} )
183
188
) ;
184
189
}
@@ -189,14 +194,14 @@ describeSpec('Bundles:', ['no-ios', 'no-android'], () => {
189
194
[ ] ,
190
195
( ) => {
191
196
const query = Query . atPath ( path ( 'collection' ) ) ;
192
- const docA = doc ( 'collection/a' , 250 , { key : 'a' } ) ;
197
+ const docA = doc ( 'collection/a' , 250 , { value : 'a' } ) ;
193
198
194
199
const bundleString = bundleWithDocument ( {
195
200
key : docA . key ,
196
201
readTime : 1001 ,
197
202
createTime : 250 ,
198
203
updateTime : 1001 ,
199
- content : { key : 'fromBundle' }
204
+ content : { value : 'fromBundle' }
200
205
} ) ;
201
206
202
207
return (
@@ -205,36 +210,36 @@ describeSpec('Bundles:', ['no-ios', 'no-android'], () => {
205
210
. userListens ( query )
206
211
. watchAcksFull ( query , 250 , docA )
207
212
. expectEvents ( query , {
208
- added : [ doc ( 'collection/a' , 250 , { key : 'a' } ) ]
213
+ added : [ doc ( 'collection/a' , 250 , { value : 'a' } ) ]
209
214
} )
210
- . userPatches ( 'collection/a' , { key : 'patched' } )
215
+ . userPatches ( 'collection/a' , { value : 'patched' } )
211
216
. expectEvents ( query , {
212
217
modified : [
213
218
doc (
214
219
'collection/a' ,
215
220
250 ,
216
- { key : 'patched' } ,
221
+ { value : 'patched' } ,
217
222
{ hasLocalMutations : true }
218
223
)
219
224
] ,
220
225
hasPendingWrites : true
221
226
} )
222
227
// Loading the bundle will not raise snapshots, because the
223
- // mutation is not acknowledged.
228
+ // mutation has not been acknowledged.
224
229
. loadBundle ( bundleString )
225
230
) ;
226
231
}
227
232
) ;
228
233
229
234
specTest ( 'Newer docs from bundles might lead to limbo doc' , [ ] , ( ) => {
230
235
const query = Query . atPath ( path ( 'collection' ) ) ;
231
- const docA = doc ( 'collection/a' , 1000 , { key : 'a' } ) ;
236
+ const docA = doc ( 'collection/a' , 1000 , { value : 'a' } ) ;
232
237
const bundleString1 = bundleWithDocument ( {
233
238
key : docA . key ,
234
239
readTime : 500 ,
235
240
createTime : 250 ,
236
241
updateTime : 500 ,
237
- content : { key : 'b' }
242
+ content : { value : 'b' }
238
243
} ) ;
239
244
const limboQuery = Query . atPath ( docA . key . path ) ;
240
245
@@ -243,13 +248,13 @@ describeSpec('Bundles:', ['no-ios', 'no-android'], () => {
243
248
. withGCEnabled ( false )
244
249
. userListens ( query )
245
250
. watchAcksFull ( query , 250 )
246
- // Backend tells there is no such doc.
251
+ // Backend tells is there is no such doc.
247
252
. expectEvents ( query , { } )
248
253
// Bundle tells otherwise, leads to limbo.
249
254
. loadBundle ( bundleString1 )
250
255
. expectLimboDocs ( docA . key )
251
256
. expectEvents ( query , {
252
- added : [ doc ( 'collection/a' , 500 , { key : 'b' } ) ] ,
257
+ added : [ doc ( 'collection/a' , 500 , { value : 'b' } ) ] ,
253
258
fromCache : true
254
259
} )
255
260
// .watchAcksFull(limboQuery, 1002, docA1)
@@ -259,7 +264,7 @@ describeSpec('Bundles:', ['no-ios', 'no-android'], () => {
259
264
. watchSnapshots ( 1002 )
260
265
. expectLimboDocs ( )
261
266
. expectEvents ( query , {
262
- removed : [ doc ( 'collection/a' , 500 , { key : 'b' } ) ] ,
267
+ removed : [ doc ( 'collection/a' , 500 , { value : 'b' } ) ] ,
263
268
fromCache : false
264
269
} )
265
270
) ;
@@ -270,13 +275,13 @@ describeSpec('Bundles:', ['no-ios', 'no-android'], () => {
270
275
[ 'multi-client' ] ,
271
276
( ) => {
272
277
const query = Query . atPath ( path ( 'collection' ) ) ;
273
- const docA = doc ( 'collection/a' , 250 , { key : 'a' } ) ;
278
+ const docA = doc ( 'collection/a' , 250 , { value : 'a' } ) ;
274
279
const bundleString1 = bundleWithDocument ( {
275
280
key : docA . key ,
276
281
readTime : 500 ,
277
282
createTime : 250 ,
278
283
updateTime : 500 ,
279
- content : { key : 'b' }
284
+ content : { value : 'b' }
280
285
} ) ;
281
286
282
287
return client ( 0 )
@@ -292,7 +297,7 @@ describeSpec('Bundles:', ['no-ios', 'no-android'], () => {
292
297
// TODO(wuandy): Loading from secondary client does not notify other
293
298
// clients for now. We need to fix it and uncomment below.
294
299
// .expectEvents(query, {
295
- // modified: [doc('collection/a', 500, { key : 'b' })],
300
+ // modified: [doc('collection/a', 500, { value : 'b' })],
296
301
// })
297
302
}
298
303
) ;
@@ -302,13 +307,13 @@ describeSpec('Bundles:', ['no-ios', 'no-android'], () => {
302
307
[ 'multi-client' ] ,
303
308
( ) => {
304
309
const query = Query . atPath ( path ( 'collection' ) ) ;
305
- const docA = doc ( 'collection/a' , 250 , { key : 'a' } ) ;
310
+ const docA = doc ( 'collection/a' , 250 , { value : 'a' } ) ;
306
311
const bundleString1 = bundleWithDocument ( {
307
312
key : docA . key ,
308
313
readTime : 500 ,
309
314
createTime : 250 ,
310
315
updateTime : 500 ,
311
- content : { key : 'b' }
316
+ content : { value : 'b' }
312
317
} ) ;
313
318
314
319
return client ( 0 )
@@ -324,7 +329,7 @@ describeSpec('Bundles:', ['no-ios', 'no-android'], () => {
324
329
} )
325
330
. loadBundle ( bundleString1 )
326
331
. expectEvents ( query , {
327
- modified : [ doc ( 'collection/a' , 500 , { key : 'b' } ) ]
332
+ modified : [ doc ( 'collection/a' , 500 , { value : 'b' } ) ]
328
333
} ) ;
329
334
}
330
335
) ;
@@ -334,13 +339,13 @@ describeSpec('Bundles:', ['no-ios', 'no-android'], () => {
334
339
[ 'multi-client' ] ,
335
340
( ) => {
336
341
const query = Query . atPath ( path ( 'collection' ) ) ;
337
- const docA = doc ( 'collection/a' , 250 , { key : 'a' } ) ;
342
+ const docA = doc ( 'collection/a' , 250 , { value : 'a' } ) ;
338
343
const bundleString1 = bundleWithDocument ( {
339
344
key : docA . key ,
340
345
readTime : 500 ,
341
346
createTime : 250 ,
342
347
updateTime : 500 ,
343
- content : { key : 'b' }
348
+ content : { value : 'b' }
344
349
} ) ;
345
350
346
351
return client ( 0 )
@@ -357,11 +362,11 @@ describeSpec('Bundles:', ['no-ios', 'no-android'], () => {
357
362
. client ( 0 )
358
363
. loadBundle ( bundleString1 )
359
364
. expectEvents ( query , {
360
- modified : [ doc ( 'collection/a' , 500 , { key : 'b' } ) ]
365
+ modified : [ doc ( 'collection/a' , 500 , { value : 'b' } ) ]
361
366
} )
362
367
. client ( 1 )
363
368
. expectEvents ( query , {
364
- modified : [ doc ( 'collection/a' , 500 , { key : 'b' } ) ]
369
+ modified : [ doc ( 'collection/a' , 500 , { value : 'b' } ) ]
365
370
} ) ;
366
371
}
367
372
) ;
0 commit comments