Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
clean(test): failfast + extract common parts in oddname
Signed-off-by: Robbert Gurdeep Singh <[email protected]>
  • Loading branch information
beardhatcode committed May 3, 2021
commit 711ce4b92b50d6c17e3bb58977a8dbb14c3cfe61
72 changes: 35 additions & 37 deletions cypress/integration/oddname/oddname.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ function naughtyFileName(realName) {
)
}

let failsLeft = 5
Cypress.on('fail', (error, runnable) => {
failsLeft--
throw error // throw error to have test still fail
})
Comment on lines +47 to +51
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, I don't know about this one.
It seems like an odd thing to do, does cypress not support quick-fail on its own?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It supports quick-fail in their "pro plan" (see cypress-io/cypress#518 (comment)).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe using https://github.com/javierbrea/cypress-fail-fast is an option, but that would add a dependency that is only used for one thing (and is implemented in 5 + 3 lines of code)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe using javierbrea/cypress-fail-fast is an option, but that would add a dependency that is only used for one thing (and is implemented in 5 + 3 lines of code)

Let get this in then


export default function(file, type) {

const placedName = naughtyFileName(file)
Expand All @@ -59,6 +65,11 @@ export default function(file, type) {

describe(`Open ${file} in viewer with a naughty name`, function() {
before(function() {
// fail fast
if (failsLeft < 0) {
throw new Error('Too many previous tests failed')
}

// Init user
cy.nextcloudCreateUser(randUser, 'password')
cy.login(randUser, 'password')
Expand All @@ -77,39 +88,41 @@ export default function(file, type) {
// no need to log out we do this in the test to check the public link
})

it(`See ${file} as ${placedName} in the list`, function() {
cy.get(`#fileList tr[data-file="${placedNameCss}"]`, {
timeout: 10000,
}).should('contain', placedName)
})

it('Open the viewer on file click', function() {
cy.openFile(placedName)
cy.get('body > .viewer').should('be.visible')
})

it('Does not see a loading animation', function() {
function noLoadingAnimation() {
cy.get('body > .viewer', { timeout: 10000 })
.should('be.visible')
.and('have.class', 'modal-mask')
.and('not.have.class', 'icon-loading')
})
}

it('See the menu icon and title on the viewer header', function() {
function menuOk() {
cy.get('body > .viewer .icon-error').should('not.exist')
cy.get('body > .viewer .modal-title').should('contain', placedName)
cy.get(
'body > .viewer .modal-header button.action-item__menutoggle'
).should('be.visible')
cy.get('body > .viewer .modal-header button.icon-close').should(
'be.visible'
)
})
}

it('Does not see navigation arrows', function() {
function arrowsOK() {
cy.get('body > .viewer a.prev').should('not.be.visible')
cy.get('body > .viewer a.next').should('not.be.visible')
}

it(`See ${file} as ${placedName} in the list`, function() {
cy.get(`#fileList tr[data-file="${placedNameCss}"]`, {
timeout: 10000,
}).should('contain', placedName)
})

it('Open the viewer on file click', function() {
cy.openFile(placedName)
cy.get('body > .viewer').should('be.visible')
})

it('Does not see a loading animation', noLoadingAnimation)
it('See the menu icon and title on the viewer header', menuOk)
it('Does not see navigation arrows', arrowsOK)

it('Share the folder with a share link and access the share link', function() {
cy.createLinkShare(folderName).then((token) => {
cy.logout()
Expand All @@ -122,23 +135,8 @@ export default function(file, type) {
cy.get('body > .viewer').should('be.visible')
})

it('Does not see a loading animation (public)', function() {
cy.get('body > .viewer', { timeout: 10000 })
.should('be.visible')
.and('have.class', 'modal-mask')
.and('not.have.class', 'icon-loading')
})

it('See the menu icon and title on the viewer header (public)', function() {
cy.get('body > .viewer .modal-title').should('contain', placedName)
cy.get('body > .viewer .modal-header button.icon-close').should(
'be.visible'
)
})

it('Does not see navigation arrows (public)', function() {
cy.get('body > .viewer a.prev').should('not.be.visible')
cy.get('body > .viewer a.next').should('not.be.visible')
})
it('Does not see a loading animation (public)', noLoadingAnimation)
it('See the menu icon and title on the viewer header (public)', menuOk)
it('Does not see navigation arrows (public)', arrowsOK)
})
}