2014-07-30 14:06:32 +00:00
|
|
|
'use strict';
|
|
|
|
|
2015-07-29 13:11:54 +00:00
|
|
|
var TestHelper = require('../../../../TestHelper');
|
2014-07-30 14:06:32 +00:00
|
|
|
|
2014-08-05 06:17:22 +00:00
|
|
|
/* global bootstrapModeler, inject */
|
2014-07-30 14:06:32 +00:00
|
|
|
|
|
|
|
|
2015-07-29 13:11:54 +00:00
|
|
|
var modelingModule = require('../../../../../lib/features/modeling'),
|
|
|
|
coreModule = require('../../../../../lib/core');
|
2014-07-30 14:06:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
describe('features/modeling - layout connection', function() {
|
|
|
|
|
2015-07-29 13:11:54 +00:00
|
|
|
var diagramXML = require('../../../../fixtures/bpmn/sequence-flows.bpmn');
|
2014-07-30 14:06:32 +00:00
|
|
|
|
2014-10-30 11:06:43 +00:00
|
|
|
var testModules = [ coreModule, modelingModule ];
|
2014-07-30 14:06:32 +00:00
|
|
|
|
2014-08-05 06:17:22 +00:00
|
|
|
beforeEach(bootstrapModeler(diagramXML, { modules: testModules }));
|
2014-07-30 14:06:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
describe('connection handling', function() {
|
|
|
|
|
2015-07-15 15:22:19 +00:00
|
|
|
it('should execute', inject(function(elementRegistry, modeling, bpmnFactory) {
|
2014-07-30 14:06:32 +00:00
|
|
|
|
|
|
|
// given
|
2014-11-17 16:36:22 +00:00
|
|
|
var sequenceFlowConnection = elementRegistry.get('SequenceFlow_1'),
|
2014-07-30 14:06:32 +00:00
|
|
|
sequenceFlow = sequenceFlowConnection.businessObject;
|
|
|
|
|
|
|
|
// when
|
|
|
|
modeling.layoutConnection(sequenceFlowConnection);
|
|
|
|
|
|
|
|
// then
|
|
|
|
|
2014-09-04 11:47:11 +00:00
|
|
|
// expect cropped, repaired connection
|
2015-04-22 07:08:38 +00:00
|
|
|
// that was not actually modified
|
2015-08-24 09:28:54 +00:00
|
|
|
|
2015-07-15 15:22:19 +00:00
|
|
|
var waypoints = [
|
2015-04-22 07:08:38 +00:00
|
|
|
{ original: { x: 578, y: 341 }, x: 578, y: 341 },
|
2014-09-04 11:47:11 +00:00
|
|
|
{ x: 934, y: 341 },
|
|
|
|
{ x: 934, y: 436 },
|
|
|
|
{ original: { x: 832, y: 436 }, x: 832, y: 436 }
|
2015-07-15 15:22:19 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
expect(sequenceFlowConnection.waypoints).eql(waypoints);
|
2014-07-30 14:06:32 +00:00
|
|
|
|
|
|
|
// expect cropped waypoints in di
|
2015-07-15 15:22:19 +00:00
|
|
|
var diWaypoints = bpmnFactory.createDiWaypoints(waypoints);
|
|
|
|
|
|
|
|
expect(sequenceFlow.di.waypoint).eql(diWaypoints);
|
2014-07-30 14:06:32 +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-07-30 14:06:32 +00:00
|
|
|
sequenceFlow = sequenceFlowConnection.businessObject;
|
|
|
|
|
|
|
|
var oldWaypoints = sequenceFlowConnection.waypoints,
|
|
|
|
oldDiWaypoints = sequenceFlow.di.waypoint;
|
|
|
|
|
|
|
|
modeling.layoutConnection(sequenceFlowConnection);
|
|
|
|
|
|
|
|
// when
|
|
|
|
commandStack.undo();
|
|
|
|
|
|
|
|
// then
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(sequenceFlowConnection.waypoints).eql(oldWaypoints);
|
|
|
|
expect(sequenceFlow.di.waypoint).eql(oldDiWaypoints);
|
2014-07-30 14:06:32 +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-07-30 14:06:32 +00:00
|
|
|
sequenceFlow = sequenceFlowConnection.businessObject;
|
|
|
|
|
|
|
|
modeling.layoutConnection(sequenceFlowConnection);
|
|
|
|
|
|
|
|
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-07-30 14:06:32 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2015-07-15 15:22:19 +00:00
|
|
|
});
|