2015-08-25 09:16:10 +00:00
|
|
|
'use strict';
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
require('../../../TestHelper');
|
2015-08-25 09:16:10 +00:00
|
|
|
|
|
|
|
/* global bootstrapModeler, inject */
|
|
|
|
|
|
|
|
var pick = require('lodash/object/pick'),
|
|
|
|
assign = require('lodash/object/assign');
|
|
|
|
|
|
|
|
var autoResizeModule = require('../../../../lib/features/auto-resize'),
|
|
|
|
modelingModule = require('../../../../lib/features/modeling'),
|
|
|
|
createModule = require('diagram-js/lib/features/create'),
|
2015-09-14 13:14:12 +00:00
|
|
|
coreModule = require('../../../../lib/core'),
|
|
|
|
canvasEvent = require('../../../util/MockEvents').createCanvasEvent;
|
2015-08-25 09:16:10 +00:00
|
|
|
|
|
|
|
function getBounds(shape) {
|
2015-09-15 12:47:16 +00:00
|
|
|
return pick(shape, [ 'x', 'y', 'width', 'height' ]);
|
2015-08-25 09:16:10 +00:00
|
|
|
}
|
|
|
|
|
2015-08-31 13:35:32 +00:00
|
|
|
|
2015-08-25 09:16:10 +00:00
|
|
|
describe('features/auto-resize', function() {
|
|
|
|
|
2015-09-14 13:14:12 +00:00
|
|
|
var testModules = [ coreModule, modelingModule, autoResizeModule, createModule ];
|
2015-08-25 09:16:10 +00:00
|
|
|
|
|
|
|
|
2015-08-31 13:35:32 +00:00
|
|
|
describe('participant', function() {
|
2015-08-25 09:16:10 +00:00
|
|
|
|
2015-08-31 13:35:32 +00:00
|
|
|
var diagramXML = require('./AutoResize.participant.bpmn');
|
2015-08-25 09:16:10 +00:00
|
|
|
|
2016-05-03 12:38:30 +00:00
|
|
|
var taskShape,
|
|
|
|
participantShape,
|
|
|
|
startEventShape,
|
2015-09-02 12:15:45 +00:00
|
|
|
originalBounds;
|
2015-08-25 09:16:10 +00:00
|
|
|
|
2015-08-31 13:35:32 +00:00
|
|
|
beforeEach(bootstrapModeler(diagramXML, { modules: testModules }));
|
2015-08-25 09:16:10 +00:00
|
|
|
|
2015-08-31 13:35:32 +00:00
|
|
|
beforeEach(inject(function(elementRegistry) {
|
2015-08-25 09:16:10 +00:00
|
|
|
|
2016-05-03 12:38:30 +00:00
|
|
|
taskShape = elementRegistry.get('Task_1');
|
|
|
|
participantShape = elementRegistry.get('Participant_1');
|
|
|
|
startEventShape = elementRegistry.get('StartEvent_1');
|
2015-08-25 09:16:10 +00:00
|
|
|
|
2016-05-03 12:38:30 +00:00
|
|
|
originalBounds = getBounds(participantShape);
|
2015-08-25 09:16:10 +00:00
|
|
|
|
2015-09-02 12:15:45 +00:00
|
|
|
expect(originalBounds).to.eql({ x: 247, y: 160, width: 371, height: 178 });
|
2015-08-25 09:16:10 +00:00
|
|
|
|
2015-08-31 13:35:32 +00:00
|
|
|
}));
|
2015-08-25 09:16:10 +00:00
|
|
|
|
|
|
|
|
2015-08-31 13:35:32 +00:00
|
|
|
describe('after moving', function() {
|
2015-08-25 09:16:10 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
it('should expand the right edge', inject(function(modeling) {
|
2015-08-25 09:16:10 +00:00
|
|
|
|
2015-08-31 13:35:32 +00:00
|
|
|
// when
|
2016-05-03 12:38:30 +00:00
|
|
|
modeling.moveElements([ taskShape ], { x: 100, y: 0 }, participantShape);
|
2015-08-25 09:16:10 +00:00
|
|
|
|
2015-08-31 13:35:32 +00:00
|
|
|
// then
|
2015-09-02 12:15:45 +00:00
|
|
|
var expectedBounds = assign(originalBounds, { width: 525 });
|
2015-08-25 09:16:10 +00:00
|
|
|
|
2016-05-03 12:38:30 +00:00
|
|
|
expect(participantShape).to.have.bounds(expectedBounds);
|
2015-08-31 13:35:32 +00:00
|
|
|
}));
|
2015-08-25 09:16:10 +00:00
|
|
|
|
|
|
|
|
2015-09-02 08:37:51 +00:00
|
|
|
it('should expand the top edge', inject(function(modeling) {
|
2015-08-25 09:16:10 +00:00
|
|
|
|
2015-08-31 13:35:32 +00:00
|
|
|
// when
|
2016-05-03 12:38:30 +00:00
|
|
|
modeling.moveElements([ taskShape ], { x: 0, y: -50 }, participantShape);
|
2015-08-25 09:16:10 +00:00
|
|
|
|
2015-08-31 13:35:32 +00:00
|
|
|
// then
|
2015-09-02 12:15:45 +00:00
|
|
|
var expectedBounds = assign(originalBounds, { y: 99, height: 239 });
|
2015-08-25 09:16:10 +00:00
|
|
|
|
2016-05-03 12:38:30 +00:00
|
|
|
expect(participantShape).to.have.bounds(expectedBounds);
|
2015-08-31 13:35:32 +00:00
|
|
|
}));
|
2015-08-25 09:16:10 +00:00
|
|
|
|
|
|
|
|
2015-09-02 08:37:51 +00:00
|
|
|
it('should expand the bottom edge', inject(function(modeling) {
|
2015-08-25 09:16:10 +00:00
|
|
|
|
2015-08-31 13:35:32 +00:00
|
|
|
// when
|
2016-05-03 12:38:30 +00:00
|
|
|
modeling.moveElements([ taskShape ], { x: 0, y: 50 }, participantShape);
|
2015-08-25 09:16:10 +00:00
|
|
|
|
2015-08-31 13:35:32 +00:00
|
|
|
// then
|
2015-09-02 12:15:45 +00:00
|
|
|
var expectedBounds = assign(originalBounds, { height: 239 });
|
2015-08-25 09:16:10 +00:00
|
|
|
|
2016-05-03 12:38:30 +00:00
|
|
|
expect(participantShape).to.have.bounds(expectedBounds);
|
2015-08-31 13:35:32 +00:00
|
|
|
}));
|
2015-08-25 09:16:10 +00:00
|
|
|
|
|
|
|
|
2015-09-02 08:37:51 +00:00
|
|
|
it('should expand the left edge', inject(function(modeling) {
|
2015-08-25 09:16:10 +00:00
|
|
|
|
2015-08-31 13:35:32 +00:00
|
|
|
// when
|
2016-05-03 12:38:30 +00:00
|
|
|
modeling.moveElements([ startEventShape ], { x: -100, y: 0 }, participantShape);
|
2015-08-25 09:16:10 +00:00
|
|
|
|
2015-08-31 13:35:32 +00:00
|
|
|
// then
|
2015-09-02 12:15:45 +00:00
|
|
|
var expectedBounds = assign(originalBounds, { x: 122, width: 496 });
|
2015-08-25 09:16:10 +00:00
|
|
|
|
2016-05-03 12:38:30 +00:00
|
|
|
expect(participantShape).to.have.bounds(expectedBounds);
|
2015-08-31 13:35:32 +00:00
|
|
|
}));
|
2015-08-25 09:16:10 +00:00
|
|
|
|
|
|
|
|
2015-09-02 08:37:51 +00:00
|
|
|
it('should expand the bottom right edges', inject(function(modeling) {
|
2015-08-25 09:16:10 +00:00
|
|
|
|
2015-08-31 13:35:32 +00:00
|
|
|
// when
|
2016-05-03 12:38:30 +00:00
|
|
|
modeling.moveElements([ taskShape ], { x: 50, y: 50 }, participantShape);
|
2015-08-25 09:16:10 +00:00
|
|
|
|
2015-08-31 13:35:32 +00:00
|
|
|
// then
|
2015-09-02 12:15:45 +00:00
|
|
|
var expectedBounds = assign(originalBounds, { width: 475, height: 239 });
|
2015-08-25 09:16:10 +00:00
|
|
|
|
2016-05-03 12:38:30 +00:00
|
|
|
expect(participantShape).to.have.bounds(expectedBounds);
|
2015-08-31 13:35:32 +00:00
|
|
|
}));
|
2015-08-25 09:16:10 +00:00
|
|
|
|
|
|
|
|
2015-09-02 08:37:51 +00:00
|
|
|
it('should expand the top left edges', inject(function(modeling) {
|
2015-08-25 09:16:10 +00:00
|
|
|
|
2015-08-31 13:35:32 +00:00
|
|
|
// when
|
2016-05-03 12:38:30 +00:00
|
|
|
modeling.moveElements([ startEventShape ], { x: -100, y: -100 }, participantShape);
|
2015-08-25 09:16:10 +00:00
|
|
|
|
2015-08-31 13:35:32 +00:00
|
|
|
// then
|
2016-05-03 12:38:30 +00:00
|
|
|
expect(participantShape).to.have.bounds({ x: 122, y: 71, width: 496, height: 267 });
|
2015-08-31 13:35:32 +00:00
|
|
|
}));
|
2015-08-25 09:16:10 +00:00
|
|
|
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
it('should resize the parent on element/parent edge intersect', inject(function(modeling) {
|
2015-09-02 08:37:51 +00:00
|
|
|
|
|
|
|
// when
|
2016-05-03 12:38:30 +00:00
|
|
|
modeling.moveElements([ taskShape ], { x: 0, y: 49 }, participantShape);
|
2015-09-02 08:37:51 +00:00
|
|
|
|
|
|
|
// then
|
2015-09-02 12:15:45 +00:00
|
|
|
var expectedBounds = assign(originalBounds, { height: 238 });
|
2015-09-02 08:37:51 +00:00
|
|
|
|
2016-05-03 12:38:30 +00:00
|
|
|
expect(participantShape).to.have.bounds(expectedBounds);
|
2015-09-02 08:37:51 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
it('should not resize the parent if element is placed near the bottom', inject(function(modeling) {
|
2015-09-02 08:37:51 +00:00
|
|
|
|
|
|
|
// when
|
2016-05-03 12:38:30 +00:00
|
|
|
modeling.moveElements([ taskShape ], { x: 0, y: 47 }, participantShape);
|
2015-09-02 08:37:51 +00:00
|
|
|
|
|
|
|
// then
|
2016-05-03 12:38:30 +00:00
|
|
|
expect(participantShape).to.have.bounds(originalBounds);
|
2015-09-02 08:37:51 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
describe('undo / redo support', function() {
|
2015-08-25 09:16:10 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
it('should undo', inject(function(modeling, commandStack) {
|
2015-08-25 09:16:10 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
modeling.moveElements([ startEventShape ], { x: -100, y: -100 }, participantShape);
|
|
|
|
commandStack.undo();
|
2015-08-25 09:16:10 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// then
|
|
|
|
expect(participantShape).to.have.bounds(originalBounds);
|
|
|
|
}));
|
2015-08-25 09:16:10 +00:00
|
|
|
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
it('should redo', inject(function(modeling, commandStack) {
|
2015-08-25 09:16:10 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
modeling.moveElements([ startEventShape ], { x: -100, y: -100 }, participantShape);
|
|
|
|
commandStack.undo();
|
|
|
|
commandStack.redo();
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(participantShape).to.have.bounds({ x: 122, y: 71, width: 496, height: 267 });
|
|
|
|
}));
|
|
|
|
|
|
|
|
});
|
2015-08-25 09:16:10 +00:00
|
|
|
|
2015-08-31 13:35:32 +00:00
|
|
|
});
|
2015-08-25 09:16:10 +00:00
|
|
|
|
2016-05-03 12:38:30 +00:00
|
|
|
|
2015-09-08 10:01:06 +00:00
|
|
|
describe('after moving multiple elements', function() {
|
|
|
|
|
|
|
|
it('should expand the right edge', inject(function(modeling, selection) {
|
|
|
|
|
|
|
|
// when
|
2016-05-03 12:38:30 +00:00
|
|
|
modeling.moveElements([ taskShape, startEventShape ], { x: 200, y: 0 }, participantShape);
|
2015-09-08 10:01:06 +00:00
|
|
|
|
|
|
|
// then
|
|
|
|
var expectedBounds = assign(originalBounds, { width: 625 });
|
|
|
|
|
2016-05-03 12:38:30 +00:00
|
|
|
expect(participantShape).to.have.bounds(expectedBounds);
|
2015-09-08 10:01:06 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('should expand the bottom edge', inject(function(modeling, selection) {
|
|
|
|
|
|
|
|
// when
|
2016-05-03 12:38:30 +00:00
|
|
|
modeling.moveElements([ taskShape, startEventShape ], { x: 0, y: 48 }, participantShape);
|
2015-09-08 10:01:06 +00:00
|
|
|
|
|
|
|
// then
|
|
|
|
var expectedBounds = assign(originalBounds, { height: 237 });
|
|
|
|
|
2016-05-03 12:38:30 +00:00
|
|
|
expect(participantShape).to.have.bounds(expectedBounds);
|
2015-09-08 10:01:06 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
});
|
2015-08-25 09:16:10 +00:00
|
|
|
|
2015-10-20 08:49:18 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
describe('after appending', function() {
|
2015-08-25 09:16:10 +00:00
|
|
|
|
2015-09-02 08:37:51 +00:00
|
|
|
it('should expand the bottom right edges', inject(function(modeling) {
|
2015-08-31 13:35:32 +00:00
|
|
|
|
|
|
|
// when
|
2016-05-03 12:38:30 +00:00
|
|
|
modeling.appendShape(taskShape, { type: 'bpmn:Task' }, { x: 660, y: 350 }, participantShape);
|
2015-08-31 13:35:32 +00:00
|
|
|
|
|
|
|
// then
|
2015-09-02 12:15:45 +00:00
|
|
|
var expectedBounds = assign(originalBounds, { width: 563, height: 290 });
|
2015-08-31 13:35:32 +00:00
|
|
|
|
2016-05-03 12:38:30 +00:00
|
|
|
expect(participantShape).to.have.bounds(expectedBounds);
|
2015-08-31 13:35:32 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('should undo resizing', inject(function(modeling, commandStack) {
|
2015-09-02 08:37:51 +00:00
|
|
|
|
2015-08-31 13:35:32 +00:00
|
|
|
// given
|
2016-05-03 12:38:30 +00:00
|
|
|
modeling.appendShape(taskShape, { type: 'bpmn:Task' }, { x: 660, y: 250 }, participantShape);
|
2015-08-31 13:35:32 +00:00
|
|
|
|
|
|
|
// when
|
|
|
|
commandStack.undo();
|
|
|
|
|
|
|
|
// then
|
2016-05-03 12:38:30 +00:00
|
|
|
expect(participantShape).to.have.bounds(originalBounds);
|
2015-08-31 13:35:32 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('should redo resizing and restore shapes and connections',
|
|
|
|
inject(function(modeling, commandStack) {
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var taskShape2 = modeling.appendShape(taskShape, { type: 'bpmn:Task' }, { x: 660, y: 250 }, participantShape);
|
2015-08-31 13:35:32 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
commandStack.undo();
|
|
|
|
commandStack.redo();
|
2015-08-25 09:16:10 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// then
|
|
|
|
var expectedBounds = assign(originalBounds, { width: 563 });
|
2015-08-31 13:35:32 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
expect(participantShape).to.have.bounds(expectedBounds);
|
2015-08-31 13:35:32 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
expect(taskShape2).to.exist;
|
|
|
|
expect(taskShape.outgoing).not.to.be.empty;
|
|
|
|
expect(taskShape2.incoming).not.to.be.empty;
|
|
|
|
})
|
|
|
|
);
|
2015-08-31 13:35:32 +00:00
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
it('should not auto-resize when adding lane', inject(function(modeling) {
|
2015-08-25 09:16:10 +00:00
|
|
|
|
|
|
|
// given
|
2015-08-31 13:35:32 +00:00
|
|
|
var laneAttrs = {
|
|
|
|
type: 'bpmn:Lane',
|
|
|
|
width: 341,
|
|
|
|
height: 178
|
|
|
|
};
|
2015-08-25 09:16:10 +00:00
|
|
|
|
|
|
|
// when
|
2016-05-03 12:38:30 +00:00
|
|
|
modeling.createShape(laneAttrs, { x: 280, y: 200 }, participantShape);
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(participantShape).to.have.bounds(originalBounds);
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('should not auto-resize when creating with { root: false } hint', inject(function(modeling) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var taskAttrs = { type: 'bpmn:Task' };
|
|
|
|
|
|
|
|
// when
|
|
|
|
modeling.createShape(taskAttrs, { x: 600, y: 320 }, participantShape, { root: false });
|
2015-08-25 09:16:10 +00:00
|
|
|
|
|
|
|
// then
|
2016-05-03 12:38:30 +00:00
|
|
|
expect(participantShape).to.have.bounds(originalBounds);
|
2015-08-25 09:16:10 +00:00
|
|
|
}));
|
|
|
|
|
2015-08-31 13:35:32 +00:00
|
|
|
});
|
2015-08-25 09:16:10 +00:00
|
|
|
|
2015-10-20 08:49:18 +00:00
|
|
|
|
2015-08-31 13:35:32 +00:00
|
|
|
describe('lane', function() {
|
2015-08-25 09:16:10 +00:00
|
|
|
|
2015-08-31 13:35:32 +00:00
|
|
|
var diagramXML = require('./AutoResize.lanes.bpmn');
|
2015-08-25 09:16:10 +00:00
|
|
|
|
2015-08-31 13:35:32 +00:00
|
|
|
beforeEach(bootstrapModeler(diagramXML, { modules: testModules }));
|
2015-08-25 09:16:10 +00:00
|
|
|
|
|
|
|
|
2015-10-20 08:49:18 +00:00
|
|
|
it('should fit new element', inject(function(elementRegistry, modeling) {
|
2015-08-31 13:35:32 +00:00
|
|
|
|
|
|
|
// given
|
2015-10-20 08:49:18 +00:00
|
|
|
var participantShape = elementRegistry.get('Participant_Lanes');
|
2015-08-31 13:35:32 +00:00
|
|
|
|
|
|
|
// when
|
2015-10-20 08:49:18 +00:00
|
|
|
modeling.createShape({ type: 'bpmn:Task' }, { x: 600, y: 320 }, participantShape);
|
2015-08-25 09:16:10 +00:00
|
|
|
|
2015-08-31 13:35:32 +00:00
|
|
|
// then
|
2016-06-07 06:46:45 +00:00
|
|
|
expect(participantShape).to.have.bounds({ x: 247, y: 160, width: 503, height: 260 });
|
2015-08-25 09:16:10 +00:00
|
|
|
}));
|
|
|
|
|
2015-09-08 10:01:06 +00:00
|
|
|
|
2015-10-20 08:49:18 +00:00
|
|
|
it('should fit multiple moved elements', inject(function(elementRegistry, modeling) {
|
2015-09-08 10:01:06 +00:00
|
|
|
|
|
|
|
// given
|
2015-10-20 08:49:18 +00:00
|
|
|
var participantShape = elementRegistry.get('Participant_Lanes'),
|
2015-09-08 10:01:06 +00:00
|
|
|
taskShape = elementRegistry.get('Task_1'),
|
|
|
|
startEventShape = elementRegistry.get('StartEvent_1');
|
|
|
|
|
2015-10-20 08:49:18 +00:00
|
|
|
var originalBounds = getBounds(participantShape);
|
2015-09-08 10:01:06 +00:00
|
|
|
|
|
|
|
// when
|
2015-10-20 08:49:18 +00:00
|
|
|
modeling.moveElements([ taskShape, startEventShape ], { x: 200, y: 0 }, participantShape);
|
2015-09-08 10:01:06 +00:00
|
|
|
|
|
|
|
// then
|
2015-10-20 08:49:18 +00:00
|
|
|
var expectedBounds = assign(originalBounds, { width: 625 });
|
2015-09-08 10:01:06 +00:00
|
|
|
|
2015-10-20 08:49:18 +00:00
|
|
|
expect(participantShape).to.have.bounds(expectedBounds);
|
2015-09-08 10:01:06 +00:00
|
|
|
}));
|
|
|
|
|
2015-08-25 09:16:10 +00:00
|
|
|
});
|
|
|
|
|
2015-10-20 08:49:18 +00:00
|
|
|
|
2015-09-14 13:14:12 +00:00
|
|
|
describe('sub processes', function() {
|
|
|
|
|
|
|
|
var diagramXML = require('./AutoResize.sub-processes.bpmn');
|
|
|
|
|
|
|
|
beforeEach(bootstrapModeler(diagramXML, { modules: testModules }));
|
|
|
|
|
|
|
|
it('should auto-resize after moving children', inject(function(elementRegistry, modeling) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var subProcessShape = elementRegistry.get('SubProcess_1'),
|
|
|
|
taskShape = elementRegistry.get('Task_1'),
|
|
|
|
startEventShape = elementRegistry.get('StartEvent_1');
|
|
|
|
|
|
|
|
var originalBounds = getBounds(subProcessShape);
|
|
|
|
|
|
|
|
// when
|
|
|
|
modeling.moveElements([ taskShape, startEventShape ], { x: 200, y: 0 }, subProcessShape);
|
|
|
|
|
|
|
|
// then
|
|
|
|
var expectedBounds = assign(originalBounds, { width: 567 });
|
|
|
|
|
|
|
|
expect(subProcessShape).to.have.bounds(expectedBounds);
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('should auto-resize to fit new element', inject(function(elementRegistry, modeling) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var subProcessShape = elementRegistry.get('SubProcess_1');
|
|
|
|
|
|
|
|
var originalBounds = getBounds(subProcessShape);
|
|
|
|
|
|
|
|
// when
|
|
|
|
modeling.createShape({ type: 'bpmn:Task' }, { x: 450, y: 250 }, subProcessShape);
|
|
|
|
|
|
|
|
// then
|
|
|
|
var expectedBounds = assign(originalBounds, { width: 480, height: 298 });
|
|
|
|
|
|
|
|
expect(subProcessShape).to.have.bounds(expectedBounds);
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('should auto-resize after dropping selection inside',
|
|
|
|
inject(function(selection, move, dragging, elementRegistry, modeling) {
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var subProcessShape = elementRegistry.get('SubProcess_1'),
|
|
|
|
taskShape = elementRegistry.get('Task_1'),
|
|
|
|
startEventShape = elementRegistry.get('StartEvent_1');
|
2015-09-14 13:14:12 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
var originalBounds = getBounds(subProcessShape);
|
2015-09-14 13:14:12 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
selection.select([ taskShape, startEventShape ]);
|
2015-09-14 13:14:12 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
move.start(canvasEvent({ x: 265, y: 235 }), startEventShape);
|
2015-09-14 13:14:12 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
dragging.hover({
|
|
|
|
element: subProcessShape,
|
|
|
|
gfx: elementRegistry.getGraphics(subProcessShape)
|
|
|
|
});
|
2015-09-14 13:14:12 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
dragging.move(canvasEvent({ x: 450, y: 235 }));
|
2015-09-14 13:14:12 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
dragging.end();
|
2015-09-14 13:14:12 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// then
|
|
|
|
var expectedBounds = assign(originalBounds, { width: 552 });
|
2015-09-14 13:14:12 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
expect(subProcessShape).to.have.bounds(expectedBounds);
|
|
|
|
})
|
|
|
|
);
|
2015-09-14 13:14:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
it('should not auto-resize after dropping selection outside',
|
|
|
|
inject(function(selection, canvas, move, dragging, elementRegistry, modeling) {
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var subProcessShape = elementRegistry.get('SubProcess_1'),
|
|
|
|
taskShape = elementRegistry.get('Task_1'),
|
|
|
|
startEventShape = elementRegistry.get('StartEvent_1'),
|
|
|
|
rootShape = canvas.getRootElement();
|
2015-09-14 13:14:12 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
var originalBounds = getBounds(subProcessShape);
|
2015-09-14 13:14:12 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
selection.select([ taskShape, startEventShape ]);
|
2015-09-14 13:14:12 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
move.start(canvasEvent({ x: 390, y: 110 }), taskShape);
|
2015-09-14 13:14:12 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
dragging.hover({
|
|
|
|
element: rootShape,
|
|
|
|
gfx: elementRegistry.getGraphics(rootShape)
|
|
|
|
});
|
2015-09-14 13:14:12 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
dragging.move(canvasEvent({ x: 600, y: 110 }));
|
2015-09-14 13:14:12 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
dragging.end();
|
2015-09-14 13:14:12 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// then
|
|
|
|
expect(subProcessShape).to.have.bounds(originalBounds);
|
|
|
|
})
|
|
|
|
);
|
2015-09-14 13:14:12 +00:00
|
|
|
|
|
|
|
});
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
|
2015-09-23 12:58:37 +00:00
|
|
|
describe('after moving multiple elements', function() {
|
|
|
|
|
|
|
|
var diagramXML = require('./AutoResize.multi-selection.bpmn');
|
|
|
|
|
|
|
|
beforeEach(bootstrapModeler(diagramXML, { modules: testModules }));
|
|
|
|
|
|
|
|
var taskShape_1,
|
|
|
|
taskShape_2,
|
|
|
|
subProcessShape_1,
|
|
|
|
rootShape;
|
|
|
|
|
|
|
|
beforeEach(inject(function(elementRegistry, canvas) {
|
|
|
|
taskShape_1 = elementRegistry.get('Task_1');
|
|
|
|
taskShape_2 = elementRegistry.get('Task_2');
|
|
|
|
subProcessShape_1 = elementRegistry.get('SubProcess_1');
|
|
|
|
rootShape = canvas.getRootElement();
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
it('should not expand, if elements keep their parents (different original parents)', inject(function(modeling) {
|
2015-09-23 12:58:37 +00:00
|
|
|
|
|
|
|
// given
|
|
|
|
var originalBounds = getBounds(subProcessShape_1);
|
|
|
|
|
|
|
|
// when
|
|
|
|
modeling.moveElements([ taskShape_1, taskShape_2 ],
|
|
|
|
{ x: -100, y: 0 }, subProcessShape_1, { primaryShape: taskShape_1 });
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(subProcessShape_1).to.have.bounds(originalBounds);
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
it('should expand non-primary parents', inject(function(modeling) {
|
2015-10-22 16:19:06 +00:00
|
|
|
|
|
|
|
// given
|
|
|
|
var originalBounds = getBounds(subProcessShape_1);
|
|
|
|
|
|
|
|
// when
|
|
|
|
modeling.moveElements([ taskShape_1, taskShape_2 ],
|
|
|
|
{ x: 100, y: 0 }, rootShape, { primaryShape: taskShape_2 });
|
|
|
|
|
|
|
|
// then
|
|
|
|
var expectedBounds = assign(originalBounds, { width: 525 });
|
|
|
|
expect(subProcessShape_1).to.have.bounds(expectedBounds);
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
2015-09-23 12:58:37 +00:00
|
|
|
it('should expand, if elements keep their parents (same original parent)', inject(function(modeling) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var originalBounds = getBounds(subProcessShape_1);
|
|
|
|
modeling.moveElements([ taskShape_2 ], { x: -110, y: 135 }, subProcessShape_1);
|
|
|
|
|
|
|
|
// when
|
|
|
|
modeling.moveElements([ taskShape_1, taskShape_2 ],
|
|
|
|
{ x: -110, y: 0 }, subProcessShape_1, { primaryShape: taskShape_1 });
|
|
|
|
|
|
|
|
// then
|
|
|
|
var expectedBounds = assign(originalBounds, { x: 0, width: 444 });
|
|
|
|
expect(subProcessShape_1).to.have.bounds(expectedBounds);
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
it('should expand, if primary shape changes parent', inject(function(modeling) {
|
2015-09-23 12:58:37 +00:00
|
|
|
|
|
|
|
// given
|
|
|
|
var originalBounds = getBounds(subProcessShape_1);
|
|
|
|
|
|
|
|
// when
|
|
|
|
modeling.moveElements([ taskShape_1, taskShape_2 ],
|
|
|
|
{ x: 0, y: 50 }, subProcessShape_1, { primaryShape: taskShape_2 });
|
|
|
|
|
|
|
|
// then
|
|
|
|
var expectedBounds = assign(originalBounds, { y: 80, height: 317 });
|
|
|
|
expect(subProcessShape_1).to.have.bounds(expectedBounds);
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
it('should expand top and bottom edge, if primary shape changes parent', inject(function(modeling) {
|
2015-09-23 13:00:05 +00:00
|
|
|
|
|
|
|
// given
|
|
|
|
var originalBounds = getBounds(subProcessShape_1);
|
|
|
|
|
|
|
|
// when
|
|
|
|
modeling.moveElements([ taskShape_1, taskShape_2 ],
|
|
|
|
{ x: 0, y: 100 }, subProcessShape_1, { primaryShape: taskShape_2 });
|
|
|
|
|
|
|
|
// then
|
|
|
|
var expectedBounds = assign(originalBounds, { y: 130, height: 334 });
|
|
|
|
expect(subProcessShape_1).to.have.bounds(expectedBounds);
|
|
|
|
}));
|
|
|
|
|
2015-09-23 12:58:37 +00:00
|
|
|
});
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
|
2015-09-15 12:47:16 +00:00
|
|
|
describe('nested sub processes', function() {
|
|
|
|
|
|
|
|
var diagramXML = require('./AutoResize.nested-sub-processes.bpmn');
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
beforeEach(bootstrapModeler(diagramXML, {
|
|
|
|
modules: testModules
|
|
|
|
}));
|
|
|
|
|
2015-09-15 12:47:16 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
it('should recursively expand parent element', inject(function(elementRegistry, modeling) {
|
2015-09-15 12:47:16 +00:00
|
|
|
|
|
|
|
var taskShape = elementRegistry.get('Task_1'),
|
|
|
|
subProcessShape_2 = elementRegistry.get('SubProcess_2'),
|
|
|
|
subProcessShape_3 = elementRegistry.get('SubProcess_3');
|
|
|
|
|
|
|
|
var originalBounds = getBounds(subProcessShape_2);
|
|
|
|
|
|
|
|
modeling.moveElements([taskShape], { x: 100, y: 0 }, subProcessShape_3);
|
|
|
|
|
|
|
|
var expectedBounds = assign(originalBounds, { width: 755 });
|
|
|
|
|
|
|
|
expect(subProcessShape_2).to.have.bounds(expectedBounds);
|
|
|
|
}));
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
|
|
|
|
it('should recursively expand last parent element', inject(function(elementRegistry, modeling) {
|
2015-09-15 12:47:16 +00:00
|
|
|
|
|
|
|
var taskShape = elementRegistry.get('Task_1'),
|
|
|
|
subProcessShape_1 = elementRegistry.get('SubProcess_1'),
|
|
|
|
subProcessShape_3 = elementRegistry.get('SubProcess_3');
|
|
|
|
|
|
|
|
var originalBounds = getBounds(subProcessShape_1);
|
|
|
|
|
|
|
|
modeling.moveElements([ taskShape ], { x: 100, y: 0 }, subProcessShape_3);
|
|
|
|
|
|
|
|
var expectedBounds = assign(originalBounds, { width: 875 });
|
|
|
|
|
|
|
|
expect(subProcessShape_1).to.have.bounds(expectedBounds);
|
|
|
|
}));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2015-08-25 09:16:10 +00:00
|
|
|
});
|