Initialize fork and rebrand app to event_manager
CI / Server (push) Has been cancelled
Linters / Frappe Linter (push) Has been cancelled
Linters / Vulnerable Dependency Check (push) Has been cancelled
UI Tests / Playwright E2E Tests (push) Has been cancelled

This commit is contained in:
2026-05-11 09:56:57 +02:00
parent f82bb803ac
commit 786cbc724f
500 changed files with 41152 additions and 2 deletions
+54
View File
@@ -0,0 +1,54 @@
import { test as setup, expect } from "@playwright/test";
import * as fs from "fs";
import * as path from "path";
const authFile = "e2e/.auth/user.json";
const csrfFile = "e2e/.auth/csrf.json";
setup("authenticate", async ({ page }) => {
const authDir = path.dirname(authFile);
if (!fs.existsSync(authDir)) {
fs.mkdirSync(authDir, { recursive: true });
}
// Login via Frappe API using page.request
const loginResponse = await page.request.post("/api/method/login", {
form: {
usr: process.env.FRAPPE_USER || "Administrator",
pwd: process.env.FRAPPE_PASSWORD || "admin",
},
});
expect(loginResponse.ok()).toBeTruthy();
// Verify login succeeded by checking current user
const userResponse = await page.request.get("/api/method/frappe.auth.get_logged_user");
expect(userResponse.ok()).toBeTruthy();
const userData = (await userResponse.json()) as { message?: string };
expect(userData.message).not.toBe("Guest");
console.log(`✅ Authenticated as: ${userData.message}`);
// Navigate to app to load frappe context and get CSRF token
await page.goto("/app");
await page.waitForLoadState("networkidle");
// Wait for frappe to initialize and extract CSRF token
const csrfToken = await page.evaluate(() => {
return (window as Window & { frappe?: { csrf_token?: string } }).frappe
?.csrf_token;
});
if (csrfToken) {
// Save CSRF token to file for API helpers to use
fs.writeFileSync(csrfFile, JSON.stringify({ csrf_token: csrfToken }));
console.log(`🔐 Saved CSRF token to ${csrfFile}`);
} else {
console.warn("⚠️ Could not extract CSRF token from page");
}
// Save authentication state
await page.context().storageState({ path: authFile });
console.log(`💾 Saved auth state to ${authFile}`);
});