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 inline period * standings card 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 shows its anchored period standings card", async ({ page }) => { await page.goto("/minigames/flappy"); await expect( page.getByRole("heading", { level: 2, name: "Anchored period standings" }), ).toBeVisible(); await expect(page.getByRole("link", { name: "All boards" })).toBeVisible(); }); });