2018-04-02 19:01:53 +00:00
|
|
|
import {
|
|
|
|
bootstrapModeler,
|
|
|
|
inject
|
|
|
|
} from 'test/TestHelper';
|
2015-04-28 08:52:21 +00:00
|
|
|
|
2018-04-02 19:01:53 +00:00
|
|
|
import { is } from 'lib/util/ModelUtil';
|
2015-04-28 08:52:21 +00:00
|
|
|
|
2018-04-02 19:01:53 +00:00
|
|
|
import modelingModule from 'lib/features/modeling';
|
|
|
|
import coreModule from 'lib/core';
|
2015-04-28 08:52:21 +00:00
|
|
|
|
|
|
|
|
2015-08-19 09:11:47 +00:00
|
|
|
describe('features/modeling - remove participant behavior', function() {
|
2015-04-28 08:52:21 +00:00
|
|
|
|
|
|
|
var testModules = [ coreModule, modelingModule ];
|
|
|
|
|
|
|
|
|
|
|
|
describe('when removing participant in collaboration', function() {
|
|
|
|
|
|
|
|
var processDiagramXML = require('../../../../fixtures/bpmn/collaboration/collaboration-message-flows.bpmn');
|
|
|
|
|
|
|
|
beforeEach(bootstrapModeler(processDiagramXML, { modules: testModules }));
|
|
|
|
|
|
|
|
|
|
|
|
describe('retain collaboration', function() {
|
|
|
|
|
|
|
|
it('execute', inject(function(modeling, elementRegistry, canvas) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var participantShape = elementRegistry.get('Participant_2');
|
|
|
|
|
|
|
|
// when
|
|
|
|
modeling.removeShape(participantShape);
|
|
|
|
|
|
|
|
// then
|
|
|
|
var rootElement = canvas.getRootElement();
|
|
|
|
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(is(rootElement, 'bpmn:Collaboration')).to.be.ok;
|
2015-04-28 08:52:21 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
describe('when removing last remaining participant', function() {
|
|
|
|
|
|
|
|
var processDiagramXML = require('../../../../fixtures/bpmn/collaboration/collaboration-empty-participant.bpmn');
|
|
|
|
|
|
|
|
beforeEach(bootstrapModeler(processDiagramXML, { modules: testModules }));
|
|
|
|
|
|
|
|
|
|
|
|
describe('should transform diagram into process diagram', function() {
|
|
|
|
|
|
|
|
it('execute', inject(function(modeling, elementRegistry, canvas) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var participantShape = elementRegistry.get('_Participant_2'),
|
|
|
|
participant = participantShape.businessObject,
|
|
|
|
participantDi = participant.di,
|
|
|
|
process = participant.processRef,
|
|
|
|
collaborationElement = participantShape.parent,
|
|
|
|
collaboration = collaborationElement.businessObject,
|
|
|
|
diPlane = collaboration.di,
|
|
|
|
bpmnDefinitions = collaboration.$parent;
|
|
|
|
|
|
|
|
// when
|
|
|
|
modeling.removeShape(participantShape);
|
|
|
|
|
|
|
|
// then
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(participant.$parent).to.not.be.ok;
|
2015-04-28 08:52:21 +00:00
|
|
|
|
|
|
|
var newRootShape = canvas.getRootElement(),
|
|
|
|
newRootBusinessObject = newRootShape.businessObject;
|
|
|
|
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(newRootBusinessObject.$instanceOf('bpmn:Process')).to.be.true;
|
2015-04-28 08:52:21 +00:00
|
|
|
|
|
|
|
// collaboration DI is unwired
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(participantDi.$parent).to.not.be.ok;
|
|
|
|
expect(collaboration.di).to.not.be.ok;
|
2015-04-28 08:52:21 +00:00
|
|
|
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(bpmnDefinitions.rootElements).not.to.include(process);
|
|
|
|
expect(bpmnDefinitions.rootElements).not.to.include(collaboration);
|
2015-04-28 08:52:21 +00:00
|
|
|
|
|
|
|
// process DI is wired
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(diPlane.bpmnElement).to.eql(newRootBusinessObject);
|
|
|
|
expect(newRootBusinessObject.di).to.eql(diPlane);
|
2015-04-28 08:52:21 +00:00
|
|
|
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(bpmnDefinitions.rootElements).to.include(newRootBusinessObject);
|
2015-04-28 08:52:21 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('undo', inject(function(modeling, elementRegistry, canvas, commandStack) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var participantShape = elementRegistry.get('_Participant_2'),
|
|
|
|
participant = participantShape.businessObject,
|
|
|
|
originalRootElement = participantShape.parent,
|
|
|
|
originalRootElementBo = originalRootElement.businessObject,
|
|
|
|
bpmnDefinitions = originalRootElementBo.$parent,
|
|
|
|
participantDi = participant.di,
|
|
|
|
diPlane = participantDi.$parent;
|
|
|
|
|
|
|
|
modeling.removeShape(participantShape);
|
|
|
|
|
|
|
|
// when
|
|
|
|
commandStack.undo();
|
|
|
|
|
|
|
|
// then
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(participant.$parent).to.eql(originalRootElementBo);
|
|
|
|
expect(originalRootElementBo.$parent).to.eql(bpmnDefinitions);
|
2015-04-28 08:52:21 +00:00
|
|
|
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(canvas.getRootElement()).to.eql(originalRootElement);
|
2015-04-28 08:52:21 +00:00
|
|
|
|
|
|
|
// di is unwired
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(participantDi.$parent).to.eql(originalRootElementBo.di);
|
2015-04-28 08:52:21 +00:00
|
|
|
|
|
|
|
// new di is wired
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(diPlane.bpmnElement).to.eql(originalRootElementBo);
|
2015-04-28 08:52:21 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|