2323import { randUser } from '../../utils/index.js'
2424import { SyncService } from '../../../src/services/SyncService.js'
2525import createSyncServiceProvider from '../../../src/services/SyncServiceProvider.js'
26- import { Doc , applyUpdate , encodeStateAsUpdate , encodeStateVector } from 'yjs'
26+ import { Doc } from 'yjs'
2727
2828const user = randUser ( )
2929
@@ -74,29 +74,7 @@ describe('Sync service provider', function() {
7474 } )
7575 }
7676
77- it ( 'syncs even when initial state was present' , function ( ) {
78- const sourceMap = this . source . getMap ( )
79- const targetMap = this . target . getMap ( )
80- sourceMap . set ( 'unrelated' , 'value' )
81- cy . intercept ( { method : 'POST' , url : '**/apps/text/session/push' } )
82- . as ( 'push' )
83- cy . intercept ( { method : 'POST' , url : '**/apps/text/session/sync' } )
84- . as ( 'sync' )
85- cy . wait ( '@push' )
86- cy . then ( ( ) => {
87- sourceMap . set ( 'keyA' , 'valueA' )
88- expect ( targetMap . get ( 'keyB' ) ) . to . be . eq ( undefined )
89- } )
90- cy . wait ( '@sync' )
91- cy . wait ( '@sync' )
92- // eslint-disable-next-line cypress/no-unnecessary-waiting
93- cy . wait ( 1000 )
94- cy . then ( ( ) => {
95- expect ( targetMap . get ( 'keyA' ) ) . to . be . eq ( 'valueA' )
96- } )
97- } )
98-
99- it . only ( 'recovers from a dropped message' , function ( ) {
77+ it ( 'recovers from a dropped message' , function ( ) {
10078 const sourceMap = this . source . getMap ( )
10179 const targetMap = this . target . getMap ( )
10280 cy . intercept ( { method : 'POST' , url : '**/apps/text/session/push' } )
@@ -158,7 +136,11 @@ describe('Sync service provider', function() {
158136 } )
159137 } )
160138
161- it ( 'is not too chatty' , function ( ) {
139+ /*
140+ * Counts the amount of push and sync requests in one minute.
141+ * Skipped per default, useful for comparison before/after changes to SyncProvider or PollingBackend.
142+ */
143+ it . skip ( 'is not too chatty' , function ( ) {
162144 const sourceMap = this . source . getMap ( )
163145 const targetMap = this . target . getMap ( )
164146 cy . intercept ( { method : 'POST' , url : '**/apps/text/session/push' } )
@@ -180,40 +162,4 @@ describe('Sync service provider', function() {
180162 // 2 clients sync fast first and then every 5 seconds -> 2*12 = 24. Actual 32.
181163 cy . get ( '@sync.all' ) . its ( 'length' ) . should ( 'be.lessThan' , 60 )
182164 } )
183-
184- it . only ( 'applies step in wrong order' , function ( ) {
185- const source = new Doc ( )
186- const target = new Doc ( )
187- const sourceMap = source . getMap ( )
188- const targetMap = target . getMap ( )
189-
190- target . on ( 'afterTransaction' , ( tr , doc ) => {
191- // console.log('afterTransaction', tr)
192- } )
193-
194- // Add keyA to source and apply to target
195- sourceMap . set ( 'keyA' , 'valueA' )
196- const update0A = encodeStateAsUpdate ( source )
197- const sourceVectorA = encodeStateVector ( source )
198- applyUpdate ( target , update0A )
199- expect ( targetMap . get ( 'keyA' ) ) . to . be . eq ( 'valueA' )
200-
201- // Add keyB to source, don't apply to target yet
202- sourceMap . set ( 'keyB' , 'valueB' )
203- const updateAB = encodeStateAsUpdate ( source , sourceVectorA )
204- const sourceVectorB = encodeStateVector ( source )
205-
206- // Add keyC to source, apply to target
207- sourceMap . set ( 'keyC' , 'valueC' )
208- const updateBC = encodeStateAsUpdate ( source , sourceVectorB )
209- applyUpdate ( target , updateBC )
210- expect ( targetMap . get ( 'keyB' ) ) . to . be . eq ( undefined )
211- expect ( targetMap . get ( 'keyC' ) ) . to . be . eq ( undefined )
212-
213- // Apply keyB to target
214- applyUpdate ( target , updateAB )
215- expect ( targetMap . get ( 'keyB' ) ) . to . be . eq ( 'valueB' )
216- expect ( targetMap . get ( 'keyC' ) ) . to . be . eq ( 'valueC' )
217- } )
218-
219165} )
0 commit comments