From a090cb1e58af690a7300950441855e7591e0c37a Mon Sep 17 00:00:00 2001 From: que01 Date: Wed, 9 Sep 2026 13:26:16 +0800 Subject: [PATCH] test(junction): isolate foreign junction plans --- test/junction-build-plan-counterexamples.js | 29 +++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/test/junction-build-plan-counterexamples.js b/test/junction-build-plan-counterexamples.js index 0e7b74d..bdac0f8 100644 --- a/test/junction-build-plan-counterexamples.js +++ b/test/junction-build-plan-counterexamples.js @@ -431,3 +431,32 @@ const tooShortSection = tooShortGraph.sections.find( ); assert.equal(tooShortSection.transitionStatus, 'insufficient-source-length'); assert.equal(tooShortSection.transitionMeters, 0); + +// Foreign junction plans outside the selected cluster must not leak into its +// topology or change stable source identities. +const isolatedHelpers = { + ...sixArm.helpers, + junctionPlans: new Map([ + ...sixArm.helpers.junctionPlans, + [ + 'foreign:node', + { + node: point(500, 500), + approaches: [ + { + segmentId: 'foreign:segment', + roadIds: ['foreign:road'], + widthMeters: 20, + line: [point(500, 500), point(560, 500)], + }, + ], + }, + ], + ]), +}; +const isolatedTopology = resolveJunctionBuildPlan(sixArm.model, sixArm.cluster, isolatedHelpers); +assert.deepEqual( + isolatedTopology.carriageways.map((item) => item.key).sort(), + sixArm.topology.carriageways.map((item) => item.key).sort(), + 'foreign junction plans must not contaminate selected cluster topology', +);