2018-04-02 19:01:53 +00:00
|
|
|
import {
|
|
|
|
bootstrapViewer,
|
|
|
|
inject
|
|
|
|
} from 'test/TestHelper';
|
2014-06-18 09:45:30 +00:00
|
|
|
|
2016-10-26 09:26:58 +00:00
|
|
|
|
2014-10-30 11:07:28 +00:00
|
|
|
describe('import - labels', function() {
|
2014-04-25 14:14:36 +00:00
|
|
|
|
2014-05-06 08:00:06 +00:00
|
|
|
describe('should import embedded labels', function() {
|
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
it('on flow nodes', function() {
|
2015-03-31 12:17:15 +00:00
|
|
|
var xml = require('../../../fixtures/bpmn/import/labels/embedded.bpmn');
|
2020-04-29 09:02:42 +00:00
|
|
|
return bootstrapViewer(xml)().then(function(result) {
|
|
|
|
expect(result.error).not.to.exist;
|
|
|
|
});
|
2014-04-25 14:14:36 +00:00
|
|
|
});
|
2014-05-06 08:00:06 +00:00
|
|
|
|
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
it('on pools and lanes', function() {
|
2015-03-31 12:17:15 +00:00
|
|
|
var xml = require('../../../fixtures/bpmn/import/labels/collaboration.bpmn');
|
2020-04-29 09:02:42 +00:00
|
|
|
return bootstrapViewer(xml)().then(function(result) {
|
|
|
|
expect(result.error).not.to.exist;
|
|
|
|
});
|
2014-05-06 08:00:06 +00:00
|
|
|
});
|
|
|
|
|
2014-06-17 09:03:03 +00:00
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
it('on message flows', function() {
|
2015-03-31 12:17:15 +00:00
|
|
|
var xml = require('../../../fixtures/bpmn/import/labels/collaboration-message-flows.bpmn');
|
2020-04-29 09:02:42 +00:00
|
|
|
return bootstrapViewer(xml)().then(function(result) {
|
|
|
|
expect(result.error).not.to.exist;
|
|
|
|
});
|
2014-06-17 09:03:03 +00:00
|
|
|
});
|
|
|
|
|
2014-04-25 14:14:36 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
describe('should import external labels', function() {
|
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
it('with di', function() {
|
2015-03-31 12:17:15 +00:00
|
|
|
var xml = require('../../../fixtures/bpmn/import/labels/external.bpmn');
|
2014-10-30 11:07:28 +00:00
|
|
|
|
|
|
|
// given
|
2020-04-29 09:02:42 +00:00
|
|
|
return bootstrapViewer(xml)().then(function(result) {
|
|
|
|
|
|
|
|
var err = result.error;
|
|
|
|
|
|
|
|
expect(err).not.to.exist;
|
2014-10-30 11:07:28 +00:00
|
|
|
|
|
|
|
// when
|
|
|
|
inject(function(elementRegistry) {
|
|
|
|
|
2016-10-26 09:26:58 +00:00
|
|
|
var eventLabel = elementRegistry.get('EndEvent_1').label,
|
|
|
|
sequenceFlowLabel = elementRegistry.get('SequenceFlow_1').label;
|
|
|
|
|
|
|
|
var eventLabelCenter = getCenter(eventLabel),
|
|
|
|
sequenceFlowCenter = getCenter(sequenceFlowLabel);
|
2014-10-30 11:07:28 +00:00
|
|
|
|
|
|
|
// then
|
2016-10-26 09:26:58 +00:00
|
|
|
expect(eventLabelCenter.x).to.be.within(270, 272);
|
2018-05-25 11:56:12 +00:00
|
|
|
expect(eventLabelCenter.y).to.be.within(269, 271);
|
2016-10-26 09:26:58 +00:00
|
|
|
expect(eventLabel.width).to.be.above(65);
|
|
|
|
expect(eventLabel.height).to.be.above(20);
|
|
|
|
|
|
|
|
expect(sequenceFlowCenter.x).to.be.within(481, 483);
|
2016-11-18 14:03:59 +00:00
|
|
|
expect(sequenceFlowCenter.y).to.be.within(323, 335);
|
2017-02-13 12:47:00 +00:00
|
|
|
expect(sequenceFlowLabel.width).to.be.above(64);
|
2016-10-26 09:26:58 +00:00
|
|
|
expect(sequenceFlowLabel.height).to.be.above(11);
|
2014-10-30 11:07:28 +00:00
|
|
|
})();
|
|
|
|
|
|
|
|
});
|
2014-04-25 14:14:36 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
it('without di', function() {
|
2015-03-31 12:17:15 +00:00
|
|
|
var xml = require('../../../fixtures/bpmn/import/labels/external-no-di.bpmn');
|
2020-04-29 09:02:42 +00:00
|
|
|
return bootstrapViewer(xml)().then(function(result) {
|
|
|
|
expect(result.error).not.to.exist;
|
|
|
|
});
|
2014-04-25 14:14:36 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2016-09-14 06:18:56 +00:00
|
|
|
});
|
2018-04-02 19:01:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
// helper ////////////////
|
|
|
|
|
|
|
|
function getCenter(element) {
|
|
|
|
return {
|
|
|
|
x: element.x + Math.ceil(element.width / 2),
|
|
|
|
y: element.y + Math.ceil(element.height / 2)
|
|
|
|
};
|
2020-04-29 09:02:42 +00:00
|
|
|
}
|