import { bootstrapModeler, inject } from 'test/TestHelper'; 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'; import { getLabel } from 'lib/features/label-editing/LabelUtil'; var MEDIUM_LINE_HEIGHT = 12 * 1.2; var DELTA = 3; describe('features - label-editing', function() { var diagramXML = require('./LabelEditing.bpmn'); describe('basics', function() { beforeEach(bootstrapModeler(diagramXML, { modules: [ labelEditingModule, coreModule, draggingModule, modelingModule, autoPlaceModule ] })); it('should register on dblclick', inject( function(elementRegistry, directEditing, eventBus) { // given var shape = elementRegistry.get('Task_1'); // when eventBus.fire('element.dblclick', { element: shape }); // then expect(directEditing.isActive()).to.be.true; // clean up directEditing._textbox.destroy(); } )); it('should cancel on ', inject( function(elementRegistry, directEditing, eventBus) { // given var shape = elementRegistry.get('Task_1'), task = shape.businessObject; var oldName = task.name; // activate eventBus.fire('element.dblclick', { element: shape }); var textbox = directEditing._textbox.content; // when // change + ESC is pressed textbox.innerText = 'new value'; triggerKeyEvent(textbox, 'keydown', 27); // then expect(directEditing.isActive()).to.be.false; expect(task.name).to.equal(oldName); } )); it('should complete on drag start', inject( function(elementRegistry, directEditing, dragging) { // given var shape = elementRegistry.get('Task_1'), task = shape.businessObject; directEditing.activate(shape); directEditing._textbox.content.textContent = 'FOO BAR'; // when dragging.init(null, { x: 0, y: 0 }, 'foo'); // then expect(task.name).to.equal('FOO BAR'); } )); 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'); } )); it('should submit on root element click', inject( function(elementRegistry, directEditing, canvas, eventBus) { // given var shape = elementRegistry.get('Task_1'), task = shape.businessObject; // activate eventBus.fire('element.dblclick', { element: shape }); var newName = 'new value'; // a