Add a "phasingOut" minigame status and an `estimatedRemovalDate` field so a game can be announced as leaving soon while staying fully playable and keeping scoring periods (unlike retired games). Visibility is the only difference: - Sidebar badge + tooltip (amber "Phasing out", countdown to removal) in NavMinigames, via new phasingOutTooltip in countdown.ts. - In-game banner (PhasingOutBanner) on all 9 game pages, wired from getMinigameReleaseState (added the fetch to call-for-fire, which lacked it). - registry.ts status union + field; loadRegistry.ts maps the field; config status select + estimatedRemovalDate date field added. - Migration adds the enum value and column (idempotent); types + db schema regenerated. Adds tests for visibility, round-trip, and period scoring; updates the minigames domain guide.
48 lines
1.9 KiB
TypeScript
48 lines
1.9 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import {
|
|
formatCountdown,
|
|
formatReleaseInstant,
|
|
phasingOutTooltip,
|
|
upcomingTooltip,
|
|
} from "@/lib/minigames/countdown";
|
|
|
|
const TARGET = "2026-12-03T18:00:00.000Z";
|
|
const targetMs = new Date(TARGET).getTime();
|
|
const MINUTE = 60_000;
|
|
const HOUR = 3_600_000;
|
|
const DAY = 86_400_000;
|
|
|
|
describe("Minigame release countdown", () => {
|
|
it("formats the release instant in UTC", () => {
|
|
expect(formatReleaseInstant(TARGET)).toBe("Dec 3, 2026 18:00 UTC");
|
|
expect(formatReleaseInstant(null)).toBeNull();
|
|
expect(formatReleaseInstant("not-a-date")).toBeNull();
|
|
});
|
|
|
|
it("formats remaining time by magnitude", () => {
|
|
expect(formatCountdown(TARGET, new Date(targetMs - (12 * DAY + 3 * HOUR)))).toBe("in 12d 3h");
|
|
expect(formatCountdown(TARGET, new Date(targetMs - (3 * HOUR + 4 * MINUTE)))).toBe("in 3h 4m");
|
|
expect(formatCountdown(TARGET, new Date(targetMs - (12 * MINUTE + 30_000)))).toBe("in 12m 30s");
|
|
expect(formatCountdown(null)).toBeNull();
|
|
expect(formatCountdown("nope")).toBeNull();
|
|
});
|
|
|
|
it("settles on 'any time now' once the estimate has passed", () => {
|
|
expect(formatCountdown(TARGET, new Date(targetMs))).toBe("any time now");
|
|
expect(formatCountdown(TARGET, new Date(targetMs + HOUR))).toBe("any time now");
|
|
});
|
|
|
|
it("builds the tooltip line, with and without an estimate", () => {
|
|
expect(upcomingTooltip(TARGET, new Date(targetMs - (12 * DAY + 3 * HOUR)))).toBe(
|
|
"Upcoming · releases Dec 3, 2026 18:00 UTC (in 12d 3h)",
|
|
);
|
|
expect(upcomingTooltip(null)).toBe("Upcoming");
|
|
});
|
|
|
|
it("builds the phasing-out tooltip line, with and without an estimate", () => {
|
|
expect(phasingOutTooltip(TARGET, new Date(targetMs - (12 * DAY + 3 * HOUR)))).toBe(
|
|
"Phasing out · leaves Dec 3, 2026 18:00 UTC (in 12d 3h)",
|
|
);
|
|
expect(phasingOutTooltip(null)).toBe("Phasing out");
|
|
});
|
|
});
|