Files
VibemakerSandbox/app/e2e/runtime-races.spec.js
chenlin fc5ee4f2c6 feat: release v0.2 multi-robot simulator
Add declarative robot packages, shared simulation lifecycle and Microban ONNX/PD walking with independent head control.

Unify comic UI and chase camera; default robot packages to a 4.5m arena with real collision walls. Include regression tests, asset provenance/licenses and verification evidence.
2026-10-28 14:00:26 +08:00

62 lines
2.2 KiB
JavaScript

import { test, expect } from "@playwright/test";
test("switch is single-flight, drains old ticks, clears held keys and preserves pause intent", async ({
page,
}) => {
await page.goto("/");
await expect(
page.getByRole("button", { name: "Pause", exact: true }),
).toBeEnabled();
await page.evaluate(() => window.__gameApi.pause());
let release,
seen = false;
const gate = new Promise((r) => (release = r));
await page.route("**/robots/microban/model.xml", async (route) => {
seen = true;
await gate;
await route.continue();
});
await page.evaluate(() => {
window.switchPending = window.__gameApi.switchRobot("microban");
});
await expect.poll(() => seen).toBe(true);
const time = await page.evaluate(() => window.rl.data.time);
await page.waitForTimeout(150);
expect(await page.evaluate(() => window.rl.data.time)).toBe(time);
expect(
await page.evaluate(() => window.__gameApi.switchRobot("microduck-legs")),
).toBe(false);
await page.keyboard.down("w");
release();
expect(await page.evaluate(() => window.switchPending)).toBe(true);
expect(await page.evaluate(() => window.__store.getState().paused)).toBe(
true,
);
expect(await page.evaluate(() => window.rl.running)).toBe(false);
expect(await page.evaluate(() => Array.from(window.rl.command))).toEqual([
0, 0, 0,
]);
await page.keyboard.up("w");
await page.evaluate(() => window.rl.step(10));
await page.keyboard.press("Space");
await expect.poll(() => page.evaluate(() => window.rl.data.time)).toBe(0);
expect(await page.evaluate(() => window.rl.running)).toBe(false);
});
test("GLB load failure can retry without poisoned shared cache", async ({
page,
}) => {
let failed = false;
await page.route("**/microduck.glb?*", (route) => {
if (!failed) {
failed = true;
return route.fulfill({ status: 503, body: "missing" });
}
return route.continue();
});
await page.goto("/");
await expect(page.getByRole("alert")).toContainText("Simulation error");
await page.getByRole("button", { name: "Retry", exact: true }).click();
await expect(
page.getByRole("button", { name: "Pause", exact: true }),
).toBeEnabled();
});