2018-04-02 19:01:53 +00:00
|
|
|
import {
|
|
|
|
bootstrapModeler,
|
|
|
|
inject
|
|
|
|
} from 'test/TestHelper';
|
2015-09-17 07:05:09 +00:00
|
|
|
|
2018-04-02 19:01:53 +00:00
|
|
|
import replacePreviewModule from 'lib/features/replace-preview';
|
|
|
|
import modelingModule from 'lib/features/modeling';
|
|
|
|
import moveModule from 'diagram-js/lib/features/move';
|
|
|
|
import coreModule from 'lib/core';
|
2015-09-17 07:05:09 +00:00
|
|
|
|
2018-04-02 19:01:53 +00:00
|
|
|
import { is } from 'lib/util/ModelUtil';
|
2015-09-17 07:05:09 +00:00
|
|
|
|
2018-04-02 19:01:53 +00:00
|
|
|
import {
|
|
|
|
createCanvasEvent as canvasEvent
|
|
|
|
} from '../../../../util/MockEvents';
|
2015-09-17 07:05:09 +00:00
|
|
|
|
2018-04-02 19:01:53 +00:00
|
|
|
import {
|
|
|
|
query as domQuery
|
|
|
|
} from 'min-dom';
|
2016-09-14 06:18:56 +00:00
|
|
|
|
2017-12-20 09:36:07 +00:00
|
|
|
var ATTACH = { attach: true };
|
|
|
|
|
2015-09-17 07:05:09 +00:00
|
|
|
|
|
|
|
describe('features/modeling - move start event behavior', function() {
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
var testModules = [
|
|
|
|
replacePreviewModule,
|
|
|
|
modelingModule,
|
|
|
|
coreModule,
|
|
|
|
moveModule
|
|
|
|
];
|
|
|
|
|
2015-09-17 07:05:09 +00:00
|
|
|
|
|
|
|
describe('Start Events', function() {
|
2016-06-07 06:46:45 +00:00
|
|
|
|
2015-09-17 07:05:09 +00:00
|
|
|
var diagramXML = require('../../../../fixtures/bpmn/event-sub-processes.bpmn');
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
beforeEach(bootstrapModeler(diagramXML, {
|
|
|
|
modules: testModules
|
|
|
|
}));
|
|
|
|
|
|
|
|
var moveShape;
|
2015-09-17 07:05:09 +00:00
|
|
|
|
|
|
|
beforeEach(inject(function(move, dragging, elementRegistry) {
|
|
|
|
|
|
|
|
moveShape = function(shape, target, position) {
|
|
|
|
var startPosition = { x: shape.x + 10 + shape.width / 2, y: shape.y + 30 + shape.height/2 };
|
|
|
|
|
|
|
|
move.start(canvasEvent(startPosition), shape);
|
|
|
|
|
|
|
|
dragging.hover({
|
|
|
|
element: target,
|
|
|
|
gfx: elementRegistry.getGraphics(target)
|
|
|
|
});
|
|
|
|
|
|
|
|
dragging.move(canvasEvent(position));
|
|
|
|
};
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('should select the replacement after replacing the start event',
|
|
|
|
inject(function(elementRegistry, canvas, dragging, move, selection) {
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var startEvent = elementRegistry.get('StartEvent_1'),
|
|
|
|
rootElement = canvas.getRootElement();
|
2015-09-17 07:05:09 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
moveShape(startEvent, rootElement, { x: 140, y: 250 });
|
2015-09-17 07:05:09 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
dragging.end();
|
2015-09-17 07:05:09 +00:00
|
|
|
|
2016-06-07 14:45:47 +00:00
|
|
|
var replacement = elementRegistry.get('StartEvent_1');
|
2015-09-17 07:05:09 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// then
|
|
|
|
expect(selection.get()).to.include(replacement);
|
|
|
|
expect(selection.get()).not.to.include(startEvent);
|
|
|
|
})
|
|
|
|
);
|
2015-09-17 07:05:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
it('should select all moved shapes after some of them got replaced',
|
|
|
|
inject(function(elementRegistry, canvas, dragging, move, selection) {
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var startEvent1 = elementRegistry.get('StartEvent_1'),
|
|
|
|
startEvent2 = elementRegistry.get('StartEvent_2'),
|
|
|
|
startEvent3 = elementRegistry.get('StartEvent_3'),
|
|
|
|
rootElement = canvas.getRootElement();
|
2015-09-17 07:05:09 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
selection.select([ startEvent1, startEvent2, startEvent3 ]);
|
|
|
|
moveShape(startEvent1, rootElement, { x: 140, y: 250 });
|
2015-09-17 07:05:09 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
dragging.end();
|
2015-09-17 07:05:09 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
var replacements = elementRegistry.filter(function(element) {
|
|
|
|
if (is(element, 'bpmn:StartEvent') && element.type !== 'label') {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
});
|
2015-09-17 07:05:09 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// then
|
|
|
|
expect(selection.get()).to.include(replacements[0]);
|
|
|
|
expect(selection.get()).to.include(replacements[1]);
|
|
|
|
expect(selection.get()).to.include(replacements[2]);
|
2015-09-17 07:05:09 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
})
|
|
|
|
);
|
2015-09-17 07:05:09 +00:00
|
|
|
|
|
|
|
});
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
|
|
|
|
describe('Cancel Events', function() {
|
2015-09-17 07:05:09 +00:00
|
|
|
|
|
|
|
var diagramXML = require('../../../../fixtures/bpmn/features/replace/cancel-events.bpmn');
|
|
|
|
|
2016-06-07 14:45:47 +00:00
|
|
|
beforeEach(bootstrapModeler(diagramXML, { modules: testModules }));
|
2015-09-17 07:05:09 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
|
|
|
|
describe('normal', function() {
|
2015-09-17 07:05:09 +00:00
|
|
|
|
2016-04-19 15:37:34 +00:00
|
|
|
|
2016-06-07 14:45:47 +00:00
|
|
|
it('should unclaim ID and claim same ID with new element',
|
2016-04-19 15:37:34 +00:00
|
|
|
inject(function(elementRegistry, bpmnReplace) {
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var transaction = elementRegistry.get('Transaction_1');
|
2016-04-19 15:37:34 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
var ids = transaction.businessObject.$model.ids;
|
2016-04-19 15:37:34 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
var subProcess = bpmnReplace.replaceElement(transaction, { type: 'bpmn:SubProcess' });
|
2016-04-19 15:37:34 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// then
|
2016-06-07 14:45:47 +00:00
|
|
|
expect(ids.assigned(transaction.id)).to.eql(subProcess.businessObject);
|
2016-06-07 06:46:45 +00:00
|
|
|
expect(ids.assigned(subProcess.id)).to.eql(subProcess.businessObject);
|
2016-06-07 14:45:47 +00:00
|
|
|
expect(subProcess.id).to.eql(transaction.id);
|
2016-06-07 06:46:45 +00:00
|
|
|
})
|
|
|
|
);
|
2016-04-19 15:37:34 +00:00
|
|
|
|
|
|
|
|
2016-06-07 14:45:47 +00:00
|
|
|
it('should REVERT unclaim ID and claim same ID with new element on UNDO',
|
2016-04-19 15:37:34 +00:00
|
|
|
inject(function(elementRegistry, bpmnReplace, commandStack) {
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var transaction = elementRegistry.get('Transaction_1');
|
2016-04-19 15:37:34 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
var ids = transaction.businessObject.$model.ids;
|
2016-04-19 15:37:34 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
var subProcess = bpmnReplace.replaceElement(transaction, { type: 'bpmn:SubProcess' });
|
2016-04-19 15:37:34 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
commandStack.undo();
|
2016-04-19 15:37:34 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// then
|
|
|
|
expect(ids.assigned(transaction.id)).to.eql(transaction.businessObject);
|
2016-06-07 14:45:47 +00:00
|
|
|
expect(subProcess.id).not.to.equal(transaction.id);
|
2016-06-07 06:46:45 +00:00
|
|
|
})
|
|
|
|
);
|
2016-04-19 15:37:34 +00:00
|
|
|
|
|
|
|
|
2015-09-17 07:05:09 +00:00
|
|
|
it('should replace CancelEvent when morphing transaction',
|
|
|
|
inject(function(elementRegistry, bpmnReplace) {
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var transaction = elementRegistry.get('Transaction_1'),
|
|
|
|
endEvent = elementRegistry.get('EndEvent_1');
|
2015-09-17 07:05:09 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
bpmnReplace.replaceElement(endEvent, {
|
|
|
|
type: 'bpmn:EndEvent',
|
|
|
|
eventDefinitionType: 'bpmn:CancelEventDefinition'
|
|
|
|
});
|
2015-09-17 07:05:09 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
var subProcess = bpmnReplace.replaceElement(transaction, { type: 'bpmn:SubProcess' });
|
2015-09-17 07:05:09 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
var newEndEvent = subProcess.children[0].businessObject;
|
|
|
|
|
|
|
|
// then
|
2018-04-30 09:06:26 +00:00
|
|
|
expect(subProcess.children).to.have.length(1);
|
2018-05-03 14:37:24 +00:00
|
|
|
expect(newEndEvent.eventDefinitionTypes).not.to.exist;
|
2016-06-07 06:46:45 +00:00
|
|
|
})
|
|
|
|
);
|
2015-09-17 07:05:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
it('should replace CancelEvent when morphing transaction -> undo',
|
|
|
|
inject(function(elementRegistry, bpmnReplace, commandStack) {
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var transaction = elementRegistry.get('Transaction_1'),
|
|
|
|
endEvent = elementRegistry.get('EndEvent_1');
|
2015-09-17 07:05:09 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
bpmnReplace.replaceElement(endEvent, {
|
|
|
|
type: 'bpmn:EndEvent',
|
|
|
|
eventDefinitionType: 'bpmn:CancelEventDefinition'
|
|
|
|
});
|
2015-09-17 07:05:09 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
bpmnReplace.replaceElement(transaction, { type: 'bpmn:SubProcess' });
|
2015-09-17 07:05:09 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
commandStack.undo();
|
2015-09-17 07:05:09 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
var endEventAfter = elementRegistry.filter(function(element) {
|
|
|
|
return (element.id !== 'EndEvent_2' && element.type === 'bpmn:EndEvent');
|
|
|
|
})[0];
|
|
|
|
|
|
|
|
// then
|
2018-04-30 09:06:26 +00:00
|
|
|
expect(transaction.children).to.have.length(1);
|
2016-06-07 06:46:45 +00:00
|
|
|
expect(endEventAfter.businessObject.eventDefinitions).to.exist;
|
|
|
|
})
|
|
|
|
);
|
2015-09-17 07:05:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
it('should replace a CancelEvent when moving outside of a transaction',
|
|
|
|
inject(function(elementRegistry, bpmnReplace, modeling) {
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var process = elementRegistry.get('Process_1'),
|
|
|
|
transaction = elementRegistry.get('Transaction_1'),
|
|
|
|
endEvent = elementRegistry.get('EndEvent_1');
|
2015-09-17 07:05:09 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
var cancelEvent = bpmnReplace.replaceElement(endEvent, {
|
|
|
|
type: 'bpmn:EndEvent',
|
|
|
|
eventDefinitionType: 'bpmn:CancelEventDefinition'
|
|
|
|
});
|
2015-09-17 07:05:09 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
modeling.moveElements([ cancelEvent ], { x: 0, y: 150 }, process);
|
2015-09-17 07:05:09 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
var endEventAfter = elementRegistry.filter(function(element) {
|
|
|
|
return (element.parent === process && element.type === 'bpmn:EndEvent');
|
|
|
|
})[0];
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(transaction.children).to.have.length(0);
|
2018-05-03 14:37:24 +00:00
|
|
|
expect(endEventAfter.businessObject.eventDefinitions).not.to.exist;
|
2016-06-07 06:46:45 +00:00
|
|
|
})
|
|
|
|
);
|
2015-09-17 07:05:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
it('should replace a CancelEvent when moving outside of a transaction -> undo',
|
|
|
|
inject(function(elementRegistry, bpmnReplace, modeling, commandStack) {
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var process = elementRegistry.get('Process_1'),
|
|
|
|
transaction = elementRegistry.get('Transaction_1'),
|
|
|
|
endEvent = elementRegistry.get('EndEvent_1');
|
2015-09-17 07:05:09 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
var cancelEvent = bpmnReplace.replaceElement(endEvent, {
|
|
|
|
type: 'bpmn:EndEvent',
|
|
|
|
eventDefinitionType: 'bpmn:CancelEventDefinition'
|
|
|
|
});
|
2015-09-17 07:05:09 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
modeling.moveElements([ cancelEvent ], { x: 0, y: 150 }, process);
|
2015-09-17 07:05:09 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
commandStack.undo();
|
2015-09-17 07:05:09 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
var endEventAfter = elementRegistry.filter(function(element) {
|
|
|
|
return (element.id !== 'EndEvent_2' && element.type === 'bpmn:EndEvent');
|
|
|
|
})[0];
|
|
|
|
|
|
|
|
// then
|
2018-04-30 09:06:26 +00:00
|
|
|
expect(transaction.children).to.have.length(1);
|
2016-06-07 06:46:45 +00:00
|
|
|
expect(endEventAfter.businessObject.eventDefinitions).to.exist;
|
|
|
|
})
|
|
|
|
);
|
2015-09-17 07:05:09 +00:00
|
|
|
|
|
|
|
});
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
|
|
|
|
describe('boundary events', function() {
|
2015-09-17 07:05:09 +00:00
|
|
|
|
|
|
|
it('should replace CancelBoundaryEvent when morphing from a transaction',
|
|
|
|
inject(function(elementRegistry, bpmnReplace) {
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var boundaryEvent = elementRegistry.get('BoundaryEvent_1'),
|
|
|
|
transaction = elementRegistry.get('Transaction_1');
|
2015-09-17 07:05:09 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
bpmnReplace.replaceElement(boundaryEvent, {
|
|
|
|
type: 'bpmn:BoundaryEvent',
|
|
|
|
eventDefinitionType: 'bpmn:CancelEventDefinition'
|
|
|
|
});
|
2015-09-17 07:05:09 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
var subProcess = bpmnReplace.replaceElement(transaction, { type: 'bpmn:SubProcess' });
|
2015-09-17 07:05:09 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
var newBoundaryEvent = subProcess.attachers[0].businessObject;
|
|
|
|
|
|
|
|
// then
|
2018-05-03 14:37:24 +00:00
|
|
|
expect(newBoundaryEvent.eventDefinitionTypes).not.to.exist;
|
2016-06-07 06:46:45 +00:00
|
|
|
expect(newBoundaryEvent.attachedToRef).to.equal(subProcess.businessObject);
|
2016-06-07 14:45:47 +00:00
|
|
|
expect(elementRegistry.get('Transaction_1')).to.eql(subProcess);
|
2016-06-07 06:46:45 +00:00
|
|
|
})
|
|
|
|
);
|
2015-09-17 07:05:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
it('should replace CancelBoundaryEvent when morphing from a transaction -> undo',
|
|
|
|
inject(function(elementRegistry, bpmnReplace, commandStack) {
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var boundaryEvent = elementRegistry.get('BoundaryEvent_1'),
|
|
|
|
transaction = elementRegistry.get('Transaction_1');
|
2015-09-17 07:05:09 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
bpmnReplace.replaceElement(boundaryEvent, {
|
|
|
|
type: 'bpmn:BoundaryEvent',
|
|
|
|
eventDefinitionType: 'bpmn:CancelEventDefinition'
|
|
|
|
});
|
2015-09-17 07:05:09 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
bpmnReplace.replaceElement(transaction, { type: 'bpmn:SubProcess' });
|
2015-09-17 07:05:09 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
commandStack.undo();
|
2015-09-17 07:05:09 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
var afterBoundaryEvent = elementRegistry.filter(function(element) {
|
|
|
|
return (element.type === 'bpmn:BoundaryEvent' && element.id !== 'BoundaryEvent_2');
|
|
|
|
})[0];
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(afterBoundaryEvent.businessObject.eventDefinitions).exist;
|
|
|
|
expect(afterBoundaryEvent.businessObject.attachedToRef).to.equal(transaction.businessObject);
|
|
|
|
expect(transaction.attachers).to.have.length(1);
|
|
|
|
})
|
|
|
|
);
|
2015-09-17 07:05:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
it('should replace CancelBoundaryEvent when attaching to a NON-transaction',
|
|
|
|
inject(function(elementRegistry, bpmnReplace, modeling) {
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var boundaryEvent = elementRegistry.get('BoundaryEvent_1'),
|
|
|
|
subProcess = elementRegistry.get('SubProcess_1'),
|
|
|
|
process = elementRegistry.get('Process_1'),
|
|
|
|
transaction = elementRegistry.get('Transaction_1');
|
2015-09-17 07:05:09 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
var newBoundaryEvent = bpmnReplace.replaceElement(boundaryEvent, {
|
|
|
|
type: 'bpmn:BoundaryEvent',
|
|
|
|
eventDefinitionType: 'bpmn:CancelEventDefinition'
|
|
|
|
});
|
2015-09-17 07:05:09 +00:00
|
|
|
|
2017-12-20 09:36:07 +00:00
|
|
|
modeling.moveElements([ newBoundaryEvent ], { x: 500, y: 0 }, subProcess, ATTACH);
|
2015-09-17 07:05:09 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
var movedBoundaryEvent = elementRegistry.filter(function(element) {
|
|
|
|
return (element.type === 'bpmn:BoundaryEvent' && element.id !== 'BoundaryEvent_2');
|
|
|
|
})[0];
|
2015-09-17 07:05:09 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// then
|
2018-05-03 14:37:24 +00:00
|
|
|
expect(movedBoundaryEvent.businessObject.eventDefinitions).not.to.exist;
|
2016-06-07 06:46:45 +00:00
|
|
|
expect(movedBoundaryEvent.businessObject.attachedToRef).to.equal(subProcess.businessObject);
|
|
|
|
expect(movedBoundaryEvent.parent).to.equal(process);
|
|
|
|
|
|
|
|
expect(movedBoundaryEvent.host).to.equal(subProcess);
|
|
|
|
expect(subProcess.attachers).to.contain(movedBoundaryEvent);
|
|
|
|
expect(transaction.attachers).to.be.empty;
|
|
|
|
})
|
|
|
|
);
|
2015-09-17 07:05:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
it('should replace CancelBoundaryEvent when attaching to a NON-transaction -> undo',
|
|
|
|
inject(function(elementRegistry, bpmnReplace, modeling, commandStack) {
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var boundaryEvent = elementRegistry.get('BoundaryEvent_1'),
|
|
|
|
transaction = elementRegistry.get('Transaction_1'),
|
|
|
|
subProcess = elementRegistry.get('SubProcess_1');
|
2015-09-17 07:05:09 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
var newBoundaryEvent = bpmnReplace.replaceElement(boundaryEvent, {
|
|
|
|
type: 'bpmn:BoundaryEvent',
|
|
|
|
eventDefinitionType: 'bpmn:CancelEventDefinition'
|
|
|
|
});
|
2015-09-17 07:05:09 +00:00
|
|
|
|
2017-12-20 09:36:07 +00:00
|
|
|
modeling.moveElements([ newBoundaryEvent ], { x: 500, y: 0 }, subProcess, ATTACH);
|
2015-09-17 07:05:09 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
commandStack.undo();
|
2015-09-17 07:05:09 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
var movedBoundaryEvent = elementRegistry.filter(function(element) {
|
|
|
|
return (element.type === 'bpmn:BoundaryEvent' && element.id !== 'BoundaryEvent_2');
|
|
|
|
})[0];
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(movedBoundaryEvent.businessObject.eventDefinitions).to.exist;
|
|
|
|
expect(movedBoundaryEvent.businessObject.attachedToRef).to.equal(transaction.businessObject);
|
|
|
|
|
|
|
|
expect(movedBoundaryEvent.host).to.equal(transaction);
|
|
|
|
expect(transaction.attachers).to.contain(movedBoundaryEvent);
|
|
|
|
expect(subProcess.attachers).to.have.length(1);
|
|
|
|
})
|
|
|
|
);
|
2015-09-17 07:05:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
it('should NOT allow morphing into an IntermediateEvent',
|
|
|
|
inject(function(elementRegistry, bpmnReplace, commandStack, move, dragging) {
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var boundaryEvent = elementRegistry.get('BoundaryEvent_1'),
|
|
|
|
subProcess = elementRegistry.get('SubProcess_1');
|
2015-09-17 07:05:09 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
var newBoundaryEvent = bpmnReplace.replaceElement(boundaryEvent, {
|
|
|
|
type: 'bpmn:BoundaryEvent',
|
|
|
|
eventDefinitionType: 'bpmn:CancelEventDefinition'
|
|
|
|
});
|
2015-09-17 07:05:09 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
move.start(canvasEvent({ x: 0, y: 0 }), newBoundaryEvent);
|
2015-09-17 07:05:09 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
dragging.hover({
|
|
|
|
gfx: elementRegistry.getGraphics(subProcess),
|
|
|
|
element: subProcess
|
|
|
|
});
|
|
|
|
dragging.move(canvasEvent({ x: 450, y: -50 }));
|
2015-09-17 07:05:09 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
var canExecute = dragging.context().data.context.canExecute;
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(canExecute).to.be.false;
|
|
|
|
})
|
|
|
|
);
|
2015-09-17 07:05:09 +00:00
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2016-06-29 10:12:11 +00:00
|
|
|
|
|
|
|
describe('outline', function() {
|
|
|
|
|
|
|
|
var diagramXML = require('../../../../fixtures/bpmn/features/replace/connection.bpmn');
|
|
|
|
|
|
|
|
beforeEach(bootstrapModeler(diagramXML, { modules: testModules }));
|
|
|
|
|
|
|
|
|
|
|
|
it('should update size of outline on replace', inject(function(bpmnReplace, elementRegistry) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var task = elementRegistry.get('Task_2');
|
|
|
|
|
|
|
|
// when
|
|
|
|
var subProcess = bpmnReplace.replaceElement(task, {
|
|
|
|
type: 'bpmn:SubProcess',
|
|
|
|
isExpanded: true
|
|
|
|
});
|
|
|
|
|
|
|
|
// then
|
|
|
|
var gfx = elementRegistry.getGraphics(subProcess);
|
2016-09-14 06:18:56 +00:00
|
|
|
var outline = domQuery('.djs-outline', gfx);
|
2016-06-29 10:12:11 +00:00
|
|
|
|
|
|
|
expect(outline.getBBox().width).to.equal(gfx.getBBox().width);
|
|
|
|
expect(outline.getBBox().height).to.equal(gfx.getBBox().height);
|
|
|
|
}));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2015-09-17 07:05:09 +00:00
|
|
|
});
|