Skip to content

Commit fa0c72e

Browse files
author
Vinicius Reis
authored
Merge pull request #2584 from nextcloud/test/retry-failed-cypress-tests
test: retry failed cypress tests twice
2 parents 9abdea0 + 62bb1fe commit fa0c72e

16 files changed

+61
-55
lines changed

β€Žcypress.config.jsβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,5 @@ module.exports = defineConfig({
2020
experimentalSessionAndOrigin: true,
2121
specPattern: 'cypress/e2e/**/*.{js,jsx,ts,tsx}',
2222
},
23+
retries: 2,
2324
})

β€Žcypress/e2e/images.spec.jsβ€Ž

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ const waitForRequestAndCheckImage = (requestAlias, index) => {
135135
describe('Test all image insertion methods', () => {
136136
before(() => {
137137
initUserAndFiles(randUser, 'test.md', 'empty.md')
138+
138139
cy.uploadFile('github.png', 'image/png')
139140

140141
cy.nextcloudCreateUser(randUser2, 'password')
@@ -161,6 +162,7 @@ describe('Test all image insertion methods', () => {
161162

162163
it('Insert an image from files', () => {
163164
cy.openFile('test.md')
165+
164166
clickOnImageAction(ACTION_INSERT_FROM_FILES)
165167
.then(() => {
166168
const requestAlias = 'insertPathRequest'
@@ -171,7 +173,7 @@ describe('Test all image insertion methods', () => {
171173
cy.log('Click OK in the filepicker')
172174
cy.get('.oc-dialog > .oc-dialog-buttonrow button').click()
173175

174-
waitForRequestAndCheckImage(requestAlias)
176+
return waitForRequestAndCheckImage(requestAlias)
175177
})
176178
})
177179

@@ -192,8 +194,12 @@ describe('Test all image insertion methods', () => {
192194
})
193195

194196
it('Upload images with the same name', () => {
195-
cy.uploadFile('empty.md', 'text/markdown')
196-
cy.openFile('empty.md')
197+
// make sure we start from an emtpy file even on retries
198+
const filename = randHash() + '.md'
199+
200+
cy.uploadFile('empty.md', 'text/markdown', filename)
201+
cy.reloadFileList()
202+
cy.openFile(filename)
197203

198204
const assertImage = index => {
199205
return clickOnImageAction(ACTION_UPLOAD_LOCAL_FILE)

β€Žcypress/support/commands.jsβ€Ž

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -163,26 +163,26 @@ Cypress.Commands.add('shareFileToUser', (userId, password, path, targetUserId) =
163163
})
164164

165165
Cypress.Commands.add('createFolder', dirName => {
166-
cy.window().then(win => {
166+
return cy.window().then(win => {
167167
return win.OC.Files.getClient().createDirectory(dirName)
168168
})
169169
})
170170

171171
Cypress.Commands.add('moveFile', (path, destinationPath) => {
172-
cy.window().then(win => {
173-
win.OC.Files.getClient().move(path, destinationPath)
172+
return cy.window().then(win => {
173+
return win.OC.Files.getClient().move(path, destinationPath)
174174
})
175175
})
176176

177177
Cypress.Commands.add('copyFile', (path, destinationPath) => {
178-
cy.window().then(win => {
179-
win.OC.Files.getClient().copy(path, destinationPath)
178+
return cy.window().then(win => {
179+
return win.OC.Files.getClient().copy(path, destinationPath)
180180
})
181181
})
182182

183183
Cypress.Commands.add('reloadFileList', () => {
184-
cy.window().then(win => {
185-
win.OCA?.Files?.App?.fileList?.reload()
184+
return cy.window().then(win => {
185+
return win.OCA?.Files?.App?.fileList?.reload()
186186
})
187187
})
188188

β€Žcypress/utils/index.jsβ€Ž

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,15 @@ export const getSearchParams = url => {
3535
* Can be used e.g. for a `before()`
3636
*
3737
* @param {string} userName Username of the user to create
38-
* @param {...string} file one ore more markdown file names to create
38+
* @param {...string} files one ore more markdown file names to create
3939
*/
40-
export function initUserAndFiles(userName, file) {
41-
const files = [...arguments].slice(1)
42-
40+
export function initUserAndFiles(userName, ...files) {
4341
// Init user
4442
cy.nextcloudCreateUser(userName, 'password')
4543
cy.login(userName, 'password')
4644

4745
// Upload test files
48-
files.forEach(file => {
46+
;(files || []).forEach(file => {
4947
cy.uploadFile(file, 'text/markdown')
5048
})
5149
}

β€Žjs/text-files.jsβ€Ž

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

β€Žjs/text-files.js.mapβ€Ž

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

β€Žjs/text-public.jsβ€Ž

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

β€Žjs/text-public.js.mapβ€Ž

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

β€Žjs/text-text.jsβ€Ž

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

β€Žjs/text-text.js.mapβ€Ž

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
Β (0)