2015-10-13 09:07:35 +00:00
|
|
|
'use strict';
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
require('../../../../TestHelper');
|
2015-10-13 09:07:35 +00:00
|
|
|
|
|
|
|
/* global bootstrapModeler, inject */
|
|
|
|
|
2018-01-24 10:41:21 +00:00
|
|
|
var modelingModule = require('lib/features/modeling'),
|
|
|
|
coreModule = require('lib/core');
|
2015-10-13 09:07:35 +00:00
|
|
|
|
2016-06-26 21:42:11 +00:00
|
|
|
|
2015-10-13 09:07:35 +00:00
|
|
|
describe('features/modeling - layout association', function() {
|
|
|
|
|
|
|
|
var diagramXML = require('../../../../fixtures/bpmn/basic.bpmn');
|
|
|
|
|
2016-06-26 21:42:11 +00:00
|
|
|
beforeEach(bootstrapModeler(diagramXML, {
|
|
|
|
modules: [
|
|
|
|
coreModule,
|
|
|
|
modelingModule
|
|
|
|
]
|
|
|
|
}));
|
2015-10-13 09:07:35 +00:00
|
|
|
|
|
|
|
|
2016-06-26 21:42:11 +00:00
|
|
|
var rootShape;
|
2015-10-13 09:07:35 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
beforeEach(inject(function(canvas) {
|
2015-10-13 09:07:35 +00:00
|
|
|
rootShape = canvas.getRootElement();
|
|
|
|
}));
|
|
|
|
|
2016-06-26 21:42:11 +00:00
|
|
|
|
2015-10-13 09:07:35 +00:00
|
|
|
it('should layout straight after TextAnnotation creation', inject(function(elementRegistry, modeling) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var startEventShape = elementRegistry.get('StartEvent_1');
|
|
|
|
|
|
|
|
// when
|
|
|
|
var textAnnotationShape = modeling.createShape({ type: 'bpmn:TextAnnotation' }, { x: 400, y: 400 }, rootShape);
|
|
|
|
|
|
|
|
modeling.connect(textAnnotationShape, startEventShape);
|
|
|
|
|
|
|
|
var waypoints = textAnnotationShape.outgoing[0].waypoints;
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(waypoints).to.eql([
|
2016-12-01 12:17:44 +00:00
|
|
|
{ original: { x: 400, y: 400 }, x: 389, y: 385 },
|
2015-10-13 09:07:35 +00:00
|
|
|
{ original: { x: 191, y: 120 }, x: 202, y: 134 }
|
|
|
|
]);
|
|
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('should layout straight after TextAnnotation move', inject(function(elementRegistry, modeling) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var startEventShape = elementRegistry.get('StartEvent_1'),
|
|
|
|
textAnnotationShape = modeling.createShape({ type: 'bpmn:TextAnnotation' }, { x: 400, y: 400 }, rootShape);
|
|
|
|
|
|
|
|
modeling.connect(textAnnotationShape, startEventShape);
|
|
|
|
|
|
|
|
// when
|
|
|
|
modeling.moveElements([ textAnnotationShape ], { x: 20, y: 0 }, rootShape);
|
|
|
|
|
|
|
|
var waypoints = textAnnotationShape.outgoing[0].waypoints;
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(waypoints).to.eql([
|
2016-12-01 12:17:44 +00:00
|
|
|
{ original: { x: 420, y: 400 }, x: 408, y: 385 },
|
2015-10-13 09:07:35 +00:00
|
|
|
{ original: { x: 191, y: 120 }, x: 202, y: 134 }
|
|
|
|
]);
|
|
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('should retain waypoints after TextAnnotation move', inject(function(elementRegistry, modeling) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var startEventShape = elementRegistry.get('StartEvent_1'),
|
|
|
|
textAnnotationShape = modeling.createShape({ type: 'bpmn:TextAnnotation' }, { x: 400, y: 400 }, rootShape);
|
|
|
|
|
|
|
|
var connection = modeling.connect(textAnnotationShape, startEventShape),
|
|
|
|
waypoints = connection.waypoints;
|
|
|
|
|
|
|
|
// add a waypoint
|
|
|
|
waypoints.splice(1, 0, { x: 400, y: 300 });
|
|
|
|
|
|
|
|
modeling.updateWaypoints(connection, waypoints);
|
|
|
|
|
|
|
|
// when
|
|
|
|
modeling.moveElements([ textAnnotationShape ], { x: 20, y: 0 }, rootShape);
|
|
|
|
|
|
|
|
// then
|
2017-12-13 10:28:14 +00:00
|
|
|
expect(connection).to.have.waypoints([
|
2016-12-01 12:17:44 +00:00
|
|
|
{ original: { x: 420, y: 400 }, x: 417, y: 385 },
|
2015-10-13 09:07:35 +00:00
|
|
|
{ x: 400, y: 300 },
|
2017-12-13 13:05:29 +00:00
|
|
|
{ original: { x: 191, y: 120 }, x: 204, y: 132 }
|
2015-10-13 09:07:35 +00:00
|
|
|
]);
|
|
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
});
|