Skip to content

Commit

Permalink
Merge pull request #6900 from nextcloud/backport/6898/stable31
Browse files Browse the repository at this point in the history
[stable31] fix/use e2e test server
  • Loading branch information
juliusknorr authored Feb 12, 2025
2 parents 768c839 + 157ee2c commit a7b9eb0
Show file tree
Hide file tree
Showing 7 changed files with 646 additions and 544 deletions.
18 changes: 18 additions & 0 deletions cypress.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,24 @@ export default defineConfig({
cypressSplit(on, config)
configureVisualRegression(on)

// Disable spell checking to prevent rendering differences
on('before:browser:launch', (browser, launchOptions) => {
if (browser.family === 'chromium' && browser.name !== 'electron') {
launchOptions.preferences.default['browser.enable_spellchecking'] = false
return launchOptions
}

if (browser.family === 'firefox') {
launchOptions.preferences['layout.spellcheckDefault'] = 0
return launchOptions
}

if (browser.name === 'electron') {
launchOptions.preferences.spellcheck = false
return launchOptions
}
})

return config
},

Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/openreadonly.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

import { User } from '@nextcloud/cypress'
import { User } from '@nextcloud/e2e-test-server/cypress'
import { randUser } from '../utils/index.js'

const admin = new User('admin', 'admin')
Expand Down
4 changes: 2 additions & 2 deletions cypress/e2e/print.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe('Open print.md and compare print view', function() {
.get('h1:not(.hidden-visually)').should('contain', 'Print test')
.should('be.visible')

cy.compareSnapshot('print view in viewer', { capture: 'fullPage' })
cy.compareSnapshot('print view in viewer')
cy.setCssMedia('screen')
})

Expand All @@ -45,7 +45,7 @@ describe('Open print.md and compare print view', function() {
.get('h1:not(.hidden-visually)').should('contain', 'Print test')
.should('be.visible')

cy.compareSnapshot('print view in single-file share', { capture: 'fullPage' })
cy.compareSnapshot('print view in single-file share')
cy.setCssMedia('screen')
})
})
Expand Down
34 changes: 3 additions & 31 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@

import axios from '@nextcloud/axios'
import { emit } from '@nextcloud/event-bus'
import { addCommands } from '@nextcloud/cypress'
import { addCommands } from '@nextcloud/e2e-test-server/cypress'
import { addCompareSnapshotCommand } from 'cypress-visual-regression/dist/command'

// eslint-disable-next-line no-unused-vars,n/no-extraneous-import
import regeneratorRuntime from 'regenerator-runtime'

addCompareSnapshotCommand()
addCompareSnapshotCommand({ capture: 'fullPage' })

const url = Cypress.config('baseUrl').replace(/\/index.php\/?$/g, '')
Cypress.env('baseUrl', url)
Expand All @@ -27,36 +27,8 @@ window._oc_webroot = url

addCommands()

// Copy of the new login command as long as we are blocked to upgrade @nextcloud/cypress by cypress crashes
const login = function(user) {
cy.session(user, function() {
cy.request('/csrftoken').then(({ body }) => {
const requestToken = body.token
cy.request({
method: 'POST',
url: '/login',
body: {
user: user.userId,
password: user.password,
requesttoken: requestToken,
},
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
// Add the Origin header so that the request is not blocked by the browser.
Origin: (Cypress.config('baseUrl') ?? '').replace('index.php/', ''),
},
followRedirect: false,
})
})
}, {
validate() {
cy.request('/apps/files').its('status').should('eq', 200)
},
})
}

// Prepare the csrf-token for axios
Cypress.Commands.overwrite('login', (_login, user) => {
Cypress.Commands.overwrite('login', (login, user) => {
cy.window(silent).then((win) => {
win.location.href = 'about:blank'
})
Expand Down
2 changes: 1 addition & 1 deletion cypress/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

import { User } from '@nextcloud/cypress'
import { User } from '@nextcloud/e2e-test-server/cypress'

export const getSearchParams = url => {
return url
Expand Down
Loading

0 comments on commit a7b9eb0

Please sign in to comment.