Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable31] fix/use e2e test server #6900

Merged
merged 4 commits into from
Feb 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading