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.
This commit is contained in:
parent
15e434998a
commit
923831ba82
15 changed files with 164 additions and 100 deletions
|
|
@ -5,7 +5,6 @@ import { headers as nextHeaders } from "next/headers";
|
|||
import { redirect } from "next/navigation";
|
||||
import { Target } from "lucide-react";
|
||||
import { CallForFireArena } from "@/components/frontend/minigames/call-for-fire/CallForFireArena";
|
||||
import { PeriodStandingsCard } from "@/components/frontend/minigames/PeriodStandingsCard";
|
||||
import { PhasingOutBanner } from "@/components/frontend/minigames/PhasingOutBanner";
|
||||
import { getMinigameReleaseState } from "@/lib/minigames/loadRegistry";
|
||||
|
||||
|
|
@ -68,15 +67,6 @@ export default async function CallForFirePage() {
|
|||
</div>
|
||||
|
||||
<CallForFireArena initialStats={stats} currentUserId={user.id as number} />
|
||||
|
||||
<div className="flex flex-col gap-2">
|
||||
<h2 className="text-sm font-semibold text-muted-foreground">Anchored period standings</h2>
|
||||
<PeriodStandingsCard
|
||||
gameKey="callForFire"
|
||||
icon="Target"
|
||||
currentUserId={user.id as number}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ import { PhasingOutBanner } from "@/components/frontend/minigames/PhasingOutBann
|
|||
import { getMinigameReleaseState } from "@/lib/minigames/loadRegistry";
|
||||
import { Bomb } from "lucide-react";
|
||||
import { EodArena } from "@/components/frontend/minigames/eod/EodArena";
|
||||
import { PeriodStandingsCard } from "@/components/frontend/minigames/PeriodStandingsCard";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "Minefield Clearance (Polaris Task Force)",
|
||||
|
|
@ -72,11 +71,6 @@ export default async function EodPage() {
|
|||
</div>
|
||||
|
||||
<EodArena initialStats={stats} currentUserId={user.id as number} />
|
||||
|
||||
<div className="flex flex-col gap-2">
|
||||
<h2 className="text-sm font-semibold text-muted-foreground">Anchored period standings</h2>
|
||||
<PeriodStandingsCard gameKey="eod" icon="Bomb" currentUserId={user.id as number} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ import { PhasingOutBanner } from "@/components/frontend/minigames/PhasingOutBann
|
|||
import { getMinigameReleaseState } from "@/lib/minigames/loadRegistry";
|
||||
import { Bird } from "lucide-react";
|
||||
import { FlappyArena } from "@/components/frontend/minigames/flappy/FlappyArena";
|
||||
import { PeriodStandingsCard } from "@/components/frontend/minigames/PeriodStandingsCard";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "Flight Simulator: Polaris Task Force",
|
||||
|
|
@ -70,11 +69,6 @@ export default async function FlappyPage() {
|
|||
</div>
|
||||
|
||||
<FlappyArena initialStats={stats} currentUserId={user.id as number} />
|
||||
|
||||
<div className="flex flex-col gap-2">
|
||||
<h2 className="text-sm font-semibold text-muted-foreground">Anchored period standings</h2>
|
||||
<PeriodStandingsCard gameKey="flappy" icon="Bird" currentUserId={user.id as number} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ import { PhasingOutBanner } from "@/components/frontend/minigames/PhasingOutBann
|
|||
import { getMinigameReleaseState } from "@/lib/minigames/loadRegistry";
|
||||
import { ScrollText } from "lucide-react";
|
||||
import { OpordArena } from "@/components/frontend/minigames/opord/OpordArena";
|
||||
import { PeriodStandingsCard } from "@/components/frontend/minigames/PeriodStandingsCard";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "OPORD Recall (Polaris Task Force)",
|
||||
|
|
@ -73,11 +72,6 @@ export default async function OpordPage() {
|
|||
</div>
|
||||
|
||||
<OpordArena initialStats={stats} currentUserId={user.id as number} />
|
||||
|
||||
<div className="flex flex-col gap-2">
|
||||
<h2 className="text-sm font-semibold text-muted-foreground">Anchored period standings</h2>
|
||||
<PeriodStandingsCard gameKey="opord" icon="FileTextIcon" currentUserId={user.id as number} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ import { Crosshair } from "lucide-react";
|
|||
|
||||
import type { AimTrainerStats } from "@/app/(frontend)/minigames/qualification/actions";
|
||||
import { AimTrainerArena } from "@/components/frontend/minigames/qualification/AimTrainerArena";
|
||||
import { PeriodStandingsCard } from "@/components/frontend/minigames/PeriodStandingsCard";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "Qualification Course: Polaris Task Force",
|
||||
|
|
@ -77,11 +76,6 @@ export default async function QualificationPage() {
|
|||
</div>
|
||||
|
||||
<AimTrainerArena initialStats={stats} currentUserId={user.id} />
|
||||
|
||||
<div className="flex flex-col gap-2">
|
||||
<h2 className="text-sm font-semibold text-muted-foreground">Anchored period standings</h2>
|
||||
<PeriodStandingsCard gameKey="qualification" icon="Crosshair" currentUserId={user.id as number} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ import { PhasingOutBanner } from "@/components/frontend/minigames/PhasingOutBann
|
|||
import { getMinigameReleaseState } from "@/lib/minigames/loadRegistry";
|
||||
import { Radio } from "lucide-react";
|
||||
import { RadioArena } from "@/components/frontend/minigames/radio/RadioArena";
|
||||
import { PeriodStandingsCard } from "@/components/frontend/minigames/PeriodStandingsCard";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "Radio Traffic (Polaris Task Force)",
|
||||
|
|
@ -81,11 +80,6 @@ export default async function RadioPage() {
|
|||
</div>
|
||||
|
||||
<RadioArena initialStats={stats} currentUserId={user.id as number} />
|
||||
|
||||
<div className="flex flex-col gap-2">
|
||||
<h2 className="text-sm font-semibold text-muted-foreground">Anchored period standings</h2>
|
||||
<PeriodStandingsCard gameKey="radio" icon="Radio" currentUserId={user.id as number} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
40
src/components/frontend/minigames/AllTimeLeaderboard.tsx
Normal file
40
src/components/frontend/minigames/AllTimeLeaderboard.tsx
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
"use client";
|
||||
|
||||
import { ChevronDown, History } from "lucide-react";
|
||||
|
||||
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@/components/ui/collapsible";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
export interface AllTimeLeaderboardProps {
|
||||
children: React.ReactNode;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Collapsed container for a game's lifetime board. The period standings stay
|
||||
* the primary surface on the game page; the all-time board is opt-in.
|
||||
*/
|
||||
export function AllTimeLeaderboard({ children, className }: AllTimeLeaderboardProps) {
|
||||
return (
|
||||
<Collapsible className={cn("w-full max-w-[520px]", className)}>
|
||||
<CollapsibleTrigger asChild>
|
||||
<button
|
||||
type="button"
|
||||
className="group flex w-full items-center gap-2 rounded-xl border border-border bg-card px-4 py-3 text-left text-sm font-semibold text-muted-foreground transition-colors hover:bg-accent/40 hover:text-foreground"
|
||||
>
|
||||
<History className="size-4" aria-hidden="true" />
|
||||
<span>All-time leaderboard</span>
|
||||
<span className="ml-auto text-xs font-normal group-data-[state=open]:hidden">Expand</span>
|
||||
<span className="ml-auto hidden text-xs font-normal group-data-[state=open]:inline">
|
||||
Collapse
|
||||
</span>
|
||||
<ChevronDown
|
||||
className="size-4 transition-transform group-data-[state=open]:rotate-180"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
</button>
|
||||
</CollapsibleTrigger>
|
||||
<CollapsibleContent className="pt-2">{children}</CollapsibleContent>
|
||||
</Collapsible>
|
||||
);
|
||||
}
|
||||
|
|
@ -1,6 +1,5 @@
|
|||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import Link from "next/link";
|
||||
import { Trophy } from "lucide-react";
|
||||
|
||||
|
|
@ -22,9 +21,9 @@ export interface PeriodStandingsCardProps {
|
|||
}
|
||||
|
||||
/**
|
||||
* Period-scoped standings for a single game, embedded on the game page. Defaults
|
||||
* to the current period and offers an All-Time toggle; the full multi-board view
|
||||
* lives at /minigames/leaderboards.
|
||||
* Current-period standings for a single game, embedded on the game page. The
|
||||
* game's lifetime board sits below it in a collapsed all-time section; the full
|
||||
* multi-board view lives at /minigames/leaderboards.
|
||||
*/
|
||||
export function PeriodStandingsCard({
|
||||
gameKey,
|
||||
|
|
@ -34,12 +33,13 @@ export function PeriodStandingsCard({
|
|||
presence,
|
||||
className,
|
||||
}: PeriodStandingsCardProps) {
|
||||
const [view, setView] = useState<"period" | "all-time">("period");
|
||||
const { data, failed, loading } = useLeaderboards(view === "all-time" ? "all-time" : "current", refreshKey);
|
||||
const { data, failed, loading } = useLeaderboards("current", refreshKey);
|
||||
|
||||
const board = data?.boards.find((entry) => entry.key === gameKey) ?? null;
|
||||
const Icon = minigameIcon(icon ?? board?.icon);
|
||||
const isAllTime = view === "all-time";
|
||||
const presenceNoun = presence?.noun ?? "operator";
|
||||
const presenceLabel =
|
||||
presence && presence.participants.length === 1 ? presenceNoun : `${presenceNoun}s`;
|
||||
|
||||
return (
|
||||
<div className={cn("w-full max-w-[420px] rounded-xl border border-border bg-card", className)}>
|
||||
|
|
@ -48,43 +48,27 @@ export function PeriodStandingsCard({
|
|||
<Icon className="size-4 text-muted-foreground" />
|
||||
<h2 className="truncate text-sm font-semibold">{board?.label ?? "Standings"}</h2>
|
||||
<span className="ml-auto shrink-0 text-xs text-muted-foreground">
|
||||
{isAllTime ? "All-Time" : (data?.period?.label ?? "No active period")}
|
||||
{data?.period?.label ?? "No active period"}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center gap-1 border-b border-border px-2 py-1.5">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setView("period")}
|
||||
className={cn(
|
||||
"rounded-md px-2.5 py-1 text-xs font-medium",
|
||||
!isAllTime ? "bg-accent text-foreground" : "text-muted-foreground hover:text-foreground",
|
||||
)}
|
||||
>
|
||||
This period
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setView("all-time")}
|
||||
className={cn(
|
||||
"rounded-md px-2.5 py-1 text-xs font-medium",
|
||||
isAllTime ? "bg-accent text-foreground" : "text-muted-foreground hover:text-foreground",
|
||||
)}
|
||||
>
|
||||
All-Time
|
||||
</button>
|
||||
<div className="flex items-center gap-2 border-b border-border px-4 py-2 text-xs text-muted-foreground">
|
||||
<span>Best run this period · placement points</span>
|
||||
<Link
|
||||
href={`/minigames/leaderboards?game=${gameKey}`}
|
||||
className="ml-auto py-1 pr-1 text-xs text-muted-foreground hover:text-foreground"
|
||||
className="ml-auto shrink-0 py-1 text-xs text-muted-foreground hover:text-foreground"
|
||||
>
|
||||
All boards
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
{presence && !isAllTime && (
|
||||
<div className="border-b border-border px-4 py-2 text-xs text-muted-foreground" aria-live="polite">
|
||||
{presence && (
|
||||
<div
|
||||
className="border-b border-border px-4 py-2 text-xs text-muted-foreground"
|
||||
aria-live="polite"
|
||||
>
|
||||
<span className="font-medium text-emerald-400">{presence.participants.length}</span>{" "}
|
||||
{presence.participants.length === 1 ? `${presence.noun ?? "operator"} is` : `${presence.noun ?? "operators"} are`} active now
|
||||
{presenceLabel} {presence.participants.length === 1 ? "is" : "are"} active now
|
||||
{presence.participants.length > 0 && (
|
||||
<span className="ml-1 text-foreground">
|
||||
({presence.participants.map((participant) => participant.name).join(", ")})
|
||||
|
|
@ -106,8 +90,8 @@ export function PeriodStandingsCard({
|
|||
rows={board?.rows ?? []}
|
||||
scoreLabel={board?.scoreLabel ?? "Score"}
|
||||
currentUserId={currentUserId}
|
||||
showPoints={!isAllTime}
|
||||
emptyLabel={isAllTime ? "No all-time runs yet." : "No runs this period yet. Be the first!"}
|
||||
showPoints
|
||||
emptyLabel="No runs this period yet. Be the first!"
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ import type {
|
|||
} from "@/app/(frontend)/minigames/call-for-fire/actions";
|
||||
import { useRealtimePresence } from "@/hooks/useRealtimePresence";
|
||||
import { useSidebar } from "@/components/ui/sidebar";
|
||||
import { AllTimeLeaderboard } from "@/components/frontend/minigames/AllTimeLeaderboard";
|
||||
import { PeriodStandingsCard } from "@/components/frontend/minigames/PeriodStandingsCard";
|
||||
import { CallForFireLeaderboard } from "./CallForFireLeaderboard";
|
||||
import { FireMissionBoard } from "./FireMissionBoard";
|
||||
|
||||
|
|
@ -38,13 +40,23 @@ export function CallForFireArena({
|
|||
onPhaseChange={onPhaseChange}
|
||||
onDifficultyChange={setSelectedDifficulty}
|
||||
/>
|
||||
<CallForFireLeaderboard
|
||||
<PeriodStandingsCard
|
||||
gameKey="callForFire"
|
||||
icon="Target"
|
||||
refreshKey={refreshKey}
|
||||
currentUserId={currentUserId}
|
||||
activeTeams={activeTeams}
|
||||
difficulty={selectedDifficulty}
|
||||
onDifficultyChange={setSelectedDifficulty}
|
||||
presence={{ participants: activeTeams, noun: "team" }}
|
||||
className="max-w-[520px]"
|
||||
/>
|
||||
<AllTimeLeaderboard>
|
||||
<CallForFireLeaderboard
|
||||
refreshKey={refreshKey}
|
||||
currentUserId={currentUserId}
|
||||
activeTeams={activeTeams}
|
||||
difficulty={selectedDifficulty}
|
||||
onDifficultyChange={setSelectedDifficulty}
|
||||
/>
|
||||
</AllTimeLeaderboard>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ import type { EodDifficulty, EodStats } from "@/app/(frontend)/minigames/eod/act
|
|||
import { isEodUnlocked } from "@/lib/minigames/custom/eod";
|
||||
import { useRealtimePresence } from "@/hooks/useRealtimePresence";
|
||||
import { useSidebar } from "@/components/ui/sidebar";
|
||||
import { AllTimeLeaderboard } from "@/components/frontend/minigames/AllTimeLeaderboard";
|
||||
import { PeriodStandingsCard } from "@/components/frontend/minigames/PeriodStandingsCard";
|
||||
import { UnlockNotice } from "@/components/frontend/minigames/UnlockNotice";
|
||||
import { UgcLinkButton } from "@/components/frontend/minigames/UgcLinkButton";
|
||||
import { EodLeaderboard } from "./EodLeaderboard";
|
||||
|
|
@ -64,13 +66,23 @@ export function EodArena({
|
|||
onPhaseChange={onPhaseChange}
|
||||
onDifficultyChange={setSelectedDifficulty}
|
||||
/>
|
||||
<EodLeaderboard
|
||||
<PeriodStandingsCard
|
||||
gameKey="eod"
|
||||
icon="Bomb"
|
||||
refreshKey={refreshKey}
|
||||
currentUserId={currentUserId}
|
||||
activeTeams={activeTeams}
|
||||
difficulty={selectedDifficulty}
|
||||
onDifficultyChange={setSelectedDifficulty}
|
||||
presence={{ participants: activeTeams, noun: "team" }}
|
||||
className="max-w-[520px]"
|
||||
/>
|
||||
<AllTimeLeaderboard>
|
||||
<EodLeaderboard
|
||||
refreshKey={refreshKey}
|
||||
currentUserId={currentUserId}
|
||||
activeTeams={activeTeams}
|
||||
difficulty={selectedDifficulty}
|
||||
onDifficultyChange={setSelectedDifficulty}
|
||||
/>
|
||||
</AllTimeLeaderboard>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@
|
|||
import { useCallback, useState } from "react";
|
||||
import type { FlappyStats } from "@/app/(frontend)/minigames/flappy/actions";
|
||||
import { useRealtimePresence } from "@/hooks/useRealtimePresence";
|
||||
import { AllTimeLeaderboard } from "@/components/frontend/minigames/AllTimeLeaderboard";
|
||||
import { PeriodStandingsCard } from "@/components/frontend/minigames/PeriodStandingsCard";
|
||||
import { FlappyBird } from "./FlappyBird";
|
||||
import { FlappyLeaderboard } from "./FlappyLeaderboard";
|
||||
|
||||
|
|
@ -24,7 +26,16 @@ export function FlappyArena({
|
|||
return (
|
||||
<div className="flex flex-col items-center gap-6">
|
||||
<FlappyBird initialStats={initialStats} onGameRecorded={() => setRefreshKey((k) => k + 1)} onPhaseChange={onPhaseChange} />
|
||||
<FlappyLeaderboard refreshKey={refreshKey} currentUserId={currentUserId} activePilots={activePilots} />
|
||||
<PeriodStandingsCard
|
||||
gameKey="flappy"
|
||||
icon="Bird"
|
||||
refreshKey={refreshKey}
|
||||
currentUserId={currentUserId}
|
||||
presence={{ participants: activePilots, noun: "pilot" }}
|
||||
/>
|
||||
<AllTimeLeaderboard className="max-w-[420px]">
|
||||
<FlappyLeaderboard refreshKey={refreshKey} currentUserId={currentUserId} activePilots={activePilots} />
|
||||
</AllTimeLeaderboard>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ import { OPORD_DIFFICULTIES, type OpordDifficulty } from "@/lib/minigames/opord-
|
|||
import type { OpordStats } from "@/app/(frontend)/minigames/opord/actions";
|
||||
import { useRealtimePresence } from "@/hooks/useRealtimePresence";
|
||||
import { useSidebar } from "@/components/ui/sidebar";
|
||||
import { AllTimeLeaderboard } from "@/components/frontend/minigames/AllTimeLeaderboard";
|
||||
import { PeriodStandingsCard } from "@/components/frontend/minigames/PeriodStandingsCard";
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
|
@ -158,12 +160,22 @@ export function OpordArena({
|
|||
</CardContent>
|
||||
</Card>
|
||||
|
||||
<OpordLeaderboard
|
||||
<PeriodStandingsCard
|
||||
gameKey="opord"
|
||||
icon="FileTextIcon"
|
||||
refreshKey={refreshKey}
|
||||
difficulty={difficulty}
|
||||
currentUserId={currentUserId}
|
||||
activeOperators={activeOperators}
|
||||
presence={{ participants: activeOperators, noun: "operator" }}
|
||||
className="max-w-3xl"
|
||||
/>
|
||||
<AllTimeLeaderboard className="max-w-3xl">
|
||||
<OpordLeaderboard
|
||||
refreshKey={refreshKey}
|
||||
difficulty={difficulty}
|
||||
currentUserId={currentUserId}
|
||||
activeOperators={activeOperators}
|
||||
/>
|
||||
</AllTimeLeaderboard>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ import {
|
|||
import type { AimTrainerStats } from "@/app/(frontend)/minigames/qualification/actions";
|
||||
import { useRealtimePresence } from "@/hooks/useRealtimePresence";
|
||||
import { useSidebar } from "@/components/ui/sidebar";
|
||||
import { AllTimeLeaderboard } from "@/components/frontend/minigames/AllTimeLeaderboard";
|
||||
import { PeriodStandingsCard } from "@/components/frontend/minigames/PeriodStandingsCard";
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
|
@ -170,12 +172,22 @@ export function AimTrainerArena({
|
|||
</CardContent>
|
||||
</Card>
|
||||
|
||||
<AimTrainerLeaderboard
|
||||
<PeriodStandingsCard
|
||||
gameKey="qualification"
|
||||
icon="Crosshair"
|
||||
refreshKey={refreshKey}
|
||||
difficulty={difficulty}
|
||||
currentUserId={currentUserId}
|
||||
activeTrainees={activeTrainees}
|
||||
presence={{ participants: activeTrainees, noun: "trainee" }}
|
||||
className="max-w-3xl"
|
||||
/>
|
||||
<AllTimeLeaderboard className="max-w-3xl">
|
||||
<AimTrainerLeaderboard
|
||||
refreshKey={refreshKey}
|
||||
difficulty={difficulty}
|
||||
currentUserId={currentUserId}
|
||||
activeTrainees={activeTrainees}
|
||||
/>
|
||||
</AllTimeLeaderboard>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ import {
|
|||
WATCH_ACCURACY_REQUIREMENT,
|
||||
} from "@/lib/minigames/custom/radio";
|
||||
import { useRealtimePresence } from "@/hooks/useRealtimePresence";
|
||||
import { AllTimeLeaderboard } from "@/components/frontend/minigames/AllTimeLeaderboard";
|
||||
import { PeriodStandingsCard } from "@/components/frontend/minigames/PeriodStandingsCard";
|
||||
import { UnlockNotice } from "@/components/frontend/minigames/UnlockNotice";
|
||||
import { UgcLinkButton } from "@/components/frontend/minigames/UgcLinkButton";
|
||||
import { RadioLeaderboard } from "./RadioLeaderboard";
|
||||
|
|
@ -90,13 +92,23 @@ export function RadioArena({
|
|||
<li>The lifetime leaderboard ranks Top Score, Top Accuracy, Fastest Sprint, and Most Messages.</li>
|
||||
</ul>
|
||||
</div>
|
||||
<RadioLeaderboard
|
||||
<PeriodStandingsCard
|
||||
gameKey="radio"
|
||||
icon="Radio"
|
||||
refreshKey={refreshKey}
|
||||
mode={mode}
|
||||
modeHydrated={modeHydrated}
|
||||
currentUserId={currentUserId}
|
||||
activeOperators={activeOperators}
|
||||
presence={{ participants: activeOperators, noun: "operator" }}
|
||||
className="max-w-[520px]"
|
||||
/>
|
||||
<AllTimeLeaderboard>
|
||||
<RadioLeaderboard
|
||||
refreshKey={refreshKey}
|
||||
mode={mode}
|
||||
modeHydrated={modeHydrated}
|
||||
currentUserId={currentUserId}
|
||||
activeOperators={activeOperators}
|
||||
/>
|
||||
</AllTimeLeaderboard>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@ 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.
|
||||
* 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 }) => {
|
||||
|
|
@ -37,12 +37,21 @@ test.describe("Minigame leaderboards", () => {
|
|||
await expect(page.getByRole("tab", { name: "Blackjack" })).toBeVisible();
|
||||
});
|
||||
|
||||
test("a game page shows its anchored period standings card", async ({ page }) => {
|
||||
test("a game page centers period standings with all-time collapsed", 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();
|
||||
|
||||
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 });
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue