diff --git a/.github/workflows/cypress.yml b/.github/workflows/cypress.yml index 1a72e65d119..cbb7f30bc0d 100644 --- a/.github/workflows/cypress.yml +++ b/.github/workflows/cypress.yml @@ -168,7 +168,7 @@ jobs: - name: Upload test failure screenshots - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 if: failure() with: name: Upload screenshots @@ -178,10 +178,10 @@ jobs: retention-days: 5 - name: Upload nextcloud logs - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 if: failure() with: - name: Upload nextcloud log + name: cypress-${{ matrix.containers }}.log path: data/nextcloud.log retention-days: 5 diff --git a/cypress/e2e/attachments.spec.js b/cypress/e2e/attachments.spec.js index 0222f949768..865fa4bc005 100644 --- a/cypress/e2e/attachments.spec.js +++ b/cypress/e2e/attachments.spec.js @@ -401,6 +401,7 @@ describe('Test all attachment insertion methods', () => { }) cy.login(recipient) + cy.showHiddenFiles() cy.visit('/apps/files') // check the file list @@ -408,7 +409,6 @@ describe('Test all attachment insertion methods', () => { .should('exist') cy.getFile('github.png') .should('not.exist') - cy.showHiddenFiles() // check the attachment folder is not there cy.getFile('testShared.md') diff --git a/cypress/support/commands.js b/cypress/support/commands.js index 9fe05ea79a6..ca7a0f2e0f6 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -22,7 +22,6 @@ import axios from '@nextcloud/axios' import { addCommands } from '@nextcloud/cypress' -import 'cypress-if' import compareSnapshotCommand from 'cypress-visual-regression/dist/command.js' // eslint-disable-next-line no-unused-vars,n/no-extraneous-import @@ -32,6 +31,7 @@ compareSnapshotCommand() const url = Cypress.config('baseUrl').replace(/\/index.php\/?$/g, '') Cypress.env('baseUrl', url) +const silent = { log: false } addCommands() @@ -40,44 +40,36 @@ addCommands() // and also to determine paths, urls and the like. let auth Cypress.Commands.overwrite('login', (login, user) => { - cy.window().then((win) => { + cy.window(silent).then((win) => { win.location.href = 'about:blank' }) auth = { user: user.userId, password: user.password } + cy.wrap(null).as('requesttoken') login(user) }) Cypress.Commands.overwrite('visit', (originalFn, url, options) => { // Make sure that each visit call that triggers a page load will update the stored requesttoken return originalFn(url, options).then((result) => { - cy.window() - .then((win) => cy.wrap(win?.OC?.requestToken)) - .as('requesttoken') + cy.window(silent) + .then((win) => { + cy.wrap(win?.OC?.requestToken) + .as('requesttoken') + }) }) }) Cypress.Commands.add('getRequestToken', () => { - cy.get('@requesttoken') - .if((token) => !token) - .then(() => { - cy.window() - .then((win) => cy.wrap(win?.OC?.requestToken)) - .if((token) => !!token) - .then((token) => { - cy.log('Request token from window', token) - }) + cy.then(function() { + if (this.requesttoken) { + return this.requesttoken + } else { + cy.log('Fetching request token') + return cy.request('/csrftoken') + .its('body.token') .as('requesttoken') - .else() - .then((token) => { - cy.log('Request token fetching', token) - return cy.request('/csrftoken') - .then(({ body }) => { - return body.token - }) - }).as('requesttoken') - }) - - return cy.get('@requesttoken') + } + }) }) Cypress.Commands.add('ocsRequest', (options) => { @@ -339,7 +331,7 @@ Cypress.Commands.add('getFileContent', (path) => { }) Cypress.Commands.add('propfindFolder', (path, depth = 0) => { - return cy.window() + return cy.window(silent) .then(win => { const files = win.OC.Files const PROPERTY_WORKSPACE_FILE @@ -490,7 +482,7 @@ Cypress.Commands.add('openWorkspace', (folder) => { }) Cypress.Commands.add('configureText', (key, value) => { - return cy.window().then(win => { + return cy.window(silent).then(win => { return axios.post( `${url}/index.php/apps/text/settings`, { key, value }, diff --git a/package-lock.json b/package-lock.json index 6bf22770c9b..bce8df7b3ce 100644 --- a/package-lock.json +++ b/package-lock.json @@ -99,7 +99,6 @@ "@vue/vue2-jest": "^29.2.6", "@vueuse/core": "^10.7.0", "cypress": "^13.6.1", - "cypress-if": "^1.10.5", "cypress-split": "^1.17.1", "cypress-visual-regression": "^3.0.0", "eslint-plugin-cypress": "^2.15.1", @@ -8852,15 +8851,6 @@ "node": "^16.0.0 || ^18.0.0 || >=20.0.0" } }, - "node_modules/cypress-if": { - "version": "1.10.5", - "resolved": "https://registry.npmjs.org/cypress-if/-/cypress-if-1.10.5.tgz", - "integrity": "sha512-7EJSTvoUM+6XumIA7T0cU69dkkdUEmncvIuFFgQ3ry57m2kXc9vtNTCdGjfnGQgMBDRR6vtx7no1ZDDg8IOICA==", - "dev": true, - "dependencies": { - "debug": "^4.3.4" - } - }, "node_modules/cypress-split": { "version": "1.17.1", "resolved": "https://registry.npmjs.org/cypress-split/-/cypress-split-1.17.1.tgz", @@ -32167,15 +32157,6 @@ } } }, - "cypress-if": { - "version": "1.10.5", - "resolved": "https://registry.npmjs.org/cypress-if/-/cypress-if-1.10.5.tgz", - "integrity": "sha512-7EJSTvoUM+6XumIA7T0cU69dkkdUEmncvIuFFgQ3ry57m2kXc9vtNTCdGjfnGQgMBDRR6vtx7no1ZDDg8IOICA==", - "dev": true, - "requires": { - "debug": "^4.3.4" - } - }, "cypress-split": { "version": "1.17.1", "resolved": "https://registry.npmjs.org/cypress-split/-/cypress-split-1.17.1.tgz", diff --git a/package.json b/package.json index c74d612df4c..0d281d8c7b9 100644 --- a/package.json +++ b/package.json @@ -129,7 +129,6 @@ "@vue/vue2-jest": "^29.2.6", "@vueuse/core": "^10.7.0", "cypress": "^13.6.1", - "cypress-if": "^1.10.5", "cypress-split": "^1.17.1", "cypress-visual-regression": "^3.0.0", "eslint-plugin-cypress": "^2.15.1",