From 175e8598db8e6d0732eb65b5e4effa46ccea857c Mon Sep 17 00:00:00 2001 From: Jonas Date: Thu, 19 Dec 2024 11:46:08 +0100 Subject: [PATCH] test(cypress): Fix flaky test outline test by waiting some seconds This works around a race condition and is not the perfect solution, but it fixes a long-standing flaky test. Signed-off-by: Jonas --- cypress/e2e/page-details.spec.js | 7 +++++++ cypress/e2e/pages.spec.js | 10 ++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/cypress/e2e/page-details.spec.js b/cypress/e2e/page-details.spec.js index ff026cce6..678bb7203 100644 --- a/cypress/e2e/page-details.spec.js +++ b/cypress/e2e/page-details.spec.js @@ -23,6 +23,9 @@ describe('Page details', function() { describe('Display table of contents', function() { it('Allows to display/close TOC and switch page modes in between', function() { cy.openPage('TableOfContents') + cy.getReadOnlyEditor() + .contains('Second-Level Heading') + cy.wait(200) // eslint-disable-line cypress/no-unnecessary-waiting cy.get('#titleform .action-item__menutoggle') .click() @@ -34,6 +37,9 @@ describe('Page details', function() { .should('contain', 'Second-Level Heading') cy.switchToEditMode() + cy.getEditor() + .contains('Second-Level Heading') + cy.wait(200) // eslint-disable-line cypress/no-unnecessary-waiting cy.getEditor() .find('.editor--toc .editor--toc__item') @@ -46,6 +52,7 @@ describe('Page details', function() { // Switch back to view mode cy.switchToViewMode() + .contains('Second-Level Heading') cy.get('.editor--toc') .should('not.exist') diff --git a/cypress/e2e/pages.spec.js b/cypress/e2e/pages.spec.js index 54b72762c..403d18f5d 100644 --- a/cypress/e2e/pages.spec.js +++ b/cypress/e2e/pages.spec.js @@ -87,7 +87,7 @@ describe('Pages', function() { describe('Creating a page from template', function() { it('New page has template content', function() { - // Do some handstands to ensure that new page with editor is loaded before we edit the title + // Do some handstands to ensure that new page with editor is loaded cy.intercept('POST', '**/_api/*/_pages/*').as('createPage') if (['stable27'].includes(Cypress.env('ncVersion'))) { cy.intercept('PUT', '**/apps/text/session/create').as('textCreateSession') @@ -98,15 +98,17 @@ describe('Pages', function() { .find('button.action-button-add') .click() cy.wait(['@createPage', '@textCreateSession']) + + cy.getEditor() + .should('be.visible') + .contains('This is going to be our template.') + cy.intercept('PUT', '**/_api/*/_pages/*').as('renamePage') cy.get('#titleform input.title') .type('New page from Template') cy.get('#titleform input.title') .blur() cy.wait('@renamePage') - cy.getEditor(Cypress.config('defaultCommandTimeout') * 2) - .should('be.visible') - .contains('This is going to be our template.') cy.get('.app-content-list-item').eq(1) .should('contain', 'New page from Template') })