Skip to content

Commit

Permalink
fix(cy): format test with actions in overflow menu
Browse files Browse the repository at this point in the history
Signed-off-by: Max <max@nextcloud.com>
  • Loading branch information
max-nextcloud authored and backportbot-nextcloud[bot] committed Dec 28, 2023
1 parent 7c9517c commit 8a735a9
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions cypress/e2e/workspace.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,13 @@ describe('Workspace', function() {
]
cy.getContent().click()
buttons.forEach(([button, tag]) => testButtonUnselected(button, tag))
cy.getContent().type('Format me{selectall}')
// format is gone when text is gone
cy.getContent().type('Format me')
cy.getContent().find('s')
.should('not.exist')
cy.getContent()
.should('contain', 'Format me')
cy.getContent().type('{selectall}')
buttons.forEach(([button, tag]) => testButton(button, tag, 'Format me'))
})

Expand Down Expand Up @@ -303,13 +309,15 @@ const openSidebar = filename => {
* @param {string} content Content expected in the element.
*/
function testButton(button, tag, content) {
cy.getMenuEntry(button).click()
cy.getMenuEntry(button).should('have.class', 'is-active')
cy.getMenuEntry(button)
.should('not.have.class', 'is-active')
.click()
cy.getContent()
.find(`${tag}`)
.should('contain', content)
cy.getMenuEntry(button).click()
cy.getMenuEntry(button).should('not.have.class', 'is-active')
cy.getMenuEntry(button)
.should('have.class', 'is-active')
.click()
}

/**
Expand All @@ -318,16 +326,11 @@ function testButton(button, tag, content) {
* @param {string} tag Html tag expected to be toggled.
*/
function testButtonUnselected(button, tag) {
cy.getMenuEntry(button).click()
cy.getMenuEntry(button).should('have.class', 'is-active')
cy.getContent().type('Format me{selectall}')
cy.getMenuEntry(button)
.should('not.have.class', 'is-active')
.click()
cy.getContent().type('Format me')
cy.getContent().find(`${tag}`)
.should('contain', 'Format me').type('{del}')
cy.getMenuEntry(button).click()
cy.getMenuEntry(button).should('have.class', 'is-active').click()
cy.getMenuEntry(button).should('not.have.class', 'is-active')
cy.getContent().type('Format me{selectall}')
cy.getMenuEntry(button).find(`${tag}`)
.should('not.exist')
cy.getContent().type('{del}')
.should('contain', 'Format me')
cy.getContent().type('{selectall}{del}')
}

0 comments on commit 8a735a9

Please sign in to comment.