2018-04-02 19:01:53 +00:00
|
|
|
import {
|
|
|
|
bootstrapModeler,
|
|
|
|
inject
|
|
|
|
} from 'test/TestHelper';
|
2014-06-11 13:08:45 +00:00
|
|
|
|
2018-04-02 19:01:53 +00:00
|
|
|
import labelEditingModule from 'lib/features/label-editing';
|
|
|
|
import coreModule from 'lib/core';
|
|
|
|
import draggingModule from 'diagram-js/lib/features/dragging';
|
|
|
|
import modelingModule from 'lib/features/modeling';
|
|
|
|
import autoPlaceModule from 'lib/features/auto-place';
|
2016-09-05 12:27:34 +00:00
|
|
|
|
2018-04-02 19:01:53 +00:00
|
|
|
import {
|
|
|
|
getLabel
|
|
|
|
} from 'lib/features/label-editing/LabelUtil';
|
2014-06-17 09:53:07 +00:00
|
|
|
|
2018-05-25 11:56:12 +00:00
|
|
|
var MEDIUM_LINE_HEIGHT = 12 * 1.2;
|
2017-06-27 07:37:58 +00:00
|
|
|
|
|
|
|
var DELTA = 3;
|
|
|
|
|
|
|
|
|
2016-09-01 16:01:04 +00:00
|
|
|
describe('features - label-editing', function() {
|
2014-06-17 09:53:07 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
var diagramXML = require('./LabelEditing.bpmn');
|
2014-06-17 09:53:07 +00:00
|
|
|
|
2019-03-25 15:43:41 +00:00
|
|
|
|
2016-03-08 13:41:32 +00:00
|
|
|
describe('basics', function() {
|
2014-06-17 09:53:07 +00:00
|
|
|
|
2018-02-15 22:04:02 +00:00
|
|
|
beforeEach(bootstrapModeler(diagramXML, {
|
2018-01-24 19:25:28 +00:00
|
|
|
modules: [
|
|
|
|
labelEditingModule,
|
|
|
|
coreModule,
|
|
|
|
draggingModule,
|
2018-02-15 22:04:02 +00:00
|
|
|
modelingModule,
|
|
|
|
autoPlaceModule
|
2018-01-24 19:25:28 +00:00
|
|
|
]
|
|
|
|
}));
|
2014-06-17 09:53:07 +00:00
|
|
|
|
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
it('should register on dblclick', inject(
|
|
|
|
function(elementRegistry, directEditing, eventBus) {
|
2016-05-18 05:54:58 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
// given
|
|
|
|
var shape = elementRegistry.get('Task_1');
|
2014-06-17 09:53:07 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
// when
|
|
|
|
eventBus.fire('element.dblclick', { element: shape });
|
2014-06-17 09:53:07 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
// then
|
|
|
|
expect(directEditing.isActive()).to.be.true;
|
2016-09-27 12:32:22 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
// clean up
|
|
|
|
directEditing._textbox.destroy();
|
|
|
|
}
|
|
|
|
));
|
2014-06-17 09:53:07 +00:00
|
|
|
|
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
it('should cancel on <ESC>', inject(
|
|
|
|
function(elementRegistry, directEditing, eventBus) {
|
2016-05-18 05:54:58 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
// given
|
|
|
|
var shape = elementRegistry.get('Task_1'),
|
|
|
|
task = shape.businessObject;
|
2014-06-17 09:53:07 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
var oldName = task.name;
|
2014-06-17 09:53:07 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
// activate
|
|
|
|
eventBus.fire('element.dblclick', { element: shape });
|
2014-06-17 09:53:07 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
var textbox = directEditing._textbox.content;
|
2014-06-17 09:53:07 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
// when
|
|
|
|
// change + ESC is pressed
|
|
|
|
textbox.innerText = 'new value';
|
|
|
|
triggerKeyEvent(textbox, 'keydown', 27);
|
2014-06-17 09:53:07 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
// then
|
|
|
|
expect(directEditing.isActive()).to.be.false;
|
|
|
|
expect(task.name).to.equal(oldName);
|
|
|
|
}
|
|
|
|
));
|
2014-06-17 09:53:07 +00:00
|
|
|
|
2014-07-07 15:17:41 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
it('should complete on drag start', inject(
|
|
|
|
function(elementRegistry, directEditing, dragging) {
|
2016-05-18 05:54:58 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
// given
|
|
|
|
var shape = elementRegistry.get('Task_1'),
|
|
|
|
task = shape.businessObject;
|
2016-03-08 13:41:32 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
directEditing.activate(shape);
|
2016-03-08 13:41:32 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
directEditing._textbox.content.textContent = 'FOO BAR';
|
2016-03-08 13:41:32 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
// when
|
|
|
|
dragging.init(null, { x: 0, y: 0 }, 'foo');
|
2016-03-08 13:41:32 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
// then
|
|
|
|
expect(task.name).to.equal('FOO BAR');
|
|
|
|
}
|
|
|
|
));
|
2016-03-08 13:41:32 +00:00
|
|
|
|
|
|
|
|
2018-02-15 22:04:02 +00:00
|
|
|
it('should complete on auto place', inject(
|
|
|
|
function(elementRegistry, directEditing, elementFactory, autoPlace) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var shape = elementRegistry.get('Task_1'),
|
|
|
|
task = shape.businessObject;
|
|
|
|
|
|
|
|
directEditing.activate(shape);
|
|
|
|
|
|
|
|
directEditing._textbox.content.textContent = 'FOO BAR';
|
|
|
|
|
|
|
|
// when
|
|
|
|
autoPlace.append(shape, elementFactory.create(
|
|
|
|
'shape',
|
|
|
|
{ type: 'bpmn:ServiceTask' }
|
|
|
|
));
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(task.name).to.equal('FOO BAR');
|
|
|
|
}
|
|
|
|
));
|
|
|
|
|
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
it('should submit on root element click', inject(
|
|
|
|
function(elementRegistry, directEditing, canvas, eventBus) {
|
2016-05-18 05:54:58 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
// given
|
|
|
|
var shape = elementRegistry.get('Task_1'),
|
|
|
|
task = shape.businessObject;
|
2014-07-07 15:17:41 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
// activate
|
|
|
|
eventBus.fire('element.dblclick', { element: shape });
|
2014-07-07 15:17:41 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
var newName = 'new value';
|
2014-07-07 15:17:41 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
// a <textarea /> element
|
|
|
|
var content = directEditing._textbox.content;
|
2016-08-19 14:16:37 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
content.innerText = newName;
|
2014-07-07 15:17:41 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
// when
|
|
|
|
// change + <element.mousedown>
|
2015-02-05 08:24:27 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
eventBus.fire('element.mousedown', { element: canvas.getRootElement() });
|
2014-07-07 15:17:41 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
// then
|
|
|
|
expect(directEditing.isActive()).to.be.false;
|
|
|
|
expect(task.name).to.equal(newName);
|
|
|
|
}
|
|
|
|
));
|
2014-07-07 15:17:41 +00:00
|
|
|
|
2014-06-17 09:53:07 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
2016-03-08 13:41:32 +00:00
|
|
|
describe('details', function() {
|
|
|
|
|
2018-02-15 22:04:02 +00:00
|
|
|
beforeEach(bootstrapModeler(diagramXML, {
|
2018-01-24 19:25:28 +00:00
|
|
|
modules: [
|
|
|
|
labelEditingModule,
|
|
|
|
coreModule,
|
|
|
|
modelingModule
|
|
|
|
]
|
|
|
|
}));
|
2016-03-08 13:41:32 +00:00
|
|
|
|
|
|
|
var elementRegistry,
|
|
|
|
eventBus,
|
|
|
|
directEditing;
|
2014-06-17 09:53:07 +00:00
|
|
|
|
2016-05-18 05:54:58 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
beforeEach(inject([
|
|
|
|
'elementRegistry', 'eventBus', 'directEditing',
|
|
|
|
function(_elementRegistry, _eventBus, _directEditing) {
|
|
|
|
elementRegistry = _elementRegistry;
|
|
|
|
eventBus = _eventBus;
|
|
|
|
directEditing = _directEditing;
|
|
|
|
}
|
|
|
|
]));
|
2016-05-18 05:54:58 +00:00
|
|
|
|
2014-06-17 09:53:07 +00:00
|
|
|
|
2016-03-08 13:41:32 +00:00
|
|
|
function directEditActivate(element) {
|
|
|
|
if (element.waypoints) {
|
|
|
|
eventBus.fire('element.dblclick', { element: element });
|
|
|
|
} else {
|
|
|
|
eventBus.fire('element.dblclick', { element: element });
|
|
|
|
}
|
2014-06-17 09:53:07 +00:00
|
|
|
}
|
|
|
|
|
2016-05-18 05:54:58 +00:00
|
|
|
function directEditUpdate(value) {
|
2016-08-19 14:16:37 +00:00
|
|
|
directEditing._textbox.content.innerText = value;
|
2016-03-08 13:41:32 +00:00
|
|
|
}
|
2014-06-17 09:53:07 +00:00
|
|
|
|
2016-05-18 05:54:58 +00:00
|
|
|
function directEditComplete(value) {
|
|
|
|
directEditUpdate(value);
|
2016-03-08 13:41:32 +00:00
|
|
|
directEditing.complete();
|
|
|
|
}
|
2014-06-17 09:53:07 +00:00
|
|
|
|
2016-05-18 05:54:58 +00:00
|
|
|
function directEditCancel(value) {
|
|
|
|
directEditUpdate(value);
|
2016-03-08 13:41:32 +00:00
|
|
|
directEditing.cancel();
|
|
|
|
}
|
2014-06-17 09:53:07 +00:00
|
|
|
|
|
|
|
|
2016-03-08 13:41:32 +00:00
|
|
|
describe('command support', function() {
|
2014-06-17 09:53:07 +00:00
|
|
|
|
2016-05-18 05:54:58 +00:00
|
|
|
it('should update via command stack', function() {
|
2016-03-15 14:03:11 +00:00
|
|
|
|
2016-05-18 05:54:58 +00:00
|
|
|
// given
|
2017-06-27 07:37:58 +00:00
|
|
|
var diagramElement = elementRegistry.get('Task_1');
|
2016-03-15 14:03:11 +00:00
|
|
|
|
2016-05-18 05:54:58 +00:00
|
|
|
var listenerCalled;
|
2016-03-15 14:03:11 +00:00
|
|
|
|
2016-05-18 05:54:58 +00:00
|
|
|
eventBus.on('commandStack.changed', function(e) {
|
|
|
|
listenerCalled = true;
|
2016-03-15 14:03:11 +00:00
|
|
|
});
|
|
|
|
|
2016-05-18 05:54:58 +00:00
|
|
|
// when
|
|
|
|
directEditActivate(diagramElement);
|
|
|
|
directEditComplete('BAR');
|
2016-03-15 14:03:11 +00:00
|
|
|
|
2016-05-18 05:54:58 +00:00
|
|
|
// then
|
|
|
|
expect(listenerCalled).to.be.true;
|
2014-06-17 09:53:07 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
2016-05-18 05:54:58 +00:00
|
|
|
it('should undo via command stack', inject(function(commandStack) {
|
2014-06-17 09:53:07 +00:00
|
|
|
|
2016-03-08 13:41:32 +00:00
|
|
|
// given
|
2017-06-27 07:37:58 +00:00
|
|
|
var diagramElement = elementRegistry.get('Task_1');
|
2016-03-15 14:03:11 +00:00
|
|
|
|
2018-04-02 19:01:53 +00:00
|
|
|
var oldLabel = getLabel(diagramElement);
|
2016-03-15 14:03:11 +00:00
|
|
|
|
2016-05-18 05:54:58 +00:00
|
|
|
// when
|
2016-03-08 13:41:32 +00:00
|
|
|
directEditActivate(diagramElement);
|
2016-05-18 05:54:58 +00:00
|
|
|
directEditComplete('BAR');
|
2014-06-17 09:53:07 +00:00
|
|
|
|
2016-03-08 13:41:32 +00:00
|
|
|
commandStack.undo();
|
2014-06-17 09:53:07 +00:00
|
|
|
|
2016-03-08 13:41:32 +00:00
|
|
|
// then
|
2018-04-02 19:01:53 +00:00
|
|
|
var label = getLabel(diagramElement);
|
2016-05-18 05:54:58 +00:00
|
|
|
expect(label).to.eql(oldLabel);
|
2016-03-08 13:41:32 +00:00
|
|
|
}));
|
2014-06-17 09:53:07 +00:00
|
|
|
|
2016-03-08 13:41:32 +00:00
|
|
|
});
|
2014-06-17 09:53:07 +00:00
|
|
|
|
|
|
|
|
2018-06-08 14:13:18 +00:00
|
|
|
describe('should unset', function() {
|
|
|
|
|
|
|
|
it('name on empty text', function() {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var diagramElement = elementRegistry.get('SequenceFlow_1');
|
|
|
|
|
|
|
|
// when
|
|
|
|
directEditActivate(diagramElement);
|
|
|
|
directEditComplete(' ');
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(diagramElement.businessObject.name).not.to.exist;
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
it('text on empty text', function() {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var diagramElement = elementRegistry.get('TextAnnotation_1');
|
|
|
|
|
|
|
|
// when
|
|
|
|
directEditActivate(diagramElement);
|
|
|
|
directEditComplete(' ');
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(diagramElement.businessObject.text).not.to.exist;
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2016-03-08 13:41:32 +00:00
|
|
|
describe('should trigger redraw', function() {
|
2014-06-17 09:53:07 +00:00
|
|
|
|
2016-03-08 13:41:32 +00:00
|
|
|
it('on shape change', function() {
|
2016-05-18 05:54:58 +00:00
|
|
|
|
2016-03-08 13:41:32 +00:00
|
|
|
// given
|
2017-06-27 07:37:58 +00:00
|
|
|
var diagramElement = elementRegistry.get('Task_1');
|
2014-06-17 09:53:07 +00:00
|
|
|
|
2016-03-08 13:41:32 +00:00
|
|
|
var listenerCalled;
|
2014-06-17 09:53:07 +00:00
|
|
|
|
2016-03-08 13:41:32 +00:00
|
|
|
eventBus.on('element.changed', function(e) {
|
|
|
|
if (e.element === diagramElement) {
|
|
|
|
listenerCalled = true;
|
|
|
|
}
|
|
|
|
});
|
2014-06-17 09:53:07 +00:00
|
|
|
|
2016-03-08 13:41:32 +00:00
|
|
|
// when
|
|
|
|
directEditActivate(diagramElement);
|
2016-05-18 05:54:58 +00:00
|
|
|
directEditComplete('BAR');
|
2014-06-17 09:53:07 +00:00
|
|
|
|
2016-03-08 13:41:32 +00:00
|
|
|
// then
|
|
|
|
expect(listenerCalled).to.be.true;
|
2014-06-17 09:53:07 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
2016-03-08 13:41:32 +00:00
|
|
|
it('on connection on change', function() {
|
2014-06-17 09:53:07 +00:00
|
|
|
|
2016-03-08 13:41:32 +00:00
|
|
|
// given
|
2017-06-27 07:37:58 +00:00
|
|
|
var diagramElement = elementRegistry.get('SequenceFlow_1');
|
2014-06-17 09:53:07 +00:00
|
|
|
|
2016-03-08 13:41:32 +00:00
|
|
|
var listenerCalled;
|
2014-06-17 09:53:07 +00:00
|
|
|
|
2016-03-08 13:41:32 +00:00
|
|
|
eventBus.on('element.changed', function(e) {
|
|
|
|
if (e.element === diagramElement.label) {
|
|
|
|
listenerCalled = true;
|
|
|
|
}
|
|
|
|
});
|
2014-06-17 09:53:07 +00:00
|
|
|
|
2016-03-08 13:41:32 +00:00
|
|
|
// when
|
|
|
|
directEditActivate(diagramElement);
|
2016-05-18 05:54:58 +00:00
|
|
|
directEditComplete('BAR');
|
2014-06-17 09:53:07 +00:00
|
|
|
|
2016-03-08 13:41:32 +00:00
|
|
|
// then
|
|
|
|
expect(listenerCalled).to.be.true;
|
2014-06-17 09:53:07 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
});
|
2014-06-11 13:08:45 +00:00
|
|
|
|
|
|
|
|
2016-03-08 13:41:32 +00:00
|
|
|
describe('element support, should edit', function() {
|
2014-06-17 09:53:07 +00:00
|
|
|
|
2016-03-08 13:41:32 +00:00
|
|
|
function directEdit(elementId) {
|
2016-05-18 05:54:58 +00:00
|
|
|
|
2016-03-08 13:41:32 +00:00
|
|
|
return inject(function(elementRegistry, eventBus, directEditing) {
|
2014-06-17 09:53:07 +00:00
|
|
|
|
2016-03-08 13:41:32 +00:00
|
|
|
var diagramElement = elementRegistry.get(elementId);
|
2014-06-17 09:53:07 +00:00
|
|
|
|
2018-04-02 19:01:53 +00:00
|
|
|
var label = getLabel(diagramElement);
|
2014-06-17 09:53:07 +00:00
|
|
|
|
2016-05-18 05:54:58 +00:00
|
|
|
|
2016-03-08 13:41:32 +00:00
|
|
|
// when
|
|
|
|
directEditActivate(diagramElement);
|
2014-06-17 09:53:07 +00:00
|
|
|
|
2016-03-08 13:41:32 +00:00
|
|
|
// then
|
|
|
|
// expect editing to be active
|
|
|
|
expect(directEditing.getValue()).to.eql(label);
|
|
|
|
expect(directEditing.isActive()).to.be.true;
|
2014-06-17 09:53:07 +00:00
|
|
|
|
|
|
|
|
2016-05-18 05:54:58 +00:00
|
|
|
// when
|
|
|
|
directEditComplete('B');
|
2014-06-17 09:53:07 +00:00
|
|
|
|
2016-03-08 13:41:32 +00:00
|
|
|
// then
|
2016-05-18 05:54:58 +00:00
|
|
|
// expect update to have happened
|
2018-04-02 19:01:53 +00:00
|
|
|
label = getLabel(diagramElement);
|
2016-05-18 05:54:58 +00:00
|
|
|
expect(label).to.equal('B');
|
2014-06-17 09:53:07 +00:00
|
|
|
|
|
|
|
|
2016-03-08 13:41:32 +00:00
|
|
|
// when
|
|
|
|
directEditActivate(diagramElement);
|
|
|
|
directEditCancel('C');
|
2014-06-17 09:53:07 +00:00
|
|
|
|
2016-03-08 13:41:32 +00:00
|
|
|
// expect no label update to have happened
|
2018-04-02 19:01:53 +00:00
|
|
|
label = getLabel(diagramElement);
|
2016-03-08 13:41:32 +00:00
|
|
|
expect(label).to.equal('B');
|
|
|
|
});
|
|
|
|
}
|
2014-06-17 09:53:07 +00:00
|
|
|
|
|
|
|
|
2017-06-27 07:37:58 +00:00
|
|
|
it('task', directEdit('Task_1'));
|
2014-06-17 09:53:07 +00:00
|
|
|
|
|
|
|
|
2017-06-27 07:37:58 +00:00
|
|
|
it('gateway', directEdit('ExclusiveGateway_1'));
|
2014-06-17 09:53:07 +00:00
|
|
|
|
2017-06-27 07:37:58 +00:00
|
|
|
it('gateway via label', directEdit('ExclusiveGateway_1_label'));
|
2014-06-17 09:53:07 +00:00
|
|
|
|
2016-05-18 05:54:58 +00:00
|
|
|
|
2017-06-27 07:37:58 +00:00
|
|
|
it('event', directEdit('StartEvent_1'));
|
2014-06-17 09:53:07 +00:00
|
|
|
|
2017-06-27 07:37:58 +00:00
|
|
|
it('event via label', directEdit('StartEvent_1_label'));
|
2014-06-17 09:53:07 +00:00
|
|
|
|
2017-06-27 07:37:58 +00:00
|
|
|
it('event without label', directEdit('EndEvent_1'));
|
2014-06-17 09:53:07 +00:00
|
|
|
|
|
|
|
|
2017-06-27 07:37:58 +00:00
|
|
|
it('data store reference', directEdit('DataStoreReference_1'));
|
2014-06-17 09:53:07 +00:00
|
|
|
|
2017-06-27 07:37:58 +00:00
|
|
|
it('data object reference', directEdit('DataObjectReference_1'));
|
2014-06-17 09:53:07 +00:00
|
|
|
|
|
|
|
|
2017-06-27 07:37:58 +00:00
|
|
|
it('sequenceflow', directEdit('SequenceFlow_1'));
|
2014-06-17 09:53:07 +00:00
|
|
|
|
2017-06-27 07:37:58 +00:00
|
|
|
it('sequenceflow via label', directEdit('SequenceFlow_1_label'));
|
2014-06-17 09:53:07 +00:00
|
|
|
|
2017-06-27 07:37:58 +00:00
|
|
|
it('sequenceflow without label', directEdit('SequenceFlow_2'));
|
2014-06-17 09:53:07 +00:00
|
|
|
|
|
|
|
|
2017-06-27 07:37:58 +00:00
|
|
|
it('message flow', directEdit('MessageFlow_1'));
|
2014-06-17 09:53:07 +00:00
|
|
|
|
2017-06-27 07:37:58 +00:00
|
|
|
it('message flow via label', directEdit('MessageFlow_1_label'));
|
2014-06-17 09:53:07 +00:00
|
|
|
|
|
|
|
|
2017-06-27 07:37:58 +00:00
|
|
|
it('pool', directEdit('Participant_1'));
|
2014-06-17 09:53:07 +00:00
|
|
|
|
2017-06-27 07:37:58 +00:00
|
|
|
it('pool, collapsed', directEdit('Participant_2'));
|
2014-06-17 09:53:07 +00:00
|
|
|
|
|
|
|
|
2017-06-27 07:37:58 +00:00
|
|
|
it('lane with label', directEdit('Lane_1'));
|
2014-06-17 09:53:07 +00:00
|
|
|
|
2017-06-27 07:37:58 +00:00
|
|
|
it('lane without label', directEdit('Lane_2'));
|
2014-06-11 13:08:45 +00:00
|
|
|
|
2019-03-25 15:43:41 +00:00
|
|
|
|
|
|
|
it('data input', directEdit('DataInput'));
|
|
|
|
|
|
|
|
it('data output', directEdit('DataOutput'));
|
|
|
|
|
2019-05-22 06:45:12 +00:00
|
|
|
|
|
|
|
it('group', directEdit('Group_1'));
|
|
|
|
|
|
|
|
it('group via label', directEdit('Group_1_label'));
|
|
|
|
|
2016-03-08 13:41:32 +00:00
|
|
|
});
|
2019-03-25 15:43:41 +00:00
|
|
|
|
2014-06-11 13:08:45 +00:00
|
|
|
});
|
|
|
|
|
2016-03-07 16:06:24 +00:00
|
|
|
|
2019-05-22 06:46:11 +00:00
|
|
|
describe('group support', function() {
|
|
|
|
|
|
|
|
beforeEach(bootstrapModeler(diagramXML, {
|
|
|
|
modules: [
|
|
|
|
labelEditingModule,
|
|
|
|
coreModule,
|
|
|
|
modelingModule
|
|
|
|
],
|
|
|
|
canvas: { deferUpdate: false }
|
|
|
|
}));
|
|
|
|
|
|
|
|
it('should initialize categoryValue for empty group', inject(
|
|
|
|
function(elementRegistry, directEditing) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var shape = elementRegistry.get('Group_2');
|
|
|
|
|
|
|
|
// when
|
|
|
|
directEditing.activate(shape);
|
|
|
|
directEditing._textbox.content.innerText = 'FOO';
|
|
|
|
directEditing.complete();
|
|
|
|
|
|
|
|
// then
|
|
|
|
var label = getLabel(shape);
|
|
|
|
|
|
|
|
expect(shape.businessObject.categoryValueRef).to.exist;
|
|
|
|
expect(label).to.equal('FOO');
|
|
|
|
}
|
|
|
|
));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2017-06-27 07:37:58 +00:00
|
|
|
describe('sizes', function() {
|
2016-03-07 16:06:24 +00:00
|
|
|
|
2018-02-15 22:04:02 +00:00
|
|
|
beforeEach(bootstrapModeler(diagramXML, {
|
2018-01-24 19:25:28 +00:00
|
|
|
modules: [
|
|
|
|
labelEditingModule,
|
|
|
|
coreModule,
|
|
|
|
modelingModule
|
|
|
|
],
|
2016-03-07 16:06:24 +00:00
|
|
|
canvas: { deferUpdate: false }
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
2017-06-27 07:37:58 +00:00
|
|
|
describe('bounds', function() {
|
2016-08-19 14:16:37 +00:00
|
|
|
|
|
|
|
describe('external labels', function() {
|
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
it('[zoom 1] should have fixed width and element height', inject(
|
|
|
|
function(canvas, directEditing, elementRegistry) {
|
|
|
|
var zoom = 1;
|
2016-08-19 14:16:37 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
canvas.zoom(zoom);
|
2016-08-19 14:16:37 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
var startEvent = elementRegistry.get('StartEvent_1');
|
2016-08-19 14:16:37 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
var bounds = canvas.getAbsoluteBBox(startEvent.label);
|
|
|
|
var mid = {
|
|
|
|
x: bounds.x + bounds.width / 2,
|
|
|
|
y: bounds.y + bounds.height / 2
|
|
|
|
};
|
2016-08-19 14:16:37 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
directEditing.activate(startEvent);
|
2016-08-19 14:16:37 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
expectBounds(directEditing._textbox.parent, {
|
|
|
|
x: mid.x - (45 * zoom),
|
|
|
|
y: bounds.y - (7 * zoom),
|
|
|
|
width: (90 * zoom),
|
|
|
|
height: bounds.height + (5 * zoom) + 7
|
|
|
|
});
|
|
|
|
}
|
|
|
|
));
|
2016-08-19 14:16:37 +00:00
|
|
|
|
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
it('[zoom 1.5] should have fixed width and element height', inject(
|
|
|
|
function(canvas, directEditing, elementRegistry) {
|
|
|
|
var zoom = 1.5;
|
2016-08-19 14:16:37 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
canvas.zoom(zoom);
|
2016-08-19 14:16:37 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
var startEvent = elementRegistry.get('StartEvent_1');
|
2016-08-19 14:16:37 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
var bounds = canvas.getAbsoluteBBox(startEvent.label);
|
|
|
|
var mid = {
|
|
|
|
x: bounds.x + bounds.width / 2,
|
|
|
|
y: bounds.y + bounds.height / 2
|
|
|
|
};
|
2016-08-19 14:16:37 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
directEditing.activate(startEvent);
|
2016-08-19 14:16:37 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
expectBounds(directEditing._textbox.parent, {
|
|
|
|
x: mid.x - (45 * zoom),
|
|
|
|
y: bounds.y - (7 * zoom),
|
|
|
|
width: (90 * zoom),
|
|
|
|
height: bounds.height + (5 * zoom) + (7 * zoom)
|
|
|
|
});
|
|
|
|
}
|
|
|
|
));
|
2016-08-19 14:16:37 +00:00
|
|
|
|
2017-06-27 07:37:58 +00:00
|
|
|
});
|
2016-08-19 14:16:37 +00:00
|
|
|
|
|
|
|
|
2017-06-27 07:37:58 +00:00
|
|
|
describe('internal labels', function() {
|
2016-08-19 14:16:37 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
it('[zoom 1] should have element size', inject(
|
|
|
|
function(canvas, directEditing, elementRegistry) {
|
|
|
|
var zoom = 1;
|
2016-08-19 14:16:37 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
canvas.zoom(zoom);
|
2016-08-19 14:16:37 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
var task = elementRegistry.get('Task_1');
|
2016-08-19 14:16:37 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
var bounds = canvas.getAbsoluteBBox(task);
|
2016-08-19 14:16:37 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
directEditing.activate(task);
|
2016-08-19 14:16:37 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
expectBounds(directEditing._textbox.parent, bounds);
|
|
|
|
}
|
|
|
|
));
|
2016-08-19 14:16:37 +00:00
|
|
|
|
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
it('[zoom 1.5] should have element size', inject(
|
|
|
|
function(canvas, directEditing, elementRegistry) {
|
|
|
|
var zoom = 1.5;
|
2016-08-19 14:16:37 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
canvas.zoom(zoom);
|
2016-08-19 14:16:37 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
var task = elementRegistry.get('Task_1');
|
2016-08-19 14:16:37 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
var bounds = canvas.getAbsoluteBBox(task);
|
2016-08-19 14:16:37 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
directEditing.activate(task);
|
2016-08-19 14:16:37 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
expectBounds(directEditing._textbox.parent, bounds);
|
|
|
|
}
|
|
|
|
));
|
2016-08-19 14:16:37 +00:00
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2017-06-27 07:37:58 +00:00
|
|
|
describe('sequence flows', function() {
|
2016-03-07 16:06:24 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
it('[zoom 1] should have fixed width and element height', inject(
|
|
|
|
function(canvas, directEditing, elementRegistry) {
|
|
|
|
var zoom = 1;
|
2016-03-07 16:06:24 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
canvas.zoom(zoom);
|
2016-03-07 16:06:24 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
var sequenceFlow = elementRegistry.get('SequenceFlow_1');
|
2016-03-07 16:06:24 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
var bounds = canvas.getAbsoluteBBox(sequenceFlow.label);
|
|
|
|
var mid = {
|
|
|
|
x: bounds.x + bounds.width / 2,
|
|
|
|
y: bounds.y + bounds.height / 2
|
|
|
|
};
|
2016-08-19 14:16:37 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
directEditing.activate(sequenceFlow);
|
2016-08-19 14:16:37 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
expectBounds(directEditing._textbox.parent, {
|
|
|
|
x: mid.x - (45 * zoom),
|
|
|
|
y: bounds.y - (7 * zoom),
|
|
|
|
width: (90 * zoom),
|
|
|
|
height: bounds.height + (5 * zoom) + 7
|
|
|
|
});
|
|
|
|
}
|
|
|
|
));
|
2016-08-19 14:16:37 +00:00
|
|
|
|
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
it('[zoom 1.5] should have fixed width and element height', inject(
|
|
|
|
function(canvas, directEditing, elementRegistry) {
|
|
|
|
var zoom = 1.5;
|
2016-08-19 14:16:37 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
canvas.zoom(zoom);
|
2016-08-19 14:16:37 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
var sequenceflow = elementRegistry.get('SequenceFlow_1');
|
2016-08-19 14:16:37 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
var bounds = canvas.getAbsoluteBBox(sequenceflow.label);
|
|
|
|
var mid = {
|
|
|
|
x: bounds.x + bounds.width / 2,
|
|
|
|
y: bounds.y + bounds.height / 2
|
|
|
|
};
|
2016-08-19 14:16:37 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
directEditing.activate(sequenceflow);
|
2016-08-19 14:16:37 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
expectBounds(directEditing._textbox.parent, {
|
|
|
|
x: mid.x - (45 * zoom),
|
|
|
|
y: bounds.y - (7 * zoom),
|
|
|
|
width: (90 * zoom),
|
|
|
|
height: bounds.height + (5 * zoom) + (7 * zoom)
|
|
|
|
});
|
|
|
|
}
|
|
|
|
));
|
2016-08-19 14:16:37 +00:00
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2017-06-27 07:37:58 +00:00
|
|
|
describe('text annotations', function() {
|
2016-08-19 14:16:37 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
it('[zoom 1] should have element size', inject(
|
|
|
|
function(canvas, directEditing, elementRegistry) {
|
|
|
|
var zoom = 1;
|
2016-08-19 14:16:37 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
canvas.zoom(zoom);
|
2016-08-19 14:16:37 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
var textAnnotation = elementRegistry.get('TextAnnotation_1');
|
2016-08-19 14:16:37 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
var bounds = canvas.getAbsoluteBBox(textAnnotation);
|
2016-08-19 14:16:37 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
directEditing.activate(textAnnotation);
|
2016-08-19 14:16:37 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
expectBounds(directEditing._textbox.parent, bounds);
|
|
|
|
}
|
|
|
|
));
|
2016-08-19 14:16:37 +00:00
|
|
|
|
2016-09-05 12:27:34 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
it('[zoom 1.5] should have element size', inject(
|
|
|
|
function(canvas, directEditing, elementRegistry) {
|
|
|
|
var zoom = 1.5;
|
2016-09-05 12:27:34 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
canvas.zoom(zoom);
|
2016-09-05 12:27:34 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
var textAnnotation = elementRegistry.get('TextAnnotation_1');
|
2016-09-05 12:27:34 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
var bounds = canvas.getAbsoluteBBox(textAnnotation);
|
2016-09-05 12:27:34 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
directEditing.activate(textAnnotation);
|
2016-09-05 12:27:34 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
expectBounds(directEditing._textbox.parent, bounds);
|
|
|
|
}
|
|
|
|
));
|
2016-09-05 12:27:34 +00:00
|
|
|
|
2017-06-27 07:37:58 +00:00
|
|
|
});
|
2016-09-05 12:27:34 +00:00
|
|
|
|
|
|
|
|
2017-06-27 07:37:58 +00:00
|
|
|
describe('expanded sub processes', function() {
|
2016-09-05 12:27:34 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
it('[zoom 1] should have element width and height to fit text', inject(
|
|
|
|
function(canvas, directEditing, elementRegistry) {
|
|
|
|
var zoom = 1;
|
2016-09-05 12:27:34 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
canvas.zoom(zoom);
|
2016-08-19 14:16:37 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
var subProcess = elementRegistry.get('SubProcess_1');
|
2016-08-19 14:16:37 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
var bounds = canvas.getAbsoluteBBox(subProcess);
|
2016-08-19 14:16:37 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
directEditing.activate(subProcess);
|
2016-08-19 14:16:37 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
expectBounds(directEditing._textbox.parent, {
|
|
|
|
x: bounds.x,
|
|
|
|
y: bounds.y,
|
|
|
|
width: bounds.width,
|
|
|
|
height: (MEDIUM_LINE_HEIGHT * zoom) + (7 * 2 * zoom)
|
|
|
|
});
|
|
|
|
}
|
|
|
|
));
|
2016-08-19 14:16:37 +00:00
|
|
|
|
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
it('[zoom 1.5] should have element width and height to fit text', inject(
|
|
|
|
function(canvas, directEditing, elementRegistry) {
|
|
|
|
var zoom = 1.5;
|
2016-08-19 14:16:37 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
canvas.zoom(zoom);
|
2016-08-19 14:16:37 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
var subProcess = elementRegistry.get('SubProcess_1');
|
2016-08-19 14:16:37 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
var bounds = canvas.getAbsoluteBBox(subProcess);
|
2016-08-19 14:16:37 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
directEditing.activate(subProcess);
|
2016-08-19 14:16:37 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
expectBounds(directEditing._textbox.parent, {
|
|
|
|
x: bounds.x,
|
|
|
|
y: bounds.y,
|
|
|
|
width: bounds.width,
|
|
|
|
height: (MEDIUM_LINE_HEIGHT * zoom) + (7 * 2 * zoom)
|
|
|
|
});
|
|
|
|
}
|
|
|
|
));
|
2016-08-19 14:16:37 +00:00
|
|
|
|
2017-06-27 07:37:58 +00:00
|
|
|
});
|
2016-08-19 14:16:37 +00:00
|
|
|
|
|
|
|
|
2017-06-27 07:37:58 +00:00
|
|
|
describe('pools/lanes', function() {
|
2016-08-19 14:16:37 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
it('[zoom 1] should have width of element height, height of 30', inject(
|
|
|
|
function(canvas, directEditing, elementRegistry) {
|
|
|
|
var zoom = 1;
|
2016-08-19 14:16:37 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
canvas.zoom(zoom);
|
2016-08-19 14:16:37 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
var pool = elementRegistry.get('Participant_1');
|
2016-08-19 14:16:37 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
var bounds = canvas.getAbsoluteBBox(pool);
|
|
|
|
var mid = {
|
|
|
|
x: bounds.x + bounds.width / 2,
|
|
|
|
y: bounds.y + bounds.height / 2
|
|
|
|
};
|
2016-08-19 14:16:37 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
directEditing.activate(pool);
|
2016-08-19 14:16:37 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
expectBounds(directEditing._textbox.parent, {
|
|
|
|
x: bounds.x - (bounds.height / 2) + (15 * zoom),
|
|
|
|
y: mid.y - (30 * zoom) / 2,
|
|
|
|
width: bounds.height * zoom,
|
|
|
|
height: 30 * zoom
|
|
|
|
});
|
|
|
|
}
|
|
|
|
));
|
2016-08-19 14:16:37 +00:00
|
|
|
|
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
it('[zoom 1.5] should have width of element height, height of 30', inject(
|
|
|
|
function(canvas, directEditing, elementRegistry) {
|
|
|
|
var zoom = 1.5;
|
2016-08-19 14:16:37 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
canvas.zoom(zoom);
|
2016-08-19 14:16:37 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
var pool = elementRegistry.get('Participant_1');
|
2016-08-19 14:16:37 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
var bounds = canvas.getAbsoluteBBox(pool);
|
|
|
|
var mid = {
|
|
|
|
x: bounds.x + bounds.width / 2,
|
|
|
|
y: bounds.y + bounds.height / 2
|
|
|
|
};
|
2016-08-19 14:16:37 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
directEditing.activate(pool);
|
2016-08-19 14:16:37 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
expectBounds(directEditing._textbox.parent, {
|
|
|
|
x: bounds.x - (bounds.height / 2) + (15 * zoom),
|
|
|
|
y: mid.y - (30 * zoom) / 2,
|
|
|
|
width: bounds.height,
|
|
|
|
height: 30 * zoom
|
|
|
|
});
|
|
|
|
}
|
|
|
|
));
|
2016-08-19 14:16:37 +00:00
|
|
|
|
|
|
|
});
|
2016-03-07 16:06:24 +00:00
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2015-07-15 15:22:19 +00:00
|
|
|
});
|
2018-04-02 19:01:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
// helpers //////////////////
|
|
|
|
|
|
|
|
function triggerKeyEvent(element, event, code) {
|
|
|
|
var e = document.createEvent('Events');
|
|
|
|
|
|
|
|
if (e.initEvent) {
|
|
|
|
e.initEvent(event, true, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
e.keyCode = code;
|
|
|
|
e.which = code;
|
|
|
|
|
|
|
|
return element.dispatchEvent(e);
|
|
|
|
}
|
|
|
|
|
|
|
|
function expectBounds(parent, bounds) {
|
|
|
|
expect(parent.offsetLeft).to.be.closeTo(bounds.x, DELTA);
|
|
|
|
expect(parent.offsetTop).to.be.closeTo(bounds.y, DELTA);
|
|
|
|
expect(parent.offsetWidth).to.be.closeTo(bounds.width, DELTA);
|
|
|
|
expect(parent.offsetHeight).to.be.closeTo(bounds.height, DELTA);
|
|
|
|
}
|