Files
VibemakerSandbox/app/e2e/arena-presentation.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

106 lines
3.3 KiB
JavaScript

import { test, expect } from "@playwright/test";
import { bootDuck } from "./support/simulation.js";
test("arena appearance matches Microduck while Microban physics stays flat and World visuals dispose on switch", async ({
page,
}, info) => {
const errors = [];
page.on("pageerror", (e) => errors.push(e.message));
page.on("console", (m) => {
if (m.type() === "error") errors.push(m.text());
});
await bootDuck(page);
expect(
await page.evaluate(() => window.__gameApi.switchRobot("microban")),
).toBe(true);
await page.evaluate(() => window.__gameApi.resume());
await expect
.poll(() => page.evaluate(() => window.rl.data.time))
.toBeGreaterThan(1);
await page.evaluate(() => window.__gameApi.pause());
await expect
.poll(() =>
page.evaluate(
() => !!window.rl.scene.getObjectByName("arena-floor-presentation"),
),
)
.toBe(true);
const state = await page.evaluate(() => {
const r = window.rl,
grid = r.scene.getObjectByName("arena-grid"),
u = grid.material.uniforms,
id = r.model.geom("platform_floor").id;
let floor;
r.scene.traverse((o) => {
if (o.userData.geomId === id) floor = o;
});
window.__retiredArena = r.scene.getObjectByName("arena-floor-presentation");
window.__arenaReleased = [];
grid.geometry.addEventListener("dispose", () =>
window.__arenaReleased.push("geometry"),
);
grid.material.addEventListener("dispose", () =>
window.__arenaReleased.push("material"),
);
return {
cell: u.uCell.value,
section: u.uSection.value,
color: u.uSectionColor.value.getHex(),
reveal: u.uReveal.value,
topo: u.uTopoScale.value,
hiddenFloor: !floor.visible,
floorType: r.model.geom_type[id],
friction: Array.from(r.model.geom_friction.slice(id * 3, id * 3 + 3)),
gravity: Array.from(r.model.opt.gravity),
heightfields: r.model.nhfield,
finite: Array.from(r.data.qpos).every(Number.isFinite),
fallen: r.fallen,
};
});
expect(state).toEqual({
cell: 0.1 * (0.33 / 0.27),
section: 0.6 * (0.33 / 0.27),
color: 0xf7e6cb,
reveal: 1,
topo: 0,
hiddenFloor: true,
floorType: 0,
friction: [1, 0.005, 0.0001],
gravity: [0, 0, -9.81],
heightfields: 0,
finite: true,
fallen: false,
});
await page.screenshot({ path: info.outputPath("microban-arena.png") });
await page.evaluate(() => {
const r = window.rl;
r.data.qpos[0] = 4;
r.data.qpos[1] = -3;
r.mujoco.mj_forward(r.model, r.data);
});
await expect
.poll(() =>
page.evaluate(() => {
const g = window.rl.scene.getObjectByName("arena-grid");
return [
g.position.x,
g.position.z,
g.material.uniforms.uFocus.value.x,
g.material.uniforms.uFocus.value.z,
];
}),
)
.toEqual([4, 3, 4, 3]);
expect(
await page.evaluate(() => window.__gameApi.switchRobot("microduck-legs")),
).toBe(true);
expect(await page.evaluate(() => window.__arenaReleased.sort())).toEqual([
"geometry",
"material",
]);
expect(await page.evaluate(() => window.__retiredArena.parent === null)).toBe(
true,
);
expect(await page.evaluate(() => window.rl.chaseCam)).toBe(true);
expect(errors).toEqual([]);
});