fix(bpmn-rules): correctly evaluate waypoints update rule

Closes #1048
This commit is contained in:
Maciej Barelkowski 2019-05-27 16:13:38 +02:00 committed by merge-me[bot]
parent 3a0f044d9e
commit ba5bf31e42
2 changed files with 59 additions and 2 deletions

View File

@ -104,8 +104,9 @@ BpmnRules.prototype.init = function() {
}); });
this.addRule('connection.updateWaypoints', function(context) { this.addRule('connection.updateWaypoints', function(context) {
// OK! but visually ignore return {
return null; type: context.connection.type
};
}); });
this.addRule('shape.resize', function(context) { this.addRule('shape.resize', function(context) {

View File

@ -334,6 +334,62 @@ describe('features/modeling - layout connection', function() {
expect(task1.incoming[0].waypoints).to.deep.eql(waypointsPreview); expect(task1.incoming[0].waypoints).to.deep.eql(waypointsPreview);
}) })
); );
it('should correctly lay out connection preview on inserted bendpoint move',
inject(function(bendpointMove, dragging, elementRegistry) {
// given
var task2 = elementRegistry.get('Task_2'),
sequenceFlow1 = elementRegistry.get('SequenceFlow_1');
// when
bendpointMove.start(canvasEvent({ x: 700, y: 341 }), sequenceFlow1, 1, true);
dragging.move(canvasEvent({ x: 700, y: 400 }));
var ctx = dragging.context();
var context = ctx.data.context;
var connectionPreview = context.getConnection(context.allowed);
var waypointsPreview = connectionPreview.waypoints.slice();
dragging.end();
// then
expect(task2.incoming[0]).to.exist;
expect(task2.incoming[0].waypoints).to.deep.eql(waypointsPreview);
})
);
it('should correctly lay out connection preview on existing bendpoint move',
inject(function(bendpointMove, dragging, elementRegistry) {
// given
var task2 = elementRegistry.get('Task_2'),
sequenceFlow1 = elementRegistry.get('SequenceFlow_1');
// when
bendpointMove.start(canvasEvent({ x: 934, y: 341 }), sequenceFlow1, 1);
dragging.move(canvasEvent({ x: 960, y: 340 }));
var ctx = dragging.context();
var context = ctx.data.context;
var connectionPreview = context.getConnection(context.allowed);
var waypointsPreview = connectionPreview.waypoints.slice();
dragging.end();
// then
expect(task2.incoming[0]).to.exist;
expect(task2.incoming[0].waypoints).to.deep.eql(waypointsPreview);
})
);
}); });
}); });