import assert from "node:assert/strict"; import fs from "node:fs"; import os from "node:os"; import path from "node:path"; import test from "node:test"; import { auditGeometryBoundary, inspectGeometrySource } from "./audit-geometry-boundary.mjs"; test("native buffers, display bounds and picking remain allowed", () => { const source = 'import * as THREE from "three"; const geometry=new THREE.BufferGeometry(); geometry.computeBoundingSphere(); new THREE.Box3(); new THREE.Raycaster();'; assert.deepEqual(inspectGeometrySource("src/render-object-registry.ts", source).findings, []); }); test("Three imports in a native worker or facade are rejected", () => { for (const file of ["src/part.worker.ts", "src/part-facade.ts"]) { const result = inspectGeometrySource(file, 'import * as THREE from "three";'); assert.equal(result.findings[0].code, "three_outside_display"); } }); test("procedural CAD geometry is detected through namespace and named aliases", () => { for (const source of ['import * as Render from "three"; new Render.ExtrudeGeometry();', 'import { BoxGeometry as Shape } from "three"; new Shape();']) { assert.equal(inspectGeometrySource("src/main.ts", source).findings[0].code, "three_procedural_cad"); } }); test("alternate CSG imports, re-exports and dynamic imports are rejected", () => { for (const source of ['import { CSG } from "three-csg-ts";', 'export * from "@jscad/modeling";', 'const csg=await import("three-bvh-csg");', 'const csg=require("manifold-3d");']) { assert.equal(inspectGeometrySource("src/main.ts", source).findings[0].code, "alternate_geometry_backend"); } }); test("type-only mesh transport declarations do not import a renderer at runtime", () => { assert.deepEqual(inspectGeometrySource("src/shape-types.ts", 'import type { BufferGeometry } from "three";').findings, []); }); test("missing or invalid supplied artifacts fail without triggering a build", () => { const root = fs.mkdtempSync(path.join(os.tmpdir(), "freecad-boundary-")); try { fs.mkdirSync(path.join(root, "src")); assert.equal(auditGeometryBoundary(root).findings.length, 2); fs.mkdirSync(path.join(root, "public/kernel"), { recursive: true }); fs.writeFileSync(path.join(root, "public/kernel/FreeCADWebKernel.js"), "export default factory;"); fs.writeFileSync(path.join(root, "public/kernel/FreeCADWebKernel.wasm"), "not wasm"); const invalid = auditGeometryBoundary(root); assert.equal(invalid.findings.length, 1); assert.equal(invalid.singleRuntimeVerified, false); } finally { fs.rmSync(root, { recursive: true, force: true }); } }); test("the actual frontend obeys the checked display boundary", () => { const report = auditGeometryBoundary(); assert.deepEqual(report.findings, []); assert.equal(report.renderers.length, 4); assert.equal(report.singleRuntimeVerified, false); });