@@ -170,14 +170,67 @@ function genericDocumentOverlayCacheTests(): void {
170
170
it ( 'can delete overlays repeatedly' , async ( ) => {
171
171
const m = patchMutation ( 'coll/doc1' , { 'foo' : 'bar' } ) ;
172
172
await saveOverlaysForMutations ( 2 , m ) ;
173
- await overlayCache . removeOverlaysForBatchId ( 2 ) ;
173
+ await overlayCache . removeOverlaysForBatchId (
174
+ documentKeySet ( key ( 'coll/doc1' ) ) ,
175
+ 2
176
+ ) ;
174
177
expect ( await overlayCache . getOverlay ( key ( 'coll/doc1' ) ) ) . to . equal ( null ) ;
175
178
176
179
// Repeat
177
- await overlayCache . removeOverlaysForBatchId ( 2 ) ;
180
+ await overlayCache . removeOverlaysForBatchId (
181
+ documentKeySet ( key ( 'coll/doc1' ) ) ,
182
+ 2
183
+ ) ;
178
184
expect ( await overlayCache . getOverlay ( key ( 'coll/doc1' ) ) ) . to . equal ( null ) ;
179
185
} ) ;
180
186
187
+ it ( 'can delete overlays' , async ( ) => {
188
+ const m1 = patchMutation ( 'coll1/doc1' , { 'a' : 'b' } ) ;
189
+ const m2 = patchMutation ( 'coll1/doc2' , { 'a' : 'b' } ) ;
190
+ const m3 = patchMutation ( 'coll1/doc3' , { 'a' : 'b' } ) ;
191
+ const m4 = patchMutation ( 'coll1/doc4' , { 'a' : 'b' } ) ;
192
+ const m5 = patchMutation ( 'coll2/doc1/coll3/doc1' , { 'a' : 'b' } ) ;
193
+ const m6 = patchMutation ( 'coll2/doc2/coll3/doc2' , { 'a' : 'b' } ) ;
194
+ await saveOverlaysForMutations ( 2 , m1 , m2 ) ;
195
+ await saveOverlaysForMutations ( 3 , m3 ) ;
196
+ await saveOverlaysForMutations ( 4 , m4 ) ;
197
+ await saveOverlaysForMutations ( 2 , m5 , m6 ) ;
198
+
199
+ // Remove documents with batch id 2.
200
+ const set1 = documentKeySet (
201
+ key ( 'coll1/doc1' ) ,
202
+ key ( 'coll1/doc2' ) ,
203
+ key ( 'coll2/doc1/coll3/doc1' ) ,
204
+ key ( 'coll2/doc2/coll3/doc2' )
205
+ ) ;
206
+ await overlayCache . removeOverlaysForBatchId ( set1 , 2 ) ;
207
+ expect ( await overlayCache . getOverlay ( key ( 'coll1/doc1' ) ) ) . to . equal ( null ) ;
208
+ expect ( await overlayCache . getOverlay ( key ( 'coll1/doc2' ) ) ) . to . equal ( null ) ;
209
+ expect (
210
+ await overlayCache . getOverlay ( key ( 'coll2/doc1/coll3/doc1' ) )
211
+ ) . to . equal ( null ) ;
212
+ expect (
213
+ await overlayCache . getOverlay ( key ( 'coll2/doc2/coll3/doc2' ) )
214
+ ) . to . equal ( null ) ;
215
+ expect ( await overlayCache . getOverlay ( key ( 'coll1/doc3' ) ) ) . to . not . equal ( null ) ;
216
+ expect ( await overlayCache . getOverlay ( key ( 'coll1/doc4' ) ) ) . to . not . equal ( null ) ;
217
+
218
+ // Remove documents with batch id 3.
219
+ await overlayCache . removeOverlaysForBatchId (
220
+ documentKeySet ( key ( 'coll1/doc3' ) ) ,
221
+ 3
222
+ ) ;
223
+ expect ( await overlayCache . getOverlay ( key ( 'coll1/doc3' ) ) ) . to . equal ( null ) ;
224
+ expect ( await overlayCache . getOverlay ( key ( 'coll1/doc4' ) ) ) . to . not . equal ( null ) ;
225
+
226
+ // Remove documents with batch id 4.
227
+ await overlayCache . removeOverlaysForBatchId (
228
+ documentKeySet ( key ( 'coll1/doc4' ) ) ,
229
+ 4
230
+ ) ;
231
+ expect ( await overlayCache . getOverlay ( key ( 'coll1/doc4' ) ) ) . to . equal ( null ) ;
232
+ } ) ;
233
+
181
234
it ( 'can get all overlays for collection' , async ( ) => {
182
235
const m1 = patchMutation ( 'coll/doc1' , { 'foo' : 'bar' } ) ;
183
236
const m2 = setMutation ( 'coll/doc2' , { 'foo' : 'bar' } ) ;
0 commit comments