snapshot of https://github.com/frappe/crm.git (develop, 2026-09-18; blobs > 131072B omitted)
Some checks failed
Frontend / Unit Tests & Coverage (push) Has been skipped
Regenerate POT file (translatable strings) / Regenerate POT file (develop) (push) Failing after 1m13s
Regenerate POT file (translatable strings) / Regenerate POT file (main-hotfix) (push) Failing after 6s
Server / Tests (frappe ${{ matrix.frappe-branch }}) (push) Has been skipped
Server / Resolve frappe matrix (push) Failing after 1s
Frontend / Lint (push) Failing after 1s
Frontend / Production Build (push) Failing after 1s
Server / Coverage Wrap Up (push) Has been skipped
Frontend / Coverage Wrap Up (push) Has been skipped
Some checks failed
Frontend / Unit Tests & Coverage (push) Has been skipped
Regenerate POT file (translatable strings) / Regenerate POT file (develop) (push) Failing after 1m13s
Regenerate POT file (translatable strings) / Regenerate POT file (main-hotfix) (push) Failing after 6s
Server / Tests (frappe ${{ matrix.frappe-branch }}) (push) Has been skipped
Server / Resolve frappe matrix (push) Failing after 1s
Frontend / Lint (push) Failing after 1s
Frontend / Production Build (push) Failing after 1s
Server / Coverage Wrap Up (push) Has been skipped
Frontend / Coverage Wrap Up (push) Has been skipped
This commit is contained in:
46
e2e/helpers/auth.ts
Normal file
46
e2e/helpers/auth.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
import { APIRequestContext, Page } from '@playwright/test'
|
||||
|
||||
/**
|
||||
* Login via the Frappe API (faster than UI login).
|
||||
* Sets session cookies on the request context for subsequent API calls.
|
||||
*/
|
||||
export async function loginViaAPI(
|
||||
request: APIRequestContext,
|
||||
email = 'Administrator',
|
||||
password = 'admin',
|
||||
): Promise<void> {
|
||||
const response = await request.post('/api/method/login', {
|
||||
form: { usr: email, pwd: password },
|
||||
})
|
||||
|
||||
if (!response.ok()) {
|
||||
throw new Error(
|
||||
`Login failed: ${response.status()} ${await response.text()}`,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Logout the current user.
|
||||
*/
|
||||
export async function logout(page: Page): Promise<void> {
|
||||
await page.goto('/api/method/logout')
|
||||
await page.waitForLoadState('networkidle')
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a user is logged in by verifying the session.
|
||||
*/
|
||||
export async function isLoggedIn(request: APIRequestContext): Promise<boolean> {
|
||||
try {
|
||||
const response = await request.get(
|
||||
'/api/method/frappe.auth.get_logged_user',
|
||||
)
|
||||
if (!response.ok()) return false
|
||||
|
||||
const data = await response.json()
|
||||
return data.message && data.message !== 'Guest'
|
||||
} catch {
|
||||
return false
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user