import assert from 'node:assert/strict'; import { readFileSync } from 'node:fs'; import { test } from 'node:test'; import ts from 'typescript'; const code=ts.transpileModule(readFileSync(new URL('../src/core/simulation/planDraft.ts',import.meta.url),'utf8'),{compilerOptions:{module:ts.ModuleKind.ESNext}}).outputText; const {planMatchesDraft}=await import(`data:text/javascript;base64,${Buffer.from(code).toString('base64')}`); const points=[{id:'start',position:[0,0,0]},{id:'finish',position:[3,1,0]}]; const plan={editor_cache_key:'scene-v1',robot_sha256:'rover-v1',points}; test('editor launch reuses only the exact ordered saved route, including elevation',()=>{ assert.equal(planMatchesDraft(plan,'scene-v1','rover-v1',structuredClone(points)),true); const moved=structuredClone(points);moved[1].position[2]=.2; assert.equal(planMatchesDraft(plan,'scene-v1','rover-v1',moved),false); assert.equal(planMatchesDraft(plan,'scene-v1','rover-v1',[...points].reverse()),false); assert.equal(planMatchesDraft(plan,'scene-v1','rover-v1',points.slice(1)),false); }); test('changed scene or rover requires a fresh task even when coordinates match',()=>{ assert.equal(planMatchesDraft(plan,'scene-v2','rover-v1',points),false); assert.equal(planMatchesDraft(plan,'scene-v1','rover-v2',points),false); assert.equal(planMatchesDraft(undefined,'scene-v1','rover-v1',points),false); });