Files
funman300 fd98f46267
Test / test (pull_request) Successful in 37m24s
test(e2e): update replay payload specs to schema v4
PR #170 changed the web replay payload (moves list -> embedded session
recording) but missed these Playwright specs, which only run on master
pushes and so failed post-merge. Assertions now match the v4 shape:
schema_version 4, recording.initial_state present, moves at
recording.instructions.

Verified locally against a real server with freshly built wasm bundles:
full suite 18/18 green, including the five play_canvas specs.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-10 11:07:08 -07:00

71 lines
2.9 KiB
JavaScript

const { test, expect } = require("@playwright/test");
test("play-classic loads and exposes debug bridge", async ({ page }) => {
await page.goto("/play-classic?seed=42");
await page.waitForFunction(() => typeof window.__FERROUS_DEBUG__ === "object");
const seed = await page.evaluate(() => window.__FERROUS_DEBUG__.seed());
expect(seed).toBe(42);
const legalMoves = await page.evaluate(() => window.__FERROUS_DEBUG__.legalMoves());
expect(Array.isArray(legalMoves)).toBeTruthy();
});
test("keyboard parity: Space draws and U undoes", async ({ page }) => {
await page.goto("/play-classic?seed=42");
await page.waitForFunction(
() =>
typeof window.__FERROUS_DEBUG__ === "object" &&
window.__FERROUS_DEBUG__.seed() !== null
);
const baselineHistoryLen = await page.evaluate(
() => window.__FERROUS_DEBUG__.moveHistory().length
);
await page.keyboard.press("Space");
await expect
.poll(async () => await page.evaluate(() => window.__FERROUS_DEBUG__.moveHistory().length))
.toBe(baselineHistoryLen + 1);
await page.keyboard.press("KeyU");
await expect
.poll(async () => await page.evaluate(() => window.__FERROUS_DEBUG__.moveHistory().length))
.toBe(baselineHistoryLen);
});
test("debug failure report contains replay diagnostics", async ({ page }) => {
await page.goto("/play-classic?seed=42");
await page.waitForFunction(() => typeof window.__FERROUS_DEBUG__ === "object");
const report = await page.evaluate(() => window.__FERROUS_DEBUG__.failureReport());
expect(report).not.toBeNull();
expect(typeof report.seed).toBe("number");
expect(Array.isArray(report.moveHistory)).toBeTruthy();
expect(Array.isArray(report.legalMoves)).toBeTruthy();
expect(report.currentState).toBeTruthy();
expect(report.invariants).toBeTruthy();
});
test("replay payload builder exports a schema-v4 recording", async ({ page }) => {
await page.goto("/play-classic?seed=42");
await page.waitForFunction(() => typeof window.__FERROUS_DEBUG__ === "object");
await page.keyboard.press("Space");
await expect
.poll(async () => await page.evaluate(() => window.__FERROUS_DEBUG__.replayPayload() !== null))
.toBe(true);
const payload = await page.evaluate(() => window.__FERROUS_DEBUG__.replayPayload());
// Schema v4: the wasm layer assembles the whole payload; the deal is
// embedded in `recording` and moves live at recording.instructions.
expect(payload.schema_version).toBe(4);
expect(payload.draw_mode).toMatch(/Draw(One|Three)/);
expect(payload.mode).toBe("Classic");
expect(payload.recording).toBeTruthy();
expect(payload.recording.initial_state).toBeTruthy();
expect(Array.isArray(payload.recording.instructions)).toBeTruthy();
expect(payload.recording.instructions.length).toBeGreaterThan(0);
expect(payload.win_move_index).toBe(payload.recording.instructions.length - 1);
});