const { test, expect } = require("@playwright/test"); async function postJson(request, url, data) { const response = await request.post(url, { data }); expect(response.ok()).toBeTruthy(); return await response.json(); } async function registerAndLogin(request, username, displayName) { await postJson(request, "/api/auth/register", { username, password: "Password123", displayName }); const loginResponse = await request.post("/api/auth/login", { data: { username, password: "Password123" } }); expect(loginResponse.ok()).toBeTruthy(); } test("home page loads auth entry points", async ({ page }) => { await page.goto("/play"); await expect(page).toHaveURL(/\/login$/); await expect(page.locator("h1")).toContainText("RpgRoller"); await expect(page.getByRole("heading", { name: "Register" })).toBeVisible(); await expect(page.getByRole("heading", { name: "Login" })).toBeVisible(); await expect(page.getByLabel("Username").first()).toBeVisible(); await expect(page.getByLabel("Password").nth(1)).toBeVisible(); }); test("root document redirects anonymous users to login", async ({ request }) => { const response = await request.get("/", { maxRedirects: 0 }); expect(response.status()).toBe(302); expect(response.headers()["location"]).toBe("/login"); }); test("login document renders static auth markup without bootstrapping blazor", async ({ request }) => { const response = await request.get("/login"); expect(response.ok()).toBeTruthy(); const html = await response.text(); expect(html).not.toContain("Connecting..."); expect(html).toContain("Register or log in to join a campaign session."); expect(html).not.toContain("_framework/blazor.web.js"); expect(html).not.toContain("