fc5ee4f2c6
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.
46 lines
1.7 KiB
JavaScript
46 lines
1.7 KiB
JavaScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import fs from "node:fs/promises";
|
|
import { validatePackage } from "../src/platform/loader/SchemaValidator.js";
|
|
import { assetUrl } from "../src/platform/loader/PackageLoader.js";
|
|
const config = JSON.parse(
|
|
await fs.readFile(
|
|
new URL("../public/robots/microban/robot.json", import.meta.url),
|
|
),
|
|
);
|
|
test("all shipped packages match schema and reject unsupported capability", async () => {
|
|
for (const id of ["microduck-legs", "microduck-rollers", "microban"])
|
|
validatePackage(
|
|
JSON.parse(
|
|
await fs.readFile(
|
|
new URL(`../public/robots/${id}/robot.json`, import.meta.url),
|
|
),
|
|
),
|
|
);
|
|
const copy = structuredClone(config);
|
|
copy.skills[0].controller.type = "ik";
|
|
assert.throws(() => validatePackage(copy), /controller/);
|
|
});
|
|
test("overlapping ownership, unknown group, duplicate binding rejected", () => {
|
|
let copy = structuredClone(config);
|
|
copy.skills[1].owns = "policy";
|
|
assert.throws(() => validatePackage(copy), /overlapping/);
|
|
copy = structuredClone(config);
|
|
copy.actions[0].group = "unknown";
|
|
assert.throws(() => validatePackage(copy), /group/);
|
|
copy = structuredClone(config);
|
|
copy.input.bindings.push(copy.input.bindings[0]);
|
|
assert.throws(() => validatePackage(copy), /duplicate/);
|
|
});
|
|
test("asset URLs preserve prefix and authenticate only same origin", () => {
|
|
const loc = { origin: "https://host.test", search: "?__sign=secret" };
|
|
assert.equal(
|
|
assetUrl("../policies/w.onnx", "https://host.test/play/robots/a/", loc),
|
|
"https://host.test/play/robots/policies/w.onnx?__sign=secret",
|
|
);
|
|
assert.throws(
|
|
() => assetUrl("https://other.test/a", "https://host.test/", loc),
|
|
/External/,
|
|
);
|
|
});
|