@@ -1398,7 +1398,7 @@ function genericLocalStoreTests(
1398
1398
) ;
1399
1399
} ) ;
1400
1400
1401
- it ( 'holds back only non-idempotent transforms' , ( ) => {
1401
+ it ( 'holds back transforms' , ( ) => {
1402
1402
const query1 = query ( 'foo' ) ;
1403
1403
return (
1404
1404
expectLocalStore ( )
@@ -1439,9 +1439,8 @@ function genericLocalStoreTests(
1439
1439
arrayUnion : [ 'foo' ]
1440
1440
} ) . setHasLocalMutations ( )
1441
1441
)
1442
- // The sum transform is not idempotent and the backend's updated value
1443
- // is ignored. The ArrayUnion transform is recomputed and includes the
1444
- // backend value.
1442
+ // The sum transform and array union transform make the SDK ignore the
1443
+ // backend's updated value.
1445
1444
. afterRemoteEvent (
1446
1445
docUpdateRemoteEvent (
1447
1446
doc ( 'foo/bar' , 2 , { sum : 1337 , arrayUnion : [ 'bar' ] } ) ,
@@ -1454,6 +1453,8 @@ function genericLocalStoreTests(
1454
1453
arrayUnion : [ 'foo' ]
1455
1454
} ) . setHasLocalMutations ( )
1456
1455
)
1456
+ // With a field transform acknowledgement, the overlay is recalculated
1457
+ // with the remaining local mutations.
1457
1458
. afterAcknowledgingMutation ( {
1458
1459
documentVersion : 3 ,
1459
1460
transformResults : [ { integerValue : 1338 } ]
@@ -1890,6 +1891,73 @@ function genericLocalStoreTests(
1890
1891
. finish ( ) ;
1891
1892
} ) ;
1892
1893
1894
+ it ( 'can handle multiple field patches in one batch on remote docs' , ( ) => {
1895
+ const query1 = query ( 'foo' ) ;
1896
+ return expectLocalStore ( )
1897
+ . afterAllocatingQuery ( query1 )
1898
+ . toReturnTargetId ( 2 )
1899
+ . afterRemoteEvent (
1900
+ docAddedRemoteEvent (
1901
+ [ doc ( 'foo/bar' , 1 , { 'likes' : 0 , 'stars' : 0 } ) ] ,
1902
+ [ 2 ] ,
1903
+ [ ]
1904
+ )
1905
+ )
1906
+ . toReturnChanged ( doc ( 'foo/bar' , 1 , { 'likes' : 0 , 'stars' : 0 } ) )
1907
+ . toContain ( doc ( 'foo/bar' , 1 , { 'likes' : 0 , 'stars' : 0 } ) )
1908
+ . afterMutations ( [
1909
+ patchMutation ( 'foo/bar' , { 'likes' : 1 } ) ,
1910
+ patchMutation ( 'foo/bar' , { 'stars' : 1 } )
1911
+ ] )
1912
+ . toReturnChanged (
1913
+ doc ( 'foo/bar' , 1 , { 'likes' : 1 , 'stars' : 1 } ) . setHasLocalMutations ( )
1914
+ )
1915
+ . toContain (
1916
+ doc ( 'foo/bar' , 1 , { 'likes' : 1 , 'stars' : 1 } ) . setHasLocalMutations ( )
1917
+ )
1918
+ . after ( patchMutation ( 'foo/bar' , { 'stars' : 2 } ) )
1919
+ . toReturnChanged (
1920
+ doc ( 'foo/bar' , 1 , { 'likes' : 1 , 'stars' : 2 } ) . setHasLocalMutations ( )
1921
+ )
1922
+ . toContain (
1923
+ doc ( 'foo/bar' , 1 , { 'likes' : 1 , 'stars' : 2 } ) . setHasLocalMutations ( )
1924
+ )
1925
+ . finish ( ) ;
1926
+ } ) ;
1927
+
1928
+ it ( 'can handle multiple field patches on local docs' , ( ) => {
1929
+ return expectLocalStore ( )
1930
+ . after ( setMutation ( 'foo/bar' , { 'likes' : 0 , 'stars' : 0 } ) )
1931
+ . toReturnChanged (
1932
+ doc ( 'foo/bar' , 1 , { 'likes' : 0 , 'stars' : 0 } ) . setHasLocalMutations ( )
1933
+ )
1934
+ . toContain (
1935
+ doc ( 'foo/bar' , 1 , { 'likes' : 0 , 'stars' : 0 } ) . setHasLocalMutations ( )
1936
+ )
1937
+ . after ( patchMutation ( 'foo/bar' , { 'likes' : 1 } ) )
1938
+ . toReturnChanged (
1939
+ doc ( 'foo/bar' , 1 , { 'likes' : 1 , 'stars' : 0 } ) . setHasLocalMutations ( )
1940
+ )
1941
+ . toContain (
1942
+ doc ( 'foo/bar' , 1 , { 'likes' : 1 , 'stars' : 0 } ) . setHasLocalMutations ( )
1943
+ )
1944
+ . after ( patchMutation ( 'foo/bar' , { 'stars' : 1 } ) )
1945
+ . toReturnChanged (
1946
+ doc ( 'foo/bar' , 1 , { 'likes' : 1 , 'stars' : 1 } ) . setHasLocalMutations ( )
1947
+ )
1948
+ . toContain (
1949
+ doc ( 'foo/bar' , 1 , { 'likes' : 1 , 'stars' : 1 } ) . setHasLocalMutations ( )
1950
+ )
1951
+ . after ( patchMutation ( 'foo/bar' , { 'stars' : 2 } ) )
1952
+ . toReturnChanged (
1953
+ doc ( 'foo/bar' , 1 , { 'likes' : 1 , 'stars' : 2 } ) . setHasLocalMutations ( )
1954
+ )
1955
+ . toContain (
1956
+ doc ( 'foo/bar' , 1 , { 'likes' : 1 , 'stars' : 2 } ) . setHasLocalMutations ( )
1957
+ )
1958
+ . finish ( ) ;
1959
+ } ) ;
1960
+
1893
1961
it ( 'uses target mapping to execute queries' , ( ) => {
1894
1962
if ( gcIsEager ) {
1895
1963
return ;
0 commit comments