Files
VibemakerSandbox/app/e2e/robot-switching.spec.js
T
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

65 lines
2.4 KiB
JavaScript

import { test, expect } from "@playwright/test";
async function ready(page) {
await page.goto("/");
await expect(
page.getByRole("button", { name: "Pause", exact: true }),
).toBeEnabled();
}
test("Microduck → Microban → Microduck restores theme, colours and locomotion", async ({
page,
}) => {
const errors = [];
page.on("pageerror", (e) => errors.push(e.message));
await ready(page);
await page.getByRole("button", { name: "Lavender colours" }).click();
await page.getByRole("button", { name: "Rollers", exact: true }).click();
await page.waitForFunction(() => window.rl?.loco === "rollers");
await page.getByLabel("Robot", { exact: true }).selectOption("microban");
await page.waitForFunction(
() =>
window.__store.getState().robotId === "microban" ||
window.__store.getState().runtimeError,
);
expect(
await page.evaluate(() => window.__store.getState().runtimeError),
).toBeNull();
await expect(
page.getByText("Toggle head rotation", { exact: false }),
).toBeVisible();
await expect(page.getByRole("group", { name: "Duck colours" })).toHaveCount(
0,
);
expect(await page.evaluate(() => window.rl.buildObs().length)).toBe(63);
await page.getByLabel("Robot", { exact: true }).selectOption("microduck");
await page.waitForFunction(
() =>
window.__store.getState().presentationTheme === "comic" &&
window.rl?.loco === "rollers",
);
await expect(
page.getByRole("button", { name: "Lavender colours" }),
).toHaveAttribute("aria-pressed", "true");
expect(await page.evaluate(() => window.rl.data.time)).toBeLessThan(3);
expect(errors).toEqual([]);
});
test("failed switch rolls back and retry does not reload the page", async ({
page,
}) => {
await ready(page);
let fail = true;
await page.route("**/robots/microban/policies/walk.onnx", (route) =>
fail ? route.fulfill({ status: 404, body: "missing" }) : route.continue(),
);
await page.getByLabel("Robot", { exact: true }).selectOption("microban");
await expect(page.getByRole("alert")).toContainText("404");
expect(await page.evaluate(() => window.__store.getState().robotId)).toBe(
"microduck-legs",
);
expect(await page.evaluate(() => window.rl.running)).toBe(true);
fail = false;
await page.getByRole("button", { name: "Retry", exact: true }).click();
await expect
.poll(() => page.evaluate(() => window.__store.getState().robotId))
.toBe("microban");
});