Merge branch 'master' into develop

This commit is contained in:
Maciej Barelkowski 2020-03-13 14:15:14 +01:00
commit 62f331bc3d
12 changed files with 262 additions and 80 deletions

View File

@ -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))

View File

@ -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);

View File

@ -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, '');

View File

@ -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 [];
}

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "bpmn-js",
"version": "6.3.1",
"version": "6.3.2",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@ -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",

View File

@ -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,

View File

@ -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,

View File

@ -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);
})
);
});

View File

@ -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);
}));
});

View File

@ -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);
}));
});

View File

@ -0,0 +1,88 @@
<?xml version="1.0" encoding="UTF-8"?>
<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="_4bAZoD9WEeWLcNBL4nCk1A" targetNamespace="http://camunda.org/schema/1.0/bpmn" exporter="bpmn-js (https://demo.bpmn.io)" exporterVersion="6.3.1" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd">
<bpmn2:collaboration id="_Collaboration_2">
<bpmn2:participant id="Participant_Lane" name="Participant_Lane" processRef="Process_Lane" />
</bpmn2:collaboration>
<bpmn2:process id="Process_Lane" isExecutable="false">
<bpmn2:laneSet id="LaneSet_1" name="Lane Set 1">
<bpmn2:lane id="Lane_A" name="Lane_A">
<bpmn2:flowNodeRef>Task_Boundary</bpmn2:flowNodeRef>
<bpmn2:flowNodeRef>Task</bpmn2:flowNodeRef>
<bpmn2:flowNodeRef>Event</bpmn2:flowNodeRef>
<bpmn2:flowNodeRef>Boundary</bpmn2:flowNodeRef>
<bpmn2:childLaneSet id="LaneSet_2">
<bpmn2:lane id="Nested_Lane_B" name="Nested_Lane_B" />
<bpmn2:lane id="Nested_Lane_A" name="Nested_Lane_A">
<bpmn2:flowNodeRef>Task_Boundary</bpmn2:flowNodeRef>
<bpmn2:flowNodeRef>Task</bpmn2:flowNodeRef>
<bpmn2:flowNodeRef>Event</bpmn2:flowNodeRef>
<bpmn2:flowNodeRef>Boundary</bpmn2:flowNodeRef>
</bpmn2:lane>
</bpmn2:childLaneSet>
</bpmn2:lane>
</bpmn2:laneSet>
<bpmn2:task id="Task_Boundary" name="Task_Boundary">
<bpmn2:outgoing>SequenceFlow</bpmn2:outgoing>
</bpmn2:task>
<bpmn2:task id="Task" name="Task">
<bpmn2:incoming>SequenceFlow_From_Boundary</bpmn2:incoming>
<bpmn2:incoming>SequenceFlow</bpmn2:incoming>
</bpmn2:task>
<bpmn2:startEvent id="Event" name="Start" />
<bpmn2:boundaryEvent id="Boundary" name="Boundary" attachedToRef="Task_Boundary">
<bpmn2:outgoing>SequenceFlow_From_Boundary</bpmn2:outgoing>
</bpmn2:boundaryEvent>
<bpmn2:sequenceFlow id="SequenceFlow" name="Flow" sourceRef="Task_Boundary" targetRef="Task" />
<bpmn2:sequenceFlow id="SequenceFlow_From_Boundary" name="" sourceRef="Boundary" targetRef="Task" />
</bpmn2:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="_Collaboration_2">
<bpmndi:BPMNShape id="_BPMNShape_Participant_2" bpmnElement="Participant_Lane" isHorizontal="true">
<dc:Bounds x="152" y="83" width="540" height="537" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="_BPMNShape_Task_2" bpmnElement="Task_Boundary">
<dc:Bounds x="344" y="113" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="_BPMNShape_BoundaryEvent_2" bpmnElement="Boundary">
<dc:Bounds x="391" y="175" width="36" height="36" />
<bpmndi:BPMNLabel>
<dc:Bounds x="339" y="210" width="48" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="_BPMNShape_Task_3" bpmnElement="Task">
<dc:Bounds x="512" y="113" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_1" bpmnElement="SequenceFlow_From_Boundary" sourceElement="_BPMNShape_BoundaryEvent_2" targetElement="_BPMNShape_Task_3">
<di:waypoint x="409" y="211" />
<di:waypoint x="409" y="238" />
<di:waypoint x="562" y="238" />
<di:waypoint x="562" y="193" />
<bpmndi:BPMNLabel>
<dc:Bounds x="377" y="188" width="6" height="6" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_2" bpmnElement="SequenceFlow" sourceElement="_BPMNShape_Task_2" targetElement="_BPMNShape_Task_3">
<di:waypoint x="444" y="153" />
<di:waypoint x="512" y="153" />
<bpmndi:BPMNLabel>
<dc:Bounds x="466" y="135" width="25" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="_BPMNShape_Lane_3" bpmnElement="Lane_A" isHorizontal="true">
<dc:Bounds x="182" y="83" width="510" height="537" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="_BPMNShape_Lane_4" bpmnElement="Nested_Lane_A" isHorizontal="true">
<dc:Bounds x="212" y="83" width="480" height="180" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="_BPMNShape_Lane_5" bpmnElement="Nested_Lane_B" isHorizontal="true">
<dc:Bounds x="212" y="263" width="480" height="357" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_di" bpmnElement="Event">
<dc:Bounds x="262" y="135" width="36" height="36" />
<bpmndi:BPMNLabel>
<dc:Bounds x="268" y="178" width="24" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn2:definitions>