2018-04-02 19:01:53 +00:00
|
|
|
import {
|
|
|
|
bootstrapModeler,
|
|
|
|
inject
|
|
|
|
} from 'test/TestHelper';
|
2016-03-03 16:09:43 +00:00
|
|
|
|
2018-04-02 19:01:53 +00:00
|
|
|
import modelingModule from 'lib/features/modeling';
|
|
|
|
import coreModule from 'lib/core';
|
2016-03-03 16:09:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
describe('features/modeling - update label', function() {
|
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
var diagramXML = require('./UpdateLabel.bpmn');
|
2016-03-03 16:09:43 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
beforeEach(bootstrapModeler(diagramXML, {
|
2018-01-24 19:25:28 +00:00
|
|
|
modules: [
|
|
|
|
coreModule,
|
|
|
|
modelingModule
|
|
|
|
]
|
2016-06-07 06:46:45 +00:00
|
|
|
}));
|
2016-03-03 16:09:43 +00:00
|
|
|
|
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
it('should change name of start event', inject(
|
|
|
|
function(modeling, elementRegistry, eventBus) {
|
2016-03-03 16:09:43 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
// given
|
|
|
|
var startEvent_1 = elementRegistry.get('StartEvent_1');
|
2016-03-03 16:09:43 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
// when
|
|
|
|
modeling.updateLabel(startEvent_1, 'bar');
|
2016-03-03 16:09:43 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
// then
|
|
|
|
expect(startEvent_1.businessObject.name).to.equal('bar');
|
|
|
|
}
|
|
|
|
));
|
2016-03-03 16:09:43 +00:00
|
|
|
|
|
|
|
|
2018-04-30 09:06:26 +00:00
|
|
|
it('should create label name of start event', inject(
|
2018-01-24 19:25:28 +00:00
|
|
|
function(modeling, elementRegistry) {
|
2016-03-03 16:09:43 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
// given
|
|
|
|
var startEvent_2 = elementRegistry.get('StartEvent_2');
|
2016-03-03 16:09:43 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
// when
|
|
|
|
modeling.updateLabel(startEvent_2, 'bar');
|
2016-03-03 16:09:43 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
// then
|
|
|
|
expect(startEvent_2.businessObject.name).to.equal('bar');
|
2018-04-30 09:06:26 +00:00
|
|
|
expect(startEvent_2.label).to.exist;
|
2018-01-24 19:25:28 +00:00
|
|
|
}
|
|
|
|
));
|
2016-03-03 16:09:43 +00:00
|
|
|
|
|
|
|
|
2018-06-08 14:01:40 +00:00
|
|
|
describe('should delete label', function() {
|
2016-03-03 16:09:43 +00:00
|
|
|
|
2018-06-08 14:01:40 +00:00
|
|
|
it('when setting null', inject(
|
|
|
|
function(modeling, elementRegistry) {
|
2016-03-03 16:09:43 +00:00
|
|
|
|
2018-06-08 14:01:40 +00:00
|
|
|
// given
|
|
|
|
var startEvent_1 = elementRegistry.get('StartEvent_1');
|
2016-03-03 16:09:43 +00:00
|
|
|
|
2018-06-08 14:01:40 +00:00
|
|
|
// when
|
|
|
|
modeling.updateLabel(startEvent_1, null);
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(startEvent_1.businessObject.name).not.to.exist;
|
|
|
|
expect(startEvent_1.label).not.to.exist;
|
|
|
|
}
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
|
|
it('when setting empty string', inject(
|
|
|
|
function(modeling, elementRegistry) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var startEvent_1 = elementRegistry.get('StartEvent_1');
|
|
|
|
|
|
|
|
// when
|
|
|
|
modeling.updateLabel(startEvent_1, '');
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(startEvent_1.businessObject.name).to.equal('');
|
|
|
|
expect(startEvent_1.label).not.to.exist;
|
|
|
|
}
|
|
|
|
));
|
|
|
|
|
|
|
|
});
|
2016-03-03 16:09:43 +00:00
|
|
|
|
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
it('should change name of start event when editing label', inject(
|
|
|
|
function(modeling, elementRegistry) {
|
2016-03-03 16:09:43 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
// given
|
|
|
|
var startEvent_1 = elementRegistry.get('StartEvent_1');
|
|
|
|
var startEvent_1_label = elementRegistry.get('StartEvent_1_label');
|
2016-03-03 16:09:43 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
// when
|
|
|
|
modeling.updateLabel(startEvent_1_label, 'bar');
|
2016-03-03 16:09:43 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
// then
|
|
|
|
expect(startEvent_1.businessObject.name).to.equal('bar');
|
|
|
|
}
|
|
|
|
));
|
2016-03-03 16:09:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
it('should change name of task', inject(function(modeling, elementRegistry) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var task_1 = elementRegistry.get('Task_1');
|
|
|
|
|
|
|
|
// when
|
|
|
|
modeling.updateLabel(task_1, 'foo');
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(task_1.businessObject.name).to.equal('foo');
|
|
|
|
expect(task_1.label).to.be.undefined;
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
it('should change text annotation text and bounds', inject(
|
|
|
|
function(modeling, elementRegistry) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var element = elementRegistry.get('TextAnnotation_1');
|
|
|
|
|
|
|
|
var newBounds = { x: 100, y: 100, width: 100, height: 30 };
|
|
|
|
|
|
|
|
// when
|
|
|
|
modeling.updateLabel(element, 'bar', newBounds);
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(element.businessObject.text).to.equal('bar');
|
|
|
|
expect(element).to.have.bounds(newBounds);
|
|
|
|
}
|
|
|
|
));
|
|
|
|
|
|
|
|
|
2019-05-22 06:45:12 +00:00
|
|
|
it('should change value of group', inject(function(modeling, elementRegistry) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var group_1 = elementRegistry.get('Group_1');
|
|
|
|
|
|
|
|
// when
|
|
|
|
modeling.updateLabel(group_1, 'foo');
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(group_1.businessObject.categoryValueRef.value).to.equal('foo');
|
|
|
|
expect(group_1.label).to.exist;
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
it('should propertly fire events.changed after event name change', inject(
|
|
|
|
function(modeling, elementRegistry, eventBus) {
|
2016-03-03 16:09:43 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var startEvent_1 = elementRegistry.get('StartEvent_1');
|
2016-03-03 16:09:43 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
var changedEvent;
|
2016-03-03 16:09:43 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
eventBus.on('elements.changed', function(event) {
|
|
|
|
changedEvent = event;
|
|
|
|
});
|
2016-03-03 16:09:43 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
modeling.updateLabel(startEvent_1, 'foo');
|
2016-03-03 16:09:43 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// then
|
|
|
|
expect(changedEvent.elements).to.include(startEvent_1);
|
2018-01-24 19:25:28 +00:00
|
|
|
}
|
|
|
|
));
|
2016-03-03 16:09:43 +00:00
|
|
|
|
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
it('should propertly fire events.changed after event label change', inject(
|
|
|
|
function(modeling, elementRegistry, eventBus) {
|
2016-03-03 16:09:43 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var startEvent_1 = elementRegistry.get('StartEvent_1');
|
|
|
|
var startEvent_1_label = elementRegistry.get('StartEvent_1_label');
|
2016-03-03 16:09:43 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
var changedEvent;
|
2016-03-03 16:09:43 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
eventBus.on('elements.changed', function(event) {
|
|
|
|
changedEvent = event;
|
|
|
|
});
|
2016-03-03 16:09:43 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
modeling.updateLabel(startEvent_1_label, 'foo');
|
2016-03-03 16:09:43 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// then
|
|
|
|
expect(changedEvent.elements).to.include(startEvent_1);
|
2018-01-24 19:25:28 +00:00
|
|
|
}
|
|
|
|
));
|
2016-03-03 16:09:43 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
});
|