Files
VibemakerSandbox/app/e2e/simulation-shell.spec.js
T
chenlin fa089d5f0c 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

93 lines
3.7 KiB
JavaScript

import { test, expect } from "@playwright/test";
test("automatically runs with inline pause, reset and keyboard help; no menu assets", async ({
page,
}) => {
const errors = [],
requests = [];
page.on("pageerror", (e) => errors.push(e.message));
page.on("request", (r) => requests.push(r.url()));
await page.goto("/");
await expect(
page.getByRole("button", { name: "Pause", exact: true }),
).toBeEnabled();
expect(await page.evaluate(() => window.rl.data.time)).toBeGreaterThanOrEqual(
0,
);
await expect(page.getByRole("dialog")).toHaveCount(0);
await expect(page.getByText("Waddle in", { exact: true })).toHaveCount(0);
await expect(
page.getByRole("button", { name: "Keyboard controls", exact: false }),
).toHaveAttribute("aria-expanded", "true");
await page.getByRole("button", { name: "Pause", exact: true }).click();
await page.evaluate(() => window.rl.pause());
const time = await page.evaluate(() => window.rl.data.time);
await page.waitForTimeout(400);
expect(await page.evaluate(() => window.rl.data.time)).toBe(time);
await expect(page.getByRole("status")).toHaveText(/Paused/);
await page.keyboard.press("Escape");
await expect
.poll(() => page.evaluate(() => window.rl.data.time))
.toBeGreaterThan(time);
await page.getByRole("button", { name: "Pause", exact: true }).click();
await page.evaluate(() => window.rl.pause());
await page.getByRole("button", { name: "Reset", exact: true }).click();
await expect.poll(() => page.evaluate(() => window.rl.data.time)).toBe(0);
await expect(
page.getByRole("button", { name: "Continue", exact: true }),
).toBeEnabled();
await page
.getByRole("button", { name: "Keyboard controls", exact: false })
.click();
await expect(
page.getByRole("button", { name: "Keyboard controls", exact: false }),
).toHaveAttribute("aria-expanded", "false");
expect(
requests.filter(
(url) => url.includes("nostr") || url.includes("duck-head-mark"),
),
).toEqual([]);
expect(errors).toEqual([]);
});
test("paused sit timer freezes; keyboard focus does not send robot commands", async ({
page,
}) => {
await page.goto("/");
await page.waitForFunction(() => window.rl);
await page.evaluate(() => window.rl.setMode("sit"));
await page.getByRole("button", { name: "Pause", exact: true }).click();
await page.evaluate(() => window.rl.pause());
const before = await page.evaluate(() => window.rl.sitFlag);
await page.waitForTimeout(1100);
expect(await page.evaluate(() => window.rl.sitFlag)).toBe(before);
await page.keyboard.press("ArrowUp");
expect(await page.evaluate(() => Array.from(window.rl.velCmd))).toEqual([
0, 0, 0,
]);
// Native Space activates the focused Continue button, not robot reset.
await page.keyboard.press("Space");
await expect.poll(() => page.evaluate(() => window.rl.running)).toBe(true);
expect(await page.evaluate(() => window.rl.mode)).toBe("sitstand");
await page.keyboard.down("w");
expect(await page.evaluate(() => window.rl.velCmd[0])).toBeGreaterThan(0);
await page.keyboard.up("w");
});
test("load failure is inline and retry boots a clean instance", async ({
page,
}) => {
let failed = false;
await page.route("**/policies/BEST_alpha_walking.onnx", (route) => {
if (!failed) {
failed = true;
return route.fulfill({ status: 404, body: "not found" });
}
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();
await expect(page.getByRole("alert")).toHaveCount(0);
});