Skip to content

Commit

Permalink
Merge pull request #2483 from nextcloud/fix/playwright-login-with-origin
Browse files Browse the repository at this point in the history
Fix: playwright login with origin
  • Loading branch information
Chartman123 authored Jan 9, 2025
2 parents 404b846 + df836b5 commit cf84d13
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions playwright/support/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

import { test as setup } from '@playwright/test'
import { configureNextcloud, getContainer } from '@nextcloud/cypress/docker'
import { configureNextcloud } from '@nextcloud/cypress/docker'

/**
* We use this to ensure Nextcloud is configured correctly before running our tests
Expand All @@ -13,5 +13,5 @@ import { configureNextcloud, getContainer } from '@nextcloud/cypress/docker'
* as that only checks for the URL to be accessible which happens already before everything is configured.
*/
setup('Configure Nextcloud', async () => {
await configureNextcloud(['forms', 'viewer'], undefined, getContainer())
await configureNextcloud(['forms'])
})
7 changes: 6 additions & 1 deletion playwright/support/utils/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,20 @@ export async function login(
password: string,
) {
const tokenResponse = await request.get('./csrftoken')
expect(tokenResponse.status()).toBe(200)
const requesttoken = (await tokenResponse.json()).token

await request.post('./login', {
const loginResponse = await request.post('./login', {
form: {
user,
password,
requesttoken,
},
headers: {
Origin: tokenResponse.url().replace(/index.php.*/, ''),
},
})
expect(loginResponse.status()).toBe(200)

const response = await request.get('apps/files')
expect(response.status()).toBe(200)
Expand Down

0 comments on commit cf84d13

Please sign in to comment.