2018-04-02 19:01:53 +00:00
|
|
|
import Modeler from 'lib/Modeler';
|
|
|
|
import Viewer from 'lib/Viewer';
|
|
|
|
import NavigatedViewer from 'lib/NavigatedViewer';
|
2014-03-13 15:06:30 +00:00
|
|
|
|
2018-04-02 19:01:53 +00:00
|
|
|
import TestContainer from 'mocha-test-container-support';
|
|
|
|
|
|
|
|
import {
|
|
|
|
createEvent
|
|
|
|
} from '../util/MockEvents';
|
2014-03-13 15:06:30 +00:00
|
|
|
|
2019-07-19 11:49:24 +00:00
|
|
|
import {
|
|
|
|
setBpmnJS,
|
2020-11-03 12:44:40 +00:00
|
|
|
clearBpmnJS,
|
|
|
|
collectTranslations
|
2019-07-19 11:49:24 +00:00
|
|
|
} from 'test/TestHelper';
|
|
|
|
|
2021-01-21 09:02:07 +00:00
|
|
|
import AlignToOrigin from 'align-to-origin-xml';
|
|
|
|
|
2018-04-02 07:12:44 +00:00
|
|
|
|
2020-12-21 12:32:16 +00:00
|
|
|
var singleStart = window.__env__ && window.__env__.SINGLE_START === 'modeler';
|
|
|
|
|
|
|
|
|
2014-12-18 08:45:45 +00:00
|
|
|
describe('Modeler', function() {
|
2014-03-13 15:06:30 +00:00
|
|
|
|
|
|
|
var container;
|
|
|
|
|
2018-04-02 07:12:44 +00:00
|
|
|
var modeler;
|
|
|
|
|
2014-03-13 15:06:30 +00:00
|
|
|
beforeEach(function() {
|
2015-07-15 15:22:19 +00:00
|
|
|
container = TestContainer.get(this);
|
2014-03-13 15:06:30 +00:00
|
|
|
});
|
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
function createModeler(xml) {
|
2018-04-02 07:12:44 +00:00
|
|
|
|
2019-07-19 11:49:24 +00:00
|
|
|
clearBpmnJS();
|
|
|
|
|
2018-04-02 07:12:44 +00:00
|
|
|
modeler = new Modeler({
|
|
|
|
container: container,
|
|
|
|
keyboard: {
|
|
|
|
bindTo: document
|
2021-01-21 09:02:07 +00:00
|
|
|
},
|
|
|
|
additionalModules: [
|
|
|
|
AlignToOrigin
|
|
|
|
]
|
2018-04-02 07:12:44 +00:00
|
|
|
});
|
2014-06-17 09:19:31 +00:00
|
|
|
|
2019-07-19 11:49:24 +00:00
|
|
|
setBpmnJS(modeler);
|
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
return modeler.importXML(xml).then(function(result) {
|
|
|
|
return { error: null, warnings: result.warnings, modeler: modeler };
|
|
|
|
}).catch(function(err) {
|
|
|
|
return { error: err, warnings: err.warnings, modeler: modeler };
|
2014-06-17 09:19:31 +00:00
|
|
|
});
|
|
|
|
}
|
2014-03-13 15:06:30 +00:00
|
|
|
|
2014-06-18 09:45:30 +00:00
|
|
|
|
2021-01-21 09:02:07 +00:00
|
|
|
it.only('should import simple process', function() {
|
2015-03-31 12:17:15 +00:00
|
|
|
var xml = require('../fixtures/bpmn/simple.bpmn');
|
2020-04-29 09:02:42 +00:00
|
|
|
return createModeler(xml).then(function(result) {
|
|
|
|
|
|
|
|
expect(result.error).not.to.exist;
|
2021-01-21 09:02:07 +00:00
|
|
|
|
|
|
|
result.modeler.on('commandStack.changed', function() {
|
|
|
|
result.modeler.saveXML({ format: true }).then(function(result) {
|
|
|
|
console.log(result.xml);
|
|
|
|
});
|
|
|
|
})
|
2020-04-29 09:02:42 +00:00
|
|
|
});
|
2014-06-17 09:19:31 +00:00
|
|
|
});
|
2014-03-13 15:06:30 +00:00
|
|
|
|
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
it('should import collaboration', function() {
|
2015-04-16 07:11:04 +00:00
|
|
|
var xml = require('../fixtures/bpmn/collaboration-message-flows.bpmn');
|
2020-04-29 09:02:42 +00:00
|
|
|
return createModeler(xml).then(function(result) {
|
|
|
|
|
|
|
|
expect(result.error).not.to.exist;
|
|
|
|
});
|
2015-04-16 07:11:04 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
it('should import nested lanes', function() {
|
2015-10-09 23:40:52 +00:00
|
|
|
var xml = require('./features/modeling/lanes/lanes.bpmn');
|
2020-04-29 09:02:42 +00:00
|
|
|
return createModeler(xml).then(function(result) {
|
|
|
|
|
|
|
|
expect(result.error).not.to.exist;
|
|
|
|
});
|
2015-10-09 23:40:52 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
it('should import ioSpecification', function() {
|
2019-03-25 15:44:01 +00:00
|
|
|
var xml = require('./features/modeling/input-output/DataInputOutput.bpmn');
|
2020-04-29 09:02:42 +00:00
|
|
|
return createModeler(xml).then(function(result) {
|
|
|
|
|
|
|
|
expect(result.error).not.to.exist;
|
|
|
|
});
|
2019-03-25 15:44:01 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
it.skip('should import complex', function() {
|
2016-06-27 12:14:07 +00:00
|
|
|
var xml = require('../fixtures/bpmn/complex.bpmn');
|
2020-04-29 09:02:42 +00:00
|
|
|
return createModeler(xml).then(function(result) {
|
|
|
|
|
|
|
|
expect(result.error).not.to.exist;
|
|
|
|
});
|
2016-06-27 12:14:07 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
it('should not import empty definitions', function() {
|
2015-03-31 12:17:15 +00:00
|
|
|
var xml = require('../fixtures/bpmn/empty-definitions.bpmn');
|
2015-11-24 11:53:18 +00:00
|
|
|
|
|
|
|
// given
|
2020-04-29 09:02:42 +00:00
|
|
|
return createModeler(xml).then(function(result) {
|
2015-11-24 11:53:18 +00:00
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
var modeler = result.modeler;
|
2015-11-24 11:53:18 +00:00
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
// when
|
|
|
|
return modeler.importXML(xml);
|
|
|
|
}).catch(function(err) {
|
2015-11-24 11:53:18 +00:00
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
// then
|
|
|
|
expect(err.message).to.equal('no diagram to display');
|
2015-11-24 11:53:18 +00:00
|
|
|
});
|
2014-03-13 15:06:30 +00:00
|
|
|
});
|
2014-04-25 11:30:10 +00:00
|
|
|
|
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
it('should re-import simple process', function() {
|
2015-02-17 11:03:27 +00:00
|
|
|
|
2015-03-31 12:17:15 +00:00
|
|
|
var xml = require('../fixtures/bpmn/simple.bpmn');
|
2015-02-17 11:03:27 +00:00
|
|
|
|
|
|
|
// given
|
2020-04-29 09:02:42 +00:00
|
|
|
return createModeler(xml).then(function(result) {
|
|
|
|
|
|
|
|
var modeler = result.modeler;
|
2015-02-17 11:03:27 +00:00
|
|
|
|
|
|
|
// when
|
|
|
|
// mimic re-import of same diagram
|
2020-04-29 09:02:42 +00:00
|
|
|
return modeler.importXML(xml);
|
|
|
|
}).then(function(result) {
|
2015-02-17 11:03:27 +00:00
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
var warnings = result.warnings;
|
2015-02-17 11:03:27 +00:00
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
// then
|
|
|
|
expect(warnings).to.be.empty;
|
2015-02-17 11:03:27 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
it('should switch between diagrams', function() {
|
2019-04-12 11:42:29 +00:00
|
|
|
|
|
|
|
var multipleXML = require('../fixtures/bpmn/multiple-diagrams.bpmn');
|
|
|
|
|
|
|
|
// given
|
2020-04-29 09:02:42 +00:00
|
|
|
return createModeler(multipleXML).then(function(result) {
|
|
|
|
|
|
|
|
var modeler = result.modeler;
|
|
|
|
var err = result.error;
|
2019-04-12 11:42:29 +00:00
|
|
|
|
|
|
|
if (err) {
|
2020-04-29 09:02:42 +00:00
|
|
|
throw err;
|
2019-04-12 11:42:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// when
|
2020-04-29 09:02:42 +00:00
|
|
|
return modeler.open('BpmnDiagram_2');
|
|
|
|
}).then(function(result) {
|
2019-04-12 11:42:29 +00:00
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
var warnings = result.warnings;
|
2019-04-12 11:42:29 +00:00
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
// then
|
|
|
|
expect(warnings).to.be.empty;
|
2019-04-12 11:42:29 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2020-11-03 12:44:40 +00:00
|
|
|
!collectTranslations && describe('translate support', function() {
|
2016-02-25 16:40:56 +00:00
|
|
|
|
|
|
|
var xml = require('../fixtures/bpmn/simple.bpmn');
|
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
it('should allow translation of multi-lingual strings', function() {
|
|
|
|
|
|
|
|
return createModeler(xml).then(function(result) {
|
2016-02-25 16:40:56 +00:00
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
var modeler = result.modeler;
|
|
|
|
var err = result.error;
|
|
|
|
|
|
|
|
if (err) {
|
|
|
|
throw err;
|
|
|
|
}
|
2016-02-25 16:40:56 +00:00
|
|
|
|
|
|
|
// given
|
|
|
|
var translate = modeler.get('translate');
|
|
|
|
|
|
|
|
// assume
|
|
|
|
expect(translate).to.exist;
|
|
|
|
|
|
|
|
// when
|
|
|
|
var interpolatedString = translate('HELLO {you}!', { you: 'WALT' });
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(interpolatedString).to.eql('HELLO WALT!');
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2014-08-05 15:02:03 +00:00
|
|
|
describe('overlay support', function() {
|
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
it('should allow to add overlays', function() {
|
2014-08-05 15:02:03 +00:00
|
|
|
|
2015-03-31 12:17:15 +00:00
|
|
|
var xml = require('../fixtures/bpmn/simple.bpmn');
|
2014-08-05 15:02:03 +00:00
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
return createModeler(xml).then(function(result) {
|
|
|
|
|
|
|
|
var modeler = result.modeler;
|
|
|
|
var err = result.error;
|
|
|
|
|
|
|
|
if (err) {
|
|
|
|
throw err;
|
|
|
|
}
|
2014-08-05 15:02:03 +00:00
|
|
|
|
2014-08-07 20:09:12 +00:00
|
|
|
// given
|
2016-02-25 16:40:56 +00:00
|
|
|
var overlays = modeler.get('overlays'),
|
|
|
|
elementRegistry = modeler.get('elementRegistry');
|
2014-08-05 15:02:03 +00:00
|
|
|
|
2014-08-07 20:09:12 +00:00
|
|
|
// assume
|
2015-12-01 07:27:45 +00:00
|
|
|
expect(overlays).to.exist;
|
|
|
|
expect(elementRegistry).to.exist;
|
2014-08-05 15:02:03 +00:00
|
|
|
|
|
|
|
|
|
|
|
// when
|
2014-08-12 09:53:38 +00:00
|
|
|
overlays.add('SubProcess_1', 'badge', {
|
2014-08-05 15:02:03 +00:00
|
|
|
position: {
|
|
|
|
bottom: 0,
|
|
|
|
right: 0
|
|
|
|
},
|
|
|
|
html: '<div style="max-width: 50px">YUP GREAT STUFF!</div>'
|
|
|
|
});
|
|
|
|
|
2014-08-12 09:53:38 +00:00
|
|
|
overlays.add('StartEvent_1', 'badge', {
|
2014-08-07 20:09:12 +00:00
|
|
|
position: {
|
|
|
|
top: 0,
|
|
|
|
left: 0
|
|
|
|
},
|
|
|
|
html: '<div style="max-width: 50px">YUP GREAT STUFF!</div>'
|
|
|
|
});
|
|
|
|
|
2014-08-05 15:02:03 +00:00
|
|
|
// then
|
2018-04-02 07:24:21 +00:00
|
|
|
expect(overlays.get({ element: 'SubProcess_1', type: 'badge' })).to.have.length(1);
|
|
|
|
expect(overlays.get({ element: 'StartEvent_1', type: 'badge' })).to.have.length(1);
|
2014-08-05 15:02:03 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2018-10-26 15:52:02 +00:00
|
|
|
describe('editor actions support', function() {
|
|
|
|
|
|
|
|
it('should ship all actions', function() {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var expectedActions = [
|
|
|
|
'undo',
|
|
|
|
'redo',
|
|
|
|
'copy',
|
|
|
|
'paste',
|
|
|
|
'stepZoom',
|
|
|
|
'zoom',
|
|
|
|
'removeSelection',
|
|
|
|
'moveCanvas',
|
2018-10-26 23:10:21 +00:00
|
|
|
'moveSelection',
|
2018-10-26 15:52:02 +00:00
|
|
|
'selectElements',
|
|
|
|
'spaceTool',
|
|
|
|
'lassoTool',
|
|
|
|
'handTool',
|
|
|
|
'globalConnectTool',
|
|
|
|
'distributeElements',
|
|
|
|
'alignElements',
|
|
|
|
'setColor',
|
|
|
|
'directEditing',
|
|
|
|
'find',
|
|
|
|
'moveToOrigin'
|
|
|
|
];
|
|
|
|
|
|
|
|
var modeler = new Modeler();
|
|
|
|
|
|
|
|
// when
|
|
|
|
var editorActions = modeler.get('editorActions');
|
|
|
|
|
|
|
|
// then
|
|
|
|
var actualActions = editorActions.getActions();
|
|
|
|
|
|
|
|
expect(actualActions).to.eql(expectedActions);
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2015-01-14 17:48:06 +00:00
|
|
|
describe('bendpoint editing support', function() {
|
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
it('should allow to edit bendpoints', function() {
|
2015-01-14 17:48:06 +00:00
|
|
|
|
2015-03-31 12:17:15 +00:00
|
|
|
var xml = require('../fixtures/bpmn/simple.bpmn');
|
2015-01-14 17:48:06 +00:00
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
return createModeler(xml).then(function(result) {
|
|
|
|
|
|
|
|
var modeler = result.modeler;
|
|
|
|
var err = result.error;
|
|
|
|
|
|
|
|
if (err) {
|
|
|
|
throw err;
|
|
|
|
}
|
2015-01-14 17:48:06 +00:00
|
|
|
|
|
|
|
// given
|
2016-02-25 16:40:56 +00:00
|
|
|
var bendpointMove = modeler.get('bendpointMove'),
|
|
|
|
dragging = modeler.get('dragging'),
|
|
|
|
elementRegistry = modeler.get('elementRegistry'),
|
|
|
|
canvas = modeler.get('canvas');
|
2015-01-14 17:48:06 +00:00
|
|
|
|
|
|
|
// assume
|
2015-12-01 07:27:45 +00:00
|
|
|
expect(bendpointMove).to.exist;
|
2015-01-14 17:48:06 +00:00
|
|
|
|
|
|
|
// when
|
2018-04-02 07:24:21 +00:00
|
|
|
bendpointMove.start(
|
|
|
|
createEvent(canvas, { x: 0, y: 0 }),
|
|
|
|
elementRegistry.get('SequenceFlow_1'),
|
|
|
|
1
|
|
|
|
);
|
2015-08-24 13:31:47 +00:00
|
|
|
dragging.move(createEvent(canvas, { x: 200, y: 200 }));
|
2015-01-14 17:48:06 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2018-01-31 11:07:18 +00:00
|
|
|
describe('color support', function() {
|
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
it('should allow color changes', function() {
|
2018-01-31 11:07:18 +00:00
|
|
|
|
|
|
|
var xml = require('../fixtures/bpmn/simple.bpmn');
|
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
return createModeler(xml).then(function(result) {
|
|
|
|
|
|
|
|
var modeler = result.modeler;
|
2018-01-31 11:07:18 +00:00
|
|
|
|
|
|
|
// given
|
|
|
|
var modeling = modeler.get('modeling'),
|
|
|
|
elementRegistry = modeler.get('elementRegistry'),
|
|
|
|
eventShape = elementRegistry.get('StartEvent_2');
|
|
|
|
|
|
|
|
// when
|
|
|
|
// set color for StartEvent_2
|
|
|
|
modeling.setColor(eventShape, {
|
|
|
|
fill: 'FUCHSIA',
|
|
|
|
stroke: 'YELLOW'
|
|
|
|
});
|
|
|
|
|
|
|
|
// test saving process to get XML
|
2020-04-29 09:02:42 +00:00
|
|
|
return modeler.saveXML({ format: true });
|
|
|
|
}).then(function(result) {
|
|
|
|
var xml = result.xml;
|
2018-01-31 11:07:18 +00:00
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
expect(xml).not.to.contain('di="[object Object]"');
|
2018-01-31 11:07:18 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2016-01-08 13:41:58 +00:00
|
|
|
describe('configuration', function() {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var xml = require('../fixtures/bpmn/simple.bpmn');
|
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
it('should configure Canvas', function() {
|
2016-01-08 13:41:58 +00:00
|
|
|
|
|
|
|
// given
|
|
|
|
var modeler = new Modeler({
|
|
|
|
container: container,
|
|
|
|
canvas: {
|
|
|
|
deferUpdate: true
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// when
|
2020-04-29 09:02:42 +00:00
|
|
|
return modeler.importXML(xml).then(function() {
|
2016-01-08 13:41:58 +00:00
|
|
|
|
|
|
|
var canvasConfig = modeler.get('config.canvas');
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(canvasConfig.deferUpdate).to.be.true;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2016-03-16 22:11:05 +00:00
|
|
|
describe('ids', function() {
|
|
|
|
|
|
|
|
it('should provide ids with moddle', function() {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var modeler = new Modeler({ container: container });
|
|
|
|
|
|
|
|
// when
|
|
|
|
var moddle = modeler.get('moddle');
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(moddle.ids).to.exist;
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
it('should populate ids on import', function() {
|
2016-03-16 22:11:05 +00:00
|
|
|
|
|
|
|
// given
|
|
|
|
var xml = require('../fixtures/bpmn/simple.bpmn');
|
|
|
|
|
|
|
|
var modeler = new Modeler({ container: container });
|
|
|
|
|
|
|
|
var moddle = modeler.get('moddle');
|
|
|
|
var elementRegistry = modeler.get('elementRegistry');
|
|
|
|
|
|
|
|
// when
|
2020-04-29 09:02:42 +00:00
|
|
|
return modeler.importXML(xml).then(function() {
|
2016-03-16 22:11:05 +00:00
|
|
|
|
|
|
|
var subProcess = elementRegistry.get('SubProcess_1').businessObject;
|
|
|
|
var bpmnEdge = elementRegistry.get('SequenceFlow_3').businessObject.di;
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(moddle.ids.assigned('SubProcess_1')).to.eql(subProcess);
|
|
|
|
expect(moddle.ids.assigned('BPMNEdge_SequenceFlow_3')).to.eql(bpmnEdge);
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
it('should clear ids before re-import', function() {
|
2016-03-16 22:11:05 +00:00
|
|
|
|
|
|
|
// given
|
|
|
|
var someXML = require('../fixtures/bpmn/simple.bpmn'),
|
|
|
|
otherXML = require('../fixtures/bpmn/basic.bpmn');
|
|
|
|
|
|
|
|
var modeler = new Modeler({ container: container });
|
|
|
|
|
|
|
|
var moddle = modeler.get('moddle');
|
|
|
|
var elementRegistry = modeler.get('elementRegistry');
|
|
|
|
|
|
|
|
// when
|
2020-04-29 09:02:42 +00:00
|
|
|
return modeler.importXML(someXML).then(function() {
|
2016-03-16 22:11:05 +00:00
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
return modeler.importXML(otherXML);
|
|
|
|
}).then(function() {
|
2016-03-16 22:11:05 +00:00
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
var task = elementRegistry.get('Task_1').businessObject;
|
2016-03-16 22:11:05 +00:00
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
// then
|
|
|
|
// not in other.bpmn
|
|
|
|
expect(moddle.ids.assigned('SubProcess_1')).to.be.false;
|
2016-03-16 22:11:05 +00:00
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
// in other.bpmn
|
|
|
|
expect(moddle.ids.assigned('Task_1')).to.eql(task);
|
2016-03-16 22:11:05 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
it('should handle errors', function() {
|
2014-03-17 10:11:25 +00:00
|
|
|
|
2014-06-17 09:19:31 +00:00
|
|
|
var xml = 'invalid stuff';
|
2014-03-17 10:11:25 +00:00
|
|
|
|
2014-06-24 13:50:51 +00:00
|
|
|
var modeler = new Modeler({ container: container });
|
2014-03-21 20:10:01 +00:00
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
return modeler.importXML(xml).catch(function(err) {
|
2014-04-03 09:47:26 +00:00
|
|
|
|
2015-12-01 07:27:45 +00:00
|
|
|
expect(err).to.exist;
|
2014-03-21 20:10:01 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
it('should create new diagram', function() {
|
|
|
|
var modeler = new Modeler({ container: container });
|
|
|
|
return modeler.createDiagram();
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
it('should create new diagram - Legacy', function(done) {
|
2014-06-24 13:50:51 +00:00
|
|
|
var modeler = new Modeler({ container: container });
|
2020-04-29 09:02:42 +00:00
|
|
|
modeler.createDiagram(function(err, warnings) {
|
|
|
|
|
|
|
|
expect(warnings).to.exist;
|
|
|
|
expect(warnings).to.have.length(0);
|
|
|
|
|
|
|
|
done(err);
|
|
|
|
});
|
2014-06-24 13:50:51 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
2014-06-17 09:19:31 +00:00
|
|
|
describe('dependency injection', function() {
|
2014-03-21 20:10:01 +00:00
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
it('should provide self as <bpmnjs>', function() {
|
2014-03-17 10:11:25 +00:00
|
|
|
|
2015-03-31 12:17:15 +00:00
|
|
|
var xml = require('../fixtures/bpmn/simple.bpmn');
|
2014-03-21 20:10:01 +00:00
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
return createModeler(xml).then(function(result) {
|
2014-03-21 20:10:01 +00:00
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
var modeler = result.modeler;
|
|
|
|
var err = result.error;
|
2014-10-27 11:07:57 +00:00
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
if (err) {
|
|
|
|
throw err;
|
|
|
|
}
|
|
|
|
|
|
|
|
expect(modeler.get('bpmnjs')).to.equal(modeler);
|
2014-06-17 09:19:31 +00:00
|
|
|
});
|
2014-03-17 10:11:25 +00:00
|
|
|
});
|
2014-06-17 09:19:31 +00:00
|
|
|
|
2016-03-16 22:11:05 +00:00
|
|
|
|
|
|
|
it('should allow Diagram#get before import', function() {
|
|
|
|
|
|
|
|
// when
|
|
|
|
var modeler = new Modeler({ container: container });
|
|
|
|
|
|
|
|
// then
|
|
|
|
var eventBus = modeler.get('eventBus');
|
|
|
|
|
|
|
|
expect(eventBus).to.exist;
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
it('should keep references to services across re-import', function() {
|
2016-03-16 22:11:05 +00:00
|
|
|
|
|
|
|
// given
|
|
|
|
var someXML = require('../fixtures/bpmn/simple.bpmn'),
|
|
|
|
otherXML = require('../fixtures/bpmn/basic.bpmn');
|
|
|
|
|
|
|
|
var modeler = new Modeler({ container: container });
|
|
|
|
|
|
|
|
var eventBus = modeler.get('eventBus'),
|
|
|
|
canvas = modeler.get('canvas');
|
|
|
|
|
|
|
|
// when
|
2020-04-29 09:02:42 +00:00
|
|
|
return modeler.importXML(someXML).then(function() {
|
2016-03-16 22:11:05 +00:00
|
|
|
|
|
|
|
// then
|
|
|
|
expect(modeler.get('canvas')).to.equal(canvas);
|
|
|
|
expect(modeler.get('eventBus')).to.equal(eventBus);
|
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
return modeler.importXML(otherXML);
|
|
|
|
}).then(function() {
|
2016-03-16 22:11:05 +00:00
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
// then
|
|
|
|
expect(modeler.get('canvas')).to.equal(canvas);
|
|
|
|
expect(modeler.get('eventBus')).to.equal(eventBus);
|
2016-03-16 22:11:05 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
it('should inject mandatory modules', function() {
|
2018-11-06 13:00:44 +00:00
|
|
|
|
|
|
|
// given
|
|
|
|
var xml = require('../fixtures/bpmn/simple.bpmn');
|
|
|
|
|
|
|
|
// when
|
2020-04-29 09:02:42 +00:00
|
|
|
return createModeler(xml).then(function(result) {
|
|
|
|
|
|
|
|
var modeler = result.modeler;
|
|
|
|
var err = result.error;
|
2018-11-06 13:00:44 +00:00
|
|
|
|
|
|
|
// then
|
2020-04-29 09:02:42 +00:00
|
|
|
|
|
|
|
if (err) {
|
|
|
|
throw err;
|
|
|
|
}
|
|
|
|
|
2018-11-06 13:00:44 +00:00
|
|
|
expect(modeler.get('alignElements')).to.exist;
|
|
|
|
expect(modeler.get('autoPlace')).to.exist;
|
|
|
|
expect(modeler.get('bpmnAutoResize')).to.exist;
|
|
|
|
expect(modeler.get('autoScroll')).to.exist;
|
|
|
|
expect(modeler.get('bendpoints')).to.exist;
|
|
|
|
expect(modeler.get('bpmnCopyPaste')).to.exist;
|
|
|
|
expect(modeler.get('bpmnSearch')).to.exist;
|
|
|
|
expect(modeler.get('contextPad')).to.exist;
|
|
|
|
expect(modeler.get('copyPaste')).to.exist;
|
|
|
|
expect(modeler.get('alignElements')).to.exist;
|
|
|
|
expect(modeler.get('distributeElements')).to.exist;
|
|
|
|
expect(modeler.get('editorActions')).to.exist;
|
|
|
|
expect(modeler.get('keyboard')).to.exist;
|
|
|
|
expect(modeler.get('keyboardMoveSelection')).to.exist;
|
|
|
|
expect(modeler.get('labelEditingProvider')).to.exist;
|
|
|
|
expect(modeler.get('modeling')).to.exist;
|
|
|
|
expect(modeler.get('move')).to.exist;
|
|
|
|
expect(modeler.get('paletteProvider')).to.exist;
|
|
|
|
expect(modeler.get('resize')).to.exist;
|
|
|
|
expect(modeler.get('snapping')).to.exist;
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2014-03-17 10:11:25 +00:00
|
|
|
});
|
2014-03-21 20:10:01 +00:00
|
|
|
|
2016-05-12 11:15:32 +00:00
|
|
|
|
|
|
|
it('should expose Viewer and NavigatedViewer', function() {
|
|
|
|
expect(Modeler.Viewer).to.equal(Viewer);
|
|
|
|
expect(Modeler.NavigatedViewer).to.equal(NavigatedViewer);
|
|
|
|
});
|
|
|
|
|
2014-10-27 11:07:57 +00:00
|
|
|
});
|