bpmn-js 0.20.7 → 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,7 +13,6 @@ var coreModule = require('../../../../../lib/core'),
13
13
 
14
14
  var canvasEvent = require('../../../../util/MockEvents').createCanvasEvent;
15
15
 
16
-
17
16
  describe('modeling/behavior - drop on connection', function() {
18
17
 
19
18
  var diagramXML = require('./DropOnFlowBehavior.bpmn');
@@ -150,6 +149,54 @@ describe('modeling/behavior - drop on connection', function() {
150
149
  ]));
151
150
  }));
152
151
 
152
+
153
+ it('should connect start -> target -> end (with bendpointBefore inside bbox)',
154
+ inject(function(modeling, elementRegistry, elementFactory) {
155
+ // given
156
+ var taskShape = elementFactory.createShape({ type: 'bpmn:Task' }),
157
+ sequenceFlow = elementRegistry.get('SequenceFlow_1'),
158
+ originalWaypoints = sequenceFlow.waypoints,
159
+ dropPosition = { x: 340, y: 145 }; // 25 pixels below bendpoint
160
+
161
+ // when
162
+ modeling.createShape(taskShape, dropPosition, sequenceFlow);
163
+
164
+ // then
165
+ // split target but don't keep insertion point
166
+ expect(sequenceFlow).to.have.waypoints(flatten([
167
+ originalWaypoints.slice(0, 1),
168
+ { x: 290, y: 120 }
169
+ ]));
170
+
171
+ expect(sequenceFlow).to.have.endDocking({ x: 340, y: 120 });
172
+ }
173
+ ));
174
+
175
+
176
+ it('should connect start -> target -> end (with bendpointAfter inside bbox)',
177
+ inject(function(modeling, elementRegistry, elementFactory) {
178
+
179
+ // given
180
+ var taskShape = elementFactory.createShape({ type: 'bpmn:Task' }),
181
+ sequenceFlow = elementRegistry.get('SequenceFlow_1'),
182
+ originalWaypoints = sequenceFlow.waypoints,
183
+ dropPosition = { x: 340, y: 280 }; // 25 pixels above bendpoint
184
+
185
+ // when
186
+ var newShape = modeling.createShape(taskShape, dropPosition, sequenceFlow),
187
+ targetConnection = newShape.outgoing[0];
188
+
189
+ // then
190
+ // split target but don't keep insertion point
191
+ expect(targetConnection).to.have.waypoints(flatten([
192
+ { x: 390, y: 299 },
193
+ originalWaypoints.slice(3)
194
+ ]));
195
+
196
+ expect(targetConnection).to.have.startDocking({ x: 340, y: 299 });
197
+ }
198
+ ));
199
+
153
200
  });
154
201
 
155
202
  describe('move', function() {
@@ -216,6 +263,132 @@ describe('modeling/behavior - drop on connection', function() {
216
263
  }));
217
264
 
218
265
 
266
+ it('should connect start -> target -> end (hovering parent)',
267
+ inject(function(dragging, move, elementRegistry, selection, canvas) {
268
+
269
+ // given
270
+ var intermediateThrowEvent = elementRegistry.get('IntermediateThrowEvent_foo');
271
+
272
+ var startEvent = elementRegistry.get('StartEvent'),
273
+ sequenceFlow = elementRegistry.get('SequenceFlow_1'),
274
+ task = elementRegistry.get('Task_1'),
275
+ rootElement = canvas.getRootElement(),
276
+ rootElementGfx = elementRegistry.getGraphics(rootElement);
277
+
278
+ var originalWaypoints = sequenceFlow.waypoints;
279
+
280
+ // when
281
+ selection.select(intermediateThrowEvent);
282
+
283
+ move.start(canvasEvent({ x: 0, y: 0 }), intermediateThrowEvent);
284
+
285
+ dragging.hover({
286
+ element: rootElement,
287
+ gfx: rootElementGfx
288
+ });
289
+
290
+ dragging.move(canvasEvent({ x: 150, y: 0 }));
291
+ dragging.end();
292
+
293
+ // then
294
+ var targetConnection = intermediateThrowEvent.outgoing[0];
295
+
296
+ // new incoming connection
297
+ expect(intermediateThrowEvent.incoming.length).to.equal(1);
298
+ expect(intermediateThrowEvent.incoming[0]).to.eql(sequenceFlow);
299
+
300
+ // new outgoing connection
301
+ expect(intermediateThrowEvent.outgoing.length).to.equal(1);
302
+ expect(targetConnection).to.be.ok;
303
+ expect(targetConnection.type).to.equal('bpmn:SequenceFlow');
304
+
305
+ expect(startEvent.outgoing[0]).to.equal(intermediateThrowEvent.incoming[0]);
306
+ expect(task.incoming[0]).to.equal(intermediateThrowEvent.outgoing[0]);
307
+
308
+ // split target at insertion point
309
+ expect(sequenceFlow).to.have.waypoints(flatten([
310
+ originalWaypoints.slice(0, 2),
311
+ { x: 341, y: 192 }
312
+ ]));
313
+
314
+ expect(sequenceFlow).to.have.endDocking({ x: 341, y: 210 });
315
+
316
+ expect(targetConnection).to.have.waypoints(flatten([
317
+ { x: 341, y: 228 },
318
+ originalWaypoints.slice(2)
319
+ ]));
320
+
321
+ expect(targetConnection).to.have.startDocking({ x: 341, y: 210 });
322
+ }
323
+ ));
324
+
325
+
326
+ it('should connect start -> target -> end (with bendpointBefore inside bbox)',
327
+ inject(function(elementRegistry, selection, move, dragging) {
328
+ // given
329
+ var task3 = elementRegistry.get('Task_3'),
330
+ sequenceFlow = elementRegistry.get('SequenceFlow_1'),
331
+ sequenceFlowGfx = elementRegistry.getGraphics(sequenceFlow),
332
+ originalWaypoints = sequenceFlow.waypoints;
333
+
334
+ // when
335
+ selection.select(task3);
336
+
337
+ move.start(canvasEvent({ x: 0, y: 0 }), task3);
338
+
339
+ dragging.hover({
340
+ element: sequenceFlow,
341
+ gfx: sequenceFlowGfx
342
+ });
343
+
344
+ dragging.move(canvasEvent({ x: 150, y: -130 }));
345
+ dragging.end();
346
+
347
+ // then
348
+ // split target but don't keep insertion point
349
+ expect(sequenceFlow).to.have.waypoints(flatten([
350
+ originalWaypoints.slice(0, 2),
351
+ { x: 341, y: 241 }
352
+ ]));
353
+
354
+ expect(sequenceFlow).to.have.endDocking({ x: 341, y: 281 });
355
+ }
356
+ ));
357
+
358
+
359
+ it('should connect start -> target -> end (with bendpointAfter inside bbox)',
360
+ inject(function(elementRegistry, selection, move, dragging) {
361
+ // given
362
+ var task3 = elementRegistry.get('Task_3'),
363
+ sequenceFlow = elementRegistry.get('SequenceFlow_1'),
364
+ sequenceFlowGfx = elementRegistry.getGraphics(sequenceFlow),
365
+ originalWaypoints = sequenceFlow.waypoints;
366
+
367
+ // when
368
+ selection.select(task3);
369
+
370
+ move.start(canvasEvent({ x: 0, y: 0 }), task3);
371
+
372
+ dragging.hover({
373
+ element: sequenceFlow,
374
+ gfx: sequenceFlowGfx
375
+ });
376
+
377
+ dragging.move(canvasEvent({ x: 170, y: -110 }));
378
+ dragging.end();
379
+
380
+ // then
381
+ // split target but don't keep insertion point
382
+ expect(sequenceFlow).to.have.waypoints(flatten([
383
+ originalWaypoints.slice(0, 2),
384
+ { x: 340, y: 261 }
385
+ ]));
386
+
387
+ expect(sequenceFlow).to.have.endDocking({ x: 340, y: 299 });
388
+ }
389
+ ));
390
+
391
+
219
392
  it('should connect start -> target', inject(function(modeling, elementRegistry, selection, move, dragging) {
220
393
 
221
394
  // given
@@ -0,0 +1,41 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <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="1.9.0-dev">
3
+ <bpmn:process id="Process_1" isExecutable="false">
4
+ <bpmn:startEvent id="StartEvent_1">
5
+ <bpmn:outgoing>SequenceFlow_1</bpmn:outgoing>
6
+ </bpmn:startEvent>
7
+ <bpmn:task id="Task_1">
8
+ <bpmn:incoming>SequenceFlow_1</bpmn:incoming>
9
+ </bpmn:task>
10
+ <bpmn:sequenceFlow id="SequenceFlow_1" sourceRef="StartEvent_1" targetRef="Task_1" />
11
+ <bpmn:task id="Task_099t40a" />
12
+ </bpmn:process>
13
+ <bpmndi:BPMNDiagram id="BPMNDiagram_1">
14
+ <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1">
15
+ <bpmndi:BPMNShape id="StartEvent_1oc4unz_di" bpmnElement="StartEvent_1">
16
+ <dc:Bounds x="70" y="49" width="36" height="36" />
17
+ <bpmndi:BPMNLabel>
18
+ <dc:Bounds x="88" y="88" width="0" height="13" />
19
+ </bpmndi:BPMNLabel>
20
+ </bpmndi:BPMNShape>
21
+ <bpmndi:BPMNShape id="Task_1ndpsyi_di" bpmnElement="Task_1">
22
+ <dc:Bounds x="538" y="405" width="100" height="80" />
23
+ </bpmndi:BPMNShape>
24
+ <bpmndi:BPMNEdge id="SequenceFlow_1mpqh64_di" bpmnElement="SequenceFlow_1">
25
+ <di:waypoint xsi:type="dc:Point" x="106" y="67" />
26
+ <di:waypoint xsi:type="dc:Point" x="191" y="67" />
27
+ <di:waypoint xsi:type="dc:Point" x="191" y="134" />
28
+ <di:waypoint xsi:type="dc:Point" x="304" y="134" />
29
+ <di:waypoint xsi:type="dc:Point" x="304" y="325" />
30
+ <di:waypoint xsi:type="dc:Point" x="588" y="325" />
31
+ <di:waypoint xsi:type="dc:Point" x="588" y="405" />
32
+ <bpmndi:BPMNLabel>
33
+ <dc:Bounds x="247.5" y="112.5" width="0" height="13" />
34
+ </bpmndi:BPMNLabel>
35
+ </bpmndi:BPMNEdge>
36
+ <bpmndi:BPMNShape id="Task_099t40a_di" bpmnElement="Task_099t40a">
37
+ <dc:Bounds x="118" y="405" width="100" height="80" />
38
+ </bpmndi:BPMNShape>
39
+ </bpmndi:BPMNPlane>
40
+ </bpmndi:BPMNDiagram>
41
+ </bpmn:definitions>
@@ -99,6 +99,72 @@ describe('features/snapping - BpmnSnapping', function() {
99
99
  });
100
100
 
101
101
 
102
+ describe('on Sequence Flows', function() {
103
+
104
+ var diagramXML = require('./BpmnSnapping.sequenceFlow.bpmn');
105
+
106
+ beforeEach(bootstrapModeler(diagramXML, {
107
+ modules: testModules
108
+ }));
109
+
110
+ var sequenceFlow, task;
111
+
112
+ beforeEach(inject(function(elementFactory, elementRegistry, dragging) {
113
+ sequenceFlow = elementRegistry.get('SequenceFlow_1');
114
+
115
+ task = elementFactory.createShape({
116
+ type: 'bpmn:Task'
117
+ });
118
+
119
+ dragging.setOptions({ manual: true });
120
+ }));
121
+
122
+ afterEach(inject(function(dragging) {
123
+ dragging.setOptions({ manual: false });
124
+ }));
125
+
126
+
127
+ it('should snap vertically',
128
+ inject(function(canvas, create, dragging) {
129
+
130
+ // given
131
+ var sequenceFlowGfx = canvas.getGraphics(sequenceFlow);
132
+
133
+ // when
134
+ create.start(canvasEvent({ x: 0, y: 0 }), task);
135
+
136
+ dragging.hover({ element: sequenceFlow, gfx: sequenceFlowGfx });
137
+
138
+ dragging.move(canvasEvent({ x: 300, y: 245 }));
139
+ dragging.end();
140
+
141
+ // then
142
+ expect(task.x).to.eql(254);
143
+ })
144
+ );
145
+
146
+
147
+ it('should snap horizontally',
148
+ inject(function(canvas, create, dragging) {
149
+
150
+ // given
151
+ var sequenceFlowGfx = canvas.getGraphics(sequenceFlow);
152
+
153
+ // when
154
+ create.start(canvasEvent({ x: 0, y: 0 }), task);
155
+
156
+ dragging.hover({ element: sequenceFlow, gfx: sequenceFlowGfx });
157
+
158
+ dragging.move(canvasEvent({ x: 410, y: 320 }));
159
+ dragging.end();
160
+
161
+ // then
162
+ expect(task.y).to.eql(285);
163
+ })
164
+ );
165
+ });
166
+
167
+
102
168
  describe('on Participant create', function() {
103
169
 
104
170
  describe('in non-empty process', function() {