Skip to content

Commit 5abb9d0

Browse files
max-nextcloudmejo-
authored andcommitted
chore(test): add test for 4480
See #4480. (Fixed before)
1 parent c732064 commit 5abb9d0

1 file changed

Lines changed: 25 additions & 2 deletions

File tree

cypress/e2e/api/SyncServiceProvider.spec.js

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ describe('Sync service provider', function () {
3434
})
3535

3636
afterEach(function () {
37-
this.sourceProvider?.destroy()
38-
this.targetProvider?.destroy()
37+
cy.get('@sourceProvider').invoke('destroy')
38+
cy.get('@targetProvider').invoke('destroy')
3939
})
4040

4141
/**
@@ -167,4 +167,27 @@ describe('Sync service provider', function () {
167167
// 2 clients sync fast first and then every 5 seconds -> 2*12 = 24. Actual 32.
168168
cy.get('@sync.all').its('length').should('be.lessThan', 60)
169169
})
170+
171+
it('syncs even when initial state was present', function() {
172+
const sourceMap = this.source.getMap()
173+
const targetMap = this.target.getMap()
174+
sourceMap.set('unrelated', 'value')
175+
cy.intercept({ method: 'POST', url: '**/apps/text/session/*/push' })
176+
.as('push')
177+
cy.intercept({ method: 'POST', url: '**/apps/text/session/*/sync' })
178+
.as('sync')
179+
cy.wait('@push')
180+
cy.then(() => {
181+
sourceMap.set('keyA', 'valueA')
182+
expect(targetMap.get('keyB')).to.be.eq(undefined)
183+
})
184+
cy.wait('@sync')
185+
cy.wait('@sync')
186+
// eslint-disable-next-line cypress/no-unnecessary-waiting
187+
cy.wait(1000)
188+
cy.then(() => {
189+
expect(targetMap.get('keyA')).to.be.eq('valueA')
190+
})
191+
})
192+
170193
})

0 commit comments

Comments
 (0)