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
+35
View File
@@ -0,0 +1,35 @@
import { auth } from "@/auth/config";
import { AuthError, requirePermission } from "@/auth/permissions";
import type { SystemRole } from "@/auth/roles";
import { resetAndSeed } from "@/db/seed";
const JSON_HEADERS = { "content-type": "application/json" };
/**
* Dev console reset. Admin-only (admin.settings): truncates the seed-owned
* tables and repopulates them, so E2E tests start from a known-clean state on
* every run instead of accumulating the mutations of prior runs. Not wired into
* any UI — it exists only for test harnesses.
*/
export const POST = async () => {
try {
const session = await auth();
requirePermission(
(session?.user as { systemRole: SystemRole } | null | undefined),
"admin.settings",
);
await resetAndSeed();
return new Response(JSON.stringify({ ok: true }), {
status: 200,
headers: JSON_HEADERS,
});
} catch (e) {
if (e instanceof AuthError) {
return new Response(JSON.stringify({ error: e.message, code: e.code }), {
status: e.status,
headers: JSON_HEADERS,
});
}
throw e;
}
};