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:
+12
-18
@@ -1,21 +1,5 @@
|
||||
import { test, expect, type Page } from "@playwright/test";
|
||||
|
||||
const BASE = "http://localhost:3000";
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
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/);
|
||||
}
|
||||
import { test, expect } from "@playwright/test";
|
||||
import { signInAs, resetDb, BASE } from "./dev";
|
||||
|
||||
/**
|
||||
* Unit D7 — read-only scheduling grid. Done when: renders a seeded week; no
|
||||
@@ -23,6 +7,16 @@ async function signInAs(page: Page, email: string) {
|
||||
* logged while the grid is mounted.
|
||||
*/
|
||||
test.describe("schedule grid", () => {
|
||||
// Establish a clean seeded state before the read-only suite runs. The grid
|
||||
// is read-only, but it shares the DB with the mutating assign-mutations
|
||||
// suite; resetting here keeps this suite independent of run order.
|
||||
test.beforeAll(async ({ browser }) => {
|
||||
const context = await browser.newContext();
|
||||
const page = await context.newPage();
|
||||
await resetDb(page);
|
||||
await context.close();
|
||||
});
|
||||
|
||||
test("renders a seeded week with no console errors", async ({ page }) => {
|
||||
const errors: string[] = [];
|
||||
page.on("console", (msg) => {
|
||||
|
||||
Reference in New Issue
Block a user