Refactor frontend entry to login and play routes

This commit is contained in:
2026-05-04 20:23:53 +02:00
parent a7f6163c4b
commit b9fba1bbbc
10 changed files with 97 additions and 49 deletions

View File

@@ -23,8 +23,9 @@ async function registerAndLogin(request, username, displayName) {
}
test("home page loads auth entry points", async ({ page }) => {
await page.goto("/");
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();
@@ -32,8 +33,14 @@ test("home page loads auth entry points", async ({ page }) => {
await expect(page.getByLabel("Password").nth(1)).toBeVisible();
});
test("home document renders static auth markup without bootstrapping blazor", async ({ request }) => {
const response = await request.get("/");
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();
@@ -44,7 +51,7 @@ test("home document renders static auth markup without bootstrapping blazor", as
expect(html).toContain("data-auth-page");
});
test("authenticated home document avoids prerendered workspace shell", async ({ request }) => {
test("authenticated root document redirects to play", async ({ request }) => {
const username = `doc-auth-${Date.now()}`;
const password = "Password123";
@@ -62,14 +69,9 @@ test("authenticated home document avoids prerendered workspace shell", async ({
});
expect(loginResponse.ok()).toBeTruthy();
const response = await request.get("/");
expect(response.ok()).toBeTruthy();
const html = await response.text();
expect(html).toContain("_framework/blazor.web.js");
expect(html).not.toContain("Register or log in to join a campaign session.");
expect(html).not.toContain("Loading user...");
expect(html).not.toContain("Offline fallback");
const response = await request.get("/", { maxRedirects: 0 });
expect(response.status()).toBe(302);
expect(response.headers()["location"]).toBe("/play");
});
test("successful login transitions to play workspace", async ({ page, context }) => {
@@ -82,11 +84,12 @@ test("successful login transitions to play workspace", async ({ page, context })
displayName: "Login Flow"
});
await page.goto("/");
await page.goto("/login");
await page.locator("#login-username").fill(username);
await page.locator("#login-password").fill(password);
await page.getByRole("button", { name: "Login" }).click();
await expect(page).toHaveURL(/\/play$/);
await expect(page.getByText("Campaign Log")).toBeVisible();
await expect(page.locator("#login-username")).toHaveCount(0);
});
@@ -166,7 +169,7 @@ test("workspace stays usable when input controls are DOM-wrapped during mount",
}
});
await page.goto("/");
await page.goto("/play");
await expect(page.getByText("Campaign Log")).toBeVisible();
await expect(page.locator("#skill-filter-input")).toBeVisible();
await expect(page.locator("#custom-roll-expression")).toBeVisible();
@@ -198,7 +201,7 @@ test("Rolemaster open-ended roll detail renders specialized dice chips", async (
await postJson(context.request, `/api/skills/${skill.id}/roll`, { visibility: "public" });
await page.goto("/");
await page.goto("/play");
await expect(page.getByText("Campaign Log")).toBeVisible();
await expect(page.locator(".log-panel .log-entry").first()).toBeVisible();
await expect(page.locator(".log-panel .log-event-badge")).toContainText(["Fumble"]);
@@ -244,7 +247,7 @@ test("Rolemaster automatic retry badge shows before detail expands", async ({ pa
expect(retriedRoll, "expected a retry-enabled Rolemaster roll within 10 attempts").not.toBeNull();
await page.goto("/");
await page.goto("/play");
await expect(page.getByText("Campaign Log")).toBeVisible();
const retryEntry = page.locator(".log-panel .log-entry").filter({ hasText: "retry +" }).last();
@@ -281,7 +284,7 @@ test("Rolemaster skill roll modal autofocuses, validates, and closes on escape o
rolemasterAutoRetry: true
});
await page.goto("/");
await page.goto("/play");
await expect(page.getByText("Campaign Log")).toBeVisible();
const rollButton = page.getByRole("button", { name: "Roll Observation" });
@@ -332,7 +335,7 @@ test("newly rolled log entry auto-expands", async ({ page, context }) => {
allowFumble: true
});
await page.goto("/");
await page.goto("/play");
await expect(page.getByText("Campaign Log")).toBeVisible();
await page.getByRole("button", { name: "Roll Stealth" }).click();
@@ -355,7 +358,7 @@ test("custom roll composer keeps parse errors inline and records successful roll
campaignId: campaign.id
});
await page.goto("/");
await page.goto("/play");
await expect(page.getByText("Campaign Log")).toBeVisible();
const composer = page.locator(".custom-roll-composer");
@@ -402,7 +405,7 @@ test("Rolemaster UI exposes conditional create and edit fields", async ({ page,
rolemasterAutoRetry: true
});
await page.goto("/");
await page.goto("/play");
await expect(page.locator("#workspace-screen-menu-button")).toBeVisible();
await page.locator("#workspace-screen-menu-button").click();