d0a696167f
- src/db/grid.ts: key role map by ID (was slug, causing all cells to show '—') - src/components/app/schedule-grid-editor.tsx: revert only failed cell, not entire grid - src/db/audit.ts: fix import path ./db → @/db - src/db/seed.ts: add resetAndSeed(), assign Audio only (leave Livestream/Slides open) - src/auth/config.ts: carry id/email on JWT for audit actor - e2e/dev.ts: shared signInAs + resetDb helpers - e2e/schedule-grid.spec.ts: use shared helpers, reset DB beforeAll - e2e/assign-mutations.spec.ts: E2E for assign/clear with optimistic update + rollback - src/app/api/dev/reset/route.ts: admin-only DB reset endpoint - playwright.config.ts: workers: 1 (serial, suites share one Postgres)
42 lines
1.5 KiB
TypeScript
42 lines
1.5 KiB
TypeScript
import { expect, type Page } from "@playwright/test";
|
|
|
|
const BASE = "http://localhost:3000";
|
|
|
|
/**
|
|
* Shared E2E helpers. Both test files run against the same Postgres, so they
|
|
* share the dev-console sign-in transport and the DB reset used to establish a
|
|
* known-clean state before each suite.
|
|
*/
|
|
|
|
/**
|
|
* Dev console transport: request a magic link, then complete it in the browser
|
|
* context so the Auth.js session cookie is set for the navigation under test.
|
|
*/
|
|
export async function signInAs(page: Page, email: string) {
|
|
const res = await page.request.post(`${BASE}/api/dev/magic-link`, {
|
|
data: { email },
|
|
});
|
|
expect(res.ok(), "magic-link request should succeed").toBe(true);
|
|
const body = (await res.json()) as { url?: string };
|
|
expect(body.url, "magic-link should return a sign-in url").toBeTruthy();
|
|
await page.goto(body.url!);
|
|
await expect(page).toHaveURL(/complete/);
|
|
}
|
|
|
|
/**
|
|
* Reset the DB to the clean seed. Admin-only (admin.settings): truncates the
|
|
* seed-owned tables and repopulates them, so each suite starts from a known
|
|
* state instead of accumulating the mutations of prior runs. Runs from inside
|
|
* the page (page.request does not share the session cookie).
|
|
*/
|
|
export async function resetDb(page: Page) {
|
|
await signInAs(page, "admin@glenloch.local");
|
|
const status = await page.evaluate(async () => {
|
|
const res = await fetch("/api/dev/reset", { method: "POST" });
|
|
return res.status;
|
|
});
|
|
expect(status, "admin reset should succeed").toBe(200);
|
|
}
|
|
|
|
export { BASE };
|