2014-06-17 09:53:07 +00:00
|
|
|
'use strict';
|
|
|
|
|
2016-08-19 14:16:37 +00:00
|
|
|
var TestHelper = require('../../../TestHelper');
|
2014-06-17 09:53:07 +00:00
|
|
|
|
2014-08-05 06:17:22 +00:00
|
|
|
/* global bootstrapViewer, inject */
|
2014-06-11 13:08:45 +00:00
|
|
|
|
2016-08-19 14:16:37 +00:00
|
|
|
TestHelper.insertCSS('diagram-js-label-editing.css',
|
|
|
|
'div { box-sizing: border-box; }' +
|
|
|
|
'div[contenteditable=true] { line-height: 14px; font-family: Arial; font-size: 12px }'
|
|
|
|
);
|
2014-06-18 09:45:30 +00:00
|
|
|
|
2014-08-01 05:16:59 +00:00
|
|
|
var labelEditingModule = require('../../../../lib/features/label-editing'),
|
2016-03-08 13:41:32 +00:00
|
|
|
coreModule = require('../../../../lib/core'),
|
2016-05-18 05:54:58 +00:00
|
|
|
draggingModule = require('diagram-js/lib/features/dragging');
|
2014-06-17 09:53:07 +00:00
|
|
|
|
2014-08-01 05:16:59 +00:00
|
|
|
var LabelUtil = require('../../../../lib/features/label-editing/LabelUtil');
|
2014-06-17 09:53:07 +00:00
|
|
|
|
2015-02-05 08:24:27 +00:00
|
|
|
function triggerKeyEvent(element, event, code) {
|
|
|
|
var e = document.createEvent('Events');
|
|
|
|
|
|
|
|
if (e.initEvent) {
|
|
|
|
e.initEvent(event, true, true);
|
|
|
|
}
|
2014-06-11 13:08:45 +00:00
|
|
|
|
2015-02-05 08:24:27 +00:00
|
|
|
e.keyCode = code;
|
|
|
|
e.which = code;
|
2014-06-11 13:08:45 +00:00
|
|
|
|
2015-02-05 08:24:27 +00:00
|
|
|
return element.dispatchEvent(e);
|
|
|
|
}
|
|
|
|
|
2016-09-01 16:01:04 +00:00
|
|
|
describe('features - label-editing', function() {
|
2014-06-17 09:53:07 +00:00
|
|
|
|
2015-03-31 12:17:15 +00:00
|
|
|
var diagramXML = require('../../../fixtures/bpmn/features/label-editing/labels.bpmn');
|
2014-06-17 09:53:07 +00:00
|
|
|
|
|
|
|
|
2016-03-08 13:41:32 +00:00
|
|
|
describe('basics', function() {
|
2014-06-17 09:53:07 +00:00
|
|
|
|
2016-05-18 05:54:58 +00:00
|
|
|
var testModules = [ labelEditingModule, coreModule, draggingModule ];
|
2016-03-08 13:41:32 +00:00
|
|
|
|
|
|
|
beforeEach(bootstrapViewer(diagramXML, { modules: testModules }));
|
2014-06-17 09:53:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
it('should register on dblclick', inject(function(elementRegistry, directEditing, eventBus) {
|
2016-05-18 05:54:58 +00:00
|
|
|
|
2014-06-17 09:53:07 +00:00
|
|
|
// given
|
2014-11-17 16:36:22 +00:00
|
|
|
var shape = elementRegistry.get('task-nested-embedded');
|
2014-06-17 09:53:07 +00:00
|
|
|
|
|
|
|
// when
|
2014-12-17 20:54:25 +00:00
|
|
|
eventBus.fire('element.dblclick', { element: shape });
|
2014-06-17 09:53:07 +00:00
|
|
|
|
|
|
|
// then
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(directEditing.isActive()).to.be.true;
|
2014-06-17 09:53:07 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
|
2014-07-16 14:15:23 +00:00
|
|
|
it('should cancel on <ESC>', inject(function(elementRegistry, directEditing, eventBus) {
|
2016-05-18 05:54:58 +00:00
|
|
|
|
2014-06-17 09:53:07 +00:00
|
|
|
// given
|
2014-11-17 16:36:22 +00:00
|
|
|
var shape = elementRegistry.get('task-nested-embedded'),
|
2014-07-16 14:15:23 +00:00
|
|
|
task = shape.businessObject;
|
2014-06-17 09:53:07 +00:00
|
|
|
|
|
|
|
var oldName = task.name;
|
|
|
|
|
|
|
|
// activate
|
2014-12-17 20:54:25 +00:00
|
|
|
eventBus.fire('element.dblclick', { element: shape });
|
2014-06-17 09:53:07 +00:00
|
|
|
|
2016-08-19 14:16:37 +00:00
|
|
|
var textbox = directEditing._textbox.content;
|
2014-06-17 09:53:07 +00:00
|
|
|
|
|
|
|
// when
|
|
|
|
// change + ESC is pressed
|
2016-08-19 14:16:37 +00:00
|
|
|
textbox.innerText = 'new value';
|
|
|
|
triggerKeyEvent(textbox, 'keydown', 27);
|
2014-06-17 09:53:07 +00:00
|
|
|
|
|
|
|
// then
|
2015-07-15 15:22:19 +00:00
|
|
|
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
|
|
|
|
2016-03-08 13:41:32 +00:00
|
|
|
it('should complete on drag start', inject(function(elementRegistry, directEditing, dragging) {
|
2016-05-18 05:54:58 +00:00
|
|
|
|
2016-03-08 13:41:32 +00:00
|
|
|
// given
|
|
|
|
var shape = elementRegistry.get('task-nested-embedded'),
|
|
|
|
task = shape.businessObject;
|
|
|
|
|
|
|
|
directEditing.activate(shape);
|
|
|
|
|
2016-08-19 14:16:37 +00:00
|
|
|
directEditing._textbox.content.innerText = 'FOO BAR';
|
2016-03-08 13:41:32 +00:00
|
|
|
|
|
|
|
// when
|
|
|
|
dragging.init(null, { x: 0, y: 0 }, 'foo');
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(task.name).to.equal('FOO BAR');
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
2014-12-17 20:54:25 +00:00
|
|
|
it('should submit on root element click', inject(function(elementRegistry, directEditing, canvas, eventBus) {
|
2016-05-18 05:54:58 +00:00
|
|
|
|
2014-07-07 15:17:41 +00:00
|
|
|
// given
|
2014-11-17 16:36:22 +00:00
|
|
|
var shape = elementRegistry.get('task-nested-embedded'),
|
2014-07-16 14:15:23 +00:00
|
|
|
task = shape.businessObject;
|
2014-07-07 15:17:41 +00:00
|
|
|
|
|
|
|
// activate
|
2014-12-17 20:54:25 +00:00
|
|
|
eventBus.fire('element.dblclick', { element: shape });
|
2014-07-07 15:17:41 +00:00
|
|
|
|
|
|
|
var newName = 'new value';
|
|
|
|
|
2015-02-05 08:24:27 +00:00
|
|
|
// a <textarea /> element
|
2016-08-19 14:16:37 +00:00
|
|
|
var content = directEditing._textbox.content;
|
|
|
|
|
|
|
|
content.innerText = newName;
|
2014-07-07 15:17:41 +00:00
|
|
|
|
|
|
|
// when
|
2014-12-23 15:49:28 +00:00
|
|
|
// change + <element.mousedown>
|
2015-02-05 08:24:27 +00:00
|
|
|
|
2014-12-23 15:49:28 +00:00
|
|
|
eventBus.fire('element.mousedown', { element: canvas.getRootElement() });
|
2014-07-07 15:17:41 +00:00
|
|
|
|
|
|
|
// then
|
2015-07-15 15:22:19 +00:00
|
|
|
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() {
|
|
|
|
|
2016-05-18 05:54:58 +00:00
|
|
|
var testModules = [ labelEditingModule, coreModule ];
|
2016-03-08 13:41:32 +00:00
|
|
|
|
|
|
|
beforeEach(bootstrapViewer(diagramXML, { modules: testModules }));
|
|
|
|
|
|
|
|
var elementRegistry,
|
|
|
|
eventBus,
|
|
|
|
directEditing;
|
2014-06-17 09:53:07 +00:00
|
|
|
|
2016-05-18 05:54:58 +00:00
|
|
|
|
|
|
|
beforeEach(inject([ 'elementRegistry', 'eventBus', 'directEditing', function(_elementRegistry, _eventBus, _directEditing) {
|
|
|
|
elementRegistry = _elementRegistry;
|
|
|
|
eventBus = _eventBus;
|
|
|
|
directEditing = _directEditing;
|
|
|
|
}]));
|
|
|
|
|
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
|
|
|
|
var diagramElement = elementRegistry.get('user-task');
|
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
|
2016-05-18 05:54:58 +00:00
|
|
|
var diagramElement = elementRegistry.get('user-task');
|
2016-03-15 14:03:11 +00:00
|
|
|
|
2016-05-18 05:54:58 +00:00
|
|
|
var oldLabel = LabelUtil.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
|
2016-05-18 05:54:58 +00:00
|
|
|
var label = LabelUtil.getLabel(diagramElement);
|
|
|
|
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
|
|
|
|
|
|
|
|
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
|
|
|
|
var diagramElement = elementRegistry.get('user-task');
|
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
|
|
|
|
var diagramElement = elementRegistry.get('sequence-flow-no');
|
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
|
|
|
|
2016-03-08 13:41:32 +00:00
|
|
|
var label = LabelUtil.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
|
|
|
|
label = LabelUtil.getLabel(diagramElement);
|
|
|
|
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
|
|
|
|
label = LabelUtil.getLabel(diagramElement);
|
|
|
|
expect(label).to.equal('B');
|
|
|
|
});
|
|
|
|
}
|
2014-06-17 09:53:07 +00:00
|
|
|
|
|
|
|
|
2016-03-08 13:41:32 +00:00
|
|
|
it('task', directEdit('user-task'));
|
2014-06-17 09:53:07 +00:00
|
|
|
|
|
|
|
|
2016-03-08 13:41:32 +00:00
|
|
|
it('gateway', directEdit('exclusive-gateway'));
|
2014-06-17 09:53:07 +00:00
|
|
|
|
2016-03-08 13:41:32 +00:00
|
|
|
it('gateway via label', directEdit('exclusive-gateway_label'));
|
2014-06-17 09:53:07 +00:00
|
|
|
|
2016-05-18 05:54:58 +00:00
|
|
|
|
2016-03-08 13:41:32 +00:00
|
|
|
it('event', directEdit('intermediate-throw-event'));
|
2014-06-17 09:53:07 +00:00
|
|
|
|
2016-03-08 13:41:32 +00:00
|
|
|
it('event via label', directEdit('intermediate-throw-event_label'));
|
2014-06-17 09:53:07 +00:00
|
|
|
|
2016-03-08 13:41:32 +00:00
|
|
|
it('event without label', directEdit('start-event'));
|
2014-06-17 09:53:07 +00:00
|
|
|
|
|
|
|
|
2016-03-08 13:41:32 +00:00
|
|
|
it('data store reference', directEdit('data-store-reference'));
|
2014-06-17 09:53:07 +00:00
|
|
|
|
2016-03-08 13:41:32 +00:00
|
|
|
it('data object reference', directEdit('data-object-reference'));
|
2014-06-17 09:53:07 +00:00
|
|
|
|
|
|
|
|
2016-03-08 13:41:32 +00:00
|
|
|
it('sequenceflow', directEdit('sequence-flow-yes'));
|
2014-06-17 09:53:07 +00:00
|
|
|
|
2016-03-08 13:41:32 +00:00
|
|
|
it('sequenceflow without label', directEdit('sequenceflow-unlabeled'));
|
2014-06-17 09:53:07 +00:00
|
|
|
|
2016-03-08 13:41:32 +00:00
|
|
|
it('sequenceflow via label', directEdit('sequence-flow-yes_label'));
|
2014-06-17 09:53:07 +00:00
|
|
|
|
|
|
|
|
2016-03-08 13:41:32 +00:00
|
|
|
it('message flow', directEdit('message-flow'));
|
2014-06-17 09:53:07 +00:00
|
|
|
|
2016-03-08 13:41:32 +00:00
|
|
|
it('message flow via label', directEdit('message-flow_label'));
|
2014-06-17 09:53:07 +00:00
|
|
|
|
|
|
|
|
2016-03-08 13:41:32 +00:00
|
|
|
it('pool', directEdit('expanded-pool'));
|
2014-06-17 09:53:07 +00:00
|
|
|
|
2016-03-08 13:41:32 +00:00
|
|
|
it('pool, collapsed', directEdit('collapsed-pool'));
|
2014-06-17 09:53:07 +00:00
|
|
|
|
|
|
|
|
2016-03-08 13:41:32 +00:00
|
|
|
it('lane with label', directEdit('nested-lane-1-2'));
|
2014-06-17 09:53:07 +00:00
|
|
|
|
2016-03-08 13:41:32 +00:00
|
|
|
it('lane without label', directEdit('nested-lane-no-label'));
|
2014-06-11 13:08:45 +00:00
|
|
|
|
2016-03-08 13:41:32 +00:00
|
|
|
});
|
2014-06-11 13:08:45 +00:00
|
|
|
});
|
|
|
|
|
2016-03-07 16:06:24 +00:00
|
|
|
|
|
|
|
describe('sizing', function() {
|
|
|
|
|
2016-05-18 05:54:58 +00:00
|
|
|
var testModules = [ labelEditingModule, coreModule ];
|
2016-03-07 16:06:24 +00:00
|
|
|
|
2016-08-19 14:16:37 +00:00
|
|
|
|
|
|
|
|
|
|
|
function testTextboxSizing(elementId, zoom, width, height, content) {
|
|
|
|
return inject(function(canvas, elementRegistry, directEditing) {
|
|
|
|
// zoom in
|
|
|
|
canvas.zoom(zoom);
|
|
|
|
// grab one element
|
|
|
|
var shape = elementRegistry.get(elementId);
|
|
|
|
// activate label editing
|
|
|
|
directEditing.activate(shape);
|
|
|
|
// grab the textarea
|
|
|
|
var textbox = directEditing._textbox;
|
|
|
|
// optionally set content text
|
|
|
|
if (content) {
|
|
|
|
textbox.content.innerText = content;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (width === 'auto') {
|
|
|
|
width = shape.width;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (height === 'auto') {
|
|
|
|
height = shape.height;
|
|
|
|
}
|
|
|
|
|
|
|
|
// then
|
|
|
|
if (typeof width === 'object' && width.min) {
|
|
|
|
expect(textbox.content.offsetWidth).to.be.at.least(width.min);
|
|
|
|
} else {
|
|
|
|
expect(textbox.content.offsetWidth).to.be.equal(width);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (typeof height === 'object' && height.min) {
|
|
|
|
expect(textbox.content.offsetHeight).to.be.at.least(height.min);
|
|
|
|
} else {
|
|
|
|
expect(textbox.content.offsetHeight).to.be.equal(height);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2016-03-07 16:06:24 +00:00
|
|
|
beforeEach(bootstrapViewer(diagramXML, {
|
|
|
|
modules: testModules,
|
|
|
|
canvas: { deferUpdate: false }
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
2016-08-19 14:16:37 +00:00
|
|
|
describe('height', function() {
|
2016-03-07 16:06:24 +00:00
|
|
|
|
2016-08-19 14:16:37 +00:00
|
|
|
var oneLineText = 'One line',
|
|
|
|
twoLineText = 'Two\nlines',
|
|
|
|
tenLineText = '1\n2\n3\n4\n5\n6\n7\n8\n9\n0';
|
|
|
|
|
|
|
|
describe('external labels', function() {
|
|
|
|
|
|
|
|
it('[no text] should have min height', testTextboxSizing('start-event', 1, 150, 20));
|
|
|
|
|
|
|
|
it('[1 line text] should be 1 line high', testTextboxSizing('start-event', 1, 150, 20, oneLineText));
|
|
|
|
|
|
|
|
it('[2 line text] should be 2 line high', testTextboxSizing('start-event', 1, 150, 34, twoLineText));
|
|
|
|
|
|
|
|
it('[10 line text] should be 10 line high', testTextboxSizing('start-event', 1, 150, 146, tenLineText));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
describe('internal labels', function() {
|
|
|
|
|
|
|
|
it('[no text] should have fixed dimensions', testTextboxSizing('empty-task', 1, 'auto', 'auto'));
|
|
|
|
|
|
|
|
it('[1 line text] should have fixed dimensions', testTextboxSizing('empty-task', 1, 'auto', 'auto', oneLineText));
|
|
|
|
|
|
|
|
it('[2 line text] should have fixed dimensions', testTextboxSizing('empty-task', 1, 'auto', 'auto', twoLineText));
|
|
|
|
|
|
|
|
it('[10 line text] should have fixed dimensions', testTextboxSizing('empty-task', 1, 'auto', 'auto', tenLineText));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
describe('sequence flows', function() {
|
|
|
|
|
|
|
|
it('[no text] should have min height', testTextboxSizing('sequenceflow-unlabeled', 1, 150, 20));
|
|
|
|
|
|
|
|
it('[1 line text] should be 1 line high', testTextboxSizing('sequenceflow-unlabeled', 1, 150, 20, oneLineText));
|
|
|
|
|
|
|
|
it('[2 line text] should be 2 line high', testTextboxSizing('sequenceflow-unlabeled', 1, 150, 34, twoLineText));
|
|
|
|
|
|
|
|
it('[10 line text] should be 10 line high', testTextboxSizing('sequenceflow-unlabeled', 1, 150, 146, tenLineText));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
describe('text annotation', function() {
|
|
|
|
|
|
|
|
it('[no text] should have element height', testTextboxSizing('text-annotation', 1, 100, 98));
|
|
|
|
|
|
|
|
it('[1 line text] should have element height', testTextboxSizing('text-annotation', 1, 100, 98, oneLineText));
|
|
|
|
|
|
|
|
it('[2 line text] should have element height', testTextboxSizing('text-annotation', 1, 100, 98, twoLineText));
|
|
|
|
|
|
|
|
it('[10 line text] should have element height', testTextboxSizing('text-annotation', 1, 100, 98, tenLineText));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
describe('expanded sub process', function() {
|
|
|
|
|
|
|
|
it('[no text] should have min height', testTextboxSizing('subprocess-expanded', 1, 200, 20));
|
|
|
|
|
|
|
|
it('[1 line text] should be 1 line high', testTextboxSizing('subprocess-expanded', 1, 200, 20, oneLineText));
|
|
|
|
|
|
|
|
it('[2 line text] should be 2 line high', testTextboxSizing('subprocess-expanded', 1, 200, 34, twoLineText));
|
|
|
|
|
|
|
|
it('[10 line text] should be max 3 line high', testTextboxSizing('subprocess-expanded', 1, 200, 48, tenLineText));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
describe('pools/lanes', function() {
|
2016-03-07 16:06:24 +00:00
|
|
|
|
2016-08-19 14:16:37 +00:00
|
|
|
it('[no text] should have min height', testTextboxSizing('expanded-pool', 1, 150, 20));
|
2016-03-07 16:06:24 +00:00
|
|
|
|
2016-08-19 14:16:37 +00:00
|
|
|
it('[1 line text] should be 1 line high', testTextboxSizing('expanded-pool', 1, 150, 20, oneLineText));
|
2016-03-07 16:06:24 +00:00
|
|
|
|
2016-08-19 14:16:37 +00:00
|
|
|
it('[2 line text] should be 2 line high', testTextboxSizing('expanded-pool', 1, 150, 34, twoLineText));
|
2016-03-07 16:06:24 +00:00
|
|
|
|
2016-08-19 14:16:37 +00:00
|
|
|
it('[10 line text] should be max 2 line high', testTextboxSizing('expanded-pool', 1, 150, 34, tenLineText));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('width', function() {
|
|
|
|
|
|
|
|
var oneWord = 'foobar',
|
|
|
|
fiveWords = 'lorem ipsum dolor foobar foobar',
|
|
|
|
longWord = 'loremipsumdolorfoobar';
|
|
|
|
|
|
|
|
describe('external labels', function() {
|
|
|
|
|
|
|
|
it('[no text] should have fixed width', testTextboxSizing('start-event', 1, 150, 20));
|
|
|
|
|
|
|
|
it('[one word] should have fixed width', testTextboxSizing('start-event', 1, 150, 20, oneWord));
|
|
|
|
|
|
|
|
it('[five words] should have fixed width, line break', testTextboxSizing('start-event', 1, 150, { min: 34 }, fiveWords));
|
|
|
|
|
|
|
|
it('[long word] should have fixed width', testTextboxSizing('start-event', 1, 150, { min: 20 }, longWord));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
describe('internal labels', function() {
|
|
|
|
|
|
|
|
it('[no text] should have fixed dimensions (task)', testTextboxSizing('empty-task', 1, 100, 80));
|
|
|
|
|
|
|
|
it('[no text] should have fixed dimensions (call activity)', testTextboxSizing('call-activity', 1, 100, 80));
|
|
|
|
|
|
|
|
it('[no text] should have fixed dimensions (collapsed sub process)', testTextboxSizing('subprocess-collapsed', 1, 100, 80));
|
|
|
|
|
|
|
|
it('[one word] should have fixed dimensions', testTextboxSizing('empty-task', 1, 100, 80, oneWord));
|
|
|
|
|
|
|
|
it('[five words] should have fixed dimensions', testTextboxSizing('empty-task', 1, 100, 80, fiveWords));
|
|
|
|
|
|
|
|
it('[long word] should have fixed dimensions', testTextboxSizing('empty-task', 1, 100, 80, longWord));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
describe('sequence flows', function() {
|
|
|
|
|
|
|
|
it('[no text] should have fixed width', testTextboxSizing('sequenceflow-unlabeled', 1, 150, 20));
|
|
|
|
|
|
|
|
it('[one word] should have fixed width', testTextboxSizing('sequenceflow-unlabeled', 1, 150, 20, oneWord));
|
|
|
|
|
|
|
|
it('[five words] should have fixed width, line break', testTextboxSizing('sequenceflow-unlabeled', 1, 150, { min: 34 }, fiveWords));
|
|
|
|
|
|
|
|
it('[long word] should have fixed width', testTextboxSizing('sequenceflow-unlabeled', 1, 150, { min: 20 }, longWord));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
describe('text annotation', function() {
|
|
|
|
|
|
|
|
it('[no text] should have min width', testTextboxSizing('text-annotation', 1, 100, 98));
|
|
|
|
|
|
|
|
it('[one word] should have min width', testTextboxSizing('text-annotation', 1, 100, 98, oneWord));
|
|
|
|
|
|
|
|
it('[five words] should expand width', testTextboxSizing('text-annotation', 1, { min: 176 }, 98, fiveWords));
|
|
|
|
|
|
|
|
it('[long word] should expand width', testTextboxSizing('text-annotation', 1, { min: 129 }, 98, longWord));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
describe('expanded sub process', function() {
|
|
|
|
|
|
|
|
it('[no text] should have fixed width', testTextboxSizing('subprocess-expanded', 1, 200, 20));
|
|
|
|
|
|
|
|
it('[one word] should have fixed width', testTextboxSizing('subprocess-expanded', 1, 200, 20, oneWord));
|
|
|
|
|
|
|
|
it('[five words] should have fixed width, line break', testTextboxSizing('subprocess-expanded', 1, 200, 20, fiveWords));
|
|
|
|
|
|
|
|
it('[long word] should have fixed width', testTextboxSizing('subprocess-expanded', 1, 200, 20, longWord));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
describe('pools/lanes', function() {
|
|
|
|
|
|
|
|
it('[no text] should have fixed width', testTextboxSizing('expanded-pool', 1, 150, 20));
|
|
|
|
|
|
|
|
it('[one word] should have fixed width', testTextboxSizing('expanded-pool', 1, 150, 20, oneWord));
|
|
|
|
|
|
|
|
it('[five words] should have fixed width, line break', testTextboxSizing('expanded-pool', 1, 150, 34, fiveWords));
|
|
|
|
|
|
|
|
it('[long word] should have fixed width', testTextboxSizing('expanded-pool', 1, 150, { min: 20 }, longWord));
|
|
|
|
|
|
|
|
});
|
2016-03-07 16:06:24 +00:00
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2015-07-15 15:22:19 +00:00
|
|
|
});
|