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

ci: Hotfix to make login work as long as we are on older cypress version #6819

Merged
merged 1 commit into from
Jan 2, 2025
Merged
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
30 changes: 29 additions & 1 deletion cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,36 @@ 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
Loading