2018-04-02 19:01:53 +00:00
|
|
|
import TestContainer from 'mocha-test-container-support';
|
2014-06-18 09:45:30 +00:00
|
|
|
|
2018-04-02 19:01:53 +00:00
|
|
|
import Diagram from 'diagram-js/lib/Diagram';
|
|
|
|
import BpmnModdle from 'bpmn-moddle';
|
2014-04-03 09:47:26 +00:00
|
|
|
|
2018-04-02 19:01:53 +00:00
|
|
|
import {
|
|
|
|
importBpmnDiagram
|
|
|
|
} from 'lib/import/Importer';
|
2017-11-13 10:11:07 +00:00
|
|
|
|
2018-04-02 19:01:53 +00:00
|
|
|
import Viewer from 'lib/Viewer';
|
2017-11-13 10:11:07 +00:00
|
|
|
|
2018-04-02 19:01:53 +00:00
|
|
|
import {
|
|
|
|
matches as domMatches
|
|
|
|
} from 'min-dom';
|
2016-06-08 07:34:11 +00:00
|
|
|
|
2018-04-02 19:01:53 +00:00
|
|
|
import {
|
|
|
|
getChildren as getChildrenGfx
|
|
|
|
} from 'diagram-js/lib/util/GraphicsUtil';
|
|
|
|
|
|
|
|
import {
|
|
|
|
find
|
|
|
|
} from 'min-dash';
|
|
|
|
|
|
|
|
import { is } from 'lib/util/ModelUtil';
|
2017-11-13 10:11:07 +00:00
|
|
|
|
2014-05-21 14:23:52 +00:00
|
|
|
|
2015-04-21 12:22:03 +00:00
|
|
|
describe('import - Importer', function() {
|
2014-04-03 09:47:26 +00:00
|
|
|
|
2015-08-25 13:45:44 +00:00
|
|
|
function createDiagram(container, modules) {
|
2014-04-03 09:47:26 +00:00
|
|
|
return new Diagram({
|
|
|
|
canvas: { container: container },
|
2015-08-25 13:45:44 +00:00
|
|
|
modules: modules
|
2014-04-03 09:47:26 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2014-06-23 12:44:03 +00:00
|
|
|
var diagram;
|
2014-05-21 14:23:52 +00:00
|
|
|
|
2014-06-23 12:44:03 +00:00
|
|
|
beforeEach(function() {
|
2015-08-25 13:45:44 +00:00
|
|
|
diagram = createDiagram(TestContainer.get(this), Viewer.prototype._modules);
|
2014-06-23 12:44:03 +00:00
|
|
|
});
|
2014-04-03 09:47:26 +00:00
|
|
|
|
|
|
|
|
2014-06-23 12:44:03 +00:00
|
|
|
function runImport(diagram, xml, done) {
|
2015-08-25 13:45:44 +00:00
|
|
|
|
|
|
|
var moddle = new BpmnModdle();
|
|
|
|
|
2014-08-04 14:32:11 +00:00
|
|
|
moddle.fromXML(xml, function(err, definitions) {
|
2017-12-04 21:27:32 +00:00
|
|
|
importBpmnDiagram(diagram, definitions, done);
|
2014-06-23 12:44:03 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-12-08 10:56:44 +00:00
|
|
|
describe('events', function() {
|
|
|
|
|
2016-03-17 08:39:43 +00:00
|
|
|
it('should fire <import.render.start> and <import.render.complete>', function(done) {
|
2015-12-08 10:56:44 +00:00
|
|
|
|
|
|
|
// given
|
|
|
|
var xml = require('../../fixtures/bpmn/import/process.bpmn');
|
|
|
|
|
|
|
|
var eventCount = 0;
|
|
|
|
|
|
|
|
var eventBus = diagram.get('eventBus');
|
|
|
|
|
|
|
|
// log events
|
2016-03-17 08:39:43 +00:00
|
|
|
eventBus.on('import.render.start', function(event) {
|
2015-12-08 10:56:44 +00:00
|
|
|
expect(event.definitions).to.exist;
|
|
|
|
|
|
|
|
eventCount++;
|
|
|
|
});
|
|
|
|
|
2016-03-17 08:39:43 +00:00
|
|
|
eventBus.on('import.render.complete', function(event) {
|
2015-12-08 10:56:44 +00:00
|
|
|
expect(event).to.have.property('error');
|
|
|
|
expect(event).to.have.property('warnings');
|
|
|
|
|
|
|
|
eventCount++;
|
|
|
|
});
|
|
|
|
|
|
|
|
// when
|
|
|
|
runImport(diagram, xml, function(err, warnings) {
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(eventCount).to.equal(2);
|
|
|
|
|
|
|
|
done(err);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2014-06-23 12:44:03 +00:00
|
|
|
|
2015-07-15 06:50:21 +00:00
|
|
|
it('should fire <bpmnElement.added> during import', function(done) {
|
2014-06-23 12:44:03 +00:00
|
|
|
|
|
|
|
// given
|
2015-07-15 06:50:21 +00:00
|
|
|
var xml = require('../../fixtures/bpmn/import/process.bpmn');
|
2014-06-23 12:44:03 +00:00
|
|
|
|
2014-07-01 09:33:28 +00:00
|
|
|
var eventCount = 0;
|
2014-06-23 12:44:03 +00:00
|
|
|
|
|
|
|
// log events
|
2014-07-16 14:15:23 +00:00
|
|
|
diagram.get('eventBus').on('bpmnElement.added', function(e) {
|
2014-07-01 09:33:28 +00:00
|
|
|
eventCount++;
|
2014-06-23 12:44:03 +00:00
|
|
|
});
|
|
|
|
|
2014-04-03 09:47:26 +00:00
|
|
|
// when
|
2014-06-23 12:44:03 +00:00
|
|
|
runImport(diagram, xml, function(err, warnings) {
|
2014-04-03 09:47:26 +00:00
|
|
|
|
|
|
|
// then
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(eventCount).to.equal(9);
|
2014-04-03 09:47:26 +00:00
|
|
|
|
|
|
|
done(err);
|
|
|
|
});
|
|
|
|
});
|
2014-06-23 12:44:03 +00:00
|
|
|
|
2014-04-03 09:47:26 +00:00
|
|
|
});
|
|
|
|
|
2014-06-18 11:05:32 +00:00
|
|
|
|
2014-06-23 12:44:03 +00:00
|
|
|
describe('basics', function() {
|
2014-06-18 11:05:32 +00:00
|
|
|
|
2015-07-15 06:50:21 +00:00
|
|
|
it('should import process', function(done) {
|
2014-06-18 11:05:32 +00:00
|
|
|
|
2014-06-23 12:44:03 +00:00
|
|
|
// given
|
2015-07-15 06:50:21 +00:00
|
|
|
var xml = require('../../fixtures/bpmn/import/process.bpmn');
|
2014-06-18 11:05:32 +00:00
|
|
|
|
2014-06-23 12:44:03 +00:00
|
|
|
var events = [];
|
2014-06-18 11:05:32 +00:00
|
|
|
|
2014-06-23 12:44:03 +00:00
|
|
|
// log events
|
2014-07-16 14:15:23 +00:00
|
|
|
diagram.get('eventBus').on('bpmnElement.added', function(e) {
|
2014-07-01 09:33:28 +00:00
|
|
|
events.push({
|
|
|
|
type: 'add',
|
2014-07-16 14:15:23 +00:00
|
|
|
semantic: e.element.businessObject.id,
|
|
|
|
di: e.element.businessObject.di.id,
|
|
|
|
diagramElement: e.element && e.element.id
|
2014-07-01 09:33:28 +00:00
|
|
|
});
|
2014-06-23 12:44:03 +00:00
|
|
|
});
|
2014-06-18 11:05:32 +00:00
|
|
|
|
|
|
|
// when
|
2014-06-23 12:44:03 +00:00
|
|
|
runImport(diagram, xml, function(err, warnings) {
|
|
|
|
|
|
|
|
// then
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(events).to.eql([
|
2018-01-05 13:32:52 +00:00
|
|
|
{ type: 'add', semantic: 'Process_1', di: 'BPMNPlane_1', diagramElement: 'Process_1' },
|
|
|
|
{ type: 'add', semantic: 'SubProcess_1', di: '_BPMNShape_SubProcess_2', diagramElement: 'SubProcess_1' },
|
|
|
|
{ type: 'add', semantic: 'StartEvent_1', di: '_BPMNShape_StartEvent_2', diagramElement: 'StartEvent_1' },
|
|
|
|
{ type: 'add', semantic: 'Task_1', di: '_BPMNShape_Task_2', diagramElement: 'Task_1' },
|
|
|
|
{ type: 'add', semantic: 'EndEvent_1', di: '_BPMNShape_EndEvent_2', diagramElement: 'EndEvent_1' },
|
|
|
|
{ type: 'add', semantic: 'StartEvent_2', di: '_BPMNShape_StartEvent_11', diagramElement: 'StartEvent_2' },
|
|
|
|
{ type: 'add', semantic: 'SequenceFlow_1', di: 'BPMNEdge_SequenceFlow_1', diagramElement: 'SequenceFlow_1' },
|
|
|
|
{ type: 'add', semantic: 'SequenceFlow_2', di: 'BPMNEdge_SequenceFlow_2', diagramElement: 'SequenceFlow_2' },
|
|
|
|
{ type: 'add', semantic: 'SequenceFlow_3', di: 'BPMNEdge_SequenceFlow_3', diagramElement: 'SequenceFlow_3' }
|
2014-06-23 12:44:03 +00:00
|
|
|
]);
|
|
|
|
|
|
|
|
done(err);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
it('should import collaboration', function(done) {
|
|
|
|
|
|
|
|
// given
|
2015-07-15 06:50:21 +00:00
|
|
|
var xml = require('../../fixtures/bpmn/import/collaboration.bpmn');
|
2014-06-23 12:44:03 +00:00
|
|
|
|
|
|
|
var events = [];
|
|
|
|
|
|
|
|
// log events
|
2014-07-16 14:15:23 +00:00
|
|
|
diagram.get('eventBus').on('bpmnElement.added', function(e) {
|
2014-07-01 09:33:28 +00:00
|
|
|
events.push({
|
|
|
|
type: 'add',
|
2014-07-16 14:15:23 +00:00
|
|
|
semantic: e.element.businessObject.id,
|
|
|
|
di: e.element.businessObject.di.id,
|
|
|
|
diagramElement: e.element && e.element.id
|
2014-07-01 09:33:28 +00:00
|
|
|
});
|
2014-06-23 12:44:03 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
// when
|
|
|
|
runImport(diagram, xml, function(err, warnings) {
|
|
|
|
|
|
|
|
// then
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(events).to.eql([
|
2014-07-16 14:15:23 +00:00
|
|
|
{ type: 'add', semantic: '_Collaboration_2', di: 'BPMNPlane_1', diagramElement: '_Collaboration_2' },
|
2014-06-23 12:44:03 +00:00
|
|
|
{ type: 'add', semantic: 'Participant_2', di: '_BPMNShape_Participant_2', diagramElement: 'Participant_2' },
|
|
|
|
{ type: 'add', semantic: 'Task_1', di: '_BPMNShape_Task_3', diagramElement: 'Task_1' },
|
|
|
|
{ type: 'add', semantic: 'Participant_1', di: '_BPMNShape_Participant_3', diagramElement: 'Participant_1' },
|
2017-11-13 10:11:07 +00:00
|
|
|
{ type: 'add', semantic: 'StartEvent_1', di: '_BPMNShape_StartEvent_3', diagramElement: 'StartEvent_1' },
|
|
|
|
{ type: 'add', semantic: 'Lane_1', di: '_BPMNShape_Lane_2', diagramElement: 'Lane_1' },
|
|
|
|
{ type: 'add', semantic: 'Lane_2', di: '_BPMNShape_Lane_3', diagramElement: 'Lane_2' },
|
|
|
|
{ type: 'add', semantic: 'Lane_3', di: '_BPMNShape_Lane_4', diagramElement: 'Lane_3' }
|
2014-06-23 12:44:03 +00:00
|
|
|
]);
|
|
|
|
|
|
|
|
done(err);
|
|
|
|
});
|
2015-08-25 13:45:44 +00:00
|
|
|
|
2014-06-23 12:44:03 +00:00
|
|
|
});
|
|
|
|
|
2015-08-25 13:45:44 +00:00
|
|
|
});
|
2014-07-16 14:15:23 +00:00
|
|
|
|
|
|
|
|
2015-08-25 13:45:44 +00:00
|
|
|
describe('position', function() {
|
2014-07-16 14:15:23 +00:00
|
|
|
|
2015-08-25 13:45:44 +00:00
|
|
|
var xml = require('../../fixtures/bpmn/import/position/position-testcase.bpmn');
|
|
|
|
|
2017-11-13 10:11:07 +00:00
|
|
|
it('should round shape coordinates', function(done) {
|
2015-08-25 13:45:44 +00:00
|
|
|
|
|
|
|
// given
|
|
|
|
var events = {};
|
2014-07-16 14:15:23 +00:00
|
|
|
|
|
|
|
// log events
|
|
|
|
diagram.get('eventBus').on('bpmnElement.added', function(e) {
|
2015-08-25 13:45:44 +00:00
|
|
|
|
|
|
|
events[e.element.id] = e.element;
|
2014-07-16 14:15:23 +00:00
|
|
|
});
|
|
|
|
|
2015-07-15 06:50:21 +00:00
|
|
|
runImport(diagram, xml, function(err, warnings) {
|
|
|
|
|
2018-02-27 09:08:31 +00:00
|
|
|
// round up
|
2015-08-25 13:45:44 +00:00
|
|
|
expect(events.ID_End.x).to.equal(Math.round(340.6));
|
|
|
|
expect(events.ID_End.y).to.equal(Math.round(136.6));
|
|
|
|
|
2018-02-27 09:08:31 +00:00
|
|
|
// round down
|
2015-08-25 13:45:44 +00:00
|
|
|
expect(events.ID_Start.x).to.equal(Math.round(120.4));
|
|
|
|
expect(events.ID_Start.y).to.equal(Math.round(135.4));
|
2015-07-15 06:50:21 +00:00
|
|
|
|
|
|
|
done(err);
|
|
|
|
});
|
2014-07-16 14:15:23 +00:00
|
|
|
});
|
2014-06-23 12:44:03 +00:00
|
|
|
|
2014-11-26 10:49:14 +00:00
|
|
|
|
2017-11-13 10:11:07 +00:00
|
|
|
it('should round shape dimensions', function(done) {
|
2015-07-15 06:50:21 +00:00
|
|
|
|
2015-08-25 13:45:44 +00:00
|
|
|
// given
|
|
|
|
var events = {};
|
2015-07-15 06:50:21 +00:00
|
|
|
|
2015-08-25 13:45:44 +00:00
|
|
|
// log events
|
|
|
|
diagram.get('eventBus').on('bpmnElement.added', function(e) {
|
2015-07-15 06:50:21 +00:00
|
|
|
|
2015-08-25 13:45:44 +00:00
|
|
|
events[e.element.id] = e.element;
|
|
|
|
});
|
2015-07-15 06:50:21 +00:00
|
|
|
|
2015-08-25 13:45:44 +00:00
|
|
|
runImport(diagram, xml, function(err, warnings) {
|
2015-07-15 06:50:21 +00:00
|
|
|
|
2018-02-27 09:08:31 +00:00
|
|
|
// round down
|
2015-08-25 13:45:44 +00:00
|
|
|
expect(events.ID_Start.height).to.equal(Math.round(30.4));
|
|
|
|
expect(events.ID_Start.width).to.equal(Math.round(30.4));
|
2015-07-15 06:50:21 +00:00
|
|
|
|
2015-08-25 13:45:44 +00:00
|
|
|
done(err);
|
|
|
|
});
|
2014-07-16 14:15:23 +00:00
|
|
|
});
|
|
|
|
|
2015-08-25 13:45:44 +00:00
|
|
|
});
|
2014-07-16 14:15:23 +00:00
|
|
|
|
|
|
|
|
2017-11-13 10:11:07 +00:00
|
|
|
describe('order', function() {
|
|
|
|
|
|
|
|
it('should import sequence flows and lanes behind other flow nodes', function(done) {
|
|
|
|
|
|
|
|
var xml = require('./sequenceFlow-ordering.bpmn');
|
|
|
|
|
|
|
|
// given
|
|
|
|
var elementRegistry = diagram.get('elementRegistry');
|
|
|
|
|
|
|
|
|
|
|
|
runImport(diagram, xml, function(err, warnings) {
|
|
|
|
|
|
|
|
// when
|
|
|
|
var processShape = elementRegistry.get('Participant_1jxpy8o');
|
|
|
|
|
|
|
|
var children = processShape.children;
|
|
|
|
|
|
|
|
// lanes
|
|
|
|
// connections
|
|
|
|
// other elements
|
|
|
|
var correctlyOrdered = [].concat(
|
|
|
|
children.filter(function(c) { return is(c, 'bpmn:Lane'); }),
|
|
|
|
children.filter(function(c) { return c.waypoints; }),
|
|
|
|
children.filter(function(c) { return !is(c, 'bpmn:Lane') && !c.waypoints; })
|
|
|
|
);
|
|
|
|
|
|
|
|
// then
|
|
|
|
expectChildren(diagram, processShape, correctlyOrdered);
|
|
|
|
|
|
|
|
done(err);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2015-08-25 13:45:44 +00:00
|
|
|
describe('elements', function() {
|
2015-07-15 06:50:21 +00:00
|
|
|
|
2015-08-25 13:45:44 +00:00
|
|
|
it('should import boundary events', function(done) {
|
2015-07-15 06:50:21 +00:00
|
|
|
|
2015-08-25 13:45:44 +00:00
|
|
|
// given
|
|
|
|
var xml = require('../../fixtures/bpmn/import/boundaryEvent.bpmn');
|
2015-07-15 06:50:21 +00:00
|
|
|
|
2015-08-25 13:45:44 +00:00
|
|
|
var events = [];
|
2014-07-16 14:15:23 +00:00
|
|
|
|
2015-08-25 13:45:44 +00:00
|
|
|
// log events
|
|
|
|
diagram.get('eventBus').on('bpmnElement.added', function(e) {
|
|
|
|
events.push({
|
|
|
|
type: 'add',
|
|
|
|
semantic: e.element.businessObject.id,
|
|
|
|
di: e.element.businessObject.di.id,
|
|
|
|
diagramElement: e.element && e.element.id
|
|
|
|
});
|
|
|
|
});
|
2014-07-16 14:15:23 +00:00
|
|
|
|
2015-08-25 13:45:44 +00:00
|
|
|
// when
|
|
|
|
runImport(diagram, xml, function(err, warnings) {
|
2014-07-16 14:15:23 +00:00
|
|
|
|
2015-07-15 06:50:21 +00:00
|
|
|
// then
|
2015-08-25 13:45:44 +00:00
|
|
|
expect(events).to.eql([
|
2016-06-07 06:46:45 +00:00
|
|
|
{ type: 'add', semantic: 'Process_1', di: 'BPMNPlane_1', diagramElement: 'Process_1' },
|
|
|
|
{ type: 'add', semantic: 'Task_1', di: '_BPMNShape_Task_2', diagramElement: 'Task_1' },
|
|
|
|
{ type: 'add', semantic: 'Task_2', di: '_BPMNShape_Task_3', diagramElement: 'Task_2' },
|
|
|
|
{ type: 'add', semantic: 'BoundaryEvent_1', di: '_BPMNShape_BoundaryEvent_2', diagramElement: 'BoundaryEvent_1' },
|
|
|
|
{ type: 'add', semantic: 'SequenceFlow_1', di: 'BPMNEdge_SequenceFlow_1', diagramElement: 'SequenceFlow_1' }
|
2015-08-25 13:45:44 +00:00
|
|
|
]);
|
2014-07-16 14:15:23 +00:00
|
|
|
|
2015-08-25 13:45:44 +00:00
|
|
|
done(err);
|
|
|
|
});
|
2014-06-18 11:05:32 +00:00
|
|
|
});
|
2014-06-23 12:44:03 +00:00
|
|
|
|
2018-05-03 14:02:41 +00:00
|
|
|
|
|
|
|
it('should import data store as child of participant', function(done) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var xml = require('../../fixtures/bpmn/import/data-store.inside-participant.bpmn');
|
|
|
|
|
|
|
|
var events = {};
|
|
|
|
|
|
|
|
// log events
|
|
|
|
diagram.get('eventBus').on('bpmnElement.added', function(e) {
|
|
|
|
|
|
|
|
events[e.element.id] = e.element;
|
|
|
|
});
|
|
|
|
|
|
|
|
runImport(diagram, xml, function(err, warnings) {
|
|
|
|
expect(events.DataStoreReference.parent).to.equal(events.Participant);
|
|
|
|
|
|
|
|
done(err);
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should import data store in particpant as child of collaboration', function(done) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var xml = require('../../fixtures/bpmn/import/data-store.outside-participant.participant.bpmn');
|
|
|
|
|
|
|
|
var events = {};
|
|
|
|
|
|
|
|
// log events
|
|
|
|
diagram.get('eventBus').on('bpmnElement.added', function(e) {
|
|
|
|
|
|
|
|
events[e.element.id] = e.element;
|
|
|
|
});
|
|
|
|
|
|
|
|
runImport(diagram, xml, function(err, warnings) {
|
|
|
|
expect(events.DataStoreReference.parent).to.equal(events.Collaboration);
|
|
|
|
|
|
|
|
done(err);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
it('should import data store in subprocess as child of collaboration', function(done) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var xml = require('../../fixtures/bpmn/import/data-store.outside-participant.subprocess.bpmn');
|
|
|
|
|
|
|
|
var events = {};
|
|
|
|
|
|
|
|
// log events
|
|
|
|
diagram.get('eventBus').on('bpmnElement.added', function(e) {
|
|
|
|
|
|
|
|
events[e.element.id] = e.element;
|
|
|
|
});
|
|
|
|
|
|
|
|
runImport(diagram, xml, function(err, warnings) {
|
|
|
|
expect(events.DataStoreReference.parent).to.equal(events.Collaboration);
|
|
|
|
|
|
|
|
done(err);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2014-06-23 12:44:03 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
describe('forgiveness', function() {
|
|
|
|
|
|
|
|
it('should import invalid flowElement', function(done) {
|
|
|
|
|
|
|
|
// given
|
2015-07-15 06:50:21 +00:00
|
|
|
var xml = require('../../fixtures/bpmn/import/error/invalid-flow-element.bpmn');
|
2014-06-23 12:44:03 +00:00
|
|
|
|
|
|
|
// when
|
|
|
|
runImport(diagram, xml, function(err, warnings) {
|
|
|
|
|
2015-10-09 23:33:21 +00:00
|
|
|
expect(warnings.length).to.equal(0);
|
2014-06-23 12:44:03 +00:00
|
|
|
|
|
|
|
done(err);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2014-11-26 19:54:52 +00:00
|
|
|
|
2015-04-21 12:22:03 +00:00
|
|
|
it('should import multiple DIs', function(done) {
|
2014-11-26 19:54:52 +00:00
|
|
|
|
|
|
|
// given
|
2015-07-15 06:50:21 +00:00
|
|
|
var xml = require('../../fixtures/bpmn/import/error/multiple-dis.bpmn');
|
2014-11-26 19:54:52 +00:00
|
|
|
|
|
|
|
// when
|
|
|
|
runImport(diagram, xml, function(err, warnings) {
|
|
|
|
|
2015-02-17 09:55:28 +00:00
|
|
|
var expectedMessage =
|
|
|
|
'multiple DI elements defined for <bpmn:InclusiveGateway id="InclusiveGateway_1" />';
|
|
|
|
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(warnings.length).to.equal(1);
|
|
|
|
expect(warnings[0].message).to.equal(expectedMessage);
|
2014-11-26 19:54:52 +00:00
|
|
|
|
|
|
|
done(err);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2015-04-21 12:22:03 +00:00
|
|
|
it('should extend attributes with default value', function(done) {
|
2014-08-18 10:38:41 +00:00
|
|
|
|
|
|
|
// given
|
2015-04-21 12:22:03 +00:00
|
|
|
var xml = require('../../fixtures/bpmn/import/default-attrs.bpmn');
|
2014-08-18 10:38:41 +00:00
|
|
|
|
|
|
|
// when
|
|
|
|
runImport(diagram, xml, function(err, warnings) {
|
|
|
|
|
|
|
|
var elementRegistry = diagram.get('elementRegistry');
|
|
|
|
|
2014-11-17 16:36:22 +00:00
|
|
|
var element = elementRegistry.get('GATEWAY_1');
|
2014-08-18 10:38:41 +00:00
|
|
|
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(element.businessObject.eventGatewayType).to.equal('Exclusive');
|
2014-08-18 10:38:41 +00:00
|
|
|
|
|
|
|
done();
|
|
|
|
});
|
2014-10-31 14:05:16 +00:00
|
|
|
});
|
|
|
|
|
2015-07-15 06:50:21 +00:00
|
|
|
|
|
|
|
describe('boundary events', function() {
|
|
|
|
|
|
|
|
it('should handle missing attachToRef', function(done) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var xml = require('../../fixtures/bpmn/import/error/boundaryEvent-missingAttachToRef.bpmn');
|
|
|
|
|
|
|
|
// when
|
|
|
|
runImport(diagram, xml, function(err, warnings) {
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(warnings.length).to.eql(2);
|
|
|
|
|
|
|
|
expect(warnings[0].message).to.eql('missing <bpmn:BoundaryEvent id="BoundaryEvent_1" />#attachedToRef');
|
|
|
|
expect(warnings[1].message).to.eql('element <bpmn:BoundaryEvent id="BoundaryEvent_1" /> referenced by <bpmn:SequenceFlow id="SequenceFlow_1" />#sourceRef not yet drawn');
|
|
|
|
|
|
|
|
done(err);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
it('should handle invalid attachToRef', function(done) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var xml = require('../../fixtures/bpmn/import/error/boundaryEvent-invalidAttachToRef.bpmn');
|
|
|
|
|
|
|
|
// when
|
|
|
|
runImport(diagram, xml, function(err, warnings) {
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(warnings.length).to.eql(2);
|
|
|
|
|
|
|
|
expect(warnings[0].message).to.eql('missing <bpmn:BoundaryEvent id="BoundaryEvent_1" />#attachedToRef');
|
|
|
|
expect(warnings[1].message).to.eql('element <bpmn:BoundaryEvent id="BoundaryEvent_1" /> referenced by <bpmn:SequenceFlow id="SequenceFlow_1" />#sourceRef not yet drawn');
|
|
|
|
|
|
|
|
done(err);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2014-10-31 14:05:16 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
describe('integration', function() {
|
|
|
|
|
2015-01-02 11:56:32 +00:00
|
|
|
it('should import dangling process message flows', function(done) {
|
|
|
|
|
|
|
|
// given
|
2015-07-15 06:50:21 +00:00
|
|
|
var xml = require('../../fixtures/bpmn/import/error/dangling-process-message-flow.bpmn');
|
2015-01-02 11:56:32 +00:00
|
|
|
|
|
|
|
// when
|
|
|
|
runImport(diagram, xml, function(err, warnings) {
|
|
|
|
|
|
|
|
// then
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(warnings.length).to.equal(0);
|
2015-01-02 11:56:32 +00:00
|
|
|
|
2015-12-01 07:27:45 +00:00
|
|
|
expect(diagram.get('elementRegistry').get('_b467921a-ef7b-44c5-bf78-fd624c400d17')).to.exist;
|
|
|
|
expect(diagram.get('elementRegistry').get('_c311cc87-677e-47a4-bdb1-8744c4ec3147')).to.exist;
|
2015-01-02 11:56:32 +00:00
|
|
|
|
|
|
|
done(err);
|
|
|
|
});
|
|
|
|
});
|
2015-07-15 06:50:21 +00:00
|
|
|
|
2014-06-18 11:05:32 +00:00
|
|
|
});
|
|
|
|
|
2016-06-08 07:34:11 +00:00
|
|
|
|
|
|
|
describe('hiding', function() {
|
|
|
|
|
|
|
|
it('should hide shapes and connections inside of collapsed subprocess', function(done) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var xml = require('../../fixtures/bpmn/import/collapsed/processWithChildren.bpmn');
|
|
|
|
|
|
|
|
// when
|
|
|
|
runImport(diagram, xml, function(err, warnings) {
|
|
|
|
|
|
|
|
var elementRegistry = diagram.get('elementRegistry');
|
|
|
|
|
|
|
|
var children = elementRegistry.get('SubProcess_1').children;
|
|
|
|
var visible = find(children, function(child) {
|
|
|
|
return !child.hidden;
|
|
|
|
});
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(visible).to.be.undefined;
|
|
|
|
|
|
|
|
done(err);
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
2017-11-13 10:11:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2018-02-27 08:57:22 +00:00
|
|
|
// helpers //////////////////////
|
2017-11-13 10:11:07 +00:00
|
|
|
|
|
|
|
function expectChildren(diagram, parent, children) {
|
|
|
|
|
|
|
|
return diagram.invoke(function(elementRegistry) {
|
|
|
|
|
|
|
|
// verify model is consistent
|
|
|
|
expect(parent.children).to.eql(children);
|
|
|
|
|
|
|
|
// verify SVG is consistent
|
|
|
|
var parentGfx = elementRegistry.getGraphics(parent);
|
|
|
|
|
|
|
|
var expectedChildrenGfx = children.map(function(c) {
|
|
|
|
return elementRegistry.getGraphics(c);
|
|
|
|
});
|
|
|
|
|
|
|
|
var childrenContainerGfx =
|
|
|
|
domMatches(parentGfx, '[data-element-id="Process_1"]')
|
|
|
|
? parentGfx
|
|
|
|
: getChildrenGfx(parentGfx);
|
|
|
|
|
|
|
|
var existingChildrenGfx = Array.prototype.map.call(childrenContainerGfx.childNodes, function(c) {
|
|
|
|
return c.querySelector('.djs-element');
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(existingChildrenGfx).to.eql(expectedChildrenGfx);
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|