test(ui): migrate suite to the app-shell (state-driven navigation)
- Unit: repoint moved screen imports (lib/screens, lib/game), mock $lib/app-nav (appScreen/activeView) instead of $app/navigation, drop the removed gameId props, assert screen/view selection. - e2e: add a dev-only window.__galaxyNav affordance; specs enter a game via enterGame(...) instead of a /games/:id URL; URL assertions become content assertions (the URL stays /game/); reload uses waitUntil:"commit" (shallow routing) and mocks /rpc on game entry. - Remove the obsolete report scroll-restore test (it relied on a SvelteKit route Snapshot that no longer exists); update the missing-membership test to the new lobby-redirect+toast behaviour. Fix a stale report.svelte docstring. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -4,12 +4,15 @@
|
||||
// webkit/mobile projects adds cost without new signal).
|
||||
//
|
||||
// Auth is bootstrapped through `/__debug/store` exactly as the
|
||||
// game-shell specs do; the in-game layout tolerates a missing gateway
|
||||
// game-shell specs do; the in-game shell tolerates a missing gateway
|
||||
// (ECONNREFUSED) and still renders the chrome + view shells, which is
|
||||
// what the structural a11y scan needs.
|
||||
// what the structural a11y scan needs. Screens and in-game views are
|
||||
// reached through the dev-only `window.__galaxyNav` affordance — the
|
||||
// single-URL app-shell has no per-screen / per-view routes.
|
||||
|
||||
import AxeBuilder from "@axe-core/playwright";
|
||||
import { expect, test, type Page } from "@playwright/test";
|
||||
import type { GameView, GameViewState } from "../../src/lib/app-nav.svelte";
|
||||
|
||||
const SESSION_ID = "f2-a11y-axe-session";
|
||||
// A real UUID — the layout's auto-sync calls `uuidToHiLo` on it.
|
||||
@@ -46,38 +49,77 @@ test.describe("axe WCAG 2.2 AA", () => {
|
||||
});
|
||||
|
||||
test("login", async ({ page }) => {
|
||||
await page.goto("/login");
|
||||
// No seeded session → the dispatcher renders the login screen.
|
||||
await page.goto("/");
|
||||
await expect(page.locator("#main-content")).toBeVisible();
|
||||
await expectNoViolations(page);
|
||||
});
|
||||
|
||||
test("lobby", async ({ page }) => {
|
||||
await authenticate(page);
|
||||
await page.goto("/lobby");
|
||||
await page.goto("/");
|
||||
await expect(page.locator("#main-content")).toBeVisible();
|
||||
await expectNoViolations(page);
|
||||
});
|
||||
|
||||
test("lobby create", async ({ page }) => {
|
||||
await authenticate(page);
|
||||
await page.goto("/lobby/create");
|
||||
await page.goto("/");
|
||||
await page.waitForFunction(() => window.__galaxyNav !== undefined);
|
||||
await page.evaluate(() => window.__galaxyNav!.go("lobby-create"));
|
||||
await expect(page.locator("#main-content")).toBeVisible();
|
||||
await expectNoViolations(page);
|
||||
});
|
||||
|
||||
const inGameViews: Array<[string, string]> = [
|
||||
["map", "active-view-map"],
|
||||
["report", "active-view-report"],
|
||||
["mail", "active-view-mail"],
|
||||
["battle", "active-view-battle"],
|
||||
["designer/science", "active-view-designer-science"],
|
||||
["table/planets", "active-view-table"],
|
||||
type ViewParams = Omit<GameViewState, "view">;
|
||||
const inGameViews: Array<{
|
||||
label: string;
|
||||
view: GameView;
|
||||
params: ViewParams;
|
||||
testId: string;
|
||||
}> = [
|
||||
{ label: "map", view: "map", params: {}, testId: "active-view-map" },
|
||||
{
|
||||
label: "report",
|
||||
view: "report",
|
||||
params: {},
|
||||
testId: "active-view-report",
|
||||
},
|
||||
{ label: "mail", view: "mail", params: {}, testId: "active-view-mail" },
|
||||
{
|
||||
label: "battle",
|
||||
view: "battle",
|
||||
params: {},
|
||||
testId: "active-view-battle",
|
||||
},
|
||||
{
|
||||
label: "designer/science",
|
||||
view: "designer-science",
|
||||
params: {},
|
||||
testId: "active-view-designer-science",
|
||||
},
|
||||
{
|
||||
label: "table/planets",
|
||||
view: "table",
|
||||
params: { tableEntity: "planets" },
|
||||
testId: "active-view-table",
|
||||
},
|
||||
];
|
||||
|
||||
for (const [path, testId] of inGameViews) {
|
||||
test(`in-game: ${path}`, async ({ page }) => {
|
||||
for (const { label, view, params, testId } of inGameViews) {
|
||||
test(`in-game: ${label}`, async ({ page }) => {
|
||||
await authenticate(page);
|
||||
await page.goto(`/games/${GAME_ID}/${path}`);
|
||||
await page.goto("/");
|
||||
await page.waitForFunction(() => window.__galaxyNav !== undefined);
|
||||
await page.evaluate(
|
||||
([id, v, p]) =>
|
||||
window.__galaxyNav!.enterGame(
|
||||
id as string,
|
||||
v as GameView,
|
||||
p as ViewParams,
|
||||
),
|
||||
[GAME_ID, view, params] as const,
|
||||
);
|
||||
await expect(page.getByTestId("game-shell")).toBeVisible();
|
||||
await expect(page.getByTestId(testId)).toBeVisible();
|
||||
await expectNoViolations(page);
|
||||
|
||||
Reference in New Issue
Block a user