Wiki/e2e/tests/auth-login.spec.ts
Corentin JOGUET e9695450ef
Some checks are pending
CI / Lint bridge (Biome) (push) Waiting to run
CI / Type-check bridge (push) Blocked by required conditions
CI / Tests unit bridge (push) Blocked by required conditions
CI / Tests integration bridge (push) Blocked by required conditions
CI / Security scan (push) Waiting to run
CI / Docker build + healthcheck (push) Blocked by required conditions
E2E Playwright / Playwright e2e (chromium) (push) Waiting to run
test(e2e): add Playwright cross-stack tests for R3.1.e database-view
7 scenarios covering the full bridge+DocAdenice+Baserow chain:
auth login, database-view insert, inline edit persistence, SSE realtime
update (no reload), RBAC write-denied, kanban drag-drop, calendar reschedule.

Includes docker-compose.e2e.yml (Postgres+Redis+Baserow+bridge+DocAdenice),
playwright.config.ts (3 projects: chromium/firefox/webkit), auth+baserow+cleanup
fixtures, global setup (API login + Baserow seed), and GitHub Actions e2e.yml.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-08 00:37:23 +02:00

62 lines
2.1 KiB
TypeScript

/**
* 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 });
});
});