working
This commit is contained in:
parent
c0999370c6
commit
4e1a339432
17 changed files with 393 additions and 91 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import { test, expect, Page, APIRequestContext } from "@playwright/test";
|
||||
import { getBackendUrl } from "./helpers/backend-url";
|
||||
|
||||
// Helper to generate unique email for each test
|
||||
function uniqueEmail(): string {
|
||||
|
|
@ -14,24 +15,22 @@ async function clearAuth(page: Page) {
|
|||
const ADMIN_EMAIL = "admin@example.com";
|
||||
const ADMIN_PASSWORD = "admin123";
|
||||
|
||||
// Helper to create an invite via the API
|
||||
const API_BASE = process.env.NEXT_PUBLIC_API_URL || "http://localhost:8000";
|
||||
|
||||
async function createInvite(request: APIRequestContext): Promise<string> {
|
||||
const apiBase = getBackendUrl();
|
||||
// Login as admin
|
||||
const loginResp = await request.post(`${API_BASE}/api/auth/login`, {
|
||||
const loginResp = await request.post(`${apiBase}/api/auth/login`, {
|
||||
data: { email: ADMIN_EMAIL, password: ADMIN_PASSWORD },
|
||||
});
|
||||
const cookies = loginResp.headers()["set-cookie"];
|
||||
|
||||
// Get admin user ID (we'll use admin as godfather for simplicity)
|
||||
const meResp = await request.get(`${API_BASE}/api/auth/me`, {
|
||||
const meResp = await request.get(`${apiBase}/api/auth/me`, {
|
||||
headers: { Cookie: cookies },
|
||||
});
|
||||
const admin = await meResp.json();
|
||||
|
||||
// Create invite
|
||||
const inviteResp = await request.post(`${API_BASE}/api/admin/invites`, {
|
||||
const inviteResp = await request.post(`${apiBase}/api/admin/invites`, {
|
||||
data: { godfather_id: admin.id },
|
||||
headers: { Cookie: cookies },
|
||||
});
|
||||
|
|
@ -112,8 +111,8 @@ test.describe("Signup with Invite", () => {
|
|||
await expect(page).toHaveURL("/exchange");
|
||||
|
||||
// Test logged-in user visiting signup page - should redirect to exchange
|
||||
await page.goto("/signup");
|
||||
await expect(page).toHaveURL("/exchange");
|
||||
await page.goto("/signup", { waitUntil: "networkidle" });
|
||||
await expect(page).toHaveURL("/exchange", { timeout: 10000 });
|
||||
|
||||
// Test signup via direct URL (new session)
|
||||
await clearAuth(page);
|
||||
|
|
@ -174,7 +173,7 @@ test.describe("Login", () => {
|
|||
const inviteCode = await createInvite(request);
|
||||
|
||||
// Register the test user via backend API
|
||||
await request.post(`${API_BASE}/api/auth/register`, {
|
||||
await request.post(`${getBackendUrl()}/api/auth/register`, {
|
||||
data: {
|
||||
email: testEmail,
|
||||
password: testPassword,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue