Skip to content

Commit 90d51cc

Browse files
committed
tests(cypress): Refactor reconnect test to wait more reliably
Signed-off-by: Julius Härtl <jus@bitgrid.net>
1 parent 9ea4c7c commit 90d51cc

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

cypress/e2e/sync.spec.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -66,26 +66,26 @@ describe('Sync', () => {
6666

6767
it('recovers from a lost connection', () => {
6868
let count = 0
69-
cy.intercept({ method: 'POST', url: '**/apps/text/session/push' }, (req) => {
70-
if (count < 5) {
71-
count++
69+
cy.intercept({ method: 'POST', url: '**/apps/text/session/*' }, (req) => {
70+
if (count < 4) {
7271
req.destroy()
7372
req.alias = 'dead'
73+
} else {
74+
req.alias = 'alive'
7475
}
75-
}).as('push')
76-
cy.intercept({ method: 'POST', url: '**/apps/text/session/sync' }, (req) => {
77-
if (count < 5) {
78-
count++
79-
req.destroy()
80-
req.alias = 'deadSync'
81-
}
82-
})
83-
cy.get('#editor-container .document-status')
84-
.should('contain', 'File could not be loaded', { timeout: 10000 })
85-
cy.get('#editor-container .document-status', { timeout: 30000 })
86-
.should('not.contain', 'File could not be loaded')
76+
}).as('sessionRequests')
77+
cy.wait('@dead', { timeout: 30000 })
78+
cy.get('#editor-container .document-status', { timeout: 10000 })
79+
.should('contain', 'File could not be loaded')
80+
.then(() => {
81+
count = 4
82+
})
83+
cy.wait('@alive', { timeout: 30000 })
8784
cy.intercept({ method: 'POST', url: '**/apps/text/session/sync' })
8885
.as('syncAfterRecovery')
86+
cy.wait('@syncAfterRecovery', { timeout: 30000 })
87+
cy.get('#editor-container .document-status', { timeout: 30000 })
88+
.should('not.contain', 'File could not be loaded')
8989
cy.getContent().type('* more content added after the lost connection{enter}')
9090
cy.wait('@syncAfterRecovery')
9191
cy.closeFile()

0 commit comments

Comments
 (0)