Skip to content

Commit 711ce4b

Browse files
committed
clean(test): failfast + extract common parts in oddname
Signed-off-by: Robbert Gurdeep Singh <[email protected]>
1 parent b64ae9e commit 711ce4b

File tree

1 file changed

+35
-37
lines changed

1 file changed

+35
-37
lines changed

cypress/integration/oddname/oddname.js

Lines changed: 35 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ function naughtyFileName(realName) {
4444
)
4545
}
4646

47+
let failsLeft = 5
48+
Cypress.on('fail', (error, runnable) => {
49+
failsLeft--
50+
throw error // throw error to have test still fail
51+
})
52+
4753
export default function(file, type) {
4854

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

6066
describe(`Open ${file} in viewer with a naughty name`, function() {
6167
before(function() {
68+
// fail fast
69+
if (failsLeft < 0) {
70+
throw new Error('Too many previous tests failed')
71+
}
72+
6273
// Init user
6374
cy.nextcloudCreateUser(randUser, 'password')
6475
cy.login(randUser, 'password')
@@ -77,39 +88,41 @@ export default function(file, type) {
7788
// no need to log out we do this in the test to check the public link
7889
})
7990

80-
it(`See ${file} as ${placedName} in the list`, function() {
81-
cy.get(`#fileList tr[data-file="${placedNameCss}"]`, {
82-
timeout: 10000,
83-
}).should('contain', placedName)
84-
})
85-
86-
it('Open the viewer on file click', function() {
87-
cy.openFile(placedName)
88-
cy.get('body > .viewer').should('be.visible')
89-
})
90-
91-
it('Does not see a loading animation', function() {
91+
function noLoadingAnimation() {
9292
cy.get('body > .viewer', { timeout: 10000 })
9393
.should('be.visible')
9494
.and('have.class', 'modal-mask')
9595
.and('not.have.class', 'icon-loading')
96-
})
96+
}
9797

98-
it('See the menu icon and title on the viewer header', function() {
98+
function menuOk() {
99+
cy.get('body > .viewer .icon-error').should('not.exist')
99100
cy.get('body > .viewer .modal-title').should('contain', placedName)
100-
cy.get(
101-
'body > .viewer .modal-header button.action-item__menutoggle'
102-
).should('be.visible')
103101
cy.get('body > .viewer .modal-header button.icon-close').should(
104102
'be.visible'
105103
)
106-
})
104+
}
107105

108-
it('Does not see navigation arrows', function() {
106+
function arrowsOK() {
109107
cy.get('body > .viewer a.prev').should('not.be.visible')
110108
cy.get('body > .viewer a.next').should('not.be.visible')
109+
}
110+
111+
it(`See ${file} as ${placedName} in the list`, function() {
112+
cy.get(`#fileList tr[data-file="${placedNameCss}"]`, {
113+
timeout: 10000,
114+
}).should('contain', placedName)
111115
})
112116

117+
it('Open the viewer on file click', function() {
118+
cy.openFile(placedName)
119+
cy.get('body > .viewer').should('be.visible')
120+
})
121+
122+
it('Does not see a loading animation', noLoadingAnimation)
123+
it('See the menu icon and title on the viewer header', menuOk)
124+
it('Does not see navigation arrows', arrowsOK)
125+
113126
it('Share the folder with a share link and access the share link', function() {
114127
cy.createLinkShare(folderName).then((token) => {
115128
cy.logout()
@@ -122,23 +135,8 @@ export default function(file, type) {
122135
cy.get('body > .viewer').should('be.visible')
123136
})
124137

125-
it('Does not see a loading animation (public)', function() {
126-
cy.get('body > .viewer', { timeout: 10000 })
127-
.should('be.visible')
128-
.and('have.class', 'modal-mask')
129-
.and('not.have.class', 'icon-loading')
130-
})
131-
132-
it('See the menu icon and title on the viewer header (public)', function() {
133-
cy.get('body > .viewer .modal-title').should('contain', placedName)
134-
cy.get('body > .viewer .modal-header button.icon-close').should(
135-
'be.visible'
136-
)
137-
})
138-
139-
it('Does not see navigation arrows (public)', function() {
140-
cy.get('body > .viewer a.prev').should('not.be.visible')
141-
cy.get('body > .viewer a.next').should('not.be.visible')
142-
})
138+
it('Does not see a loading animation (public)', noLoadingAnimation)
139+
it('See the menu icon and title on the viewer header (public)', menuOk)
140+
it('Does not see navigation arrows (public)', arrowsOK)
143141
})
144142
}

0 commit comments

Comments
 (0)