fix(D8): grid slots render, per-cell optimistic revert, shared E2E helpers, admin reset endpoint

- 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)
This commit is contained in:
Tiel Coder
2026-11-18 21:51:04 +00:00
parent 137a135a5e
commit d0a696167f
16 changed files with 3304 additions and 36 deletions
+41
View File
@@ -0,0 +1,41 @@
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 };