Skip to content

Commit

Permalink
test(modeling): ensure layout is done after element removal
Browse files Browse the repository at this point in the history
Closes #940
  • Loading branch information
barmac committed Apr 9, 2019
1 parent 0e2bba0 commit 1a84f8f
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.0.1">
<bpmn:process id="Process_1" isExecutable="false">
<bpmn:startEvent id="StartEvent1">
<bpmn:outgoing>SequenceFlow1</bpmn:outgoing>
</bpmn:startEvent>
<bpmn:task id="Task1">
<bpmn:incoming>SequenceFlow1</bpmn:incoming>
<bpmn:outgoing>SequenceFlow2</bpmn:outgoing>
</bpmn:task>
<bpmn:sequenceFlow id="SequenceFlow1" sourceRef="StartEvent1" targetRef="Task1" />
<bpmn:endEvent id="EndEvent1">
<bpmn:incoming>SequenceFlow2</bpmn:incoming>
</bpmn:endEvent>
<bpmn:sequenceFlow id="SequenceFlow2" sourceRef="Task1" targetRef="EndEvent1" />
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1">
<bpmndi:BPMNShape id="StartEvent1_di" bpmnElement="StartEvent1">
<dc:Bounds x="204" y="36" width="36" height="36" />
<bpmndi:BPMNLabel>
<dc:Bounds x="177" y="72" width="90" height="20" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Task1_di" bpmnElement="Task1">
<dc:Bounds x="407" y="73" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow1_di" bpmnElement="SequenceFlow1">
<di:waypoint x="240" y="54" />
<di:waypoint x="324" y="54" />
<di:waypoint x="324" y="113" />
<di:waypoint x="407" y="113" />
<bpmndi:BPMNLabel>
<dc:Bounds x="278.5" y="44" width="90" height="20" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="EndEvent1_di" bpmnElement="EndEvent1">
<dc:Bounds x="650" y="199" width="36" height="36" />
<bpmndi:BPMNLabel>
<dc:Bounds x="622" y="72" width="90" height="20" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow2_di" bpmnElement="SequenceFlow2">
<di:waypoint x="507" y="113" />
<di:waypoint x="579" y="113" />
<di:waypoint x="579" y="217" />
<di:waypoint x="650" y="217" />
<bpmndi:BPMNLabel>
<dc:Bounds x="533" y="44" width="90" height="20" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
38 changes: 38 additions & 0 deletions test/spec/features/modeling/behavior/RemoveElementBehaviorSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,44 @@ describe('features/modeling - remove element behavior', function() {

});


describe('connections layout', function() {

var processDiagramXML = require('./RemoveElementBehavior.diagonal.bpmn');

beforeEach(bootstrapModeler(processDiagramXML, { modules: testModules }));


it('should layout connection', inject(function(modeling, elementRegistry) {

// given
var task = elementRegistry.get('Task1');
var sequenceFlow1 = elementRegistry.get('SequenceFlow1');

// when
modeling.removeShape(task);

// then
var waypoints = sequenceFlow1.waypoints;

// SequenceFlow2 should be deleted
expect(elementRegistry.get('SequenceFlow2')).to.be.undefined;
expect(elementRegistry.get(task.id)).to.be.undefined;

// source and target have one connection each
expect(elementRegistry.get('StartEvent1').outgoing.length).to.be.equal(1);
expect(elementRegistry.get('EndEvent1').incoming.length).to.be.equal(1);

// connection has Manhattan layout
expect(waypoints).to.have.length(4);
expect(waypoints[0].y).to.eql(waypoints[1].y);
expect(waypoints[1].x).to.eql(waypoints[2].x);
expect(waypoints[2].y).to.eql(waypoints[3].y);

}));

});

});


Expand Down

0 comments on commit 1a84f8f

Please sign in to comment.