test(modeling): verify correct connection parent on move

Related to #525
This commit is contained in:
Nico Rehwaldt 2016-07-05 08:23:51 +02:00
parent 8a483284de
commit 83f0343512
2 changed files with 115 additions and 0 deletions

View File

@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn">
<bpmn:collaboration id="Collaboration">
<bpmn:participant id="Pool_A" name="Pool A" processRef="Process_1" />
<bpmn:participant id="Pool_B" name="Pool B" processRef="Process_2" />
</bpmn:collaboration>
<bpmn:process id="Process_1" isExecutable="false">
<bpmn:sequenceFlow id="SequenceFlow" sourceRef="Task_B" targetRef="Task_A" />
<bpmn:task id="Task_A" name="Task A">
<bpmn:incoming>SequenceFlow</bpmn:incoming>
</bpmn:task>
<bpmn:task id="Task_B" name="Task_B">
<bpmn:outgoing>SequenceFlow</bpmn:outgoing>
</bpmn:task>
</bpmn:process>
<bpmn:process id="Process_2">
<bpmn:task id="Task_C" name="Task C" />
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Collaboration">
<bpmndi:BPMNShape id="Pool_A_di" bpmnElement="Pool_A">
<dc:Bounds x="193" y="76" width="536" height="173" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Task_B_di" bpmnElement="Task_B">
<dc:Bounds x="353" y="117" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Task_A_di" bpmnElement="Task_A">
<dc:Bounds x="537" y="117" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_di" bpmnElement="SequenceFlow">
<di:waypoint xsi:type="dc:Point" x="453" y="157" />
<di:waypoint xsi:type="dc:Point" x="537" y="157" />
<bpmndi:BPMNLabel>
<dc:Bounds x="450" y="132" width="90" height="20" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="Pool_B_di" bpmnElement="Pool_B">
<dc:Bounds x="193" y="311" width="534" height="178" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Task_C_di" bpmnElement="Task_C">
<dc:Bounds x="341" y="365" width="100" height="80" />
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>

View File

@ -0,0 +1,70 @@
'use strict';
require('../../../TestHelper');
/* global bootstrapModeler, inject */
var modelingModule = require('../../../../lib/features/modeling'),
coreModule = require('../../../../lib/core');
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() {
it('when moving shapes', inject(function(elementRegistry, modeling, bpmnFactory) {
// given
var connectionSequenceFlow = elementRegistry.get('SequenceFlow'),
shapeTask_A = elementRegistry.get('Task_A'),
shapeTask_B = elementRegistry.get('Task_B'),
shapeTask_C = elementRegistry.get('Task_C'),
shapePool_A = elementRegistry.get('Pool_A'),
shapePool_B = elementRegistry.get('Pool_B');
// when
modeling.moveElements(
[ shapeTask_A, shapeTask_B, shapeTask_C ],
{ x: 0, y: -50 },
shapePool_B,
{ primaryShape: shapeTask_C }
);
// then
expect(connectionSequenceFlow.parent).to.eql(shapePool_A);
}));
it('when moving shapes with flow', inject(function(elementRegistry, modeling, bpmnFactory) {
// given
var connectionSequenceFlow = elementRegistry.get('SequenceFlow'),
shapeTask_A = elementRegistry.get('Task_A'),
shapeTask_B = elementRegistry.get('Task_B'),
shapeTask_C = elementRegistry.get('Task_C'),
shapePool_A = elementRegistry.get('Pool_A'),
shapePool_B = elementRegistry.get('Pool_B');
// when
modeling.moveElements(
[ shapeTask_A, shapeTask_B, shapeTask_C, connectionSequenceFlow ],
{ x: 0, y: -50 },
shapePool_B,
{ primaryShape: shapeTask_C }
);
// then
expect(connectionSequenceFlow.parent).to.eql(shapePool_A);
}));
});
});