/** * Scenario: auth-login * * Verifies that the standard DocAdenice login flow redirects to the home page * and the workspace is accessible. * * This test runs WITHOUT the pre-saved storageState so it exercises the real * login UI. The admin storageState is used by subsequent tests. */ import { test, expect } from "@playwright/test"; import { adminCredentials } from "../fixtures/auth"; const BASE_URL = process.env.E2E_DOCMOST_URL ?? "http://localhost:5173"; test.describe("auth login", () => { // Override storageState — this test must start unauthenticated. test.use({ storageState: { cookies: [], origins: [] } }); test("login via UI redirects to workspace home", async ({ page }) => { await page.goto(`${BASE_URL}/login`); // Fill email. await page.getByLabel(/email/i).fill(adminCredentials.email); // Fill password. await page.getByLabel(/password/i).fill(adminCredentials.password); // Submit. await page.getByRole("button", { name: /sign in|login|connexion/i }).click(); // After login the app redirects to the workspace dashboard or home page. // We wait for any of the known post-login URLs. await expect(page).toHaveURL(/\/(home|dashboard|spaces?|pages?|$)/, { timeout: 20_000, }); // The workspace name or "New page" button must be visible — indicates the app // has bootstrapped. await expect( page.getByRole("link", { name: /new page|home|workspace/i }).or( page.getByTestId("sidebar-workspace-name"), ), ).toBeVisible({ timeout: 15_000 }); }); test("failed login shows error message", async ({ page }) => { await page.goto(`${BASE_URL}/login`); await page.getByLabel(/email/i).fill("nobody@nowhere.invalid"); await page.getByLabel(/password/i).fill("wrongpassword"); await page.getByRole("button", { name: /sign in|login|connexion/i }).click(); // The form must show some error indicator. await expect( page.getByText(/invalid|incorrect|error|failed|wrong/i), ).toBeVisible({ timeout: 10_000 }); // Must NOT navigate away from login. await expect(page).toHaveURL(/login/, { timeout: 5_000 }); }); });