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:
@@ -1,7 +1,17 @@
|
||||
// Phase 12 end-to-end coverage for the order composer skeleton. The
|
||||
// shell makes no gateway calls in this spec — the boot flow seeds an
|
||||
// authenticated session and a draft directly through `/__debug/store`,
|
||||
// then navigates into `/games/<id>/map` and exercises the order tab.
|
||||
// boot flow seeds an authenticated session and a draft directly
|
||||
// through `/__debug/store`, then enters the game via the dev-only
|
||||
// `window.__galaxyNav` affordance (the single-URL app-shell has no
|
||||
// `/games/<id>/<view>` route) and exercises the order tab.
|
||||
//
|
||||
// The shell's per-game bootstrap now talks to the gateway on entry
|
||||
// (lobby validation, report, order read-back). This spec does not
|
||||
// stand up a real gateway, so those Connect-Web calls are aborted via
|
||||
// `page.route` — the shell tolerates the failure (cache fallback +
|
||||
// `failBootstrap`) and still renders the chrome. Aborting also keeps
|
||||
// a mid-spec `page.reload()` from hanging: an unrouted `/rpc` call
|
||||
// to a dead proxy never settles, which otherwise stalls the reload's
|
||||
// load event.
|
||||
//
|
||||
// Persistence is covered by reloading the page mid-spec: the
|
||||
// `OrderDraftStore` re-reads the same cache row on the next mount,
|
||||
@@ -10,12 +20,31 @@
|
||||
import { expect, test, type Page } from "@playwright/test";
|
||||
|
||||
// `window.__galaxyDebug` is owned by `routes/__debug/store/+page.svelte`
|
||||
// and typed by `tests/e2e/storage-keypair-persistence.spec.ts`. The
|
||||
// merged global declaration covers every helper this spec calls.
|
||||
// and `window.__galaxyNav` by `routes/+page.svelte`; both are typed by
|
||||
// `tests/e2e/storage-keypair-persistence.spec.ts`.
|
||||
|
||||
const SESSION_ID = "phase-12-order-session";
|
||||
const GAME_ID = "test-order";
|
||||
|
||||
// Fail-fast the shell's gateway calls so the spec needs no real
|
||||
// backend and reloads settle promptly.
|
||||
async function stubGateway(page: Page): Promise<void> {
|
||||
await page.route("**/edge.v1.Gateway/**", (route) => route.abort());
|
||||
}
|
||||
|
||||
// Load the app (seeded session → authenticated lobby) and enter the
|
||||
// game on the map view through the in-memory nav affordance.
|
||||
async function enterGameMap(page: Page): Promise<void> {
|
||||
await page.goto("/");
|
||||
await page.waitForFunction(() => window.__galaxyNav !== undefined);
|
||||
await page.evaluate(
|
||||
(id) => window.__galaxyNav!.enterGame(id, "map", {}),
|
||||
GAME_ID,
|
||||
);
|
||||
await expect(page.getByTestId("game-shell")).toBeVisible();
|
||||
await expect(page.getByTestId("active-view-map")).toBeVisible();
|
||||
}
|
||||
|
||||
const SEED = [
|
||||
{ kind: "placeholder" as const, id: "cmd-a", label: "first command" },
|
||||
{ kind: "placeholder" as const, id: "cmd-b", label: "second command" },
|
||||
@@ -23,6 +52,7 @@ const SEED = [
|
||||
];
|
||||
|
||||
async function bootDebug(page: Page): Promise<void> {
|
||||
await stubGateway(page);
|
||||
await page.goto("/__debug/store");
|
||||
await expect(page.getByTestId("debug-store-ready")).toBeVisible();
|
||||
await page.waitForFunction(() => window.__galaxyDebug?.ready === true);
|
||||
@@ -71,14 +101,18 @@ test("seeded draft renders on the order tab and survives a reload", async ({
|
||||
}, testInfo) => {
|
||||
const isMobile = testInfo.project.name.startsWith("chromium-mobile");
|
||||
await seedShell(page);
|
||||
await page.goto(`/games/${GAME_ID}/map`);
|
||||
await expect(page.getByTestId("game-shell")).toBeVisible();
|
||||
await expect(page.getByTestId("active-view-map")).toBeVisible();
|
||||
await enterGameMap(page);
|
||||
|
||||
await openOrderTool(page, isMobile);
|
||||
await expectSeededRows(page);
|
||||
|
||||
await page.reload();
|
||||
// Reload restores the `game` screen from the persisted nav snapshot,
|
||||
// whose first authenticated render re-stamps screen history via
|
||||
// SvelteKit shallow routing. That `pushState` lands right after the
|
||||
// document loads and would abort a default `reload()` (which waits
|
||||
// for `load`); waiting only for the navigation to commit sidesteps
|
||||
// the race while still re-executing the app from scratch.
|
||||
await page.reload({ waitUntil: "commit" });
|
||||
await expect(page.getByTestId("game-shell")).toBeVisible();
|
||||
await openOrderTool(page, isMobile);
|
||||
await expectSeededRows(page);
|
||||
@@ -89,8 +123,7 @@ test("removing a command from the order tab persists the removal", async ({
|
||||
}, testInfo) => {
|
||||
const isMobile = testInfo.project.name.startsWith("chromium-mobile");
|
||||
await seedShell(page);
|
||||
await page.goto(`/games/${GAME_ID}/map`);
|
||||
await expect(page.getByTestId("game-shell")).toBeVisible();
|
||||
await enterGameMap(page);
|
||||
await openOrderTool(page, isMobile);
|
||||
|
||||
await expect(page.getByTestId("order-command-1")).toBeVisible();
|
||||
@@ -104,7 +137,10 @@ test("removing a command from the order tab persists the removal", async ({
|
||||
);
|
||||
await expect(page.getByTestId("order-command-2")).toHaveCount(0);
|
||||
|
||||
await page.reload();
|
||||
// See the note on the sibling test: the restored `game` screen
|
||||
// re-stamps history on reload, so wait only for the navigation to
|
||||
// commit to avoid the shallow-routing `pushState` aborting it.
|
||||
await page.reload({ waitUntil: "commit" });
|
||||
await expect(page.getByTestId("game-shell")).toBeVisible();
|
||||
await openOrderTool(page, isMobile);
|
||||
await expect(page.getByTestId("order-command-label-0")).toHaveText(
|
||||
@@ -131,8 +167,7 @@ test("empty draft renders the empty-state copy", async ({
|
||||
GAME_ID,
|
||||
);
|
||||
|
||||
await page.goto(`/games/${GAME_ID}/map`);
|
||||
await expect(page.getByTestId("game-shell")).toBeVisible();
|
||||
await enterGameMap(page);
|
||||
await openOrderTool(page, isMobile);
|
||||
|
||||
await expect(page.getByTestId("order-empty")).toBeVisible();
|
||||
|
||||
Reference in New Issue
Block a user