Refine workspaces and event publishing; harden uploads and email delivery

This commit is contained in:
2026-09-09 15:44:00 -04:00
parent f5702caaea
commit 574f29a68e
93 changed files with 2885 additions and 535 deletions
+25
View File
@@ -0,0 +1,25 @@
import { expect, test } from "bun:test";
import { effectiveEvent, notesAreVisible } from "./event-lifecycle";
import { galleryIsPublic } from "./publishing";
const now = new Date("2026-09-09T12:00:00Z");
const before = new Date(now.getTime() - 1000);
const after = new Date(now.getTime() + 1000);
const event = { status: "draft" as const, uploadEnabled: true, publishAt: null, submissionsOpenAt: null, submissionsCloseAt: null, completedAt: null };
test("scheduled publication opens exactly at its boundary and never exposes drafts through closing", () => {
expect(effectiveEvent({ ...event, publishAt: after }, now).status).toBe("draft");
expect(effectiveEvent({ ...event, publishAt: now }, now).status).toBe("published");
expect(effectiveEvent({ ...event, submissionsCloseAt: before }, now).status).toBe("draft");
});
test("submission windows gate uploads and completion closes them", () => {
expect(effectiveEvent({ ...event, status: "published", submissionsOpenAt: after }, now).uploadEnabled).toBe(false);
expect(effectiveEvent({ ...event, publishAt: before, submissionsCloseAt: now }, now).status).toBe("closed");
expect(effectiveEvent({ ...event, status: "published", completedAt: before }, now).uploadEnabled).toBe(false);
});
test("visibility schedules never bypass never-public or expose content early", () => {
expect(galleryIsPublic("approved", before, after, now)).toBe(false);
expect(galleryIsPublic("approved", null, now, now)).toBe(true);
expect(galleryIsPublic("never", before, before, now)).toBe(false);
expect(notesAreVisible("automatic", after, now)).toBe(false);
expect(notesAreVisible("approved", now, now)).toBe(true);
expect(notesAreVisible("never", before, now)).toBe(false);
});