diff --git a/CHANGELOG.md b/CHANGELOG.md index 85205592..0ed6d914 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,11 @@ All notable changes to [bpmn-js](https://github.com/bpmn-io/bpmn-js) are documen ___Note:__ Yet to be released changes appear here._ +## 6.3.2 + +* `FIX`: correctly move flows when adding lane ([#1287](https://github.com/bpmn-io/bpmn-js/pull/1287)) +* `FIX`: restore semantic IDs for non flow nodes ([#1285](https://github.com/bpmn-io/bpmn-js/issues/1285)) + ## 6.3.1 * `FIX`: prevent editor crash in some strict execution environments ([#1283](https://github.com/bpmn-io/bpmn-js/pull/1283)) diff --git a/lib/features/label-editing/cmd/UpdateLabelHandler.js b/lib/features/label-editing/cmd/UpdateLabelHandler.js index 04f2a382..6d12a2e9 100644 --- a/lib/features/label-editing/cmd/UpdateLabelHandler.js +++ b/lib/features/label-editing/cmd/UpdateLabelHandler.js @@ -104,11 +104,6 @@ export default function UpdateLabelHandler(modeling, textRenderer) { var text = getLabel(label); - // don't resize without text - if (!text) { - return; - } - // resize element based on label _or_ pre-defined bounds if (typeof newBounds === 'undefined') { newBounds = textRenderer.getExternalLabelBounds(label, text); diff --git a/lib/features/modeling/BpmnFactory.js b/lib/features/modeling/BpmnFactory.js index 4a2fcc91..b334d4e8 100644 --- a/lib/features/modeling/BpmnFactory.js +++ b/lib/features/modeling/BpmnFactory.js @@ -53,7 +53,7 @@ BpmnFactory.prototype._ensureId = function(element) { prefix = 'Event'; } else if (is(element, 'bpmn:Gateway')) { prefix = 'Gateway'; - } else if (is(element, 'bpmn:FlowElement')) { + } else if (isAny(element, [ 'bpmn:SequenceFlow', 'bpmn:MessageFlow' ])) { prefix = 'Flow'; } else { prefix = (element.$type || '').replace(/^[^:]*:/g, ''); diff --git a/lib/features/modeling/cmd/AddLaneHandler.js b/lib/features/modeling/cmd/AddLaneHandler.js index 711de3d7..bc9a6836 100644 --- a/lib/features/modeling/cmd/AddLaneHandler.js +++ b/lib/features/modeling/cmd/AddLaneHandler.js @@ -18,6 +18,7 @@ import { * above or below an existing one. * * @param {Modeling} modeling + * @param {SpaceTool} spaceTool */ export default function AddLaneHandler(modeling, spaceTool) { this._modeling = modeling; @@ -61,6 +62,11 @@ AddLaneHandler.prototype.preExecute = function(context) { eachElement(lanesRoot, function(element) { allAffected.push(element); + // handle element labels in the diagram root + if (element.label) { + allAffected.push(element.label); + } + if (element === shape) { return []; } diff --git a/package-lock.json b/package-lock.json index e9a1c530..acd4df45 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "bpmn-js", - "version": "6.3.1", + "version": "6.3.2", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index f3ce3270..40f87f91 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bpmn-js", - "version": "6.3.1", + "version": "6.3.2", "description": "A bpmn 2.0 toolkit and web modeler", "scripts": { "all": "run-s lint test distro test:distro", diff --git a/test/config/karma.distro.js b/test/config/karma.distro.js index fc2582f2..bed3d370 100644 --- a/test/config/karma.distro.js +++ b/test/config/karma.distro.js @@ -2,28 +2,16 @@ // configures browsers to run test against // any of [ 'ChromeHeadless', 'Chrome', 'Firefox', 'IE', 'PhantomJS' ] -var browsers = - (process.env.TEST_BROWSERS || 'PhantomJS') - .replace(/^\s+|\s+$/, '') - .split(/\s*,\s*/g) - .map(function(browser) { - if (browser === 'ChromeHeadless') { - process.env.CHROME_BIN = require('puppeteer').executablePath(); - - // workaround https://github.com/GoogleChrome/puppeteer/issues/290 - if (process.platform === 'linux') { - return 'ChromeHeadless_Linux'; - } - } - - return browser; - }); +var browsers = (process.env.TEST_BROWSERS || 'PhantomJS').split(','); +// use puppeteer provided Chrome for testing +process.env.CHROME_BIN = require('puppeteer').executablePath(); var VARIANT = process.env.VARIANT; var NODE_ENV = process.env.NODE_ENV; + module.exports = function(karma) { karma.set({ @@ -46,18 +34,7 @@ module.exports = function(karma) { reporters: [ 'progress' ], - customLaunchers: { - ChromeHeadless_Linux: { - base: 'ChromeHeadless', - flags: [ - '--no-sandbox', - '--disable-setuid-sandbox' - ], - debug: true - } - }, - - browsers: browsers, + browsers, browserNoActivityTimeout: 30000, diff --git a/test/config/karma.unit.js b/test/config/karma.unit.js index d8a99b82..d4f66c7d 100644 --- a/test/config/karma.unit.js +++ b/test/config/karma.unit.js @@ -1,31 +1,19 @@ -var coverage = process.env.COVERAGE; +/* global process */ var path = require('path'); -var basePath = '../../'; - -var absoluteBasePath = path.resolve(path.join(__dirname, basePath)); - -/* global process */ +var coverage = process.env.COVERAGE; // configures browsers to run test against // any of [ 'ChromeHeadless', 'Chrome', 'Firefox', 'IE', 'PhantomJS' ] -var browsers = - (process.env.TEST_BROWSERS || 'PhantomJS') - .replace(/^\s+|\s+$/, '') - .split(/\s*,\s*/g) - .map(function(browser) { - if (browser === 'ChromeHeadless') { - process.env.CHROME_BIN = require('puppeteer').executablePath(); +var browsers = (process.env.TEST_BROWSERS || 'PhantomJS').split(','); - // workaround https://github.com/GoogleChrome/puppeteer/issues/290 - if (process.platform === 'linux') { - return 'ChromeHeadless_Linux'; - } - } +// use puppeteer provided Chrome for testing +process.env.CHROME_BIN = require('puppeteer').executablePath(); - return browser; - }); +var basePath = '../..'; + +var absoluteBasePath = path.resolve(path.join(__dirname, basePath)); var suite = coverage ? 'test/coverageBundle.js' : 'test/testBundle.js'; @@ -33,7 +21,7 @@ var suite = coverage ? 'test/coverageBundle.js' : 'test/testBundle.js'; module.exports = function(karma) { karma.set({ - basePath: basePath, + basePath, frameworks: [ 'mocha', @@ -50,24 +38,13 @@ module.exports = function(karma) { reporters: [ 'progress' ].concat(coverage ? 'coverage' : []), - customLaunchers: { - ChromeHeadless_Linux: { - base: 'ChromeHeadless', - flags: [ - '--no-sandbox', - '--disable-setuid-sandbox' - ], - debug: true - } - }, - coverageReporter: { reporters: [ { type: 'lcov', subdir: '.' } ] }, - browsers: browsers, + browsers, browserNoActivityTimeout: 30000, diff --git a/test/spec/features/modeling/BpmnFactorySpec.js b/test/spec/features/modeling/BpmnFactorySpec.js index 96e42ea4..a388ff13 100644 --- a/test/spec/features/modeling/BpmnFactorySpec.js +++ b/test/spec/features/modeling/BpmnFactorySpec.js @@ -52,27 +52,67 @@ describe('features - bpmn-factory', function() { it('should assign id with generic semantic prefix (Gateway)', inject(function(bpmnFactory) { - var task = bpmnFactory.create('bpmn:ParallelGateway'); + var gateway = bpmnFactory.create('bpmn:ParallelGateway'); - expect(task.$type).to.equal('bpmn:ParallelGateway'); - expect(task.id).to.match(/^Gateway_/g); + expect(gateway.$type).to.equal('bpmn:ParallelGateway'); + expect(gateway.id).to.match(/^Gateway_/g); })); it('should assign id with generic semantic prefix (Event)', inject(function(bpmnFactory) { - var task = bpmnFactory.create('bpmn:EndEvent'); + var event = bpmnFactory.create('bpmn:EndEvent'); - expect(task.$type).to.equal('bpmn:EndEvent'); - expect(task.id).to.match(/^Event_/g); + expect(event.$type).to.equal('bpmn:EndEvent'); + expect(event.id).to.match(/^Event_/g); })); - it('should assign id with generic semantic prefix (FlowElement)', inject( + it('should assign id with generic semantic prefix (Flow)', inject( function(bpmnFactory) { - var task = bpmnFactory.create('bpmn:SequenceFlow'); + var flow = bpmnFactory.create('bpmn:SequenceFlow'); - expect(task.$type).to.equal('bpmn:SequenceFlow'); - expect(task.id).to.match(/^Flow_/g); + expect(flow.$type).to.equal('bpmn:SequenceFlow'); + expect(flow.id).to.match(/^Flow_/g); + }) + ); + + + it('should assign id with generic semantic prefix (Flow)', inject( + function(bpmnFactory) { + var flow = bpmnFactory.create('bpmn:MessageFlow'); + + expect(flow.$type).to.equal('bpmn:MessageFlow'); + expect(flow.id).to.match(/^Flow_/g); + }) + ); + + + it('should assign id with specific semantic prefix (DataStore)', inject( + function(bpmnFactory) { + var dataStore = bpmnFactory.create('bpmn:DataStore'); + + expect(dataStore.$type).to.equal('bpmn:DataStore'); + expect(dataStore.id).to.match(/^DataStore_/g); + }) + ); + + + it('should assign id with specific semantic prefix (DataObject)', inject( + function(bpmnFactory) { + var dataObject = bpmnFactory.create('bpmn:DataObject'); + + expect(dataObject.$type).to.equal('bpmn:DataObject'); + expect(dataObject.id).to.match(/^DataObject_/g); + }) + ); + + + it('should assign id with specific semantic prefix (DataObjectReference)', inject( + function(bpmnFactory) { + var dataObjectReference = bpmnFactory.create('bpmn:DataObjectReference'); + + expect(dataObjectReference.$type).to.equal('bpmn:DataObjectReference'); + expect(dataObjectReference.id).to.match(/^DataObjectReference_/g); }) ); }); diff --git a/test/spec/features/modeling/UpdateLabelSpec.js b/test/spec/features/modeling/UpdateLabelSpec.js index ac2e8bd9..6f8259d4 100644 --- a/test/spec/features/modeling/UpdateLabelSpec.js +++ b/test/spec/features/modeling/UpdateLabelSpec.js @@ -20,7 +20,7 @@ describe('features/modeling - update label', function() { it('should change name of start event', inject( - function(modeling, elementRegistry, eventBus) { + function(modeling, elementRegistry) { // given var startEvent_1 = elementRegistry.get('StartEvent_1'); @@ -190,4 +190,19 @@ describe('features/modeling - update label', function() { } )); + + it('should resize empty text annotation', 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, null, newBounds); + + // then + expect(element).to.have.bounds(newBounds); + })); + }); \ No newline at end of file diff --git a/test/spec/features/modeling/lanes/AddLaneSpec.js b/test/spec/features/modeling/lanes/AddLaneSpec.js index 1b5d128d..e5397e51 100644 --- a/test/spec/features/modeling/lanes/AddLaneSpec.js +++ b/test/spec/features/modeling/lanes/AddLaneSpec.js @@ -307,6 +307,85 @@ describe('features/modeling - add Lane', function() { { x: 432, y: 103 - newLane.height } ]); })); + }); + + describe('flow node handling', function() { + + var diagramXML = require('./lanes-flow-nodes.bpmn'); + + beforeEach(bootstrapModeler(diagramXML, { + modules: testModules + })); + + + function addLaneAbove(laneId) { + + return getBpmnJS().invoke(function(elementRegistry, modeling) { + var existingLane = elementRegistry.get(laneId); + + expect(existingLane).to.exist; + + return modeling.addLane(existingLane, 'top'); + }); + } + + + it('should move flow nodes', inject(function(elementRegistry, modeling) { + + // given + var task_Boundary = elementRegistry.get('Task_Boundary'), + boundary = elementRegistry.get('Boundary'); + + // when + addLaneAbove('Nested_Lane_B'); + + // then + expect(task_Boundary).to.have.position({ x: 344, y: -7 }); + expect(boundary).to.have.position({ x: 391, y: 55 }); + })); + + + it('should move sequence flows', inject(function(elementRegistry, modeling) { + + // given + var sequenceFlow = elementRegistry.get('SequenceFlow'), + sequenceFlow_From_Boundary = elementRegistry.get('SequenceFlow_From_Boundary'); + + // when + addLaneAbove('Nested_Lane_B'); + + // then + expect(sequenceFlow_From_Boundary).to.have.waypoints([ + { x: 409, y: 91 }, + { x: 409, y: 118 }, + { x: 562, y: 118 }, + { x: 562, y: 73 } + ]); + + expect(sequenceFlow).to.have.waypoints([ + { x: 444, y: 33 }, + { x: 512, y: 33 } + ]); + })); + + + it('should move external labels', inject(function(elementRegistry, modeling) { + + // given + var event = elementRegistry.get('Event'), + label = event.label; + + // TODO(nikku): consolidate import + editing behavior => not consistent right now + + // when + // force move label to trigger label editing + update parent behavior + modeling.moveElements([ label ], { x: 0, y: 0 }); + + addLaneAbove('Nested_Lane_B'); + + // then + expect(label.y).to.eql(58); + })); }); diff --git a/test/spec/features/modeling/lanes/lanes-flow-nodes.bpmn b/test/spec/features/modeling/lanes/lanes-flow-nodes.bpmn new file mode 100644 index 00000000..dce2514e --- /dev/null +++ b/test/spec/features/modeling/lanes/lanes-flow-nodes.bpmn @@ -0,0 +1,88 @@ + + + + + + + + + Task_Boundary + Task + Event + Boundary + + + + Task_Boundary + Task + Event + Boundary + + + + + + SequenceFlow + + + SequenceFlow_From_Boundary + SequenceFlow + + + + SequenceFlow_From_Boundary + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +