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', +);