chore(infra): update dev compose, add playwright e2e suite & assets
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
import { test, expect } from "@playwright/test";
|
||||
import { BASE, requireAuth, injectAuth } from "./helpers";
|
||||
|
||||
test.describe("Leaderboard", () => {
|
||||
test("weekly leaderboard returns valid shape", async ({ page }) => {
|
||||
const auth = requireAuth();
|
||||
const res = await page.request.get(`${BASE}/api/leaderboard/weekly`, {
|
||||
headers: { Authorization: `Bearer ${auth.accessToken}` },
|
||||
});
|
||||
expect(res.status()).toBe(200);
|
||||
const data = await res.json();
|
||||
expect(data).toHaveProperty("week");
|
||||
expect(data).toHaveProperty("entries");
|
||||
expect(data).toHaveProperty("totalParticipants");
|
||||
expect(data).toHaveProperty("me");
|
||||
expect(Array.isArray(data.entries)).toBe(true);
|
||||
});
|
||||
|
||||
test("leaderboard entries have tier field", async ({ page }) => {
|
||||
const auth = requireAuth();
|
||||
const res = await page.request.get(`${BASE}/api/leaderboard/weekly`, {
|
||||
headers: { Authorization: `Bearer ${auth.accessToken}` },
|
||||
});
|
||||
const data = await res.json();
|
||||
for (const entry of data.entries) {
|
||||
expect(["champion", "gold", "silver", "bronze"]).toContain(entry.tier);
|
||||
expect(entry.rank).toBeGreaterThanOrEqual(1);
|
||||
}
|
||||
});
|
||||
|
||||
test("leaderboard page renders without redirect to /login", async ({ page }) => {
|
||||
await injectAuth(page);
|
||||
await page.goto("/leaderboard");
|
||||
await page.waitForLoadState("networkidle", { timeout: 15_000 });
|
||||
expect(page.url()).not.toContain("/login");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user