26 lines
1.7 KiB
TypeScript
26 lines
1.7 KiB
TypeScript
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);
|
|
});
|