import assert from "node:assert/strict"; import { readFile } from "node:fs/promises"; import { test } from "node:test"; const sourceRoot = new URL("../src/", import.meta.url); async function read(relativePath) { return readFile(new URL(relativePath, sourceRoot), "utf8"); } test("simulation is a dedicated Polygon workspace with a bounded feature slice", async () => { const [productModel, workspaceHub, workspace, styles] = await Promise.all([ read("productModel.ts"), read("workspaces/Workspaces.tsx"), read("workspaces/simulation/SimulationWorkspace.tsx"), read("styles.css"), ]); assert.match(productModel, /id: "simulations"[\s\S]*root: "polygon"[\s\S]*kind: "simulations"/); assert.match(workspaceHub, /case "simulations":[\s\S]*/); assert.match(workspace, /simulation-catalog__table/); assert.match(workspace, / { const [core, window] = await Promise.all([ read("core/simulation/projects.ts"), read("components/simulation/SimulationProjectWindow.tsx"), ]); assert.match(core, /const API_ROOT = "\/api\/v1\/simulation-worlds\/projects"/); assert.match(core, /method: "HEAD"/); assert.match(core, /method: "PATCH"/); assert.match(core, /"Upload-Offset"/); assert.doesNotMatch(core, /Authorization|Bearer|18090|Worker 006/); assert.match(window, /accept="\.zip,\.rar,\.7z"/); assert.match(window, /webkitdirectory/); assert.match(window, /webkitGetAsEntry/); assert.match(window, /ровно одна сцена \.lcc или \.lcc2/); }); test("PlayCanvas owns the realtime scene graph without an iframe or React entity tree", async () => { const [runtime, viewport, packageDocument] = await Promise.all([ read("components/simulation/PlayCanvasRuntime.ts"), read("components/simulation/SimulationViewport.tsx"), readFile(new URL("../package.json", import.meta.url), "utf8"), ]); assert.match(packageDocument, /"playcanvas": "2\.21\.4"/); assert.doesNotMatch(packageDocument, /@playcanvas\/react/); assert.match(runtime, /new Application\(canvas/); assert.match(runtime, /new Asset\([^,]+, "gsplat"/); assert.match(runtime, /camera\.script\?\.create\(CameraControls/); assert.match(runtime, /app\.root\.addChild/); assert.match(runtime, /dispose\(\)/); assert.doesNotMatch(`${runtime}\n${viewport}`, /iframe|