Skip to content

Commit

Permalink
ci: Hotfix to make login work as long as we are on older cypress version
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Knorr <[email protected]>
  • Loading branch information
juliusknorr committed Jan 2, 2025
1 parent 1ae0a84 commit e2d75c3
Showing 1 changed file with 29 additions and 1 deletion.
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

0 comments on commit e2d75c3

Please sign in to comment.