1
0
Fork 0
polaris-task-force/tests/e2e/minigame-leaderboards.e2e.spec.ts
Z8MB1E 923831ba82 feat(minigames): make period standings the primary board on game pages
The six period-scored game pages (flappy, eod, opord, radio,
qualification, call-for-fire) now render their current-period
PeriodStandingsCard directly under the game board, in the slot the
lifetime board used to occupy. Each game's all-time leaderboard moves
below it into a collapsed AllTimeLeaderboard disclosure (shadcn
Collapsible) that expands on click, so period standings are centered and
primary and the lifetime board is opt-in.

PeriodStandingsCard drops its period/all-time toggle and keeps the
current period only, now with the presence line the pages previously
omitted. The old "Anchored period standings" heading and card block are
removed from the six page.tsx files. The e2e spec covers the collapsed
all-time section on /minigames/flappy.
2026-10-19 12:14:57 -04:00

57 lines
2.5 KiB
TypeScript

import { expect, test } from "@playwright/test";
/**
* Smoke coverage for the unified minigames leaderboards: the period view, the
* All-Time switch (which also reveals the cardtable games) and the period
* standings card plus collapsed all-time board on a game page.
*/
test.describe("Minigame leaderboards", () => {
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 the period boards, game tabs and achievements", async ({ page }) => {
await page.goto("/minigames/leaderboards");
await expect(
page.getByRole("heading", { level: 1, name: "Minigame Leaderboards" }),
).toBeVisible();
await expect(page.getByRole("tab", { name: "Flight Simulator" })).toBeVisible();
await expect(page.getByRole("tab", { name: "OPORD Recall" })).toBeVisible();
// Cardtable games are not period-scored, so they only appear All-Time.
await expect(page.getByRole("tab", { name: "Poker" })).toHaveCount(0);
await expect(page.getByText("Achievements", { exact: true })).toBeVisible();
});
test("switching to All-Time surfaces every registered game", async ({ page }) => {
await page.goto("/minigames/leaderboards");
await page.getByRole("combobox").click();
await page.getByRole("option", { name: /All-Time/ }).click();
await expect(page.getByRole("tab", { name: "Poker" })).toBeVisible({ timeout: 15_000 });
await expect(page.getByRole("tab", { name: "Blackjack" })).toBeVisible();
});
test("a game page centers period standings with all-time collapsed", async ({ page }) => {
await page.goto("/minigames/flappy");
await expect(page.getByRole("link", { name: "All boards" })).toBeVisible();
const allTime = page.getByRole("button", { name: /All-time leaderboard/ });
await expect(allTime).toBeVisible();
await expect(allTime).toHaveAttribute("data-state", "closed");
await expect(page.getByText("Flight Simulator Leaderboard")).toHaveCount(0);
// The dev-server first navigation can hydrate slowly, so retry the toggle
// until the collapsed board actually mounts.
await expect(async () => {
await allTime.click();
await expect(page.getByText("Flight Simulator Leaderboard")).toBeVisible({ timeout: 1000 });
}).toPass({ timeout: 20_000 });
});
});