2018-04-02 19:01:53 +00:00
|
|
|
import {
|
|
|
|
bootstrapModeler,
|
|
|
|
bootstrapViewer,
|
|
|
|
inject
|
|
|
|
} from 'test/TestHelper';
|
2014-04-25 11:31:18 +00:00
|
|
|
|
2018-04-02 19:01:53 +00:00
|
|
|
import {
|
|
|
|
create as svgCreate
|
|
|
|
} from 'tiny-svg';
|
2017-12-16 23:06:01 +00:00
|
|
|
|
2018-04-02 19:01:53 +00:00
|
|
|
import coreModule from 'lib/core';
|
|
|
|
import rendererModule from 'lib/draw';
|
|
|
|
import modelingModule from 'lib/features/modeling';
|
2015-04-17 14:40:45 +00:00
|
|
|
|
2018-04-02 19:01:53 +00:00
|
|
|
import {
|
|
|
|
query as domQuery
|
|
|
|
} from 'min-dom';
|
2014-04-25 11:31:18 +00:00
|
|
|
|
2018-05-23 12:27:32 +00:00
|
|
|
import { isAny } from 'lib/features/modeling/util/ModelingUtil';
|
|
|
|
|
|
|
|
import {
|
|
|
|
getDi
|
|
|
|
} from 'lib/draw/BpmnRenderUtil';
|
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
function checkErrors(err, warnings) {
|
|
|
|
expect(warnings).to.be.empty;
|
|
|
|
expect(err).not.to.exist;
|
2016-11-08 13:24:26 +00:00
|
|
|
}
|
2014-04-25 11:31:18 +00:00
|
|
|
|
2018-04-02 19:01:53 +00:00
|
|
|
|
2014-06-18 09:45:30 +00:00
|
|
|
describe('draw - bpmn renderer', function() {
|
2014-04-25 11:31:18 +00:00
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
it('should render labels', function() {
|
2018-09-20 20:18:10 +00:00
|
|
|
var xml = require('./BpmnRenderer.labels.bpmn');
|
2020-04-29 09:02:42 +00:00
|
|
|
return bootstrapViewer(xml).call(this).then(function(result) {
|
|
|
|
|
|
|
|
checkErrors(result.error, result.warnings);
|
|
|
|
});
|
2018-09-20 20:18:10 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
it('should render activity markers', function() {
|
2015-03-31 12:17:15 +00:00
|
|
|
var xml = require('../../fixtures/bpmn/draw/activity-markers.bpmn');
|
2020-04-29 09:02:42 +00:00
|
|
|
return bootstrapViewer(xml).call(this).then(function(result) {
|
|
|
|
|
|
|
|
checkErrors(result.error, result.warnings);
|
|
|
|
});
|
2014-05-21 11:51:59 +00:00
|
|
|
});
|
2014-05-09 13:20:29 +00:00
|
|
|
|
2014-05-18 10:20:11 +00:00
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
it('should render association markers', function() {
|
2016-01-21 13:19:06 +00:00
|
|
|
var xml = require('../../fixtures/bpmn/draw/associations.bpmn');
|
2020-04-29 09:02:42 +00:00
|
|
|
return bootstrapViewer(xml).call(this).then(function(result) {
|
|
|
|
|
|
|
|
checkErrors(result.error, result.warnings);
|
|
|
|
});
|
2016-01-21 13:19:06 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
it('should render activity markers (combination)', function() {
|
2015-03-31 12:17:15 +00:00
|
|
|
var xml = require('../../fixtures/bpmn/draw/activity-markers-combination.bpmn');
|
2020-04-29 09:02:42 +00:00
|
|
|
return bootstrapViewer(xml).call(this).then(function(result) {
|
|
|
|
|
|
|
|
checkErrors(result.error, result.warnings);
|
|
|
|
});
|
2014-05-19 14:22:55 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
it('should render conditional flows', function() {
|
2015-03-31 12:17:15 +00:00
|
|
|
var xml = require('../../fixtures/bpmn/draw/conditional-flow.bpmn');
|
2020-04-29 09:02:42 +00:00
|
|
|
return bootstrapViewer(xml).call(this).then(function(result) {
|
|
|
|
|
|
|
|
checkErrors(result.error, result.warnings);
|
|
|
|
});
|
2014-05-18 10:20:11 +00:00
|
|
|
});
|
|
|
|
|
2014-05-16 12:45:48 +00:00
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
it('should render conditional default flows', function() {
|
2015-03-31 12:17:15 +00:00
|
|
|
var xml = require('../../fixtures/bpmn/draw/conditional-flow-default.bpmn');
|
2020-04-29 09:02:42 +00:00
|
|
|
return bootstrapViewer(xml).call(this).then(function(result) {
|
|
|
|
|
|
|
|
return checkErrors(result.error, result.warnings);
|
|
|
|
});
|
2014-05-16 12:45:48 +00:00
|
|
|
});
|
|
|
|
|
2014-05-02 09:17:25 +00:00
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
it('should render NO conditional flow (gateway)', function() {
|
2015-03-31 12:17:15 +00:00
|
|
|
var xml = require('../../fixtures/bpmn/draw/conditional-flow-gateways.bpmn');
|
2020-04-29 09:02:42 +00:00
|
|
|
return bootstrapViewer(xml).call(this).then(function(result) {
|
|
|
|
|
|
|
|
checkErrors(result.error, result.warnings);
|
|
|
|
});
|
2014-05-02 09:17:25 +00:00
|
|
|
});
|
|
|
|
|
2014-05-12 09:48:24 +00:00
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
it('should render conditional flow (typed task)', function() {
|
2015-03-31 12:17:15 +00:00
|
|
|
var xml = require('../../fixtures/bpmn/draw/conditional-flow-typed-task.bpmn');
|
2020-04-29 09:02:42 +00:00
|
|
|
return bootstrapViewer(xml).call(this).then(function(result) {
|
|
|
|
|
|
|
|
checkErrors(result.error, result.warnings);
|
|
|
|
});
|
2014-05-12 09:48:24 +00:00
|
|
|
});
|
|
|
|
|
2014-05-05 15:22:43 +00:00
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
it('should render data objects', function() {
|
2015-03-31 12:17:15 +00:00
|
|
|
var xml = require('../../fixtures/bpmn/draw/data-objects.bpmn');
|
2020-04-29 09:02:42 +00:00
|
|
|
return bootstrapViewer(xml).call(this).then(function(result) {
|
|
|
|
|
|
|
|
checkErrors(result.error, result.warnings);
|
|
|
|
});
|
2014-05-05 15:22:43 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
it('should render events', function() {
|
2015-03-31 12:17:15 +00:00
|
|
|
var xml = require('../../fixtures/bpmn/draw/events.bpmn');
|
2020-04-29 09:02:42 +00:00
|
|
|
return bootstrapViewer(xml).call(this).then(function(result) {
|
|
|
|
|
|
|
|
checkErrors(result.error, result.warnings);
|
|
|
|
});
|
2014-05-05 15:22:43 +00:00
|
|
|
});
|
2014-05-09 13:20:29 +00:00
|
|
|
|
2014-05-02 06:25:08 +00:00
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
it('should render events (interrupting)', function() {
|
2015-03-31 12:17:15 +00:00
|
|
|
var xml = require('../../fixtures/bpmn/draw/events-interrupting.bpmn');
|
2020-04-29 09:02:42 +00:00
|
|
|
return bootstrapViewer(xml).call(this).then(function(result) {
|
|
|
|
|
|
|
|
checkErrors(result.error, result.warnings);
|
|
|
|
});
|
2014-05-02 06:25:08 +00:00
|
|
|
});
|
2014-04-25 11:31:18 +00:00
|
|
|
|
2014-05-09 13:20:29 +00:00
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
it('should render event subprocesses (collapsed)', function() {
|
2015-03-31 12:17:15 +00:00
|
|
|
var xml = require('../../fixtures/bpmn/draw/event-subprocesses-collapsed.bpmn');
|
2020-04-29 09:02:42 +00:00
|
|
|
return bootstrapViewer(xml).call(this).then(function(result) {
|
|
|
|
|
|
|
|
checkErrors(result.error, result.warnings);
|
|
|
|
});
|
2014-04-25 11:31:18 +00:00
|
|
|
});
|
|
|
|
|
2014-05-09 13:20:29 +00:00
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
it('should render event subprocesses (expanded)', function() {
|
2015-03-31 12:17:15 +00:00
|
|
|
var xml = require('../../fixtures/bpmn/draw/event-subprocesses-expanded.bpmn');
|
2020-04-29 09:02:42 +00:00
|
|
|
return bootstrapViewer(xml).call(this).then(function(result) {
|
|
|
|
|
|
|
|
checkErrors(result.error, result.warnings);
|
|
|
|
});
|
2014-05-02 06:25:08 +00:00
|
|
|
});
|
|
|
|
|
2014-05-09 13:20:29 +00:00
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
it('should render gateways', function() {
|
2015-03-31 12:17:15 +00:00
|
|
|
var xml = require('../../fixtures/bpmn/draw/gateways.bpmn');
|
2020-04-29 09:02:42 +00:00
|
|
|
return bootstrapViewer(xml).call(this).then(function(result) {
|
|
|
|
|
|
|
|
checkErrors(result.error, result.warnings);
|
|
|
|
});
|
2014-04-30 14:36:02 +00:00
|
|
|
});
|
|
|
|
|
2014-05-09 13:20:29 +00:00
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
it('should render group', function() {
|
2015-03-31 12:17:15 +00:00
|
|
|
var xml = require('../../fixtures/bpmn/draw/group.bpmn');
|
2020-04-29 09:02:42 +00:00
|
|
|
return bootstrapViewer(xml).call(this).then(function(result) {
|
|
|
|
|
|
|
|
checkErrors(result.error, result.warnings);
|
|
|
|
});
|
2014-04-25 11:31:18 +00:00
|
|
|
});
|
|
|
|
|
2014-05-09 13:20:29 +00:00
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
it('should render message marker', function() {
|
2015-03-31 12:17:15 +00:00
|
|
|
var xml = require('../../fixtures/bpmn/draw/message-marker.bpmn');
|
2020-04-29 09:02:42 +00:00
|
|
|
return bootstrapViewer(xml).call(this).then(function(result) {
|
|
|
|
|
|
|
|
checkErrors(result.error, result.warnings);
|
|
|
|
});
|
2014-05-27 15:48:04 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
2021-04-29 08:37:07 +00:00
|
|
|
it('should render message label', function() {
|
|
|
|
var xml = require('../../fixtures/bpmn/draw/message-label.bpmn');
|
|
|
|
return bootstrapViewer(xml).call(this).then(function(result) {
|
|
|
|
checkErrors(result.error, result.warnings);
|
|
|
|
inject(function(elementRegistry) {
|
|
|
|
|
|
|
|
var dataFlow = elementRegistry.getGraphics('dataFlow');
|
|
|
|
|
|
|
|
expect(domQuery('.djs-label', dataFlow)).to.exist;
|
|
|
|
})();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
it('should render pools', function() {
|
2015-03-31 12:17:15 +00:00
|
|
|
var xml = require('../../fixtures/bpmn/draw/pools.bpmn');
|
2020-04-29 09:02:42 +00:00
|
|
|
return bootstrapViewer(xml).call(this).then(function(result) {
|
|
|
|
|
|
|
|
checkErrors(result.error, result.warnings);
|
|
|
|
});
|
2014-05-02 06:25:08 +00:00
|
|
|
});
|
2014-05-09 13:20:29 +00:00
|
|
|
|
2014-05-27 15:48:04 +00:00
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
it('should render pool collection marker', function() {
|
2015-03-31 12:17:15 +00:00
|
|
|
var xml = require('../../fixtures/bpmn/draw/pools-with-collection-marker.bpmn');
|
2020-04-29 09:02:42 +00:00
|
|
|
return bootstrapViewer(xml).call(this).then(function(result) {
|
|
|
|
|
|
|
|
checkErrors(result.error, result.warnings);
|
|
|
|
});
|
2014-05-27 15:48:04 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
it('should render task types', function() {
|
2015-03-31 12:17:15 +00:00
|
|
|
var xml = require('../../fixtures/bpmn/draw/task-types.bpmn');
|
2020-04-29 09:02:42 +00:00
|
|
|
return bootstrapViewer(xml).call(this).then(function(result) {
|
|
|
|
|
|
|
|
checkErrors(result.error, result.warnings);
|
|
|
|
});
|
2014-05-27 15:48:04 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
it('should render text annotations', function() {
|
2015-03-31 12:17:15 +00:00
|
|
|
var xml = require('../../fixtures/bpmn/draw/text-annotation.bpmn');
|
2020-04-29 09:02:42 +00:00
|
|
|
return bootstrapViewer(xml).call(this).then(function(result) {
|
|
|
|
|
|
|
|
checkErrors(result.error, result.warnings);
|
|
|
|
});
|
2014-05-27 15:48:04 +00:00
|
|
|
});
|
|
|
|
|
2014-05-28 20:48:11 +00:00
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
it('should render flow markers', function() {
|
2015-03-31 12:17:15 +00:00
|
|
|
var xml = require('../../fixtures/bpmn/flow-markers.bpmn');
|
2020-04-29 09:02:42 +00:00
|
|
|
return bootstrapViewer(xml).call(this).then(function(result) {
|
|
|
|
|
|
|
|
checkErrors(result.error, result.warnings);
|
|
|
|
});
|
2014-05-28 20:48:11 +00:00
|
|
|
});
|
|
|
|
|
2015-12-23 11:59:14 +00:00
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
it('should render xor gateways blank and with X', function() {
|
2015-03-31 12:17:15 +00:00
|
|
|
var xml = require('../../fixtures/bpmn/draw/xor.bpmn');
|
2020-04-29 09:02:42 +00:00
|
|
|
return bootstrapViewer(xml).call(this).then(function(result) {
|
|
|
|
|
|
|
|
checkErrors(result.error, result.warnings);
|
|
|
|
});
|
2014-07-09 08:02:34 +00:00
|
|
|
});
|
|
|
|
|
2015-12-23 11:59:14 +00:00
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
it('should render boundary events with correct z-index', function() {
|
2015-03-31 12:17:15 +00:00
|
|
|
var xml = require('../../fixtures/bpmn/draw/boundary-event-z-index.bpmn');
|
2020-04-29 09:02:42 +00:00
|
|
|
return bootstrapViewer(xml).call(this).then(function(result) {
|
|
|
|
|
|
|
|
checkErrors(result.error, result.warnings);
|
|
|
|
});
|
2014-07-15 10:43:30 +00:00
|
|
|
});
|
|
|
|
|
2015-12-23 11:59:14 +00:00
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
it('should render boundary events without flowNodeRef', function() {
|
2016-06-07 06:46:45 +00:00
|
|
|
var xml = require('../../fixtures/bpmn/draw/boundary-event-without-refnode.bpmn');
|
2020-04-29 09:02:42 +00:00
|
|
|
return bootstrapViewer(xml).call(this).then(function(result) {
|
|
|
|
|
|
|
|
checkErrors(result.error, result.warnings);
|
|
|
|
});
|
2014-07-15 10:43:30 +00:00
|
|
|
});
|
|
|
|
|
2015-12-23 11:59:14 +00:00
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
it('should render boundary event only once if referenced incorrectly via flowNodeRef (robustness)', function() {
|
2015-03-31 12:17:15 +00:00
|
|
|
var xml = require('../../fixtures/bpmn/draw/boundary-event-with-refnode.bpmn');
|
2020-04-29 09:02:42 +00:00
|
|
|
return bootstrapViewer(xml).call(this).then(function(result) {
|
|
|
|
|
|
|
|
checkErrors(result.error, result.warnings);
|
|
|
|
});
|
2014-07-15 10:43:30 +00:00
|
|
|
});
|
|
|
|
|
2015-12-23 11:59:14 +00:00
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
it('should render gateway event if attribute is missing in XML', function() {
|
2015-03-31 12:17:15 +00:00
|
|
|
var xml = require('../../fixtures/bpmn/draw/gateway-type-default.bpmn');
|
2020-04-29 09:02:42 +00:00
|
|
|
return bootstrapViewer(xml).call(this).then(function(result) {
|
|
|
|
|
|
|
|
checkErrors(result.error, result.warnings);
|
|
|
|
});
|
2014-08-18 10:38:41 +00:00
|
|
|
});
|
|
|
|
|
2015-04-17 14:40:45 +00:00
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
it('should render call activity', function() {
|
2015-12-23 11:59:14 +00:00
|
|
|
var xml = require('../../fixtures/bpmn/draw/call-activity.bpmn');
|
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
return bootstrapViewer(xml).call(this).then(function(result) {
|
|
|
|
|
|
|
|
var err = result.error;
|
|
|
|
|
|
|
|
expect(err).not.to.exist;
|
2015-12-23 11:59:14 +00:00
|
|
|
|
|
|
|
inject(function(elementRegistry) {
|
|
|
|
|
|
|
|
var callActivityGfx = elementRegistry.getGraphics('CallActivity');
|
|
|
|
|
|
|
|
// make sure the + marker is shown
|
2016-09-14 06:18:56 +00:00
|
|
|
expect(domQuery('[data-marker=sub-process]', callActivityGfx)).to.exist;
|
2015-12-23 11:59:14 +00:00
|
|
|
})();
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
it('should render adhoc sub process', function() {
|
2015-12-23 11:59:14 +00:00
|
|
|
var xml = require('../../fixtures/bpmn/draw/activity-markers-simple.bpmn');
|
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
return bootstrapViewer(xml).call(this).then(function(result) {
|
|
|
|
|
|
|
|
var err = result.error;
|
|
|
|
|
|
|
|
expect(err).not.to.exist;
|
2015-12-23 11:59:14 +00:00
|
|
|
|
|
|
|
inject(function(elementRegistry) {
|
|
|
|
|
|
|
|
var callActivityGfx = elementRegistry.getGraphics('AdHocSubProcess');
|
|
|
|
|
|
|
|
// make sure the + marker is shown
|
2016-09-14 06:18:56 +00:00
|
|
|
expect(domQuery('[data-marker=adhoc]', callActivityGfx)).to.exist;
|
2015-12-23 11:59:14 +00:00
|
|
|
})();
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
it('should add random ID suffix to marker ID', function() {
|
2017-11-10 20:07:26 +00:00
|
|
|
|
2017-09-29 09:08:20 +00:00
|
|
|
var xml = require('../../fixtures/bpmn/simple.bpmn');
|
2020-04-29 09:02:42 +00:00
|
|
|
return bootstrapViewer(xml).call(this).then(function(result) {
|
|
|
|
|
|
|
|
var err = result.error;
|
|
|
|
|
|
|
|
expect(err).not.to.exist;
|
2017-09-29 09:08:20 +00:00
|
|
|
|
|
|
|
inject(function(canvas) {
|
|
|
|
var svg = canvas._svg;
|
|
|
|
var markers = svg.querySelectorAll('marker');
|
|
|
|
|
|
|
|
expect(markers[0].id).to.match(/^sequenceflow-end-white-black-[A-Za-z0-9]+$/);
|
|
|
|
})();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
it('should properly render colored markers', function() {
|
2019-04-16 09:34:54 +00:00
|
|
|
var xml = require('./BpmnRenderer.colors.bpmn');
|
2016-12-20 15:54:45 +00:00
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
return bootstrapViewer(xml).call(this).then(function(result) {
|
|
|
|
|
|
|
|
var err = result.error;
|
|
|
|
|
|
|
|
expect(err).not.to.exist;
|
|
|
|
|
2016-12-20 15:54:45 +00:00
|
|
|
inject(function(canvas) {
|
2019-11-07 12:52:47 +00:00
|
|
|
var svg = canvas._svg,
|
|
|
|
markers = svg.querySelectorAll('marker');
|
2016-12-20 15:54:45 +00:00
|
|
|
|
2019-04-10 19:59:25 +00:00
|
|
|
expect(markers).to.have.length(7);
|
2019-04-16 09:51:41 +00:00
|
|
|
expect(markers[0].id).to.match(/^sequenceflow-end-rgb_255_224_178_-rgb_251_140_0_-[A-Za-z0-9]{25}$/);
|
|
|
|
expect(markers[1].id).to.match(/^sequenceflow-end-yellow-blue-[A-Za-z0-9]{25}$/);
|
2021-05-25 14:07:59 +00:00
|
|
|
expect(markers[2].id).to.match(/^sequenceflow-end-white-_FB8C00-[A-Za-z0-9]{25}$/);
|
2019-11-07 12:52:47 +00:00
|
|
|
expect(markers[3].id).to.match(/^sequenceflow-end-white-rgba_255_0_0_0_9_-[A-Za-z0-9]{25}$/);
|
2019-04-16 09:51:41 +00:00
|
|
|
expect(markers[4].id).to.match(/^association-end-_FFE0B2-_FB8C00-[A-Za-z0-9]{25}$/);
|
|
|
|
expect(markers[5].id).to.match(/^messageflow-end-_FFE0B2-_FB8C00-[A-Za-z0-9]{25}$/);
|
|
|
|
expect(markers[6].id).to.match(/^messageflow-start-_FFE0B2-_FB8C00-[A-Za-z0-9]{25}$/);
|
|
|
|
})();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
it('should properly render connection markers (2)', function() {
|
2019-04-16 09:51:41 +00:00
|
|
|
var xml = require('./BpmnRenderer.connection-colors.bpmn');
|
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
return bootstrapViewer(xml).call(this).then(function(result) {
|
|
|
|
|
|
|
|
var err = result.error;
|
|
|
|
|
|
|
|
expect(err).not.to.exist;
|
|
|
|
|
2019-04-16 09:51:41 +00:00
|
|
|
inject(function(canvas) {
|
2019-11-07 12:52:47 +00:00
|
|
|
var svg = canvas._svg,
|
|
|
|
markers = svg.querySelectorAll('marker');
|
2019-04-16 09:51:41 +00:00
|
|
|
|
|
|
|
expect(markers).to.have.length(4);
|
|
|
|
expect(markers[0].id).to.match(/^association-end-rgb_23_100_344_-rgb_23_100_344_-[A-Za-z0-9]{25}$/);
|
|
|
|
expect(markers[1].id).to.match(/^association-end-_E1BEE7-_8E24AA-[A-Za-z0-9]{25}$/);
|
|
|
|
expect(markers[2].id).to.match(/^messageflow-end-rgb_23_100_344_-rgb_23_100_344_-[A-Za-z0-9]{25}$/);
|
|
|
|
expect(markers[3].id).to.match(/^messageflow-start-rgb_23_100_344_-rgb_23_100_344_-[A-Za-z0-9]{25}$/);
|
2016-12-20 15:54:45 +00:00
|
|
|
})();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
it('should render sequenceFlows without source', function() {
|
2017-12-16 23:06:01 +00:00
|
|
|
|
2019-04-16 09:34:54 +00:00
|
|
|
var xml = require('./BpmnRenderer.sequenceFlow-no-source.bpmn');
|
2020-04-29 09:02:42 +00:00
|
|
|
return bootstrapModeler(xml, {
|
2017-12-16 23:06:01 +00:00
|
|
|
modules: [
|
|
|
|
coreModule,
|
|
|
|
rendererModule,
|
|
|
|
modelingModule
|
|
|
|
]
|
2020-04-29 09:02:42 +00:00
|
|
|
}).call(this).then(function(result) {
|
|
|
|
|
|
|
|
var err = result.error;
|
|
|
|
|
|
|
|
expect(err).not.to.exist;
|
2017-12-16 23:06:01 +00:00
|
|
|
|
|
|
|
inject(function(elementFactory, graphicsFactory) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var g = svgCreate('g');
|
|
|
|
|
|
|
|
var connection = elementFactory.create('connection', {
|
|
|
|
type: 'bpmn:SequenceFlow',
|
|
|
|
waypoints: [
|
|
|
|
{ x: 0, y: 0 },
|
|
|
|
{ x: 10, y: 100 }
|
|
|
|
]
|
|
|
|
});
|
|
|
|
|
|
|
|
var gfx = graphicsFactory.drawConnection(g, connection);
|
|
|
|
|
|
|
|
expect(gfx).to.exist;
|
|
|
|
})();
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2018-05-23 12:27:32 +00:00
|
|
|
describe('colors', function() {
|
|
|
|
|
2019-04-16 09:34:54 +00:00
|
|
|
var xml = require('./BpmnRenderer.colors.bpmn');
|
2018-05-23 12:27:32 +00:00
|
|
|
|
2019-11-25 14:05:04 +00:00
|
|
|
var groupXML = require('./BpmnRenderer.group-colors.bpmn');
|
2018-05-23 12:27:32 +00:00
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
it('should render colors without warnings and errors', function() {
|
|
|
|
return bootstrapViewer(xml).call(this).then(function(result) {
|
|
|
|
|
|
|
|
checkErrors(result.error, result.warnings);
|
|
|
|
});
|
2018-05-23 12:27:32 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
it('should render group colors', function() {
|
|
|
|
return bootstrapViewer(groupXML).call(this).then(function(result) {
|
|
|
|
|
|
|
|
checkErrors(result.error, result.warnings);
|
|
|
|
});
|
2019-11-25 14:05:04 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
2018-05-23 12:27:32 +00:00
|
|
|
describe('default colors', function() {
|
|
|
|
|
|
|
|
var defaultFillColor = 'red',
|
2021-05-25 14:07:59 +00:00
|
|
|
defaultStrokeColor = 'lime',
|
|
|
|
defaultLabelColor = 'blue';
|
2018-05-23 12:27:32 +00:00
|
|
|
|
2019-11-07 12:52:47 +00:00
|
|
|
// TODO(philippfromme): remove once we drop PhantomJS
|
2019-04-16 09:51:41 +00:00
|
|
|
function expectedColors(color) {
|
|
|
|
|
|
|
|
var conversionValues = {
|
|
|
|
blue: '#0000ff',
|
|
|
|
lime: '#00ff00',
|
|
|
|
red: '#ff0000',
|
|
|
|
yellow: '#ffff00',
|
|
|
|
'rgb(251, 140, 0)': '#fb8c00',
|
2019-04-18 14:31:49 +00:00
|
|
|
'#FB8C00': 'rgb(251, 140, 0)',
|
2019-04-16 09:51:41 +00:00
|
|
|
'#3399aa': 'rgb(51, 153, 170)'
|
|
|
|
};
|
|
|
|
|
|
|
|
return [
|
|
|
|
color,
|
|
|
|
color.toLowerCase(),
|
|
|
|
color.toUpperCase(),
|
|
|
|
conversionValues[ color ],
|
|
|
|
conversionValues[ color ] && conversionValues[ color ].toLowerCase(),
|
|
|
|
conversionValues[ color ] && conversionValues[ color ].toUpperCase()
|
|
|
|
];
|
|
|
|
}
|
2018-05-23 12:27:32 +00:00
|
|
|
|
|
|
|
beforeEach(bootstrapViewer(xml,{
|
2018-05-24 13:02:02 +00:00
|
|
|
bpmnRenderer: {
|
2018-05-23 12:27:32 +00:00
|
|
|
defaultFillColor: defaultFillColor,
|
2021-05-25 14:07:59 +00:00
|
|
|
defaultStrokeColor: defaultStrokeColor,
|
|
|
|
defaultLabelColor: defaultLabelColor
|
2018-05-23 12:27:32 +00:00
|
|
|
}
|
|
|
|
}));
|
|
|
|
|
2019-11-07 12:52:47 +00:00
|
|
|
// TODO(philippfromme): remove once we drop PhantomJS
|
|
|
|
/**
|
|
|
|
* Ensure alpha channel of RGB (rgba) color has one decimal point.
|
|
|
|
*
|
|
|
|
* @param {string} color
|
|
|
|
*
|
|
|
|
* @return {string}
|
|
|
|
*/
|
|
|
|
function fixRgba(color) {
|
|
|
|
if (color.indexOf('rgba') !== -1) {
|
|
|
|
return [
|
|
|
|
'rgba(',
|
|
|
|
color
|
|
|
|
.replace(/rgba\(|\)/g, '')
|
|
|
|
.split(',')
|
|
|
|
.map(function(string) {
|
|
|
|
if (string.indexOf('.') !== -1) {
|
|
|
|
return parseFloat(string).toFixed(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
return parseInt(string);
|
|
|
|
})
|
|
|
|
.join(', '),
|
|
|
|
')'
|
|
|
|
].join('');
|
|
|
|
}
|
|
|
|
|
|
|
|
return color;
|
|
|
|
}
|
|
|
|
|
2018-05-23 12:27:32 +00:00
|
|
|
function expectFillColor(element, color) {
|
2019-11-07 12:52:47 +00:00
|
|
|
expect(expectedColors(color)).to.include(fixRgba(element.style.fill));
|
2018-05-23 12:27:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function expectStrokeColor(element, color) {
|
2019-11-07 12:52:47 +00:00
|
|
|
expect(expectedColors(color)).to.include(fixRgba(element.style.stroke));
|
2018-05-23 12:27:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Expect colors depending on element type.
|
|
|
|
*
|
|
|
|
* @param {djs.model.base} element - Element.
|
|
|
|
* @param {SVG} gfx - Graphics of element.
|
2020-04-03 13:51:45 +00:00
|
|
|
* @param {string} fillColor - Fill color to expect.
|
|
|
|
* @param {string} strokeColor - Stroke color to expect.
|
2018-05-23 12:27:32 +00:00
|
|
|
*/
|
2021-05-25 14:07:59 +00:00
|
|
|
function expectColors(element, gfx, fillColor, strokeColor, labelColor) {
|
2018-05-23 12:27:32 +00:00
|
|
|
var djsVisual = domQuery('.djs-visual', gfx);
|
|
|
|
|
|
|
|
var circle, path, polygon, polyline, rect, text;
|
|
|
|
|
|
|
|
if (element.labelTarget) {
|
|
|
|
text = domQuery('text', djsVisual);
|
|
|
|
|
2021-05-25 14:07:59 +00:00
|
|
|
expectFillColor(text, labelColor);
|
2018-05-23 12:27:32 +00:00
|
|
|
} else if (element.waypoints) {
|
|
|
|
path = domQuery('path', djsVisual);
|
|
|
|
polyline = domQuery('polyline', djsVisual);
|
|
|
|
|
|
|
|
expectStrokeColor(path || polyline, strokeColor);
|
|
|
|
} else if (isAny(element, [ 'bpmn:StartEvent', 'bpmn:EndEvent' ])) {
|
|
|
|
circle = domQuery('circle', djsVisual);
|
|
|
|
|
|
|
|
expectFillColor(circle, fillColor);
|
|
|
|
expectStrokeColor(circle, strokeColor);
|
2021-05-25 14:07:59 +00:00
|
|
|
} else if (isAny(element, [ 'bpmn:Task', 'bpmn:SubProcess', 'bpmn:Participant' ])) {
|
2018-05-23 12:27:32 +00:00
|
|
|
rect = domQuery('rect', djsVisual);
|
|
|
|
text = domQuery('text', djsVisual);
|
|
|
|
|
|
|
|
expectFillColor(rect, fillColor);
|
|
|
|
expectStrokeColor(rect, strokeColor);
|
2021-05-25 14:07:59 +00:00
|
|
|
expectFillColor(text, labelColor);
|
2018-05-23 12:27:32 +00:00
|
|
|
} else if (isAny(element, [ 'bpmn:Gateway' ])) {
|
|
|
|
polygon = domQuery('polygon', djsVisual);
|
|
|
|
|
|
|
|
expectFillColor(polygon, fillColor);
|
|
|
|
expectStrokeColor(polygon, strokeColor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
it('should render default colors without overriding', inject(function(canvas, elementRegistry) {
|
|
|
|
var rootElement = canvas.getRootElement();
|
|
|
|
|
2019-11-07 12:52:47 +00:00
|
|
|
elementRegistry.forEach(function(element) {
|
|
|
|
if (element === rootElement) {
|
2018-05-23 12:27:32 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-11-07 12:52:47 +00:00
|
|
|
var gfx = elementRegistry.getGraphics(element),
|
|
|
|
di = getDi(element),
|
2021-05-25 14:07:59 +00:00
|
|
|
fillColor = di.get('color:background-color') || di.get('bioc:fill') || defaultFillColor,
|
|
|
|
strokeColor = di.get('color:border-color') || di.get('bioc:stroke') || defaultStrokeColor,
|
|
|
|
labelDi = di.get('label'),
|
|
|
|
labelColor = labelDi && labelDi.get('color:color') || defaultLabelColor;
|
2018-05-23 12:27:32 +00:00
|
|
|
|
2021-05-25 14:07:59 +00:00
|
|
|
expectColors(element, gfx, fillColor, strokeColor, labelColor);
|
2018-05-23 12:27:32 +00:00
|
|
|
});
|
|
|
|
}));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
describe('path', function() {
|
2015-10-09 23:36:35 +00:00
|
|
|
|
2017-12-12 22:39:09 +00:00
|
|
|
var diagramXML = require('./BpmnRenderer.simple-cropping.bpmn');
|
2015-04-17 14:40:45 +00:00
|
|
|
|
2015-10-09 23:36:35 +00:00
|
|
|
var testModules = [ coreModule, rendererModule ];
|
2015-04-17 14:40:45 +00:00
|
|
|
|
2015-10-09 23:36:35 +00:00
|
|
|
beforeEach(bootstrapModeler(diagramXML, { modules: testModules }));
|
2015-04-17 14:40:45 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
describe('circle', function() {
|
2015-04-17 14:40:45 +00:00
|
|
|
|
2015-10-09 23:36:35 +00:00
|
|
|
it('should return a circle path', inject(function(canvas, elementRegistry, graphicsFactory) {
|
2015-04-17 14:40:45 +00:00
|
|
|
|
2015-10-09 23:36:35 +00:00
|
|
|
// given
|
|
|
|
var eventElement = elementRegistry.get('StartEvent_1');
|
2015-04-17 14:40:45 +00:00
|
|
|
|
2015-10-09 23:36:35 +00:00
|
|
|
// when
|
|
|
|
var startPath = graphicsFactory.getShapePath(eventElement);
|
2015-04-17 14:40:45 +00:00
|
|
|
|
2015-10-09 23:36:35 +00:00
|
|
|
// then
|
|
|
|
expect(startPath).to.equal('M247,343m0,-18a18,18,0,1,1,0,36a18,18,0,1,1,0,-36z');
|
|
|
|
}));
|
2015-04-17 14:40:45 +00:00
|
|
|
|
|
|
|
|
2015-10-09 23:36:35 +00:00
|
|
|
it('should return a diamond path', inject(function(canvas, elementRegistry, graphicsFactory) {
|
2015-04-17 14:40:45 +00:00
|
|
|
|
2015-10-09 23:36:35 +00:00
|
|
|
// given
|
|
|
|
var gatewayElement = elementRegistry.get('ExclusiveGateway_1');
|
2015-04-17 14:40:45 +00:00
|
|
|
|
2015-10-09 23:36:35 +00:00
|
|
|
// when
|
|
|
|
var gatewayPath = graphicsFactory.getShapePath(gatewayElement);
|
2015-04-17 14:40:45 +00:00
|
|
|
|
2015-10-09 23:36:35 +00:00
|
|
|
// then
|
|
|
|
expect(gatewayPath).to.equal('M418,318l25,25l-25,25l-25,-25z');
|
|
|
|
}));
|
2015-07-15 15:22:19 +00:00
|
|
|
|
2015-04-17 14:40:45 +00:00
|
|
|
|
2015-10-09 23:36:35 +00:00
|
|
|
it('should return a rounded rectangular path', inject(function(canvas, elementRegistry, graphicsFactory) {
|
2015-04-17 14:40:45 +00:00
|
|
|
|
2015-10-09 23:36:35 +00:00
|
|
|
// given
|
|
|
|
var subProcessElement = elementRegistry.get('SubProcess_1');
|
2015-04-17 14:40:45 +00:00
|
|
|
|
2015-10-09 23:36:35 +00:00
|
|
|
// when
|
|
|
|
var subProcessPath = graphicsFactory.getShapePath(subProcessElement);
|
2015-04-17 14:40:45 +00:00
|
|
|
|
2015-10-09 23:36:35 +00:00
|
|
|
// then
|
|
|
|
expect(subProcessPath).to.equal('M584,243l330,0a10,10,0,0,1,10,10l0,180a10,10,0,0,1,-10,10' +
|
|
|
|
'l-330,0a10,10,0,0,1,-10,-10l0,-180a10,10,0,0,1,10,-10z');
|
|
|
|
}));
|
2015-04-17 14:40:45 +00:00
|
|
|
|
|
|
|
|
2015-10-09 23:36:35 +00:00
|
|
|
it('should return a rectangular path', inject(function(canvas, elementRegistry, graphicsFactory) {
|
2015-04-17 14:40:45 +00:00
|
|
|
|
2015-10-09 23:36:35 +00:00
|
|
|
// given
|
|
|
|
var TextAnnotationElement = elementRegistry.get('TextAnnotation_1');
|
2015-04-17 14:40:45 +00:00
|
|
|
|
2015-10-09 23:36:35 +00:00
|
|
|
// when
|
|
|
|
var TextAnnotationPath = graphicsFactory.getShapePath(TextAnnotationElement);
|
2015-04-17 14:40:45 +00:00
|
|
|
|
2015-10-09 23:36:35 +00:00
|
|
|
// then
|
2016-12-01 12:17:44 +00:00
|
|
|
expect(TextAnnotationPath).to.equal('M368,156l100,0l0,80l-100,0z');
|
2015-10-09 23:36:35 +00:00
|
|
|
}));
|
2015-04-17 14:40:45 +00:00
|
|
|
|
2015-10-09 23:36:35 +00:00
|
|
|
});
|
2015-04-17 14:40:45 +00:00
|
|
|
|
|
|
|
});
|
|
|
|
|
2017-11-10 20:07:26 +00:00
|
|
|
|
|
|
|
describe('extension API', function() {
|
|
|
|
|
|
|
|
var diagramXML = require('../../fixtures/bpmn/simple.bpmn');
|
|
|
|
|
|
|
|
beforeEach(bootstrapModeler(diagramXML, {
|
|
|
|
modules: [
|
|
|
|
coreModule,
|
|
|
|
rendererModule
|
|
|
|
]
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('should expose helpers', inject(function(bpmnRenderer) {
|
|
|
|
|
|
|
|
// then
|
2022-01-25 11:38:50 +00:00
|
|
|
|
|
|
|
// unsafe to use render APIs
|
2017-11-10 20:07:26 +00:00
|
|
|
expect(bpmnRenderer._drawPath).to.be.a('function');
|
2022-01-25 11:38:50 +00:00
|
|
|
expect(bpmnRenderer._renderer).to.be.a('function');
|
2017-11-10 20:07:26 +00:00
|
|
|
|
2022-01-25 11:38:50 +00:00
|
|
|
// very unsafe to use internal state
|
|
|
|
expect(bpmnRenderer.handlers).to.exist;
|
2017-11-10 20:07:26 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2015-04-17 14:40:45 +00:00
|
|
|
});
|