2014-08-28 14:17:55 +00:00
|
|
|
'use strict';
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
require('../../../TestHelper');
|
2014-08-28 14:17:55 +00:00
|
|
|
|
|
|
|
/* global bootstrapModeler, inject */
|
|
|
|
|
|
|
|
|
|
|
|
var modelingModule = require('../../../../lib/features/modeling'),
|
2014-10-30 11:06:43 +00:00
|
|
|
coreModule = require('../../../../lib/core');
|
2014-08-28 14:17:55 +00:00
|
|
|
|
|
|
|
|
|
|
|
describe('features/modeling - move connection', function() {
|
|
|
|
|
2015-03-31 12:17:15 +00:00
|
|
|
var diagramXML = require('../../../fixtures/bpmn/sequence-flows.bpmn');
|
2014-08-28 14:17:55 +00:00
|
|
|
|
2014-10-30 11:06:43 +00:00
|
|
|
var testModules = [ coreModule, modelingModule ];
|
2014-08-28 14:17:55 +00:00
|
|
|
|
|
|
|
beforeEach(bootstrapModeler(diagramXML, { modules: testModules }));
|
|
|
|
|
|
|
|
|
|
|
|
describe('connection handling', function() {
|
|
|
|
|
2015-07-15 15:22:19 +00:00
|
|
|
it('should execute', inject(function(elementRegistry, modeling, bpmnFactory) {
|
2014-08-28 14:17:55 +00:00
|
|
|
|
|
|
|
// given
|
2014-11-17 16:36:22 +00:00
|
|
|
var sequenceFlowConnection = elementRegistry.get('SequenceFlow_1'),
|
2014-08-28 14:17:55 +00:00
|
|
|
sequenceFlow = sequenceFlowConnection.businessObject;
|
|
|
|
|
|
|
|
// when
|
|
|
|
modeling.moveConnection(sequenceFlowConnection, { x: 20, y: 10 });
|
|
|
|
|
2016-06-26 21:42:11 +00:00
|
|
|
var expectedWaypoints = [
|
2016-06-07 06:46:45 +00:00
|
|
|
{ x: 598, y: 351 },
|
|
|
|
{ x: 954, y: 351 },
|
|
|
|
{ x: 954, y: 446 },
|
|
|
|
{ x: 852, y: 446 }
|
2015-07-15 15:22:19 +00:00
|
|
|
];
|
|
|
|
|
2014-08-28 14:17:55 +00:00
|
|
|
// then
|
|
|
|
|
|
|
|
// expect cropped connection
|
2016-06-26 21:42:11 +00:00
|
|
|
expect(sequenceFlowConnection).to.have.waypoints(expectedWaypoints);
|
2014-08-28 14:17:55 +00:00
|
|
|
|
|
|
|
// expect cropped waypoints in di
|
2016-06-26 21:42:11 +00:00
|
|
|
var diWaypoints = bpmnFactory.createDiWaypoints(expectedWaypoints);
|
2015-07-15 15:22:19 +00:00
|
|
|
|
|
|
|
expect(sequenceFlow.di.waypoint).eql(diWaypoints);
|
2014-08-28 14:17:55 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
describe('undo support', function() {
|
|
|
|
|
|
|
|
it('should undo', inject(function(elementRegistry, commandStack, modeling) {
|
|
|
|
|
|
|
|
// given
|
2014-11-17 16:36:22 +00:00
|
|
|
var sequenceFlowConnection = elementRegistry.get('SequenceFlow_1'),
|
2014-08-28 14:17:55 +00: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 15:22:19 +00:00
|
|
|
expect(sequenceFlowConnection.waypoints).eql(oldWaypoints);
|
|
|
|
expect(sequenceFlow.di.waypoint).eql(oldDiWaypoints);
|
2014-08-28 14:17:55 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
describe('redo support', function() {
|
|
|
|
|
|
|
|
it('should redo', inject(function(elementRegistry, commandStack, modeling) {
|
|
|
|
|
|
|
|
// given
|
2014-11-17 16:36:22 +00:00
|
|
|
var sequenceFlowConnection = elementRegistry.get('SequenceFlow_1'),
|
2014-08-28 14:17:55 +00: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 15:22:19 +00:00
|
|
|
expect(sequenceFlowConnection.waypoints).eql(newWaypoints);
|
|
|
|
expect(sequenceFlow.di.waypoint).eql(newDiWaypoints);
|
2014-08-28 14:17:55 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2014-10-27 11:07:57 +00:00
|
|
|
});
|