@@ -1763,6 +1763,69 @@ describe('replication-graphql.test.js', () => {
1763
1763
return docs . length === ( amount + 1 ) ;
1764
1764
} ) ;
1765
1765
1766
+ server . close ( ) ;
1767
+ db . destroy ( ) ;
1768
+ } ) ;
1769
+ it ( '#1812 updates fail when graphql is enabled' , async ( ) => {
1770
+ const db = await RxDB . create ( {
1771
+ name : util . randomCouchString ( 10 ) ,
1772
+ adapter : 'memory' ,
1773
+ multiInstance : false ,
1774
+ queryChangeDetection : true ,
1775
+ password : util . randomCouchString ( 10 )
1776
+ } ) ;
1777
+ const schema = clone ( schemas . humanWithTimestampAllIndex ) ;
1778
+ schema . properties . name . encrypted = true ;
1779
+ const collection = await db . collection ( {
1780
+ name : 'humans' ,
1781
+ schema
1782
+ } ) ;
1783
+ const server = await SpawnServer . spawn ( ) ;
1784
+ assert . strictEqual ( server . getDocuments ( ) . length , 0 ) ;
1785
+
1786
+ const replicationState = collection . syncGraphQL ( {
1787
+ url : server . url ,
1788
+ push : {
1789
+ batchSize,
1790
+ queryBuilder : pushQueryBuilder
1791
+ } ,
1792
+ pull : {
1793
+ queryBuilder
1794
+ } ,
1795
+ live : true ,
1796
+ deletedFlag : 'deleted'
1797
+ } ) ;
1798
+ await replicationState . awaitInitialReplication ( ) ;
1799
+
1800
+ // add one doc
1801
+ const testData = getTestData ( 1 ) . pop ( ) ;
1802
+ delete testData . deleted ;
1803
+ await collection . insert ( testData ) ;
1804
+
1805
+ // sync
1806
+ await replicationState . run ( ) ;
1807
+ assert . strictEqual ( server . getDocuments ( ) . length , 1 ) ;
1808
+
1809
+ // update document
1810
+ const newTime = Math . round ( new Date ( ) . getTime ( ) / 1000 ) ;
1811
+ const doc = await collection . findOne ( ) . exec ( ) ;
1812
+ await doc . atomicSet ( 'updatedAt' , newTime ) ;
1813
+
1814
+ // check server
1815
+ await replicationState . run ( ) ;
1816
+ await AsyncTestUtil . waitUntil ( ( ) => {
1817
+ const notUpdated = server . getDocuments ( ) . find ( ( d : any ) => d . updatedAt !== newTime ) ;
1818
+ return ! notUpdated ;
1819
+ } ) ;
1820
+
1821
+ // also delete to ensure nothing broke
1822
+ await doc . remove ( ) ;
1823
+ await replicationState . run ( ) ;
1824
+ await AsyncTestUtil . waitUntil ( ( ) => {
1825
+ const d = server . getDocuments ( ) . pop ( ) ;
1826
+ return d [ 'deleted' ] ;
1827
+ } ) ;
1828
+
1766
1829
server . close ( ) ;
1767
1830
db . destroy ( ) ;
1768
1831
} ) ;
0 commit comments