Skip to content

Commit

Permalink
test(cypress): Fix flaky test outline test by waiting some seconds
Browse files Browse the repository at this point in the history
This works around a race condition and is not the perfect solution, but
it fixes a long-standing flaky test.

Signed-off-by: Jonas <[email protected]>
  • Loading branch information
mejo- committed Dec 19, 2024
1 parent 87e02e5 commit 175e859
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
7 changes: 7 additions & 0 deletions cypress/e2e/page-details.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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')
Expand All @@ -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')
Expand Down
10 changes: 6 additions & 4 deletions cypress/e2e/pages.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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')
})
Expand Down

0 comments on commit 175e859

Please sign in to comment.