@@ -1337,16 +1337,17 @@ public void testHoldsBackTransforms() {
1337
1337
emptyList ()));
1338
1338
assertChanged (doc ("foo/bar" , 1 , map ("sum" , 0 , "array_union" , new ArrayList <>())));
1339
1339
1340
- writeMutations (
1341
- asList (
1342
- patchMutation ("foo/bar" , map ("sum" , FieldValue .increment (1 ))),
1343
- patchMutation ("foo/bar" , map ("array_union" , FieldValue .arrayUnion ("foo" )))));
1340
+ writeMutation (patchMutation ("foo/bar" , map ("sum" , FieldValue .increment (1 ))));
1341
+ assertChanged (
1342
+ doc ("foo/bar" , 1 , map ("sum" , 1 , "array_union" , new ArrayList <>())).setHasLocalMutations ());
1343
+
1344
+ writeMutation (patchMutation ("foo/bar" , map ("array_union" , FieldValue .arrayUnion ("foo" ))));
1344
1345
assertChanged (
1345
1346
doc ("foo/bar" , 1 , map ("sum" , 1 , "array_union" , Collections .singletonList ("foo" )))
1346
1347
.setHasLocalMutations ());
1347
1348
1348
- // The sum transform is not idempotent and the backend's updated value is ignored. The
1349
- // ArrayUnion transform is recomputed and includes the backend value.
1349
+ // The sum transform and array union transform make the SDK ignore the
1350
+ // backend's updated value.
1350
1351
applyRemoteEvent (
1351
1352
addedRemoteEvent (
1352
1353
doc ("foo/bar" , 2 , map ("sum" , 1337 , "array_union" , Collections .singletonList ("bar" ))),
@@ -1355,10 +1356,18 @@ public void testHoldsBackTransforms() {
1355
1356
assertChanged (
1356
1357
doc ("foo/bar" , 2 , map ("sum" , 1 , "array_union" , asList ("foo" ))).setHasLocalMutations ());
1357
1358
1358
- acknowledgeMutationWithTransformResults (3 , 1338 , asList ("bar" , "foo" ));
1359
+ // With a field transform acknowledgement, the overlay is recalculated with
1360
+ // remaining local mutations.
1361
+ acknowledgeMutationWithTransformResults (3 , 1338 );
1359
1362
assertChanged (
1360
1363
doc ("foo/bar" , 3 , map ("sum" , 1338 , "array_union" , asList ("bar" , "foo" )))
1361
1364
.setReadTime (new SnapshotVersion (new Timestamp (0 , 3000 )))
1365
+ .setHasLocalMutations ());
1366
+
1367
+ acknowledgeMutationWithTransformResults (4 , asList ("bar" , "foo" ));
1368
+ assertChanged (
1369
+ doc ("foo/bar" , 4 , map ("sum" , 1338 , "array_union" , asList ("bar" , "foo" )))
1370
+ .setReadTime (new SnapshotVersion (new Timestamp (0 , 4000 )))
1362
1371
.setHasCommittedMutations ());
1363
1372
}
1364
1373
0 commit comments