2018-04-02 19:01:53 +00:00
|
|
|
import {
|
|
|
|
bootstrapModeler,
|
|
|
|
inject
|
|
|
|
} from 'test/TestHelper';
|
2015-01-02 15:15:18 +00:00
|
|
|
|
2018-04-02 19:01:53 +00:00
|
|
|
import modelingModule from 'lib/features/modeling';
|
|
|
|
import coreModule from 'lib/core';
|
2015-01-02 15:15:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
describe('features/modeling - update properties', function() {
|
|
|
|
|
2015-03-31 12:17:15 +00:00
|
|
|
var diagramXML = require('../../../fixtures/bpmn/conditions.bpmn');
|
2015-01-02 15:15:18 +00:00
|
|
|
|
|
|
|
var testModules = [ coreModule, modelingModule ];
|
|
|
|
|
|
|
|
beforeEach(bootstrapModeler(diagramXML, { modules: testModules }));
|
|
|
|
|
|
|
|
|
|
|
|
var updatedElements;
|
|
|
|
|
|
|
|
beforeEach(inject(function(eventBus) {
|
|
|
|
|
|
|
|
eventBus.on([ 'commandStack.execute', 'commandStack.revert' ], function() {
|
|
|
|
updatedElements = [];
|
|
|
|
});
|
|
|
|
|
|
|
|
eventBus.on('element.changed', function(event) {
|
|
|
|
updatedElements.push(event.element);
|
|
|
|
});
|
|
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
describe('should execute', function() {
|
|
|
|
|
2018-01-31 11:06:17 +00:00
|
|
|
it('setting loop characteristics', inject(
|
|
|
|
function(elementRegistry, modeling, moddle) {
|
2015-01-02 15:15:18 +00:00
|
|
|
|
2018-01-31 11:06:17 +00:00
|
|
|
// given
|
|
|
|
var loopCharacteristics = moddle.create(
|
|
|
|
'bpmn:MultiInstanceLoopCharacteristics'
|
|
|
|
);
|
2015-01-02 15:15:18 +00:00
|
|
|
|
2018-01-31 11:06:17 +00:00
|
|
|
var taskShape = elementRegistry.get('ServiceTask_1');
|
2015-01-02 15:15:18 +00:00
|
|
|
|
2018-01-31 11:06:17 +00:00
|
|
|
// when
|
|
|
|
modeling.updateProperties(taskShape, {
|
|
|
|
loopCharacteristics: loopCharacteristics
|
|
|
|
});
|
2015-01-02 15:15:18 +00:00
|
|
|
|
2018-01-31 11:06:17 +00:00
|
|
|
// then
|
|
|
|
expect(
|
|
|
|
taskShape.businessObject.loopCharacteristics
|
|
|
|
).to.eql(loopCharacteristics);
|
2015-01-02 15:15:18 +00:00
|
|
|
|
|
|
|
|
2018-01-31 11:06:17 +00:00
|
|
|
// task shape got updated
|
|
|
|
expect(updatedElements).to.include(taskShape);
|
|
|
|
}
|
|
|
|
));
|
2015-01-02 15:15:18 +00:00
|
|
|
|
|
|
|
|
2015-12-08 12:29:03 +00:00
|
|
|
it('unsetting default flow', inject(function(elementRegistry, modeling) {
|
2015-01-02 15:15:18 +00:00
|
|
|
|
|
|
|
// given
|
|
|
|
var gatewayShape = elementRegistry.get('ExclusiveGateway_1');
|
|
|
|
|
|
|
|
// when
|
|
|
|
modeling.updateProperties(gatewayShape, { 'default': undefined });
|
|
|
|
|
|
|
|
// then
|
2015-12-01 07:27:45 +00:00
|
|
|
expect(gatewayShape.businessObject['default']).not.to.exist;
|
2015-01-02 15:15:18 +00:00
|
|
|
|
|
|
|
// flow got updated, too
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(updatedElements).to.include(elementRegistry.get('SequenceFlow_1'));
|
2015-01-02 15:15:18 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
|
2015-12-08 12:29:03 +00:00
|
|
|
it('updating default flow', inject(function(elementRegistry, modeling) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var gatewayShape = elementRegistry.get('ExclusiveGateway_1'),
|
|
|
|
newDefaultFlowConnection = elementRegistry.get('SequenceFlow_2'),
|
|
|
|
newDefaultFlow = newDefaultFlowConnection.businessObject;
|
|
|
|
|
|
|
|
// when
|
|
|
|
modeling.updateProperties(gatewayShape, { 'default': newDefaultFlow });
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(gatewayShape.businessObject['default']).to.eql(newDefaultFlow);
|
|
|
|
|
|
|
|
// flow got updated, too
|
|
|
|
expect(updatedElements).to.include(newDefaultFlowConnection);
|
|
|
|
}));
|
|
|
|
|
2018-01-31 11:06:17 +00:00
|
|
|
|
|
|
|
it('should keep unchanged default flow untouched', inject(
|
|
|
|
function(elementRegistry, modeling) {
|
2016-10-18 11:18:13 +00:00
|
|
|
|
|
|
|
// given
|
|
|
|
var gatewayShape = elementRegistry.get('ExclusiveGateway_1'),
|
|
|
|
sequenceFlow = elementRegistry.get('SequenceFlow_2'),
|
|
|
|
taskShape = elementRegistry.get('Task_1');
|
|
|
|
|
|
|
|
// when
|
2018-01-31 11:06:17 +00:00
|
|
|
modeling.reconnectStart(
|
|
|
|
sequenceFlow,
|
|
|
|
taskShape,
|
|
|
|
{
|
|
|
|
x: taskShape.x + taskShape.width,
|
|
|
|
y: taskShape.y + taskShape.height / 2
|
|
|
|
}
|
|
|
|
);
|
2016-10-18 11:18:13 +00:00
|
|
|
|
|
|
|
// then
|
2018-01-31 11:06:17 +00:00
|
|
|
expect(gatewayShape.businessObject.default).to.exist;
|
|
|
|
}
|
|
|
|
));
|
2016-10-18 11:18:13 +00:00
|
|
|
|
2015-12-08 12:29:03 +00:00
|
|
|
|
2018-01-31 11:06:17 +00:00
|
|
|
it('updating conditional flow on source replace', inject(
|
|
|
|
function(bpmnReplace, elementRegistry) {
|
2016-06-20 14:27:36 +00:00
|
|
|
|
2018-02-27 09:08:31 +00:00
|
|
|
// given
|
2018-01-31 11:06:17 +00:00
|
|
|
var conditionalFlow = elementRegistry.get('SequenceFlow_3'),
|
|
|
|
conditionalBo = conditionalFlow.businessObject,
|
|
|
|
serviceTask = elementRegistry.get('ServiceTask_1');
|
2016-06-20 14:27:36 +00:00
|
|
|
|
2018-01-31 11:06:17 +00:00
|
|
|
var conditionExpression = conditionalBo.conditionExpression;
|
2016-06-20 14:27:36 +00:00
|
|
|
|
2018-02-27 09:08:31 +00:00
|
|
|
var userTaskData = {
|
2018-01-31 11:06:17 +00:00
|
|
|
type: 'bpmn:UserTask'
|
|
|
|
};
|
2016-06-20 14:27:36 +00:00
|
|
|
|
2018-01-31 11:06:17 +00:00
|
|
|
// when
|
|
|
|
bpmnReplace.replaceElement(serviceTask, userTaskData);
|
2016-06-20 14:27:36 +00:00
|
|
|
|
2018-01-31 11:06:17 +00:00
|
|
|
// then
|
|
|
|
expect(conditionalBo.conditionExpression).to.eql(conditionExpression);
|
|
|
|
}
|
|
|
|
));
|
2016-06-20 14:27:36 +00:00
|
|
|
|
|
|
|
|
2018-01-31 11:06:17 +00:00
|
|
|
it('updating conditional flow on target replace', inject(
|
|
|
|
function(bpmnReplace, elementRegistry) {
|
2016-06-20 14:27:36 +00:00
|
|
|
|
2018-02-27 09:08:31 +00:00
|
|
|
// given
|
2018-01-31 11:06:17 +00:00
|
|
|
var conditionalFlow = elementRegistry.get('SequenceFlow_3'),
|
|
|
|
conditionalBo = conditionalFlow.businessObject,
|
|
|
|
endEvent = elementRegistry.get('EndEvent_1');
|
2016-06-20 14:27:36 +00:00
|
|
|
|
2018-01-31 11:06:17 +00:00
|
|
|
var conditionExpression = conditionalBo.conditionExpression;
|
2016-06-20 14:27:36 +00:00
|
|
|
|
2018-02-27 09:08:31 +00:00
|
|
|
var messageEndEventData = {
|
2018-01-31 11:06:17 +00:00
|
|
|
type: 'bpmn:EndEvent',
|
|
|
|
eventDefinitionType: 'bpmn:MessageEventDefinition'
|
|
|
|
};
|
2016-06-20 14:27:36 +00:00
|
|
|
|
2018-01-31 11:06:17 +00:00
|
|
|
// when
|
|
|
|
bpmnReplace.replaceElement(endEvent, messageEndEventData);
|
2016-06-20 14:27:36 +00:00
|
|
|
|
2018-01-31 11:06:17 +00:00
|
|
|
// then
|
|
|
|
expect(conditionalBo.conditionExpression).to.eql(conditionExpression);
|
|
|
|
}
|
|
|
|
));
|
2016-06-20 14:27:36 +00:00
|
|
|
|
|
|
|
|
2015-06-18 14:57:58 +00:00
|
|
|
it('updating name', inject(function(elementRegistry, modeling) {
|
2015-01-02 15:15:18 +00:00
|
|
|
|
|
|
|
// given
|
|
|
|
var flowConnection = elementRegistry.get('SequenceFlow_1');
|
|
|
|
|
|
|
|
// when
|
|
|
|
modeling.updateProperties(flowConnection, { name: 'FOO BAR' });
|
|
|
|
|
|
|
|
// then
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(flowConnection.businessObject.name).to.equal('FOO BAR');
|
2015-01-02 15:15:18 +00:00
|
|
|
|
|
|
|
// flow label got updated, too
|
2018-01-31 11:06:17 +00:00
|
|
|
expect(updatedElements).to.include(flowConnection.label);
|
2015-01-02 15:15:18 +00:00
|
|
|
}));
|
|
|
|
|
2015-04-13 08:55:17 +00:00
|
|
|
|
2015-06-18 14:57:58 +00:00
|
|
|
it('unsetting name', inject(function(elementRegistry, modeling) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var flowConnection = elementRegistry.get('SequenceFlow_3');
|
|
|
|
|
|
|
|
// when
|
|
|
|
modeling.updateProperties(flowConnection, { name: undefined });
|
|
|
|
|
|
|
|
// then
|
2015-12-01 07:27:45 +00:00
|
|
|
expect(flowConnection.businessObject.name).not.to.exist;
|
2015-06-18 14:57:58 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
|
2015-04-13 08:55:17 +00:00
|
|
|
it('updating id', inject(function(elementRegistry, modeling) {
|
|
|
|
|
|
|
|
// given
|
2018-01-31 11:06:17 +00:00
|
|
|
var flowConnection = elementRegistry.get('SequenceFlow_1'),
|
|
|
|
flowBo = flowConnection.businessObject;
|
|
|
|
|
|
|
|
var ids = flowBo.$model.ids;
|
2015-04-13 08:55:17 +00:00
|
|
|
|
|
|
|
// when
|
|
|
|
modeling.updateProperties(flowConnection, { id: 'FOO_BAR' });
|
|
|
|
|
|
|
|
// then
|
2018-01-31 11:06:17 +00:00
|
|
|
expect(ids.assigned('FOO_BAR')).to.eql(flowBo);
|
2015-10-05 11:35:10 +00:00
|
|
|
expect(ids.assigned('SequenceFlow_1')).to.be.false;
|
|
|
|
|
2018-01-31 11:06:17 +00:00
|
|
|
expect(flowBo.id).to.equal('FOO_BAR');
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(flowConnection.id).to.equal('FOO_BAR');
|
2015-04-13 08:55:17 +00:00
|
|
|
}));
|
|
|
|
|
2015-06-18 14:57:58 +00:00
|
|
|
|
2018-01-31 11:06:17 +00:00
|
|
|
it('updating extension elements', inject(
|
|
|
|
function(elementRegistry, modeling) {
|
2015-06-18 14:57:58 +00:00
|
|
|
|
2018-01-31 11:06:17 +00:00
|
|
|
// given
|
|
|
|
var flowConnection = elementRegistry.get('SequenceFlow_1'),
|
|
|
|
flowBo = flowConnection.businessObject;
|
2015-06-18 14:57:58 +00:00
|
|
|
|
2018-01-31 11:06:17 +00:00
|
|
|
// when
|
|
|
|
modeling.updateProperties(flowConnection, {
|
|
|
|
'xmlns:foo': 'http://foo',
|
|
|
|
'foo:customAttr': 'FOO'
|
|
|
|
});
|
2015-06-18 14:57:58 +00:00
|
|
|
|
2018-01-31 11:06:17 +00:00
|
|
|
// then
|
|
|
|
expect(flowBo.get('xmlns:foo')).to.equal('http://foo');
|
|
|
|
expect(flowBo.get('foo:customAttr')).to.equal('FOO');
|
|
|
|
}
|
|
|
|
));
|
2015-06-18 14:57:58 +00:00
|
|
|
|
2016-11-28 13:26:42 +00:00
|
|
|
|
|
|
|
it('setting di properties', inject(function(elementRegistry, modeling) {
|
|
|
|
|
|
|
|
// given
|
2018-01-31 11:06:17 +00:00
|
|
|
var flowConnection = elementRegistry.get('SequenceFlow_1'),
|
|
|
|
flowBo = flowConnection.businessObject;
|
2016-11-28 13:26:42 +00:00
|
|
|
|
|
|
|
// when
|
2018-01-31 11:06:17 +00:00
|
|
|
modeling.updateProperties(flowConnection, {
|
|
|
|
di: {
|
|
|
|
fill: 'FUCHSIA'
|
|
|
|
}
|
|
|
|
});
|
2016-11-28 13:26:42 +00:00
|
|
|
|
|
|
|
// then
|
2018-01-31 11:06:17 +00:00
|
|
|
expect(flowBo.di.fill).to.equal('FUCHSIA');
|
2018-01-31 11:15:32 +00:00
|
|
|
|
|
|
|
expect(flowBo.get('di')).not.to.exist;
|
2016-11-28 13:26:42 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('unsetting di properties', inject(function(elementRegistry, modeling) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var flowConnection = elementRegistry.get('SequenceFlow_1');
|
|
|
|
modeling.updateProperties(flowConnection, { di: { fill: 'FUCHSIA' } });
|
|
|
|
|
|
|
|
// when
|
|
|
|
modeling.updateProperties(flowConnection, { di: { fill: undefined } });
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(flowConnection.businessObject.di.fill).not.to.exist;
|
|
|
|
}));
|
|
|
|
|
2015-01-02 15:15:18 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
describe('should undo', function() {
|
|
|
|
|
2018-01-31 11:06:17 +00:00
|
|
|
it('setting loop characteristics', inject(
|
|
|
|
function(elementRegistry, modeling, commandStack, moddle) {
|
2015-01-02 15:15:18 +00:00
|
|
|
|
2018-01-31 11:06:17 +00:00
|
|
|
// given
|
|
|
|
var loopCharactersistics = moddle.create('bpmn:MultiInstanceLoopCharacteristics');
|
2015-01-02 15:15:18 +00:00
|
|
|
|
2018-01-31 11:06:17 +00:00
|
|
|
var taskShape = elementRegistry.get('ServiceTask_1');
|
2015-01-02 15:15:18 +00:00
|
|
|
|
2018-01-31 11:06:17 +00:00
|
|
|
// when
|
|
|
|
modeling.updateProperties(taskShape, { loopCharacteristics: loopCharactersistics });
|
|
|
|
commandStack.undo();
|
2015-01-02 15:15:18 +00:00
|
|
|
|
2018-01-31 11:06:17 +00:00
|
|
|
// then
|
|
|
|
expect(taskShape.businessObject.loopCharactersistics).not.to.exist;
|
|
|
|
}
|
|
|
|
));
|
2015-01-02 15:15:18 +00:00
|
|
|
|
|
|
|
|
2018-01-31 11:06:17 +00:00
|
|
|
it('unsetting default flow', inject(
|
|
|
|
function(elementRegistry, commandStack, modeling) {
|
2015-01-02 15:15:18 +00:00
|
|
|
|
2018-01-31 11:06:17 +00:00
|
|
|
// given
|
|
|
|
var gatewayShape = elementRegistry.get('ExclusiveGateway_1'),
|
|
|
|
gatewayBo = gatewayShape.businessObject,
|
|
|
|
oldDefaultBo = gatewayShape.businessObject['default'],
|
|
|
|
oldDefaultConnection = elementRegistry.get(oldDefaultBo.id);
|
2015-01-02 15:15:18 +00:00
|
|
|
|
2018-01-31 11:06:17 +00:00
|
|
|
// when
|
|
|
|
modeling.updateProperties(gatewayShape, {
|
|
|
|
'default': undefined
|
|
|
|
});
|
2015-01-02 15:15:18 +00:00
|
|
|
|
2018-01-31 11:06:17 +00:00
|
|
|
commandStack.undo();
|
2015-01-02 15:15:18 +00:00
|
|
|
|
2018-01-31 11:06:17 +00:00
|
|
|
// then
|
|
|
|
expect(gatewayBo['default']).to.eql(oldDefaultBo);
|
2015-12-08 12:29:03 +00:00
|
|
|
|
2018-01-31 11:06:17 +00:00
|
|
|
// flow got updated, too
|
|
|
|
expect(updatedElements).to.include(oldDefaultConnection);
|
|
|
|
}
|
|
|
|
));
|
2015-12-08 12:29:03 +00:00
|
|
|
|
|
|
|
|
2018-01-31 11:06:17 +00:00
|
|
|
it('updating default flow', inject(
|
|
|
|
function(elementRegistry, commandStack, modeling) {
|
2015-12-08 12:29:03 +00:00
|
|
|
|
2018-01-31 11:06:17 +00:00
|
|
|
// given
|
|
|
|
var gatewayShape = elementRegistry.get('ExclusiveGateway_1'),
|
|
|
|
gatewayBo = gatewayShape.businessObject,
|
|
|
|
newDefaultFlowConnection = elementRegistry.get('SequenceFlow_2'),
|
|
|
|
newDefaultFlow = newDefaultFlowConnection.businessObject,
|
|
|
|
oldDefaultFlowConnection = elementRegistry.get('SequenceFlow_1'),
|
|
|
|
oldDefaultFlow = oldDefaultFlowConnection.businessObject;
|
2015-12-08 12:29:03 +00:00
|
|
|
|
2018-01-31 11:06:17 +00:00
|
|
|
// when
|
|
|
|
modeling.updateProperties(gatewayShape, {
|
|
|
|
'default': newDefaultFlow
|
|
|
|
});
|
|
|
|
commandStack.undo();
|
2015-12-08 12:29:03 +00:00
|
|
|
|
2018-01-31 11:06:17 +00:00
|
|
|
// then
|
|
|
|
expect(gatewayBo['default']).to.eql(oldDefaultFlow);
|
2015-01-02 15:15:18 +00:00
|
|
|
|
2018-01-31 11:06:17 +00:00
|
|
|
// flow got updated, too
|
|
|
|
expect(updatedElements).to.include(newDefaultFlowConnection);
|
|
|
|
expect(updatedElements).to.include(oldDefaultFlowConnection);
|
|
|
|
}
|
|
|
|
));
|
2015-01-02 15:15:18 +00:00
|
|
|
|
|
|
|
|
2018-01-31 11:06:17 +00:00
|
|
|
it('updating name', inject(
|
|
|
|
function(elementRegistry, commandStack, modeling) {
|
2015-01-02 15:15:18 +00:00
|
|
|
|
2018-01-31 11:06:17 +00:00
|
|
|
// given
|
|
|
|
var flowConnection = elementRegistry.get('SequenceFlow_1');
|
2015-01-02 15:15:18 +00:00
|
|
|
|
2018-01-31 11:06:17 +00:00
|
|
|
// when
|
|
|
|
modeling.updateProperties(flowConnection, { name: 'FOO BAR' });
|
|
|
|
commandStack.undo();
|
2015-01-02 15:15:18 +00:00
|
|
|
|
2018-01-31 11:06:17 +00:00
|
|
|
// then
|
|
|
|
expect(flowConnection.businessObject.name).to.equal('default');
|
2015-01-02 15:15:18 +00:00
|
|
|
|
2018-01-31 11:06:17 +00:00
|
|
|
// flow got updated, too
|
|
|
|
expect(updatedElements).to.include(flowConnection.label);
|
|
|
|
}
|
|
|
|
));
|
2015-04-13 08:55:17 +00:00
|
|
|
|
2015-06-18 14:57:58 +00:00
|
|
|
|
2018-01-31 11:06:17 +00:00
|
|
|
it('unsetting name', inject(
|
|
|
|
function(elementRegistry, commandStack, modeling) {
|
2015-06-18 14:57:58 +00:00
|
|
|
|
2018-01-31 11:06:17 +00:00
|
|
|
// given
|
|
|
|
var flowConnection = elementRegistry.get('SequenceFlow_3');
|
2015-06-18 14:57:58 +00:00
|
|
|
|
2018-01-31 11:06:17 +00:00
|
|
|
modeling.updateProperties(flowConnection, { name: undefined });
|
2015-06-18 14:57:58 +00:00
|
|
|
|
2018-01-31 11:06:17 +00:00
|
|
|
// when
|
|
|
|
commandStack.undo();
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(flowConnection.businessObject.name).to.equal('conditional');
|
|
|
|
}
|
|
|
|
));
|
2015-06-18 14:57:58 +00:00
|
|
|
|
|
|
|
|
2015-04-13 08:55:17 +00:00
|
|
|
it('updating id', inject(function(elementRegistry, commandStack, modeling) {
|
|
|
|
|
|
|
|
// given
|
2018-01-31 11:06:17 +00:00
|
|
|
var flowConnection = elementRegistry.get('SequenceFlow_1'),
|
|
|
|
flowBo = flowConnection.businessObject;
|
|
|
|
|
|
|
|
var ids = flowBo.$model.ids;
|
2015-04-13 08:55:17 +00:00
|
|
|
|
|
|
|
// when
|
|
|
|
modeling.updateProperties(flowConnection, { id: 'FOO_BAR' });
|
|
|
|
commandStack.undo();
|
|
|
|
|
|
|
|
// then
|
2015-10-05 11:35:10 +00:00
|
|
|
expect(ids.assigned('FOO_BAR')).to.be.false;
|
2018-01-31 11:06:17 +00:00
|
|
|
expect(ids.assigned('SequenceFlow_1')).to.eql(flowBo);
|
2015-10-05 11:35:10 +00:00
|
|
|
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(flowConnection.id).to.equal('SequenceFlow_1');
|
2018-01-31 11:06:17 +00:00
|
|
|
expect(flowBo.id).to.equal('SequenceFlow_1');
|
2015-04-13 08:55:17 +00:00
|
|
|
}));
|
|
|
|
|
2015-06-18 14:57:58 +00:00
|
|
|
|
2018-01-31 11:06:17 +00:00
|
|
|
it('updating extension elements', inject(
|
|
|
|
function(elementRegistry, commandStack, modeling) {
|
2015-06-18 14:57:58 +00:00
|
|
|
|
2018-01-31 11:06:17 +00:00
|
|
|
// given
|
|
|
|
var flowConnection = elementRegistry.get('SequenceFlow_1'),
|
|
|
|
flowBo = flowConnection.businessObject;
|
2015-06-18 14:57:58 +00:00
|
|
|
|
2018-01-31 11:06:17 +00:00
|
|
|
modeling.updateProperties(flowConnection, {
|
|
|
|
'xmlns:foo': 'http://foo',
|
|
|
|
'foo:customAttr': 'FOO'
|
|
|
|
});
|
2015-06-18 14:57:58 +00:00
|
|
|
|
2018-01-31 11:06:17 +00:00
|
|
|
// when
|
|
|
|
commandStack.undo();
|
2015-06-18 14:57:58 +00:00
|
|
|
|
2018-01-31 11:06:17 +00:00
|
|
|
// then
|
|
|
|
expect(flowBo.get('xmlns:foo')).not.to.exist;
|
|
|
|
expect(flowBo.get('foo:customAttr')).not.to.exist;
|
|
|
|
}
|
|
|
|
));
|
2015-06-18 14:57:58 +00:00
|
|
|
|
2015-01-02 15:15:18 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
describe('should redo', function() {
|
|
|
|
|
2018-01-31 11:06:17 +00:00
|
|
|
it('setting loop characteristics', inject(
|
|
|
|
function(elementRegistry, modeling, commandStack, moddle) {
|
2015-01-02 15:15:18 +00:00
|
|
|
|
2018-01-31 11:06:17 +00:00
|
|
|
// given
|
|
|
|
var loopCharacteristics = moddle.create(
|
|
|
|
'bpmn:MultiInstanceLoopCharacteristics'
|
|
|
|
);
|
2015-01-02 15:15:18 +00:00
|
|
|
|
2018-01-31 11:06:17 +00:00
|
|
|
var taskShape = elementRegistry.get('ServiceTask_1'),
|
|
|
|
taskBo = taskShape.businessObject;
|
2015-01-02 15:15:18 +00:00
|
|
|
|
2018-01-31 11:06:17 +00:00
|
|
|
// when
|
|
|
|
modeling.updateProperties(taskShape, {
|
|
|
|
loopCharacteristics: loopCharacteristics
|
|
|
|
});
|
|
|
|
commandStack.undo();
|
|
|
|
commandStack.redo();
|
2015-01-02 15:15:18 +00:00
|
|
|
|
2018-01-31 11:06:17 +00:00
|
|
|
// then
|
|
|
|
expect(taskBo.loopCharacteristics).to.eql(loopCharacteristics);
|
|
|
|
}
|
|
|
|
));
|
2015-01-02 15:15:18 +00:00
|
|
|
|
|
|
|
|
2018-01-31 11:06:17 +00:00
|
|
|
it('updating default flow', inject(
|
|
|
|
function(elementRegistry, commandStack, modeling) {
|
2015-01-02 15:15:18 +00:00
|
|
|
|
2018-01-31 11:06:17 +00:00
|
|
|
// given
|
|
|
|
var gatewayShape = elementRegistry.get('ExclusiveGateway_1');
|
2015-01-02 15:15:18 +00:00
|
|
|
|
2018-01-31 11:06:17 +00:00
|
|
|
// when
|
|
|
|
modeling.updateProperties(gatewayShape, { 'default': undefined });
|
|
|
|
commandStack.undo();
|
|
|
|
commandStack.redo();
|
2015-01-02 15:15:18 +00:00
|
|
|
|
2018-01-31 11:06:17 +00:00
|
|
|
// then
|
|
|
|
expect(gatewayShape.businessObject['default']).not.to.exist;
|
2015-01-02 15:15:18 +00:00
|
|
|
|
2018-01-31 11:06:17 +00:00
|
|
|
// flow got updated, too
|
|
|
|
expect(updatedElements).to.include(
|
|
|
|
elementRegistry.get('SequenceFlow_1')
|
|
|
|
);
|
|
|
|
}
|
|
|
|
));
|
2015-01-02 15:15:18 +00:00
|
|
|
|
|
|
|
|
2018-01-31 11:06:17 +00:00
|
|
|
it('updating name', inject(
|
|
|
|
function(elementRegistry, commandStack, modeling) {
|
2015-01-02 15:15:18 +00:00
|
|
|
|
2018-01-31 11:06:17 +00:00
|
|
|
// given
|
|
|
|
var flowConnection = elementRegistry.get('SequenceFlow_1');
|
2015-01-02 15:15:18 +00:00
|
|
|
|
2018-01-31 11:06:17 +00:00
|
|
|
// when
|
|
|
|
modeling.updateProperties(flowConnection, { name: 'FOO BAR' });
|
|
|
|
commandStack.undo();
|
|
|
|
commandStack.redo();
|
2015-01-02 15:15:18 +00:00
|
|
|
|
2018-01-31 11:06:17 +00:00
|
|
|
// then
|
|
|
|
expect(flowConnection.businessObject.name).to.equal('FOO BAR');
|
2015-01-02 15:15:18 +00:00
|
|
|
|
2018-01-31 11:06:17 +00:00
|
|
|
// flow got updated, too
|
|
|
|
expect(updatedElements).to.include(flowConnection.label);
|
|
|
|
}
|
|
|
|
));
|
2015-01-02 15:15:18 +00:00
|
|
|
|
2015-06-18 14:57:58 +00:00
|
|
|
|
2018-01-31 11:06:17 +00:00
|
|
|
it('unsetting name', inject(
|
|
|
|
function(elementRegistry, commandStack, modeling) {
|
2015-06-18 14:57:58 +00:00
|
|
|
|
2018-01-31 11:06:17 +00:00
|
|
|
// given
|
|
|
|
var flowConnection = elementRegistry.get('SequenceFlow_3');
|
2015-06-18 14:57:58 +00:00
|
|
|
|
2018-01-31 11:06:17 +00:00
|
|
|
modeling.updateProperties(flowConnection, { name: undefined });
|
2015-06-18 14:57:58 +00:00
|
|
|
|
2018-01-31 11:06:17 +00:00
|
|
|
// when
|
|
|
|
commandStack.undo();
|
|
|
|
commandStack.redo();
|
2015-06-18 14:57:58 +00:00
|
|
|
|
2018-01-31 11:06:17 +00:00
|
|
|
// then
|
|
|
|
expect(flowConnection.businessObject.name).not.to.exist;
|
|
|
|
}
|
|
|
|
));
|
2015-06-18 14:57:58 +00:00
|
|
|
|
2015-01-02 15:15:18 +00:00
|
|
|
});
|
|
|
|
|
2015-11-25 20:53:02 +00:00
|
|
|
|
2015-12-08 12:29:03 +00:00
|
|
|
describe('unwrap diagram elements', function() {
|
|
|
|
|
2018-01-31 11:06:17 +00:00
|
|
|
it('updating default flow with connection', inject(
|
|
|
|
function(elementRegistry, modeling) {
|
2015-12-08 12:29:03 +00:00
|
|
|
|
2018-01-31 11:06:17 +00:00
|
|
|
// given
|
|
|
|
var gatewayShape = elementRegistry.get('ExclusiveGateway_1'),
|
|
|
|
newDefaultFlowConnection = elementRegistry.get('SequenceFlow_2');
|
2015-12-08 12:29:03 +00:00
|
|
|
|
2018-01-31 11:06:17 +00:00
|
|
|
// when
|
|
|
|
modeling.updateProperties(gatewayShape, {
|
|
|
|
'default': newDefaultFlowConnection
|
|
|
|
});
|
2015-12-08 12:29:03 +00:00
|
|
|
|
2018-01-31 11:06:17 +00:00
|
|
|
// then
|
|
|
|
expect(gatewayShape.businessObject['default']).to.eql(
|
|
|
|
newDefaultFlowConnection.businessObject
|
|
|
|
);
|
2015-12-08 12:29:03 +00:00
|
|
|
|
2018-01-31 11:06:17 +00:00
|
|
|
// flow got updated, too
|
|
|
|
expect(updatedElements).to.include(newDefaultFlowConnection);
|
|
|
|
}
|
|
|
|
));
|
2015-12-08 12:29:03 +00:00
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2015-11-25 20:53:02 +00:00
|
|
|
describe('error handling', function() {
|
|
|
|
|
2018-01-31 11:06:17 +00:00
|
|
|
it('should ignore unchanged id', inject(
|
|
|
|
function(elementRegistry, modeling) {
|
2015-11-25 20:53:02 +00:00
|
|
|
|
2018-01-31 11:06:17 +00:00
|
|
|
// given
|
|
|
|
var flowConnection = elementRegistry.get('SequenceFlow_1'),
|
|
|
|
flowBo = flowConnection.businessObject;
|
2015-11-25 20:53:02 +00:00
|
|
|
|
2018-01-31 11:06:17 +00:00
|
|
|
var ids = flowBo.$model.ids;
|
2015-11-25 20:53:02 +00:00
|
|
|
|
2018-01-31 11:06:17 +00:00
|
|
|
// when
|
|
|
|
modeling.updateProperties(flowConnection, { id: 'SequenceFlow_1' });
|
2015-11-25 20:53:02 +00:00
|
|
|
|
2018-01-31 11:06:17 +00:00
|
|
|
// then
|
|
|
|
expect(ids.assigned('SequenceFlow_1')).to.eql(flowBo);
|
|
|
|
|
|
|
|
expect(flowBo.id).to.equal('SequenceFlow_1');
|
|
|
|
}
|
|
|
|
));
|
2015-11-25 20:53:02 +00:00
|
|
|
|
2018-01-31 11:15:32 +00:00
|
|
|
|
|
|
|
it('should ignore setting color on root', inject(
|
|
|
|
function(canvas, modeling) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var rootElement = canvas.getRootElement();
|
|
|
|
|
|
|
|
// when
|
|
|
|
modeling.updateProperties(rootElement, {
|
|
|
|
di: {
|
|
|
|
fill: 'fuchsia'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(rootElement.di).not.to.exist;
|
|
|
|
}
|
|
|
|
));
|
|
|
|
|
2015-11-25 20:53:02 +00:00
|
|
|
});
|
|
|
|
|
2015-01-02 15:15:18 +00:00
|
|
|
});
|