Skip to content

Commit e2d75c3

Browse files
committed
ci: Hotfix to make login work as long as we are on older cypress version
Signed-off-by: Julius Knorr <jus@bitgrid.net>
1 parent 1ae0a84 commit e2d75c3

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

cypress/support/commands.js

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,36 @@ window._oc_webroot = url
2727

2828
addCommands()
2929

30+
// Copy of the new login command as long as we are blocked to upgrade @nextcloud/cypress by cypress crashes
31+
const login = function(user) {
32+
cy.session(user, function() {
33+
cy.request('/csrftoken').then(({ body }) => {
34+
const requestToken = body.token
35+
cy.request({
36+
method: 'POST',
37+
url: '/login',
38+
body: {
39+
user: user.userId,
40+
password: user.password,
41+
requesttoken: requestToken,
42+
},
43+
headers: {
44+
'Content-Type': 'application/x-www-form-urlencoded',
45+
// Add the Origin header so that the request is not blocked by the browser.
46+
Origin: (Cypress.config('baseUrl') ?? '').replace('index.php/', ''),
47+
},
48+
followRedirect: false,
49+
})
50+
})
51+
}, {
52+
validate() {
53+
cy.request('/apps/files').its('status').should('eq', 200)
54+
},
55+
})
56+
}
57+
3058
// Prepare the csrf-token for axios
31-
Cypress.Commands.overwrite('login', (login, user) => {
59+
Cypress.Commands.overwrite('login', (_login, user) => {
3260
cy.window(silent).then((win) => {
3361
win.location.href = 'about:blank'
3462
})

0 commit comments

Comments
 (0)