From 9225acd3a8d00082994bb2a82e25b268f9225b53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Wed, 14 Jun 2023 08:48:16 +0200 Subject: [PATCH] tests(cypress): Refactor reconnect test to wait more reliably MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- cypress/e2e/sync.spec.js | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/cypress/e2e/sync.spec.js b/cypress/e2e/sync.spec.js index 0d09003b264..26449b12d88 100644 --- a/cypress/e2e/sync.spec.js +++ b/cypress/e2e/sync.spec.js @@ -66,26 +66,26 @@ describe('Sync', () => { it('recovers from a lost connection', () => { let count = 0 - cy.intercept({ method: 'POST', url: '**/apps/text/session/push' }, (req) => { - if (count < 5) { - count++ + cy.intercept({ method: 'POST', url: '**/apps/text/session/*' }, (req) => { + if (count < 4) { req.destroy() req.alias = 'dead' + } else { + req.alias = 'alive' } - }).as('push') - cy.intercept({ method: 'POST', url: '**/apps/text/session/sync' }, (req) => { - if (count < 5) { - count++ - req.destroy() - req.alias = 'deadSync' - } - }) - cy.get('#editor-container .document-status') - .should('contain', 'File could not be loaded', { timeout: 10000 }) - cy.get('#editor-container .document-status', { timeout: 30000 }) - .should('not.contain', 'File could not be loaded') + }).as('sessionRequests') + cy.wait('@dead', { timeout: 30000 }) + cy.get('#editor-container .document-status', { timeout: 10000 }) + .should('contain', 'File could not be loaded') + .then(() => { + count = 4 + }) + cy.wait('@alive', { timeout: 30000 }) cy.intercept({ method: 'POST', url: '**/apps/text/session/sync' }) .as('syncAfterRecovery') + cy.wait('@syncAfterRecovery', { timeout: 30000 }) + cy.get('#editor-container .document-status', { timeout: 30000 }) + .should('not.contain', 'File could not be loaded') cy.getContent().type('* more content added after the lost connection{enter}') cy.wait('@syncAfterRecovery') cy.closeFile()