Skip to content

Commit 07952f4

Browse files
Claudejuliusknorr
andcommitted
Stabilize Cypress tests - improve timeouts and remove hard-coded waits
Co-authored-by: juliusknorr <3404133+juliusknorr@users.noreply.github.com>
1 parent 7823c8f commit 07952f4

3 files changed

Lines changed: 19 additions & 13 deletions

File tree

cypress.config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ export default defineConfig({
1313
viewportHeight: 720,
1414
chromeWebSecurity: false,
1515
modifyObstructiveCode: false,
16+
retries: {
17+
runMode: 2,
18+
openMode: 0,
19+
},
1620
e2e: {
1721
// We've imported your old cypress plugins here.
1822
// You may want to clean this up later by importing these.

cypress/e2e/open.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ describe('Open existing office files', function() {
3838

3939
cy.waitForPostMessage('App_LoadingStatus', { Status: 'Document_Loaded' })
4040

41-
// Share action
42-
cy.wait(2000)
41+
// Wait for document to be fully loaded before verifying
4342
cy.get('@loleafletframe').within(() => {
43+
cy.get('input#document-name-input', { timeout: 10000 }).should('be.visible')
4444
cy.verifyOpen(filename)
4545
})
4646

cypress/support/commands.js

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,9 @@ Cypress.Commands.add('shareLink', (user, path, shareData = {}) => {
181181
})
182182

183183
Cypress.Commands.add('openFile', fileName => {
184-
cy.get(`[data-cy-files-list] tr[data-cy-files-list-row-name="${fileName}"] [data-cy-files-list-row-name-link]`).click()
184+
cy.get(`[data-cy-files-list] tr[data-cy-files-list-row-name="${fileName}"] [data-cy-files-list-row-name-link]`, { timeout: 10000 })
185+
.should('be.visible')
186+
.click()
185187
})
186188

187189
Cypress.Commands.add('nextcloudEnableApp', (appId) => {
@@ -238,7 +240,7 @@ Cypress.Commands.add('nextcloudTestingAppConfigSet', (appId, configKey, configVa
238240
})
239241

240242
Cypress.Commands.add('waitForViewer', () => {
241-
cy.get('#viewer', { timeout: 50000 })
243+
cy.get('#viewer', { timeout: 60000 })
242244
.should('be.visible')
243245
.and('have.class', 'modal-mask')
244246
.and('not.have.class', 'icon-loading')
@@ -252,16 +254,16 @@ Cypress.Commands.add('waitForViewerClose', () => {
252254
Cypress.Commands.add('waitForCollabora', (wrapped = false, federated = false) => {
253255
const wrappedFrameIdentifier = federated ? 'coolframe' : 'documentframe'
254256
if (wrapped) {
255-
cy.get(`[data-cy="${wrappedFrameIdentifier}"]`, { timeout: 30000 })
257+
cy.get(`[data-cy="${wrappedFrameIdentifier}"]`, { timeout: 60000 })
256258
.its('0.contentDocument')
257259
.its('body').should('not.be.empty')
258260
.should('be.visible').should('not.be.empty')
259261
.as('collaboraframe')
260262
}
261263

262264
const coolFrame = wrapped
263-
? cy.get('@collaboraframe').find('[data-cy="coolframe"]', { timeout: 30000 })
264-
: cy.get('[data-cy="coolframe"]')
265+
? cy.get('@collaboraframe').find('[data-cy="coolframe"]', { timeout: 60000 })
266+
: cy.get('[data-cy="coolframe"]', { timeout: 60000 })
265267

266268
coolFrame
267269
.its('0.contentDocument')
@@ -270,7 +272,7 @@ Cypress.Commands.add('waitForCollabora', (wrapped = false, federated = false) =>
270272

271273
cy.get('@loleafletframe')
272274
.within(() => {
273-
cy.get('#main-document-content').should('be.visible')
275+
cy.get('#main-document-content', { timeout: 30000 }).should('be.visible')
274276
})
275277

276278
return cy.get('@loleafletframe')
@@ -323,10 +325,10 @@ Cypress.Commands.add('inputCollaboraGuestName', (guestName = 'cloud') => {
323325

324326
Cypress.Commands.add('closeDocument', () => {
325327
cy.get('@loleafletframe').within(() => {
326-
cy.get('#closebutton').click()
328+
cy.get('#closebutton', { timeout: 10000 }).should('be.visible').click()
327329
})
328330

329-
cy.get('#viewer', { timeout: 5000 }).should('not.exist')
331+
cy.get('#viewer', { timeout: 10000 }).should('not.exist')
330332
})
331333

332334
Cypress.Commands.add('verifyOpen', (filename) => {
@@ -476,17 +478,17 @@ Cypress.Commands.add('makeTalkRoomPublic', (user, token, password = '') => {
476478
})
477479

478480
Cypress.Commands.add('newFileFromMenu', (fileType = 'document', fileName = 'MyNewFile') => {
479-
cy.get('form[data-cy-upload-picker=""]')
481+
cy.get('form[data-cy-upload-picker=""]', { timeout: 10000 })
480482
.first()
481483
.should('be.visible')
482484
.click()
483485

484-
cy.get('button[role="menuitem"]')
486+
cy.get('button[role="menuitem"]', { timeout: 10000 })
485487
.contains('New ' + fileType)
486488
.should('be.visible')
487489
.click()
488490

489-
cy.get('input[data-cy-files-new-node-dialog-input=""]')
491+
cy.get('input[data-cy-files-new-node-dialog-input=""]', { timeout: 10000 })
490492
.should('be.visible')
491493
.type(fileName + '{enter}')
492494
})

0 commit comments

Comments
 (0)