feat: schedule automatic form closure

This commit is contained in:
2026-07-31 00:54:15 +07:00 Unverified
parent 8ee011cdfc
commit 6a73b60c48
20 changed files with 1226 additions and 35 deletions
+37
View File
@@ -0,0 +1,37 @@
import { describe, expect, test } from "bun:test";
import { isFormAcceptingSubmissions } from "@/lib/form-availability";
const now = new Date("2026-07-30T12:00:00.000Z");
describe("isFormAcceptingSubmissions", () => {
test("keeps a manually open form without a deadline open", () => {
expect(isFormAcceptingSubmissions({ isOpen: true }, now)).toBe(true);
});
test("keeps a form open before its deadline", () => {
expect(
isFormAcceptingSubmissions(
{ isOpen: true, closesAt: "2026-07-30T12:00:01.000Z" },
now,
),
).toBe(true);
});
test("closes a form when its deadline is reached", () => {
expect(
isFormAcceptingSubmissions(
{ isOpen: true, closesAt: "2026-07-30T12:00:00.000Z" },
now,
),
).toBe(false);
});
test("manual closure overrides a future deadline", () => {
expect(
isFormAcceptingSubmissions(
{ isOpen: false, closesAt: "2026-08-01T12:00:00.000Z" },
now,
),
).toBe(false);
});
});