Skip to content

Commit

Permalink
test(cypress): Make page list trash test retriable
Browse files Browse the repository at this point in the history
Only insert the attachment once.

When opening the page for the first time
it is in edit mode and the attachment can be inserted.

On test retries the attachment was already there
and the page opened in view mode.
This led to test failures when attempting to switch to view mode.

Signed-off-by: Max <max@nextcloud.com>
  • Loading branch information
max-nextcloud committed Sep 14, 2023
1 parent 4028acd commit cfcf8d2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
9 changes: 6 additions & 3 deletions cypress/e2e/page-list.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,15 +148,18 @@ describe('Page list', function() {
})

describe('Page trash', function() {
it('allows to trash and restore page with subpage and attachment', function() {
cy.visit('/apps/collectives/Our%20Garden/Day%201')

// Insert attachment
// Insert attachment once
before(function() {
cy.visit('/apps/collectives/Our%20Garden/Day%201')
cy.intercept({ method: 'POST', url: '**/text/attachment/upload*' }).as('attachmentUpload')
cy.get('input[data-text-el="attachment-file-input"]')
.selectFile('cypress/fixtures/test.png', { force: true })
cy.wait('@attachmentUpload')
cy.switchPageMode(0)
})

it('allows to trash and restore page with subpage and attachment', function() {

// Trash page
cy.contains('.page-list .app-content-list-item', 'Day 1')
Expand Down
8 changes: 8 additions & 0 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -360,3 +360,11 @@ Cypress.Commands.add('seedCircleMember', (name, userId, type = 1, level) => {
}
})
})

/**
* Fail the test on the initial run to check if retries work
*/
Cypress.Commands.add('testRetry', () => {
cy.wrap(cy.state('test').currentRetry())
.should('be.equal', 2)
})

0 comments on commit cfcf8d2

Please sign in to comment.