Skip to content

Commit

Permalink
test(cy): use cy.getContent and more compact syntax
Browse files Browse the repository at this point in the history
Signed-off-by: Max <max@nextcloud.com>
  • Loading branch information
max-nextcloud committed Jul 24, 2024
1 parent 3fd2093 commit 144b227
Showing 1 changed file with 13 additions and 27 deletions.
40 changes: 13 additions & 27 deletions cypress/e2e/conflict.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,8 @@ variants.forEach(function({ fixture, mime }) {
cy.uploadFile('frontmatter.md', mime, fileName)
// just a read only session opened
cy.shareFile(`/${fileName}`)
.then((token) => {
cy.visit(`/s/${token}`)
})
cy.get('.text-editor__main')
.should('contain', 'Heading')
.then(token => cy.visit(`/s/${token}`))
cy.getContent().should('contain', 'Heading')
cy.intercept({ method: 'POST', url: '**/session/*/push' })
.as('push')
cy.wait('@push')
Expand All @@ -45,12 +42,9 @@ variants.forEach(function({ fixture, mime }) {
cy.get('#editor-container .document-status a.button')
.contains('Reload')
.click()
getWrapper()
.should('not.exist')
cy.getContent()
.should('contain', 'Hello world')
cy.getContent()
.should('not.contain', 'Heading')
getWrapper().should('not.exist')
cy.getContent().should('contain', 'Hello world')
cy.getContent().should('not.contain', 'Heading')
})

it('displays conflicts', function() {
Expand All @@ -77,14 +71,11 @@ variants.forEach(function({ fixture, mime }) {
cy.openFile(fileName)
cy.get('[data-cy="resolveThisVersion"]').click()

getWrapper()
.should('not.exist')
getWrapper().should('not.exist')
cy.get('[data-cy="resolveThisVersion"]')
.should('not.exist')
cy.get('.text-editor__main')
.should('contain', 'Hello world')
cy.get('.text-editor__main')
.should('contain', 'cruel conflicting')
cy.getContent().should('contain', 'Hello world')
cy.getContent().should('contain', 'cruel conflicting')
})

it('resolves conflict using server version', function() {
Expand All @@ -94,16 +85,13 @@ variants.forEach(function({ fixture, mime }) {
cy.get('[data-cy="resolveServerVersion"]')
.click()

getWrapper()
.should('not.exist')
getWrapper().should('not.exist')
cy.get('[data-cy="resolveThisVersion"]')
.should('not.exist')
cy.get('[data-cy="resolveServerVersion"]')
.should('not.exist')
cy.get('.text-editor__main')
.should('contain', 'Hello world')
cy.get('.text-editor__main')
.should('not.contain', 'cruel conflicting')
cy.getContent().should('contain', 'Hello world')
cy.getContent().should('not.contain', 'cruel conflicting')
})

it('hides conflict in read only session', function() {
Expand All @@ -113,10 +101,8 @@ variants.forEach(function({ fixture, mime }) {
cy.logout()
cy.visit(`/s/${token}`)
})
cy.get('.text-editor__main')
.should('contain', 'cruel conflicting')
getWrapper()
.should('not.exist')
cy.getContent().should('contain', 'cruel conflicting')
getWrapper().should('not.exist')
})

})
Expand Down

0 comments on commit 144b227

Please sign in to comment.