Wiki/e2e/tests/global.setup.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

47 lines
1.6 KiB
TypeScript

/**
* Global setup — runs once before all test projects (chromium, firefox, webkit).
*
* Steps:
* 1. Log in as admin via the DocAdenice API.
* 2. Persist the auth state to .auth/admin.json so all projects reuse it.
* 3. Seed Baserow (workspace + database + table + views + rows).
* 4. Write the seed IDs to .auth/baserow-seed.json so individual tests can read them.
*/
import { test as setup } from "@playwright/test";
import * as path from "path";
import * as fs from "fs";
import {
adminCredentials,
loginViaApi,
saveAuthState,
} from "../fixtures/auth";
import { seedBaserow } from "../fixtures/baserow";
const AUTH_DIR = path.resolve(__dirname, "../.auth");
const ADMIN_AUTH_FILE = path.join(AUTH_DIR, "admin.json");
const BASEROW_SEED_FILE = path.join(AUTH_DIR, "baserow-seed.json");
setup("authenticate admin + seed baserow", async ({ request }) => {
// Ensure .auth directory exists.
if (!fs.existsSync(AUTH_DIR)) {
fs.mkdirSync(AUTH_DIR, { recursive: true });
}
// Step 1: Login.
const adminToken = await loginViaApi(request, adminCredentials);
// Step 2: Persist auth state.
await saveAuthState(adminToken, ADMIN_AUTH_FILE);
console.log("[setup] Admin auth state saved.");
// Step 3: Seed Baserow.
const seed = await seedBaserow(request);
console.log(
`[setup] Baserow seeded: table=${seed.tableId} gridView=${seed.gridViewId} rows=${seed.rowIds.length}`,
);
// Step 4: Persist seed for tests.
fs.writeFileSync(BASEROW_SEED_FILE, JSON.stringify(seed, null, 2));
console.log("[setup] Baserow seed written to", BASEROW_SEED_FILE);
});