diff --git a/test/spec/features/modeling/MoveConnectionSpec.js b/test/spec/features/modeling/MoveConnectionSpec.js index 078eaf5e..eee48720 100644 --- a/test/spec/features/modeling/MoveConnectionSpec.js +++ b/test/spec/features/modeling/MoveConnectionSpec.js @@ -11,16 +11,19 @@ var modelingModule = require('../../../../lib/features/modeling'), describe('features/modeling - move connection', function() { - var diagramXML = require('../../../fixtures/bpmn/sequence-flows.bpmn'); + describe('should move connection', function() { - var testModules = [ coreModule, modelingModule ]; + var diagramXML = require('../../../fixtures/bpmn/sequence-flows.bpmn'); - beforeEach(bootstrapModeler(diagramXML, { modules: testModules })); + beforeEach(bootstrapModeler(diagramXML, { + modules: [ + coreModule, + modelingModule + ] + })); - describe('connection handling', function() { - - it('should execute', inject(function(elementRegistry, modeling, bpmnFactory) { + it('execute', inject(function(elementRegistry, modeling, bpmnFactory) { // given var sequenceFlowConnection = elementRegistry.get('SequenceFlow_1'), @@ -47,12 +50,8 @@ describe('features/modeling - move connection', function() { expect(sequenceFlow.di.waypoint).eql(diWaypoints); })); - }); - - describe('undo support', function() { - - it('should undo', inject(function(elementRegistry, commandStack, modeling) { + it('undo', inject(function(elementRegistry, commandStack, modeling) { // given var sequenceFlowConnection = elementRegistry.get('SequenceFlow_1'), @@ -71,12 +70,8 @@ describe('features/modeling - move connection', function() { expect(sequenceFlow.di.waypoint).eql(oldDiWaypoints); })); - }); - - describe('redo support', function() { - - it('should redo', inject(function(elementRegistry, commandStack, modeling) { + it('redo', inject(function(elementRegistry, commandStack, modeling) { // given var sequenceFlowConnection = elementRegistry.get('SequenceFlow_1'), @@ -97,5 +92,4 @@ describe('features/modeling - move connection', function() { })); }); - }); diff --git a/test/spec/features/modeling/MoveElements.boundary-connection.bpmn b/test/spec/features/modeling/MoveElements.boundary-connection.bpmn new file mode 100644 index 00000000..ae017724 --- /dev/null +++ b/test/spec/features/modeling/MoveElements.boundary-connection.bpmn @@ -0,0 +1,49 @@ + + + + + Task_Flow + + + Task_Flow + Boundary_Flow + + + + Boundary_Flow + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/spec/features/modeling/MoveElementsSpec.js b/test/spec/features/modeling/MoveElementsSpec.js index f9682d42..469f6076 100644 --- a/test/spec/features/modeling/MoveElementsSpec.js +++ b/test/spec/features/modeling/MoveElementsSpec.js @@ -11,15 +11,18 @@ var modelingModule = require('../../../../lib/features/modeling'), describe('features/modeling - move elements', function() { - var diagramXML = require('./MoveElements.flow-collaboration.bpmn'); - - var testModules = [ coreModule, modelingModule ]; - - beforeEach(bootstrapModeler(diagramXML, { modules: testModules })); - - describe('should keep flow parent', function() { + var diagramXML = require('./MoveElements.flow-collaboration.bpmn'); + + beforeEach(bootstrapModeler(diagramXML, { + modules: [ + coreModule, + modelingModule + ] + })); + + it('when moving shapes', inject(function(elementRegistry, modeling, bpmnFactory) { // given @@ -67,4 +70,67 @@ describe('features/modeling - move elements', function() { }); + + describe('should move boundary connection with tasks', function() { + + var diagramXML = require('./MoveElements.boundary-connection.bpmn'); + + beforeEach(bootstrapModeler(diagramXML, { + modules: [ + coreModule, + modelingModule + ] + })); + + + it('should properly adjust connection', inject(function(elementRegistry, modeling) { + + // given + var elements = [ + elementRegistry.get('Task_1'), + elementRegistry.get('Task_2'), + elementRegistry.get('BoundaryEvent') + ]; + + var boundaryFlow = elementRegistry.get('Boundary_Flow'); + + var delta = { x: 0, y: 20 }; + + var expectedWaypoints = moveWaypoints(boundaryFlow.waypoints, delta); + + // when + modeling.moveElements(elements, delta); + + // then + expect(boundaryFlow).to.have.waypoints(expectedWaypoints); + })); + + }); + }); + + +///////// helpers ///////////////////////////////// + +function moveWaypoint(p, delta) { + return { + x: p.x + delta.x || 0, + y: p.y + delta.y || 0 + }; +} + +function moveWaypoints(waypoints, delta) { + + return waypoints.map(function(p) { + + var original = p.original; + + var moved = moveWaypoint(p, delta); + + if (original) { + moved.original = moveWaypoint(original, delta); + } + + return moved; + }); +} \ No newline at end of file