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: Kostiantyn Miakshyn <[email protected]>
  • Loading branch information
Koc committed Jan 3, 2025
1 parent 43f3915 commit 30764fd
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 @@ -3,7 +3,7 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

import { login, logout } from '@nextcloud/cypress/commands'
import { logout } from '@nextcloud/cypress/commands'
import { User } from '@nextcloud/cypress'

import * as api from '../../src/apis/collectives/index.js'
Expand All @@ -29,6 +29,34 @@ Cypress.on('uncaught:exception', (err) => {
}
})

// 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)
},
})
}

// Authentication commands from @nextcloud/cypress
Cypress.Commands.add('login', login)
Cypress.Commands.add('logout', logout)
Expand Down

0 comments on commit 30764fd

Please sign in to comment.