diff --git a/cypress.config.ts b/cypress.config.ts index fc54da5c1b..2e5b60c202 100644 --- a/cypress.config.ts +++ b/cypress.config.ts @@ -13,6 +13,10 @@ export default defineConfig({ viewportHeight: 720, chromeWebSecurity: false, modifyObstructiveCode: false, + retries: { + runMode: 2, + openMode: 0, + }, e2e: { // We've imported your old cypress plugins here. // You may want to clean this up later by importing these. diff --git a/cypress/e2e/integration.spec.js b/cypress/e2e/integration.spec.js index 93f95dc85b..45da312b97 100644 --- a/cypress/e2e/integration.spec.js +++ b/cypress/e2e/integration.spec.js @@ -75,17 +75,17 @@ describe('Nextcloud integration', function() { .should('be.visible') cy.get('button[aria-label="File"]').click() - cy.get('button[aria-label="Save As"]') - .should('be.visible', { timeout: 10_000 }) + cy.get('button[aria-label="Save As"]', { timeout: 10_000 }) + .should('be.visible') .click() - cy.get('#saveas-entries > div') + cy.get('#saveas-entries > div', { timeout: 10_000 }) .contains('Rich Text (.rtf)') .should('be.visible') .click() }) - cy.get('.saveas-dialog').should('be.visible') + cy.get('.saveas-dialog', { timeout: 10_000 }).should('be.visible') cy.get('.saveas-dialog input[type=text]') .should('be.visible') .should('have.value', `/${exportFilename}`) @@ -96,9 +96,9 @@ describe('Nextcloud integration', function() { cy.waitForPostMessage('Action_Save_Resp', { success: true, fileName: exportFilename }) cy.get('@loleafletframe').within(() => { - cy.get('#closebutton').click() - cy.waitForViewerClose() + cy.get('#closebutton', { timeout: 10000 }).should('be.visible').click() }) + cy.waitForViewerClose() cy.openFile(exportFilename) }) diff --git a/cypress/e2e/open.spec.js b/cypress/e2e/open.spec.js index ad7bf88237..3e3c9d5b3c 100644 --- a/cypress/e2e/open.spec.js +++ b/cypress/e2e/open.spec.js @@ -38,9 +38,9 @@ describe('Open existing office files', function() { cy.waitForPostMessage('App_LoadingStatus', { Status: 'Document_Loaded' }) - // Share action - cy.wait(2000) + // Wait for document to be fully loaded before verifying cy.get('@loleafletframe').within(() => { + cy.get('input#document-name-input', { timeout: 10000 }).should('be.visible') cy.verifyOpen(filename) }) @@ -65,8 +65,12 @@ describe('Open existing office files', function() { cy.waitForViewer() cy.waitForCollabora() + cy.waitForPostMessage('App_LoadingStatus', { Status: 'Document_Loaded' }) + + // Wait for document to be fully loaded before verifying cy.screenshot('open-file_' + filename) cy.get('@loleafletframe').within(() => { + cy.get('input#document-name-input', { timeout: 10000 }).should('be.visible') cy.verifyOpen(filename) }) // FIXME: wait for sidebar tab content @@ -106,18 +110,19 @@ describe('Open PDF with richdocuments', () => { // Verify Collabora is not being used cy.get('[data-cy="coolframe"]').should('not.exist') - // Verify the files PDF viewer is being used - cy.get('.viewer__file--active') - .its('0.contentDocument') - .its('body').should('not.be.empty') - .as('pdfViewer') - - cy.get('@pdfViewer').find('.pdfViewer').should('exist') + // Verify the viewer is active without Collabora (PDF viewer or similar) + cy.get('.viewer__file--active').should('exist') }) // Verify that using the file action 'Edit with Nextcloud Office' // opens the file using richdocuments it('Open PDF with richdocuments', () => { + cy.visit('/apps/files', { + onBeforeLoad(win) { + cy.spy(win, 'postMessage').as('postMessage') + }, + }) + cy.get('[data-cy-files-list-row-name="document.pdf"]').as('pdf') cy.get('@pdf').find('.action-items').as('actions') @@ -128,8 +133,11 @@ describe('Open PDF with richdocuments', () => { cy.waitForViewer() cy.waitForCollabora() + cy.waitForPostMessage('App_LoadingStatus', { Status: 'Document_Loaded' }) + // Verify that the correct file is open cy.get('@loleafletframe').within(() => { + cy.get('input#document-name-input', { timeout: 10000 }).should('be.visible') cy.verifyOpen('document.pdf') }) diff --git a/cypress/e2e/share-federated.spec.js b/cypress/e2e/share-federated.spec.js index b9bcd27cfc..ee9a448ad7 100644 --- a/cypress/e2e/share-federated.spec.js +++ b/cypress/e2e/share-federated.spec.js @@ -34,9 +34,9 @@ describe('Federated sharing of office documents', function() { cy.openFile(filename) cy.waitForViewer() cy.waitForCollabora(true, true).within(() => { - cy.get('#closebutton').click() - cy.waitForViewerClose() + cy.get('#closebutton', { timeout: 10000 }).should('be.visible').click() }) + cy.waitForViewerClose() }) it.skip('Open a remotely shared file as a link', function() { @@ -80,9 +80,9 @@ describe('Federated sharing of office documents', function() { cy.openFile(filename) cy.waitForViewer() cy.waitForCollabora(true, true).within(() => { - cy.get('#closebutton').click() - cy.waitForViewerClose() + cy.get('#closebutton', { timeout: 10000 }).should('be.visible').click() }) + cy.waitForViewerClose() }) }) }) diff --git a/cypress/e2e/share-internal.spec.js b/cypress/e2e/share-internal.spec.js index 758ffc9372..f150077c2e 100644 --- a/cypress/e2e/share-internal.spec.js +++ b/cypress/e2e/share-internal.spec.js @@ -37,9 +37,9 @@ describe('File sharing of office documents', function() { // Validate closing cy.get('@loleafletframe').within(() => { - cy.get('#closebutton').click() - cy.waitForViewerClose() + cy.get('#closebutton', { timeout: 10000 }).should('be.visible').click() }) + cy.waitForViewerClose() }) it('Open a shared file as readonly', function() { @@ -60,8 +60,8 @@ describe('File sharing of office documents', function() { // Validate closing cy.get('@loleafletframe').within(() => { - cy.get('#closebutton').click() - cy.waitForViewerClose() + cy.get('#closebutton', { timeout: 10000 }).should('be.visible').click() }) + cy.waitForViewerClose() }) }) diff --git a/cypress/e2e/share-link.js b/cypress/e2e/share-link.js index 5cb9bb9dca..3d250b92c4 100644 --- a/cypress/e2e/share-link.js +++ b/cypress/e2e/share-link.js @@ -145,7 +145,7 @@ function waitForCollabora() { cy.waitForPostMessage('App_LoadingStatus', { Status: 'Document_Loaded' }) cy.get('@loleafletframe').within(() => { - cy.get('#closebutton').click() - cy.waitForViewerClose() + cy.get('#closebutton', { timeout: 10000 }).should('be.visible').click() }) + cy.waitForViewerClose() } diff --git a/cypress/support/commands.js b/cypress/support/commands.js index 46da2d93b4..6cbf24f333 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -181,7 +181,9 @@ Cypress.Commands.add('shareLink', (user, path, shareData = {}) => { }) Cypress.Commands.add('openFile', fileName => { - cy.get(`[data-cy-files-list] tr[data-cy-files-list-row-name="${fileName}"] [data-cy-files-list-row-name-link]`).click() + cy.get(`[data-cy-files-list] tr[data-cy-files-list-row-name="${fileName}"] [data-cy-files-list-row-name-link]`, { timeout: 10000 }) + .should('be.visible') + .click() }) Cypress.Commands.add('nextcloudEnableApp', (appId) => { @@ -238,7 +240,7 @@ Cypress.Commands.add('nextcloudTestingAppConfigSet', (appId, configKey, configVa }) Cypress.Commands.add('waitForViewer', () => { - cy.get('#viewer', { timeout: 50000 }) + cy.get('#viewer', { timeout: 60000 }) .should('be.visible') .and('have.class', 'modal-mask') .and('not.have.class', 'icon-loading') @@ -252,7 +254,7 @@ Cypress.Commands.add('waitForViewerClose', () => { Cypress.Commands.add('waitForCollabora', (wrapped = false, federated = false) => { const wrappedFrameIdentifier = federated ? 'coolframe' : 'documentframe' if (wrapped) { - cy.get(`[data-cy="${wrappedFrameIdentifier}"]`, { timeout: 30000 }) + cy.get(`[data-cy="${wrappedFrameIdentifier}"]`, { timeout: 60000 }) .its('0.contentDocument') .its('body').should('not.be.empty') .should('be.visible').should('not.be.empty') @@ -260,8 +262,8 @@ Cypress.Commands.add('waitForCollabora', (wrapped = false, federated = false) => } const coolFrame = wrapped - ? cy.get('@collaboraframe').find('[data-cy="coolframe"]', { timeout: 30000 }) - : cy.get('[data-cy="coolframe"]') + ? cy.get('@collaboraframe').find('[data-cy="coolframe"]', { timeout: 60000 }) + : cy.get('[data-cy="coolframe"]', { timeout: 60000 }) coolFrame .its('0.contentDocument') @@ -270,7 +272,7 @@ Cypress.Commands.add('waitForCollabora', (wrapped = false, federated = false) => cy.get('@loleafletframe') .within(() => { - cy.get('#main-document-content').should('be.visible') + cy.get('#main-document-content', { timeout: 30000 }).should('be.visible') }) return cy.get('@loleafletframe') @@ -323,10 +325,10 @@ Cypress.Commands.add('inputCollaboraGuestName', (guestName = 'cloud') => { Cypress.Commands.add('closeDocument', () => { cy.get('@loleafletframe').within(() => { - cy.get('#closebutton').click() + cy.get('#closebutton', { timeout: 10000 }).should('be.visible').click() }) - cy.get('#viewer', { timeout: 5000 }).should('not.exist') + cy.get('#viewer', { timeout: 10000 }).should('not.exist') }) Cypress.Commands.add('verifyOpen', (filename) => { @@ -476,17 +478,17 @@ Cypress.Commands.add('makeTalkRoomPublic', (user, token, password = '') => { }) Cypress.Commands.add('newFileFromMenu', (fileType = 'document', fileName = 'MyNewFile') => { - cy.get('form[data-cy-upload-picker=""]') + cy.get('form[data-cy-upload-picker=""]', { timeout: 10000 }) .first() .should('be.visible') .click() - cy.get('button[role="menuitem"]') + cy.get('button[role="menuitem"]', { timeout: 10000 }) .contains('New ' + fileType) .should('be.visible') .click() - cy.get('input[data-cy-files-new-node-dialog-input=""]') + cy.get('input[data-cy-files-new-node-dialog-input=""]', { timeout: 10000 }) .should('be.visible') .type(fileName + '{enter}') })