- Optional `estimatedReleaseDate` (date and time) on the minigames registry,
with a named migration and regenerated types.
- Sidebar: an `upcoming` game renders greyed out and non-interactive, with a
tooltip carrying the estimate and a live countdown. It is a hoverable row
rather than a disabled menu item, because a disabled Radix item sets
`pointer-events: none` and would swallow the tooltip.
- Page gate: each minigame page checks its registry status and renders
`MinigameComingSoon` instead of the arena while the game is upcoming, so a
typed URL cannot reach unfinished gameplay. The date is display only: the
game goes live when an admin flips `status` to active.
- Leaderboards exclude upcoming games, so they get neither a tab nor a board.
- Pure `countdown.ts` formatter plus a client ticker that computes the
remaining time only after mount, avoiding an SSR hydration mismatch.
Note: `registry.ts`, `payload-types.ts` and `migrations/index.ts` also carry
the Call for Fire registry row and its generated types. That feature was
committed as 6d6a5fb and announced a separate commit for those files; they are
included here because they are entangled with these edits in the same files.
Tests: pure countdown unit tests, registry/gate/leaderboard integration tests,
and an e2e that seeds an upcoming row, hovers the disabled sidebar entry to
assert the tooltip, and checks the coming-soon gate.
99 lines
3.5 KiB
TypeScript
99 lines
3.5 KiB
TypeScript
import { expect, test, type APIRequestContext } from "@playwright/test";
|
|
|
|
/**
|
|
* Upcoming-game treatment: a registry row with `status: "upcoming"` is shown
|
|
* greyed out and non-interactive in the sidebar with a countdown tooltip, and
|
|
* its game page renders the coming-soon gate instead of the arena.
|
|
*
|
|
* The test seeds its own registry rows over the REST API (the e2e database is
|
|
* seeded from the schema push, which does not run the registry migration) and
|
|
* deletes them again, so other specs see the built-in fallback list.
|
|
*/
|
|
|
|
const RELEASE = new Date(Date.now() + 12 * 86_400_000 + 3 * 3_600_000).toISOString();
|
|
|
|
const seedGame = async (
|
|
request: APIRequestContext,
|
|
game: { key: string; label: string; status: "active" | "upcoming"; route: string },
|
|
): Promise<number> => {
|
|
const res = await request.post("/api/minigames", {
|
|
data: {
|
|
key: game.key,
|
|
label: game.label,
|
|
description: "e2e upcoming game",
|
|
route: game.route,
|
|
icon: "Radio",
|
|
category: "core",
|
|
status: game.status,
|
|
order: 90,
|
|
countsForPeriods: false,
|
|
scoreLabel: "Score",
|
|
estimatedReleaseDate: RELEASE,
|
|
},
|
|
});
|
|
expect(res.status(), `seed ${game.key}: ${await res.text()}`).toBeLessThan(400);
|
|
const body = (await res.json()) as { doc?: { id: number } };
|
|
expect(body.doc?.id, `seed ${game.key} returned no id`).toBeTruthy();
|
|
return body.doc!.id;
|
|
};
|
|
|
|
const deleteGame = async (request: APIRequestContext, id: number) => {
|
|
await request.delete(`/api/minigames/${id}`);
|
|
};
|
|
|
|
test.describe("Upcoming minigames", () => {
|
|
test.beforeEach(async ({ page }) => {
|
|
await page.goto("/login");
|
|
await page.getByLabel("Username").fill("dev");
|
|
await page.getByLabel("Password").fill("Test123");
|
|
await page.getByRole("button", { name: "Log in" }).click();
|
|
await page.waitForURL((url) => !url.pathname.startsWith("/login"), { timeout: 30_000 });
|
|
});
|
|
|
|
test("shows a disabled sidebar entry with a countdown tooltip", async ({ page }) => {
|
|
const id = await seedGame(page.request, {
|
|
key: "signals-e2e",
|
|
label: "Signals Intercept",
|
|
status: "upcoming",
|
|
route: "/minigames/leaderboards",
|
|
});
|
|
|
|
try {
|
|
await page.goto("/");
|
|
await page.getByRole("button", { name: "Minigames" }).click();
|
|
|
|
const entry = page.getByText("Signals Intercept");
|
|
await expect(entry).toBeVisible();
|
|
// Non-interactive: the row is not a link and not a menu item.
|
|
await expect(page.getByRole("menuitem", { name: /Signals Intercept/ })).toHaveCount(0);
|
|
|
|
await entry.hover();
|
|
const tooltip = page.getByRole("tooltip");
|
|
await expect(tooltip).toContainText("Upcoming · releases");
|
|
await expect(tooltip).toContainText(/in \d+[dhms]/);
|
|
} finally {
|
|
await deleteGame(page.request, id);
|
|
}
|
|
});
|
|
|
|
test("gates the game page with a coming-soon screen", async ({ page }) => {
|
|
const id = await seedGame(page.request, {
|
|
key: "flappy",
|
|
label: "Flight Simulator",
|
|
status: "upcoming",
|
|
route: "/minigames/flappy",
|
|
});
|
|
|
|
try {
|
|
await page.goto("/minigames/flappy");
|
|
// exact: true keeps this from also matching the countdown's "coming soon"
|
|
// placeholder text.
|
|
await expect(page.getByText("Coming soon", { exact: true })).toBeVisible();
|
|
await expect(page.getByText(/Estimated release/)).toBeVisible();
|
|
// The playable arena is not rendered.
|
|
await expect(page.getByText("Tap or press Space to flap")).toHaveCount(0);
|
|
} finally {
|
|
await deleteGame(page.request, id);
|
|
}
|
|
});
|
|
});
|