2017-01-25 16:27:30 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
require('../../../../TestHelper');
|
|
|
|
|
|
|
|
/* global inject, bootstrapModeler */
|
|
|
|
|
|
|
|
var flatten = require('lodash/array/flatten');
|
|
|
|
|
2018-01-24 10:41:21 +00:00
|
|
|
var coreModule = require('lib/core'),
|
2017-01-25 16:27:30 +00:00
|
|
|
moveModule = require('diagram-js/lib/features/move'),
|
2018-01-24 10:41:21 +00:00
|
|
|
modelingModule = require('lib/features/modeling'),
|
2017-01-25 16:27:30 +00:00
|
|
|
noTouchInteractionModule = { touchInteractionEvents: ['value', null ] };
|
|
|
|
|
|
|
|
var canvasEvent = require('../../../../util/MockEvents').createCanvasEvent;
|
|
|
|
|
|
|
|
describe('modeling/behavior - drop on connection', function() {
|
|
|
|
|
|
|
|
var diagramXML = require('./DropOnFlowBehavior.bpmn');
|
|
|
|
|
|
|
|
var testModules = [ noTouchInteractionModule, moveModule, modelingModule, coreModule ];
|
|
|
|
|
|
|
|
beforeEach(bootstrapModeler(diagramXML, { modules: testModules }));
|
|
|
|
|
|
|
|
|
|
|
|
describe('rules', function() {
|
|
|
|
|
|
|
|
it('should be allowed for an IntermediateThrowEvent', inject(function(elementRegistry, bpmnRules, elementFactory) {
|
|
|
|
|
|
|
|
// when
|
2017-03-10 09:38:29 +00:00
|
|
|
var sequenceFlow = elementRegistry.get('SequenceFlow_1');
|
2017-01-25 16:27:30 +00:00
|
|
|
var intermediateThrowEvent = elementFactory.createShape({ type: 'bpmn:IntermediateThrowEvent' });
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(bpmnRules.canCreate(intermediateThrowEvent, sequenceFlow)).to.be.true;
|
|
|
|
}));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
describe('execution', function() {
|
|
|
|
|
|
|
|
describe('create', function() {
|
|
|
|
|
|
|
|
it('should connect start -> target -> end', inject(function(modeling, elementRegistry, elementFactory) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var intermediateThrowEvent = elementFactory.createShape({ type: 'bpmn:IntermediateThrowEvent' });
|
|
|
|
|
|
|
|
var startEvent = elementRegistry.get('StartEvent'),
|
2017-03-10 09:38:29 +00:00
|
|
|
sequenceFlow = elementRegistry.get('SequenceFlow_1'),
|
|
|
|
task = elementRegistry.get('Task_1');
|
2017-01-25 16:27:30 +00:00
|
|
|
|
|
|
|
var originalWaypoints = sequenceFlow.waypoints;
|
|
|
|
|
|
|
|
var dropPosition = { x: 340, y: 120 }; // first bendpoint
|
|
|
|
|
|
|
|
// when
|
|
|
|
var newShape = modeling.createShape(intermediateThrowEvent, dropPosition, sequenceFlow);
|
|
|
|
|
|
|
|
// then
|
|
|
|
|
|
|
|
var targetConnection = newShape.outgoing[0];
|
|
|
|
|
|
|
|
// new incoming connection
|
|
|
|
expect(newShape.incoming.length).to.equal(1);
|
|
|
|
expect(newShape.incoming[0]).to.eql(sequenceFlow);
|
|
|
|
|
|
|
|
// new outgoing connection
|
|
|
|
expect(newShape.outgoing.length).to.equal(1);
|
|
|
|
expect(targetConnection).to.be.ok;
|
|
|
|
expect(targetConnection.type).to.equal('bpmn:SequenceFlow');
|
|
|
|
|
|
|
|
expect(startEvent.outgoing[0]).to.equal(newShape.incoming[0]);
|
|
|
|
expect(task.incoming[0]).to.equal(newShape.outgoing[0]);
|
|
|
|
|
|
|
|
// split target at insertion point
|
|
|
|
expect(sequenceFlow).to.have.waypoints(flatten([
|
|
|
|
originalWaypoints.slice(0, 1),
|
|
|
|
{ x: 322, y: 120 }
|
|
|
|
]));
|
|
|
|
|
|
|
|
expect(sequenceFlow).to.have.endDocking(dropPosition);
|
|
|
|
|
|
|
|
expect(targetConnection).to.have.waypoints(flatten([
|
|
|
|
{ x: 340, y: 138 },
|
|
|
|
originalWaypoints.slice(2)
|
|
|
|
]));
|
|
|
|
|
|
|
|
expect(targetConnection).to.have.startDocking(dropPosition);
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('should connect start -> target', inject(function(modeling, elementRegistry, elementFactory) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var endEventShape = elementFactory.createShape({ type: 'bpmn:EndEvent' });
|
|
|
|
|
2017-03-10 09:38:29 +00:00
|
|
|
var sequenceFlow = elementRegistry.get('SequenceFlow_1');
|
2017-01-25 16:27:30 +00:00
|
|
|
var originalWaypoints = sequenceFlow.waypoints;
|
|
|
|
|
|
|
|
var dropPosition = { x: 340, y: 120 }; // first bendpoint
|
|
|
|
|
|
|
|
// when
|
|
|
|
var newShape = modeling.createShape(endEventShape, dropPosition, sequenceFlow);
|
|
|
|
|
|
|
|
// then
|
|
|
|
|
|
|
|
// new incoming connection
|
|
|
|
expect(newShape.incoming.length).to.equal(1);
|
|
|
|
expect(newShape.incoming[0]).to.eql(sequenceFlow);
|
|
|
|
|
|
|
|
// no outgoing edges
|
|
|
|
expect(newShape.outgoing.length).to.equal(0);
|
|
|
|
|
|
|
|
// split target at insertion point
|
|
|
|
expect(sequenceFlow).to.have.waypoints(flatten([
|
|
|
|
originalWaypoints.slice(0, 1),
|
|
|
|
{ x: 322, y: 120 }
|
|
|
|
]));
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('should connect target -> end', inject(function(modeling, elementRegistry, elementFactory) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var startEventShape = elementFactory.createShape({ type: 'bpmn:StartEvent' });
|
|
|
|
|
2017-03-10 09:38:29 +00:00
|
|
|
var sequenceFlow = elementRegistry.get('SequenceFlow_1');
|
2017-01-25 16:27:30 +00:00
|
|
|
var originalWaypoints = sequenceFlow.waypoints;
|
|
|
|
|
|
|
|
var dropPosition = { x: 340, y: 120 }; // first bendpoint
|
|
|
|
|
|
|
|
// when
|
|
|
|
var newShape = modeling.createShape(startEventShape, dropPosition, sequenceFlow);
|
|
|
|
|
|
|
|
// then
|
|
|
|
|
|
|
|
// no incoming connection
|
|
|
|
expect(newShape.incoming.length).to.equal(0);
|
|
|
|
|
|
|
|
// no outgoing edges
|
|
|
|
expect(newShape.outgoing.length).to.equal(1);
|
|
|
|
expect(newShape.outgoing[0]).to.eql(sequenceFlow);
|
|
|
|
|
|
|
|
// split target at insertion point
|
|
|
|
expect(sequenceFlow).to.have.waypoints(flatten([
|
|
|
|
{ x: 340, y: 138 },
|
|
|
|
originalWaypoints.slice(2)
|
|
|
|
]));
|
|
|
|
}));
|
|
|
|
|
2017-07-24 13:07:44 +00:00
|
|
|
|
2018-01-05 13:32:52 +00:00
|
|
|
it('should connect start -> target -> end (with bendpointBefore inside bbox)', inject(
|
|
|
|
function(modeling, elementRegistry, elementFactory) {
|
2017-07-24 13:07:44 +00:00
|
|
|
// given
|
|
|
|
var taskShape = elementFactory.createShape({ type: 'bpmn:Task' }),
|
|
|
|
sequenceFlow = elementRegistry.get('SequenceFlow_1'),
|
|
|
|
originalWaypoints = sequenceFlow.waypoints,
|
|
|
|
dropPosition = { x: 340, y: 145 }; // 25 pixels below bendpoint
|
|
|
|
|
|
|
|
// when
|
|
|
|
modeling.createShape(taskShape, dropPosition, sequenceFlow);
|
|
|
|
|
|
|
|
// then
|
|
|
|
// split target but don't keep insertion point
|
|
|
|
expect(sequenceFlow).to.have.waypoints(flatten([
|
|
|
|
originalWaypoints.slice(0, 1),
|
|
|
|
{ x: 290, y: 120 }
|
|
|
|
]));
|
|
|
|
|
|
|
|
expect(sequenceFlow).to.have.endDocking({ x: 340, y: 120 });
|
|
|
|
}
|
|
|
|
));
|
|
|
|
|
|
|
|
|
2018-01-05 13:32:52 +00:00
|
|
|
it('should connect start -> target -> end (with bendpointAfter inside bbox)', inject(
|
|
|
|
function(modeling, elementRegistry, elementFactory) {
|
2017-07-24 13:07:44 +00:00
|
|
|
|
2018-01-05 13:32:52 +00:00
|
|
|
// given
|
2017-07-24 13:07:44 +00:00
|
|
|
var taskShape = elementFactory.createShape({ type: 'bpmn:Task' }),
|
|
|
|
sequenceFlow = elementRegistry.get('SequenceFlow_1'),
|
|
|
|
originalWaypoints = sequenceFlow.waypoints,
|
|
|
|
dropPosition = { x: 340, y: 280 }; // 25 pixels above bendpoint
|
|
|
|
|
|
|
|
// when
|
|
|
|
var newShape = modeling.createShape(taskShape, dropPosition, sequenceFlow),
|
|
|
|
targetConnection = newShape.outgoing[0];
|
|
|
|
|
|
|
|
// then
|
|
|
|
// split target but don't keep insertion point
|
|
|
|
expect(targetConnection).to.have.waypoints(flatten([
|
|
|
|
{ x: 390, y: 299 },
|
|
|
|
originalWaypoints.slice(3)
|
|
|
|
]));
|
|
|
|
|
|
|
|
expect(targetConnection).to.have.startDocking({ x: 340, y: 299 });
|
|
|
|
}
|
|
|
|
));
|
|
|
|
|
2017-01-25 16:27:30 +00:00
|
|
|
});
|
|
|
|
|
2018-01-05 13:32:52 +00:00
|
|
|
|
2017-01-25 16:27:30 +00:00
|
|
|
describe('move', function() {
|
|
|
|
|
|
|
|
beforeEach(inject(function(dragging) {
|
|
|
|
dragging.setOptions({ manual: true });
|
|
|
|
}));
|
|
|
|
|
|
|
|
it('should connect start -> target -> end', inject(function(dragging, move, elementRegistry, selection) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var intermediateThrowEvent = elementRegistry.get('IntermediateThrowEvent_foo');
|
|
|
|
|
|
|
|
var startEvent = elementRegistry.get('StartEvent'),
|
2017-03-10 09:38:29 +00:00
|
|
|
sequenceFlow = elementRegistry.get('SequenceFlow_1'),
|
2017-01-25 16:27:30 +00:00
|
|
|
sequenceFlowGfx = elementRegistry.getGraphics(sequenceFlow),
|
2017-03-10 09:38:29 +00:00
|
|
|
task = elementRegistry.get('Task_1');
|
2017-01-25 16:27:30 +00:00
|
|
|
|
|
|
|
var originalWaypoints = sequenceFlow.waypoints;
|
|
|
|
|
|
|
|
// when
|
|
|
|
selection.select(intermediateThrowEvent);
|
|
|
|
|
|
|
|
move.start(canvasEvent({ x: 0, y: 0 }), intermediateThrowEvent);
|
|
|
|
|
|
|
|
dragging.hover({
|
|
|
|
element: sequenceFlow,
|
|
|
|
gfx: sequenceFlowGfx
|
|
|
|
});
|
|
|
|
|
|
|
|
dragging.move(canvasEvent({ x: 150, y: 0 }));
|
|
|
|
|
|
|
|
dragging.end();
|
|
|
|
|
|
|
|
// then
|
|
|
|
var targetConnection = intermediateThrowEvent.outgoing[0];
|
|
|
|
|
|
|
|
// new incoming connection
|
|
|
|
expect(intermediateThrowEvent.incoming.length).to.equal(1);
|
|
|
|
expect(intermediateThrowEvent.incoming[0]).to.eql(sequenceFlow);
|
|
|
|
|
|
|
|
// new outgoing connection
|
|
|
|
expect(intermediateThrowEvent.outgoing.length).to.equal(1);
|
|
|
|
expect(targetConnection).to.be.ok;
|
|
|
|
expect(targetConnection.type).to.equal('bpmn:SequenceFlow');
|
|
|
|
|
|
|
|
expect(startEvent.outgoing[0]).to.equal(intermediateThrowEvent.incoming[0]);
|
|
|
|
expect(task.incoming[0]).to.equal(intermediateThrowEvent.outgoing[0]);
|
|
|
|
|
|
|
|
// split target at insertion point
|
|
|
|
expect(sequenceFlow).to.have.waypoints(flatten([
|
|
|
|
originalWaypoints.slice(0, 2),
|
|
|
|
{ x: 341, y: 192 }
|
|
|
|
]));
|
|
|
|
|
|
|
|
expect(sequenceFlow).to.have.endDocking({ x: 341, y: 210 });
|
|
|
|
|
|
|
|
expect(targetConnection).to.have.waypoints(flatten([
|
|
|
|
{ x: 341, y: 228 },
|
|
|
|
originalWaypoints.slice(2)
|
|
|
|
]));
|
|
|
|
|
|
|
|
expect(targetConnection).to.have.startDocking({ x: 341, y: 210 });
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
2018-01-05 13:32:52 +00:00
|
|
|
it('should connect start -> target -> end (hovering parent)', inject(
|
|
|
|
function(dragging, move, elementRegistry, selection, canvas) {
|
2017-07-27 11:40:21 +00:00
|
|
|
|
|
|
|
// given
|
|
|
|
var intermediateThrowEvent = elementRegistry.get('IntermediateThrowEvent_foo');
|
|
|
|
|
|
|
|
var startEvent = elementRegistry.get('StartEvent'),
|
|
|
|
sequenceFlow = elementRegistry.get('SequenceFlow_1'),
|
|
|
|
task = elementRegistry.get('Task_1'),
|
|
|
|
rootElement = canvas.getRootElement(),
|
|
|
|
rootElementGfx = elementRegistry.getGraphics(rootElement);
|
|
|
|
|
|
|
|
var originalWaypoints = sequenceFlow.waypoints;
|
|
|
|
|
|
|
|
// when
|
|
|
|
selection.select(intermediateThrowEvent);
|
|
|
|
|
|
|
|
move.start(canvasEvent({ x: 0, y: 0 }), intermediateThrowEvent);
|
|
|
|
|
|
|
|
dragging.hover({
|
|
|
|
element: rootElement,
|
|
|
|
gfx: rootElementGfx
|
|
|
|
});
|
|
|
|
|
|
|
|
dragging.move(canvasEvent({ x: 150, y: 0 }));
|
|
|
|
dragging.end();
|
|
|
|
|
|
|
|
// then
|
|
|
|
var targetConnection = intermediateThrowEvent.outgoing[0];
|
|
|
|
|
|
|
|
// new incoming connection
|
|
|
|
expect(intermediateThrowEvent.incoming.length).to.equal(1);
|
|
|
|
expect(intermediateThrowEvent.incoming[0]).to.eql(sequenceFlow);
|
|
|
|
|
|
|
|
// new outgoing connection
|
|
|
|
expect(intermediateThrowEvent.outgoing.length).to.equal(1);
|
|
|
|
expect(targetConnection).to.be.ok;
|
|
|
|
expect(targetConnection.type).to.equal('bpmn:SequenceFlow');
|
|
|
|
|
|
|
|
expect(startEvent.outgoing[0]).to.equal(intermediateThrowEvent.incoming[0]);
|
|
|
|
expect(task.incoming[0]).to.equal(intermediateThrowEvent.outgoing[0]);
|
|
|
|
|
|
|
|
// split target at insertion point
|
|
|
|
expect(sequenceFlow).to.have.waypoints(flatten([
|
|
|
|
originalWaypoints.slice(0, 2),
|
|
|
|
{ x: 341, y: 192 }
|
|
|
|
]));
|
|
|
|
|
|
|
|
expect(sequenceFlow).to.have.endDocking({ x: 341, y: 210 });
|
|
|
|
|
|
|
|
expect(targetConnection).to.have.waypoints(flatten([
|
|
|
|
{ x: 341, y: 228 },
|
|
|
|
originalWaypoints.slice(2)
|
|
|
|
]));
|
|
|
|
|
|
|
|
expect(targetConnection).to.have.startDocking({ x: 341, y: 210 });
|
|
|
|
}
|
|
|
|
));
|
|
|
|
|
|
|
|
|
2018-01-05 13:32:52 +00:00
|
|
|
it('should connect start -> target -> end (with bendpointBefore inside bbox)', inject(
|
|
|
|
function(elementRegistry, selection, move, dragging) {
|
2017-07-27 11:40:21 +00:00
|
|
|
// given
|
|
|
|
var task3 = elementRegistry.get('Task_3'),
|
|
|
|
sequenceFlow = elementRegistry.get('SequenceFlow_1'),
|
|
|
|
sequenceFlowGfx = elementRegistry.getGraphics(sequenceFlow),
|
|
|
|
originalWaypoints = sequenceFlow.waypoints;
|
|
|
|
|
|
|
|
// when
|
|
|
|
selection.select(task3);
|
|
|
|
|
|
|
|
move.start(canvasEvent({ x: 0, y: 0 }), task3);
|
|
|
|
|
|
|
|
dragging.hover({
|
|
|
|
element: sequenceFlow,
|
|
|
|
gfx: sequenceFlowGfx
|
|
|
|
});
|
|
|
|
|
|
|
|
dragging.move(canvasEvent({ x: 150, y: -130 }));
|
|
|
|
dragging.end();
|
|
|
|
|
|
|
|
// then
|
|
|
|
// split target but don't keep insertion point
|
|
|
|
expect(sequenceFlow).to.have.waypoints(flatten([
|
|
|
|
originalWaypoints.slice(0, 2),
|
|
|
|
{ x: 341, y: 241 }
|
|
|
|
]));
|
|
|
|
|
|
|
|
expect(sequenceFlow).to.have.endDocking({ x: 341, y: 281 });
|
|
|
|
}
|
|
|
|
));
|
|
|
|
|
|
|
|
|
2018-01-05 13:32:52 +00:00
|
|
|
it('should connect start -> target -> end (with bendpointAfter inside bbox)', inject(
|
|
|
|
function(elementRegistry, selection, move, dragging) {
|
2017-07-27 11:40:21 +00:00
|
|
|
// given
|
|
|
|
var task3 = elementRegistry.get('Task_3'),
|
|
|
|
sequenceFlow = elementRegistry.get('SequenceFlow_1'),
|
|
|
|
sequenceFlowGfx = elementRegistry.getGraphics(sequenceFlow),
|
|
|
|
originalWaypoints = sequenceFlow.waypoints;
|
|
|
|
|
|
|
|
// when
|
|
|
|
selection.select(task3);
|
|
|
|
|
|
|
|
move.start(canvasEvent({ x: 0, y: 0 }), task3);
|
|
|
|
|
|
|
|
dragging.hover({
|
|
|
|
element: sequenceFlow,
|
|
|
|
gfx: sequenceFlowGfx
|
|
|
|
});
|
|
|
|
|
|
|
|
dragging.move(canvasEvent({ x: 170, y: -110 }));
|
|
|
|
dragging.end();
|
|
|
|
|
|
|
|
// then
|
|
|
|
// split target but don't keep insertion point
|
|
|
|
expect(sequenceFlow).to.have.waypoints(flatten([
|
|
|
|
originalWaypoints.slice(0, 2),
|
|
|
|
{ x: 340, y: 261 }
|
|
|
|
]));
|
|
|
|
|
|
|
|
expect(sequenceFlow).to.have.endDocking({ x: 340, y: 299 });
|
|
|
|
}
|
|
|
|
));
|
|
|
|
|
|
|
|
|
2018-01-05 13:32:52 +00:00
|
|
|
it('should connect start -> target', inject(
|
|
|
|
function(modeling, elementRegistry, selection, move, dragging) {
|
2017-01-25 16:27:30 +00:00
|
|
|
|
2018-01-05 13:32:52 +00:00
|
|
|
// given
|
|
|
|
var endEventShape = elementRegistry.get('EndEvent_foo');
|
2017-01-25 16:27:30 +00:00
|
|
|
|
2018-01-05 13:32:52 +00:00
|
|
|
var sequenceFlow = elementRegistry.get('SequenceFlow_1'),
|
|
|
|
sequenceFlowGfx = elementRegistry.getGraphics(sequenceFlow),
|
|
|
|
originalWaypoints = sequenceFlow.waypoints;
|
2017-01-25 16:27:30 +00:00
|
|
|
|
2018-01-05 13:32:52 +00:00
|
|
|
// when
|
|
|
|
selection.select(endEventShape);
|
2017-01-25 16:27:30 +00:00
|
|
|
|
2018-01-05 13:32:52 +00:00
|
|
|
move.start(canvasEvent({ x: 0, y: 0 }), endEventShape);
|
2017-01-25 16:27:30 +00:00
|
|
|
|
2018-01-05 13:32:52 +00:00
|
|
|
dragging.hover({
|
|
|
|
element: sequenceFlow,
|
|
|
|
gfx: sequenceFlowGfx
|
|
|
|
});
|
2017-01-25 16:27:30 +00:00
|
|
|
|
2018-01-05 13:32:52 +00:00
|
|
|
dragging.move(canvasEvent({ x: 150, y: 0 }));
|
2017-01-25 16:27:30 +00:00
|
|
|
|
2018-01-05 13:32:52 +00:00
|
|
|
dragging.end();
|
2017-01-25 16:27:30 +00:00
|
|
|
|
2018-01-05 13:32:52 +00:00
|
|
|
// then
|
2017-01-25 16:27:30 +00:00
|
|
|
|
2018-01-05 13:32:52 +00:00
|
|
|
// new incoming connection
|
|
|
|
expect(endEventShape.incoming.length).to.equal(1);
|
|
|
|
expect(endEventShape.incoming[0]).to.eql(sequenceFlow);
|
2017-01-25 16:27:30 +00:00
|
|
|
|
2018-01-05 13:32:52 +00:00
|
|
|
// no outgoing edges
|
|
|
|
expect(endEventShape.outgoing.length).to.equal(0);
|
2017-01-25 16:27:30 +00:00
|
|
|
|
2018-01-05 13:32:52 +00:00
|
|
|
// split target at insertion point
|
|
|
|
expect(sequenceFlow).to.have.waypoints(flatten([
|
|
|
|
originalWaypoints.slice(0, 2),
|
|
|
|
{ x: 340, y: 281 }
|
|
|
|
]));
|
|
|
|
}
|
|
|
|
));
|
2017-01-25 16:27:30 +00:00
|
|
|
|
|
|
|
|
2018-01-05 13:32:52 +00:00
|
|
|
it('should connect target -> end', inject(
|
|
|
|
function(modeling, elementRegistry, dragging, selection, move) {
|
2017-01-25 16:27:30 +00:00
|
|
|
|
2018-01-05 13:32:52 +00:00
|
|
|
var startEventShape = elementRegistry.get('StartEvent_foo');
|
2017-01-25 16:27:30 +00:00
|
|
|
|
2018-01-05 13:32:52 +00:00
|
|
|
var sequenceFlow = elementRegistry.get('SequenceFlow_1'),
|
|
|
|
sequenceFlowGfx = elementRegistry.getGraphics(sequenceFlow),
|
|
|
|
originalWaypoints = sequenceFlow.waypoints;
|
2017-01-25 16:27:30 +00:00
|
|
|
|
2018-01-05 13:32:52 +00:00
|
|
|
// when
|
|
|
|
selection.select(startEventShape);
|
2017-01-25 16:27:30 +00:00
|
|
|
|
2018-01-05 13:32:52 +00:00
|
|
|
move.start(canvasEvent({ x: 0, y: 0 }), startEventShape);
|
2017-01-25 16:27:30 +00:00
|
|
|
|
2018-01-05 13:32:52 +00:00
|
|
|
dragging.hover({
|
|
|
|
element: sequenceFlow,
|
|
|
|
gfx: sequenceFlowGfx
|
|
|
|
});
|
2017-01-25 16:27:30 +00:00
|
|
|
|
2018-01-05 13:32:52 +00:00
|
|
|
dragging.move(canvasEvent({ x: -215, y: 0 }));
|
2017-01-25 16:27:30 +00:00
|
|
|
|
2018-01-05 13:32:52 +00:00
|
|
|
dragging.end();
|
2017-01-25 16:27:30 +00:00
|
|
|
|
2018-01-05 13:32:52 +00:00
|
|
|
// then
|
2017-01-25 16:27:30 +00:00
|
|
|
|
2018-01-05 13:32:52 +00:00
|
|
|
// no incoming connection
|
|
|
|
expect(startEventShape.incoming.length).to.equal(0);
|
2017-01-25 16:27:30 +00:00
|
|
|
|
2018-01-05 13:32:52 +00:00
|
|
|
// 1 outgoing connection
|
|
|
|
expect(startEventShape.outgoing.length).to.equal(1);
|
|
|
|
expect(startEventShape.outgoing[0]).to.eql(sequenceFlow);
|
2017-01-25 16:27:30 +00:00
|
|
|
|
2018-01-05 13:32:52 +00:00
|
|
|
// split target at insertion point
|
|
|
|
expect(sequenceFlow).to.have.waypoints(flatten([
|
|
|
|
{ x: 338, y: 228 },
|
|
|
|
originalWaypoints.slice(2)
|
|
|
|
]));
|
|
|
|
}
|
|
|
|
));
|
2017-01-25 16:27:30 +00:00
|
|
|
|
2017-03-01 10:25:33 +00:00
|
|
|
|
2018-01-05 13:32:52 +00:00
|
|
|
it('should undo', inject(
|
|
|
|
function(modeling, elementRegistry, dragging, selection, move, commandStack) {
|
2017-03-01 10:25:33 +00:00
|
|
|
|
|
|
|
// given
|
|
|
|
var startEventShape = elementRegistry.get('StartEvent_foo');
|
|
|
|
|
2017-03-10 09:38:29 +00:00
|
|
|
var sequenceFlow = elementRegistry.get('SequenceFlow_1'),
|
2017-03-01 10:25:33 +00:00
|
|
|
sequenceFlowGfx = elementRegistry.getGraphics(sequenceFlow),
|
|
|
|
originalWaypoints = sequenceFlow.waypoints;
|
|
|
|
|
|
|
|
selection.select(startEventShape);
|
|
|
|
|
|
|
|
move.start(canvasEvent({ x: 0, y: 0 }), startEventShape);
|
|
|
|
|
|
|
|
dragging.hover({
|
|
|
|
element: sequenceFlow,
|
|
|
|
gfx: sequenceFlowGfx
|
|
|
|
});
|
|
|
|
|
|
|
|
dragging.move(canvasEvent({ x: -215, y: 0 }));
|
|
|
|
|
|
|
|
dragging.end();
|
|
|
|
|
|
|
|
// when
|
|
|
|
commandStack.undo();
|
|
|
|
|
|
|
|
// then
|
|
|
|
|
|
|
|
// no incoming connection
|
|
|
|
expect(startEventShape.incoming.length).to.equal(0);
|
|
|
|
|
|
|
|
// no outgoing edges
|
|
|
|
expect(startEventShape.outgoing.length).to.equal(0);
|
|
|
|
|
|
|
|
// split target at insertion point
|
|
|
|
expect(sequenceFlow).to.have.waypoints(flatten([ originalWaypoints ]));
|
2018-01-05 13:32:52 +00:00
|
|
|
}
|
|
|
|
));
|
2017-03-01 10:25:33 +00:00
|
|
|
|
2017-01-25 16:27:30 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
describe('rules', function() {
|
|
|
|
|
2018-01-05 13:32:52 +00:00
|
|
|
it('should not insert participant', inject(
|
|
|
|
function(rules, elementRegistry, elementFactory) {
|
2017-01-25 16:27:30 +00:00
|
|
|
|
2018-01-05 13:32:52 +00:00
|
|
|
// given
|
|
|
|
var participantShape = elementFactory.createShape({ type: 'bpmn:Participant' });
|
2017-01-25 16:27:30 +00:00
|
|
|
|
2018-01-05 13:32:52 +00:00
|
|
|
var sequenceFlow = elementRegistry.get('SequenceFlow_1');
|
2017-01-25 16:27:30 +00:00
|
|
|
|
2018-01-05 13:32:52 +00:00
|
|
|
var dropPosition = { x: 340, y: 120 }; // first bendpoint
|
2017-01-25 16:27:30 +00:00
|
|
|
|
2018-01-05 13:32:52 +00:00
|
|
|
// when
|
|
|
|
var canDrop = rules.allowed('shape.create', {
|
|
|
|
shape: participantShape,
|
|
|
|
parent: sequenceFlow,
|
|
|
|
dropPosition: dropPosition
|
|
|
|
});
|
2017-01-25 16:27:30 +00:00
|
|
|
|
2018-01-05 13:32:52 +00:00
|
|
|
// then
|
|
|
|
expect(canDrop).to.be.false;
|
|
|
|
}
|
|
|
|
));
|
2017-01-25 16:27:30 +00:00
|
|
|
|
|
|
|
|
2018-01-05 13:32:52 +00:00
|
|
|
it('should not insert multiple with "move"', inject(
|
|
|
|
function(elementRegistry, selection, move, dragging) {
|
2017-01-25 16:27:30 +00:00
|
|
|
|
2018-01-05 13:32:52 +00:00
|
|
|
// given
|
|
|
|
var intermediateThrowEvent = elementRegistry.get('IntermediateThrowEvent_foo'),
|
|
|
|
endEventShape = elementRegistry.get('EndEvent_foo');
|
2017-01-25 16:27:30 +00:00
|
|
|
|
2018-01-05 13:32:52 +00:00
|
|
|
var sequenceFlow = elementRegistry.get('SequenceFlow_1'),
|
|
|
|
sequenceFlowGfx = elementRegistry.getGraphics(sequenceFlow);
|
2017-01-25 16:27:30 +00:00
|
|
|
|
2018-01-05 13:32:52 +00:00
|
|
|
var intInitPosition = {
|
|
|
|
x: intermediateThrowEvent.x,
|
|
|
|
y: intermediateThrowEvent.y
|
|
|
|
},
|
|
|
|
endInitPosition = {
|
|
|
|
x: endEventShape.x,
|
|
|
|
y: endEventShape.y
|
|
|
|
};
|
2017-01-25 16:27:30 +00:00
|
|
|
|
2018-01-05 13:32:52 +00:00
|
|
|
selection.select([ intermediateThrowEvent, endEventShape ]);
|
2017-01-25 16:27:30 +00:00
|
|
|
|
2018-01-05 13:32:52 +00:00
|
|
|
// when
|
|
|
|
move.start(canvasEvent({ x: 0, y: 0 }), intermediateThrowEvent);
|
2017-01-25 16:27:30 +00:00
|
|
|
|
2018-01-05 13:32:52 +00:00
|
|
|
dragging.hover({
|
|
|
|
element: sequenceFlow,
|
|
|
|
gfx: sequenceFlowGfx
|
|
|
|
});
|
2017-01-25 16:27:30 +00:00
|
|
|
|
2018-01-05 13:32:52 +00:00
|
|
|
dragging.move(canvasEvent({ x: -215, y: 0 }));
|
2017-01-25 16:27:30 +00:00
|
|
|
|
2018-01-05 13:32:52 +00:00
|
|
|
dragging.end();
|
2017-01-25 16:27:30 +00:00
|
|
|
|
2018-01-05 13:32:52 +00:00
|
|
|
// then
|
|
|
|
expect(intermediateThrowEvent).to.have.position(intInitPosition);
|
|
|
|
expect(endEventShape).to.have.position(endInitPosition);
|
|
|
|
}
|
|
|
|
));
|
2017-01-25 16:27:30 +00:00
|
|
|
|
2017-03-10 09:38:29 +00:00
|
|
|
|
|
|
|
it('should not insert on sequence flow label', inject(function(bpmnRules, elementRegistry) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var eventShape = elementRegistry.get('IntermediateThrowEvent_foo'),
|
|
|
|
sequenceFlowLabel = elementRegistry.get('SequenceFlow_2').label;
|
|
|
|
|
|
|
|
var dropPosition = { x: 675, y: 275 }; // sequence flow label
|
|
|
|
|
|
|
|
// when
|
|
|
|
var canInsert = bpmnRules.canInsert(eventShape, sequenceFlowLabel, dropPosition);
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(canInsert).to.be.false;
|
|
|
|
}));
|
2018-01-05 13:32:52 +00:00
|
|
|
|
2017-01-25 16:27:30 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
});
|