2018-04-02 21:01:53 +02:00
|
|
|
import {
|
|
|
|
bootstrapModeler,
|
|
|
|
inject
|
|
|
|
} from 'test/TestHelper';
|
2014-08-28 16:17:55 +02:00
|
|
|
|
2018-04-02 21:01:53 +02:00
|
|
|
import modelingModule from 'lib/features/modeling';
|
|
|
|
import coreModule from 'lib/core';
|
2014-08-28 16:17:55 +02:00
|
|
|
|
|
|
|
|
|
|
|
describe('features/modeling - move connection', function() {
|
|
|
|
|
2017-12-14 15:38:46 +01:00
|
|
|
describe('should move connection', function() {
|
2014-08-28 16:17:55 +02:00
|
|
|
|
2017-12-14 15:38:46 +01:00
|
|
|
var diagramXML = require('../../../fixtures/bpmn/sequence-flows.bpmn');
|
2014-08-28 16:17:55 +02:00
|
|
|
|
2017-12-14 15:38:46 +01:00
|
|
|
beforeEach(bootstrapModeler(diagramXML, {
|
|
|
|
modules: [
|
|
|
|
coreModule,
|
|
|
|
modelingModule
|
|
|
|
]
|
|
|
|
}));
|
2014-08-28 16:17:55 +02:00
|
|
|
|
|
|
|
|
2017-12-14 15:38:46 +01:00
|
|
|
it('execute', inject(function(elementRegistry, modeling, bpmnFactory) {
|
2014-08-28 16:17:55 +02:00
|
|
|
|
|
|
|
// given
|
2014-11-17 17:36:22 +01:00
|
|
|
var sequenceFlowConnection = elementRegistry.get('SequenceFlow_1'),
|
2014-08-28 16:17:55 +02:00
|
|
|
sequenceFlow = sequenceFlowConnection.businessObject;
|
|
|
|
|
|
|
|
// when
|
|
|
|
modeling.moveConnection(sequenceFlowConnection, { x: 20, y: 10 });
|
|
|
|
|
2016-06-26 23:42:11 +02:00
|
|
|
var expectedWaypoints = [
|
2016-06-07 08:46:45 +02:00
|
|
|
{ x: 598, y: 351 },
|
|
|
|
{ x: 954, y: 351 },
|
|
|
|
{ x: 954, y: 446 },
|
|
|
|
{ x: 852, y: 446 }
|
2015-07-15 17:22:19 +02:00
|
|
|
];
|
|
|
|
|
2014-08-28 16:17:55 +02:00
|
|
|
// then
|
|
|
|
|
|
|
|
// expect cropped connection
|
2016-06-26 23:42:11 +02:00
|
|
|
expect(sequenceFlowConnection).to.have.waypoints(expectedWaypoints);
|
2014-08-28 16:17:55 +02:00
|
|
|
|
|
|
|
// expect cropped waypoints in di
|
2016-06-26 23:42:11 +02:00
|
|
|
var diWaypoints = bpmnFactory.createDiWaypoints(expectedWaypoints);
|
2015-07-15 17:22:19 +02:00
|
|
|
|
|
|
|
expect(sequenceFlow.di.waypoint).eql(diWaypoints);
|
2014-08-28 16:17:55 +02:00
|
|
|
}));
|
|
|
|
|
|
|
|
|
2017-12-14 15:38:46 +01:00
|
|
|
it('undo', inject(function(elementRegistry, commandStack, modeling) {
|
2014-08-28 16:17:55 +02:00
|
|
|
|
|
|
|
// given
|
2014-11-17 17:36:22 +01:00
|
|
|
var sequenceFlowConnection = elementRegistry.get('SequenceFlow_1'),
|
2014-08-28 16:17:55 +02:00
|
|
|
sequenceFlow = sequenceFlowConnection.businessObject;
|
|
|
|
|
|
|
|
var oldWaypoints = sequenceFlowConnection.waypoints,
|
|
|
|
oldDiWaypoints = sequenceFlow.di.waypoint;
|
|
|
|
|
|
|
|
modeling.moveConnection(sequenceFlowConnection, { x: 20, y: 10 });
|
|
|
|
|
|
|
|
// when
|
|
|
|
commandStack.undo();
|
|
|
|
|
|
|
|
// then
|
2015-07-15 17:22:19 +02:00
|
|
|
expect(sequenceFlowConnection.waypoints).eql(oldWaypoints);
|
|
|
|
expect(sequenceFlow.di.waypoint).eql(oldDiWaypoints);
|
2014-08-28 16:17:55 +02:00
|
|
|
}));
|
|
|
|
|
|
|
|
|
2017-12-14 15:38:46 +01:00
|
|
|
it('redo', inject(function(elementRegistry, commandStack, modeling) {
|
2014-08-28 16:17:55 +02:00
|
|
|
|
|
|
|
// given
|
2014-11-17 17:36:22 +01:00
|
|
|
var sequenceFlowConnection = elementRegistry.get('SequenceFlow_1'),
|
2014-08-28 16:17:55 +02:00
|
|
|
sequenceFlow = sequenceFlowConnection.businessObject;
|
|
|
|
|
|
|
|
modeling.moveConnection(sequenceFlowConnection, { x: 20, y: 10 });
|
|
|
|
|
|
|
|
var newWaypoints = sequenceFlowConnection.waypoints,
|
|
|
|
newDiWaypoints = sequenceFlow.di.waypoint;
|
|
|
|
|
|
|
|
// when
|
|
|
|
commandStack.undo();
|
|
|
|
commandStack.redo();
|
|
|
|
|
|
|
|
// then
|
2015-07-15 17:22:19 +02:00
|
|
|
expect(sequenceFlowConnection.waypoints).eql(newWaypoints);
|
|
|
|
expect(sequenceFlow.di.waypoint).eql(newDiWaypoints);
|
2014-08-28 16:17:55 +02:00
|
|
|
}));
|
|
|
|
|
|
|
|
});
|
2014-10-27 12:07:57 +01:00
|
|
|
});
|