import { test, expect, HAS_AUTH_FIXTURE } from "./_helpers"; /** * Auth flow specs require a seeded PocketBase user (E2E_TEST_EMAIL / * E2E_TEST_PASSWORD). When those are missing we skip cleanly so the rest of * the suite still runs. */ test.describe("login flow", () => { test.skip(!HAS_AUTH_FIXTURE, "E2E_TEST_EMAIL / E2E_TEST_PASSWORD not set — skipping auth specs"); test("signs in and lands on a protected page", async ({ page }) => { await page.goto("/login"); await page.getByLabel(/email/i).fill(process.env.E2E_TEST_EMAIL!); await page.getByLabel(/password/i).fill(process.env.E2E_TEST_PASSWORD!); await page.getByRole("button", { name: /sign in|log in|login/i }).click(); // After auth the layout sends the user into the (app) group — typically // /dashboard. We only assert we left /login. await page.waitForURL((u) => !u.pathname.startsWith("/login"), { timeout: 10_000 }); expect(page.url()).not.toContain("/login"); }); test("rejects a bad password and stays on /login", async ({ page }) => { await page.goto("/login"); await page.getByLabel(/email/i).fill(process.env.E2E_TEST_EMAIL!); await page.getByLabel(/password/i).fill("definitely-wrong-password"); await page.getByRole("button", { name: /sign in|log in|login/i }).click(); // We should still be on the login page. PocketBase typically surfaces a // toast on failure; we just check the URL didn't change. await expect(page).toHaveURL(/\/login/); }); });