This commit is contained in:
counterweight 2025-12-26 19:21:34 +01:00
parent c0999370c6
commit 4e1a339432
Signed by: counterweight
GPG key ID: 883EDBAA726BD96C
17 changed files with 393 additions and 91 deletions

View file

@ -1,4 +1,5 @@
import { test, expect, Page } from "@playwright/test";
import { getBackendUrl } from "./helpers/backend-url";
/**
* Profile E2E tests
@ -10,8 +11,6 @@ import { test, expect, Page } from "@playwright/test";
* 4. Validation works as expected
*/
const API_URL = process.env.NEXT_PUBLIC_API_URL || "http://localhost:8000";
// Test credentials - must match what's seeded in the database via seed.py
function getRequiredEnv(name: string): string {
const value = process.env[name];
@ -54,7 +53,7 @@ async function clearProfileData(page: Page) {
const authCookie = cookies.find((c) => c.name === "auth_token");
if (authCookie) {
await page.request.put(`${API_URL}/api/profile`, {
await page.request.put(`${getBackendUrl()}/api/profile`, {
headers: {
Cookie: `auth_token=${authCookie.value}`,
"Content-Type": "application/json",
@ -254,7 +253,7 @@ test.describe("Profile - Admin User Access", () => {
const authCookie = cookies.find((c) => c.name === "auth_token");
if (authCookie) {
const response = await request.get(`${API_URL}/api/profile`, {
const response = await request.get(`${getBackendUrl()}/api/profile`, {
headers: {
Cookie: `auth_token=${authCookie.value}`,
},
@ -278,7 +277,7 @@ test.describe("Profile - Unauthenticated Access", () => {
await expect(page).toHaveURL("/login");
// API requires authentication
const response = await request.get(`${API_URL}/api/profile`);
const response = await request.get(`${getBackendUrl()}/api/profile`);
expect(response.status()).toBe(401);
});
});