2018-04-02 19:01:53 +00:00
|
|
|
import {
|
|
|
|
bootstrapModeler,
|
2019-08-06 16:57:30 +00:00
|
|
|
getBpmnJS,
|
2018-04-02 19:01:53 +00:00
|
|
|
inject
|
|
|
|
} from 'test/TestHelper';
|
|
|
|
|
2019-08-06 16:57:30 +00:00
|
|
|
import coreModule from 'lib/core';
|
|
|
|
import createModule from 'diagram-js/lib/features/create';
|
2018-04-02 19:01:53 +00:00
|
|
|
import modelingModule from 'lib/features/modeling';
|
|
|
|
import paletteModule from 'lib/features/palette';
|
2019-08-06 16:57:30 +00:00
|
|
|
|
|
|
|
import { createMoveEvent } from 'diagram-js/lib/features/mouse/Mouse';
|
|
|
|
|
|
|
|
import { is } from 'lib/util/ModelUtil';
|
2018-04-02 19:01:53 +00:00
|
|
|
|
2019-08-08 12:13:56 +00:00
|
|
|
import {
|
|
|
|
createCanvasEvent as canvasEvent
|
|
|
|
} from '../../../util/MockEvents';
|
|
|
|
|
2018-04-02 19:01:53 +00:00
|
|
|
import {
|
|
|
|
query as domQuery,
|
|
|
|
queryAll as domQueryAll
|
|
|
|
} from 'min-dom';
|
2014-11-17 10:01:07 +00:00
|
|
|
|
|
|
|
|
2015-06-17 10:03:37 +00:00
|
|
|
describe('features/palette', function() {
|
2014-11-17 10:01:07 +00:00
|
|
|
|
2015-06-17 10:03:37 +00:00
|
|
|
var diagramXML = require('../../../fixtures/bpmn/features/replace/01_replace.bpmn');
|
2014-11-17 10:01:07 +00:00
|
|
|
|
2019-08-06 16:57:30 +00:00
|
|
|
var testModules = [
|
|
|
|
coreModule,
|
|
|
|
createModule,
|
|
|
|
modelingModule,
|
|
|
|
paletteModule
|
|
|
|
];
|
2014-11-17 10:01:07 +00:00
|
|
|
|
2015-06-17 10:03:37 +00:00
|
|
|
beforeEach(bootstrapModeler(diagramXML, { modules: testModules }));
|
2014-11-17 10:01:07 +00:00
|
|
|
|
|
|
|
|
2019-08-06 16:57:30 +00:00
|
|
|
it('should provide BPMN modeling palette', inject(function(canvas) {
|
2014-11-17 10:01:07 +00:00
|
|
|
|
2015-06-17 10:03:37 +00:00
|
|
|
// when
|
|
|
|
var paletteElement = domQuery('.djs-palette', canvas._container);
|
2018-03-21 23:54:59 +00:00
|
|
|
var entries = domQueryAll('.entry', paletteElement);
|
2014-11-17 10:01:07 +00:00
|
|
|
|
2015-06-17 10:03:37 +00:00
|
|
|
// then
|
2019-05-08 09:09:06 +00:00
|
|
|
expect(entries.length).to.equal(14);
|
2015-06-17 10:03:37 +00:00
|
|
|
}));
|
2014-11-17 10:01:07 +00:00
|
|
|
|
2019-08-06 16:57:30 +00:00
|
|
|
|
|
|
|
describe('sub process', function() {
|
|
|
|
|
2019-08-08 12:13:56 +00:00
|
|
|
it('should create sub process with start event', inject(function(dragging) {
|
2019-08-06 16:57:30 +00:00
|
|
|
|
|
|
|
// when
|
|
|
|
triggerPaletteEntry('create.subprocess-expanded');
|
|
|
|
|
|
|
|
// then
|
|
|
|
var context = dragging.context(),
|
|
|
|
elements = context.data.elements;
|
|
|
|
|
|
|
|
expect(elements).to.have.length(2);
|
|
|
|
expect(is(elements[0], 'bpmn:SubProcess')).to.be.true;
|
|
|
|
expect(is(elements[1], 'bpmn:StartEvent')).to.be.true;
|
|
|
|
}));
|
|
|
|
|
2019-08-08 12:13:56 +00:00
|
|
|
|
|
|
|
it('should select start event', inject(function(canvas, dragging, selection) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var rootElement = canvas.getRootElement(),
|
|
|
|
rootGfx = canvas.getGraphics(rootElement);
|
|
|
|
|
|
|
|
triggerPaletteEntry('create.subprocess-expanded');
|
|
|
|
|
|
|
|
// when
|
|
|
|
dragging.hover({ element: rootElement, gfx: rootGfx });
|
|
|
|
|
|
|
|
dragging.move(canvasEvent({ x: 100, y: 100 }));
|
|
|
|
|
|
|
|
// when
|
|
|
|
dragging.end();
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(selection.get()).to.have.length(1);
|
|
|
|
expect(is(selection.get()[0], 'bpmn:StartEvent')).to.be.true;
|
|
|
|
}));
|
|
|
|
|
2019-08-06 16:57:30 +00:00
|
|
|
});
|
|
|
|
|
2014-11-17 10:01:07 +00:00
|
|
|
});
|
2019-08-06 16:57:30 +00:00
|
|
|
|
|
|
|
// helpers //////////
|
|
|
|
|
|
|
|
function triggerPaletteEntry(id) {
|
|
|
|
getBpmnJS().invoke(function(palette) {
|
|
|
|
var entry = palette.getEntries()[ id ];
|
|
|
|
|
|
|
|
if (entry && entry.action && entry.action.click) {
|
|
|
|
entry.action.click(createMoveEvent(0, 0));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|