fix(drop-on-flow): don't insert on accidentally found intersection

Related to camunda/camunda-modeler#727
This commit is contained in:
Philipp Fromme 2018-02-14 13:36:30 +01:00 committed by Nico Rehwaldt
parent 607866d6ef
commit f5afc732fe
2 changed files with 45 additions and 16 deletions

View File

@ -50,6 +50,11 @@ function DropOnFlow(eventBus, bpmnRules, modeling) {
waypointsBefore = waypoints.slice(0, intersection.index);
waypointsAfter = waypoints.slice(intersection.index + (intersection.bendpoint ? 1 : 0));
// due to inaccuracy intersection might have been found
if (!waypointsBefore.length || !waypointsAfter.length) {
return;
}
dockingPoint = intersection.bendpoint ? waypoints[intersection.index] : position;
// if last waypointBefore is inside shape's bounds, ignore docking point

View File

@ -22,21 +22,6 @@ describe('modeling/behavior - drop on connection', function() {
beforeEach(bootstrapModeler(diagramXML, { modules: testModules }));
describe('rules', function() {
it('should be allowed for an IntermediateThrowEvent', inject(function(elementRegistry, bpmnRules, elementFactory) {
// when
var sequenceFlow = elementRegistry.get('SequenceFlow_1');
var intermediateThrowEvent = elementFactory.createShape({ type: 'bpmn:IntermediateThrowEvent' });
// then
expect(bpmnRules.canCreate(intermediateThrowEvent, sequenceFlow)).to.be.true;
}));
});
describe('execution', function() {
describe('create', function() {
@ -512,6 +497,34 @@ describe('modeling/behavior - drop on connection', function() {
}
));
it('should not insert on inaccuratly found intersection', inject(function(dragging, move, elementRegistry, selection) {
// given
var intermediateThrowEvent = elementRegistry.get('IntermediateThrowEvent_foo');
var sequenceFlow = elementRegistry.get('SequenceFlow_1'),
sequenceFlowGfx = elementRegistry.getGraphics(sequenceFlow);
// when
selection.select(intermediateThrowEvent);
move.start(canvasEvent({ x: 0, y: 0 }), intermediateThrowEvent);
dragging.hover({
element: sequenceFlow,
gfx: sequenceFlowGfx
});
dragging.move(canvasEvent({ x: 20, y: -90 }));
dragging.end();
// then
expect(intermediateThrowEvent.incoming).to.have.lengthOf(0);
expect(intermediateThrowEvent.outgoing).to.have.lengthOf(0);
}));
});
});
@ -519,6 +532,17 @@ describe('modeling/behavior - drop on connection', function() {
describe('rules', function() {
it('should be allowed for an IntermediateThrowEvent', inject(function(elementRegistry, bpmnRules, elementFactory) {
// when
var sequenceFlow = elementRegistry.get('SequenceFlow_1');
var intermediateThrowEvent = elementFactory.createShape({ type: 'bpmn:IntermediateThrowEvent' });
// then
expect(bpmnRules.canCreate(intermediateThrowEvent, sequenceFlow)).to.be.true;
}));
it('should not insert participant', inject(
function(rules, elementRegistry, elementFactory) {