From d902a970e87b2505efdc3b3cbfb91f48b703a2b9 Mon Sep 17 00:00:00 2001 From: Nico Rehwaldt Date: Mon, 9 Mar 2020 10:48:05 +0100 Subject: [PATCH] fix(modeling): update AddLaneHandler to new spaceTool API Related to https://github.com/camunda/camunda-modeler/issues/1715 --- lib/features/modeling/cmd/AddLaneHandler.js | 8 ++- .../features/modeling/lanes/AddLaneSpec.js | 54 +++++++++++++++++-- 2 files changed, 56 insertions(+), 6 deletions(-) diff --git a/lib/features/modeling/cmd/AddLaneHandler.js b/lib/features/modeling/cmd/AddLaneHandler.js index ba2a34ad..711de3d7 100644 --- a/lib/features/modeling/cmd/AddLaneHandler.js +++ b/lib/features/modeling/cmd/AddLaneHandler.js @@ -77,7 +77,13 @@ AddLaneHandler.prototype.preExecute = function(context) { var adjustments = spaceTool.calculateAdjustments(allAffected, 'y', offset, spacePos); - spaceTool.makeSpace(adjustments.movingShapes, adjustments.resizingShapes, { x: 0, y: offset }, direction); + spaceTool.makeSpace( + adjustments.movingShapes, + adjustments.resizingShapes, + { x: 0, y: offset }, + direction, + spacePos + ); // (2) create new lane at open space context.newLane = modeling.createShape({ type: 'bpmn:Lane' }, { diff --git a/test/spec/features/modeling/lanes/AddLaneSpec.js b/test/spec/features/modeling/lanes/AddLaneSpec.js index b7229034..1b5d128d 100644 --- a/test/spec/features/modeling/lanes/AddLaneSpec.js +++ b/test/spec/features/modeling/lanes/AddLaneSpec.js @@ -20,6 +20,8 @@ import { query as domQuery } from 'min-dom'; var DEFAULT_LANE_HEIGHT = 120; +var testModules = [ coreModule, modelingModule ]; + function getBounds(element) { return pick(element, [ 'x', 'y', 'width', 'height' ]); @@ -32,9 +34,10 @@ describe('features/modeling - add Lane', function() { var diagramXML = require('./lanes.bpmn'); - var testModules = [ coreModule, modelingModule ]; + beforeEach(bootstrapModeler(diagramXML, { + modules: testModules + })); - beforeEach(bootstrapModeler(diagramXML, { modules: testModules })); it('should add after Lane', inject(function(elementRegistry, modeling) { @@ -191,9 +194,9 @@ describe('features/modeling - add Lane', function() { var diagramXML = require('./participant-no-lane.bpmn'); - var testModules = [ coreModule, modelingModule ]; - - beforeEach(bootstrapModeler(diagramXML, { modules: testModules })); + beforeEach(bootstrapModeler(diagramXML, { + modules: testModules + })); it('should add after Participant', inject(function(elementRegistry, modeling) { @@ -267,6 +270,47 @@ describe('features/modeling - add Lane', function() { }); + describe('flow node handling', function() { + + var diagramXML = require('./lanes.bpmn'); + + beforeEach(bootstrapModeler(diagramXML, { + modules: testModules + })); + + + it('should move flow nodes and sequence flows', inject(function(elementRegistry, modeling) { + + // given + var laneShape = elementRegistry.get('Nested_Lane_B'), + task_Boundary = elementRegistry.get('Task_Boundary'), + boundary = elementRegistry.get('Boundary'), + sequenceFlow = elementRegistry.get('SequenceFlow'), + sequenceFlow_From_Boundary = elementRegistry.get('SequenceFlow_From_Boundary'); + + // when + var newLane = modeling.addLane(laneShape, 'top'); + + // then + expect(task_Boundary).to.have.position({ x: 264, y: -57 }); + expect(boundary).to.have.position({ x: 311, y: 5 }); + + expect(sequenceFlow_From_Boundary).to.have.waypoints([ + { x: 329, y: 161 - newLane.height }, + { x: 329, y: 188 - newLane.height }, + { x: 482, y: 188 - newLane.height }, + { x: 482, y: 143 - newLane.height } + ]); + + expect(sequenceFlow).to.have.waypoints([ + { x: 364, y: 103 - newLane.height }, + { x: 432, y: 103 - newLane.height } + ]); + })); + + }); + + describe('Internet Explorer', function() { var diagramXML = require('./participant-single-lane.bpmn');