Files
VibemakerSandbox/app/e2e/microduck-regression.spec.js
chenlin a8be5e0134 feat: release v0.5 with shared interactive arenas and textured RP1
Unify lighting and line-colour controls across robots, replace the football with a shared layout of draggable physical props, and import the supplied RP1 GLBs without changing trained physics or policies.

Include reproducible visual import/provenance, regression coverage and verification records. Verified 66 unit tests, 55 browser tests and production-build checks.
2026-10-30 14:14:03 +08:00

87 lines
3.0 KiB
JavaScript

import { test, expect } from "@playwright/test";
import fs from "node:fs/promises";
import { fileURLToPath } from "node:url";
import { bootDuck, snapshot } from "./support/simulation.js";
const fixtures = fileURLToPath(
new URL("../test/fixtures/microduck/", import.meta.url),
);
for (const scenario of [
"stand",
"walk",
"kick",
"sitstand",
"groundpick",
"roll",
"recovery",
"rollers",
"crouch",
]) {
test(`Microduck deterministic ${scenario}`, async ({ page }) => {
// Keep the ORIGINAL 3m World for the accepted original-code oracle.
// The current 4.5m production default is independently tested in bounded-world.
await page.route("**/worlds/arena/world.json*", async (route) => {
const response = await route.fetch(),
world = await response.json();
world.boundary.half_extent = 1.5;
await route.fulfill({ response, json: world });
});
const errors = await bootDuck(page, { legacyPhysics: true });
await page.evaluate(async (scenario) => {
const r = window.rl;
if (scenario === "rollers" || scenario === "crouch") {
await r.setLoco("rollers", { force: true });
await r.prepareTest();
}
r.resetSim();
await r.prepareTest();
await r.step(50);
if (scenario === "walk" || scenario === "rollers")
r.velCmd[0] = scenario === "walk" ? 0.1 : 0.2;
if (scenario === "kick") r.triggerKick("left");
if (scenario === "sitstand") r.setMode("sit");
if (scenario === "groundpick") r.triggerGroundPick();
if (scenario === "roll") r.triggerRoll();
if (scenario === "crouch") r.triggerCrouch();
if (scenario === "recovery") {
r.data.qpos[3] = Math.SQRT1_2;
r.data.qpos[4] = Math.SQRT1_2;
r.mujoco.mj_forward(r.model, r.data);
}
}, scenario);
// Preserve the accepted input sequence: latch the sit flag before the
// recorded physics interval. Timers now use a controllable sim clock.
if (scenario === "sitstand")
await page.evaluate(() => window.rl.advanceTimers(0.85));
const trajectory = [];
for (let i = 0; i < 6; i++) {
await page.evaluate(() => window.rl.step(25));
trajectory.push(await snapshot(page));
}
const path = `${fixtures}${scenario}.json`;
if (process.env.RECORD_BASELINE === "1") {
const candidates = fileURLToPath(
new URL("../test-results/baseline-candidates/", import.meta.url),
);
await fs.mkdir(candidates, { recursive: true });
// Never overwrite accepted goldens: candidates require explicit review.
await fs.writeFile(
`${candidates}${scenario}.json`,
JSON.stringify(
{
scenario,
backend: "mujoco-3.11.0/ort-wasm-single-thread",
trajectory,
},
null,
2,
) + "\n",
);
} else {
const expected = JSON.parse(await fs.readFile(path, "utf8"));
expect(trajectory).toEqual(expected.trajectory);
}
expect(errors).toEqual([]);
});
}