Fix: Update auth E2E tests for exchange redirect

The auth tests expected '/' to show user email (old counter page).
Now regular users redirect to '/exchange' after login/signup.

Updated tests to:
- Expect /exchange URL after login/signup
- Check for 'Exchange Bitcoin' heading instead of email
- Update logout tests to verify /exchange access
- Update invite redirect tests for /exchange
This commit is contained in:
counterweight 2025-12-22 21:15:27 +01:00
parent fa07490b7b
commit 65ba4dc42a
Signed by: counterweight
GPG key ID: 883EDBAA726BD96C

View file

@ -80,7 +80,7 @@ test.describe("Authentication Flow", () => {
});
test.describe("Logged-in User Visiting Invite URL", () => {
test("redirects to home when logged-in user visits direct invite URL", async ({
test("redirects to exchange when logged-in user visits direct invite URL", async ({
page,
request,
}) => {
@ -97,17 +97,20 @@ test.describe("Logged-in User Visiting Invite URL", () => {
await page.fill("input#password", "password123");
await page.fill("input#confirmPassword", "password123");
await page.click('button[type="submit"]');
await expect(page).toHaveURL("/");
await expect(page).toHaveURL("/exchange");
// Create another invite
const anotherInvite = await createInvite(request);
// Visit invite URL while logged in - should redirect to home
// Visit invite URL while logged in - should redirect to exchange
await page.goto(`/signup/${anotherInvite}`);
await expect(page).toHaveURL("/");
await expect(page).toHaveURL("/exchange");
});
test("redirects to home when logged-in user visits signup page", async ({ page, request }) => {
test("redirects to exchange when logged-in user visits signup page", async ({
page,
request,
}) => {
const email = uniqueEmail();
const inviteCode = await createInvite(request);
@ -121,11 +124,11 @@ test.describe("Logged-in User Visiting Invite URL", () => {
await page.fill("input#password", "password123");
await page.fill("input#confirmPassword", "password123");
await page.click('button[type="submit"]');
await expect(page).toHaveURL("/");
await expect(page).toHaveURL("/exchange");
// Try to visit signup page while logged in - should redirect to home
// Try to visit signup page while logged in - should redirect to exchange
await page.goto("/signup");
await expect(page).toHaveURL("/");
await expect(page).toHaveURL("/exchange");
});
});
@ -153,10 +156,10 @@ test.describe("Signup with Invite", () => {
await page.fill("input#confirmPassword", "password123");
await page.click('button[type="submit"]');
// Should redirect to home after signup
await expect(page).toHaveURL("/");
// Should show user email
await expect(page.getByText(email)).toBeVisible();
// Should redirect to exchange after signup (regular user home)
await expect(page).toHaveURL("/exchange");
// Should see Exchange page heading
await expect(page.getByRole("heading", { name: "Exchange Bitcoin" })).toBeVisible();
});
test("signup with direct invite URL works", async ({ page, request }) => {
@ -178,8 +181,8 @@ test.describe("Signup with Invite", () => {
await page.fill("input#confirmPassword", "password123");
await page.click('button[type="submit"]');
// Should redirect to home
await expect(page).toHaveURL("/");
// Should redirect to exchange
await expect(page).toHaveURL("/exchange");
});
test("shows error for invalid invite code", async ({ page }) => {
@ -255,8 +258,9 @@ test.describe("Login", () => {
await page.fill('input[type="password"]', testPassword);
await page.click('button[type="submit"]');
await expect(page).toHaveURL("/");
await expect(page.getByText(testEmail)).toBeVisible();
// Regular user redirects to exchange
await expect(page).toHaveURL("/exchange");
await expect(page.getByRole("heading", { name: "Exchange Bitcoin" })).toBeVisible();
});
test("shows error for wrong password", async ({ page }) => {
@ -303,7 +307,7 @@ test.describe("Logout", () => {
await page.fill("input#password", "password123");
await page.fill("input#confirmPassword", "password123");
await page.click('button[type="submit"]');
await expect(page).toHaveURL("/");
await expect(page).toHaveURL("/exchange");
// Click logout
await page.click("text=Sign out");
@ -326,14 +330,14 @@ test.describe("Logout", () => {
await page.fill("input#password", "password123");
await page.fill("input#confirmPassword", "password123");
await page.click('button[type="submit"]');
await expect(page).toHaveURL("/");
await expect(page).toHaveURL("/exchange");
// Logout
await page.click("text=Sign out");
await expect(page).toHaveURL("/login");
// Try to access home
await page.goto("/");
// Try to access exchange (protected page)
await page.goto("/exchange");
await expect(page).toHaveURL("/login");
});
});
@ -353,15 +357,15 @@ test.describe("Session Persistence", () => {
await page.fill("input#password", "password123");
await page.fill("input#confirmPassword", "password123");
await page.click('button[type="submit"]');
await expect(page).toHaveURL("/");
await expect(page.getByText(email)).toBeVisible();
await expect(page).toHaveURL("/exchange");
await expect(page.getByRole("heading", { name: "Exchange Bitcoin" })).toBeVisible();
// Reload page
await page.reload();
// Should still be logged in
await expect(page).toHaveURL("/");
await expect(page.getByText(email)).toBeVisible();
// Should still be logged in on exchange page
await expect(page).toHaveURL("/exchange");
await expect(page.getByRole("heading", { name: "Exchange Bitcoin" })).toBeVisible();
});
test("auth cookie is set after signup", async ({ page, request }) => {
@ -377,7 +381,7 @@ test.describe("Session Persistence", () => {
await page.fill("input#password", "password123");
await page.fill("input#confirmPassword", "password123");
await page.click('button[type="submit"]');
await expect(page).toHaveURL("/");
await expect(page).toHaveURL("/exchange");
// Check cookies
const cookies = await page.context().cookies();
@ -399,7 +403,7 @@ test.describe("Session Persistence", () => {
await page.fill("input#password", "password123");
await page.fill("input#confirmPassword", "password123");
await page.click('button[type="submit"]');
await expect(page).toHaveURL("/");
await expect(page).toHaveURL("/exchange");
await page.click("text=Sign out");
await expect(page).toHaveURL("/login");