2018-04-02 19:01:53 +00:00
|
|
|
import {
|
|
|
|
bootstrapModeler,
|
|
|
|
inject
|
|
|
|
} from 'test/TestHelper';
|
2016-08-18 07:08:00 +00:00
|
|
|
|
2018-03-14 20:43:53 +00:00
|
|
|
var pick = require('min-dash').pick;
|
2016-08-18 07:08:00 +00:00
|
|
|
|
|
|
|
var getBBox = require('diagram-js/lib/util/Elements').getBBox;
|
|
|
|
|
2017-01-09 13:30:39 +00:00
|
|
|
var getParent = require('lib/features/modeling/util/ModelingUtil').getParent;
|
|
|
|
|
2016-08-18 07:08:00 +00:00
|
|
|
|
2018-04-02 19:01:53 +00:00
|
|
|
import bpmnEditorActionsModule from 'lib/features/editor-actions';
|
|
|
|
import modelingModule from 'lib/features/modeling';
|
|
|
|
import coreModule from 'lib/core';
|
2016-08-18 07:08:00 +00:00
|
|
|
|
2018-04-02 19:01:53 +00:00
|
|
|
var basicXML = require('../../../fixtures/bpmn/nested-subprocesses.bpmn');
|
|
|
|
var collaborationXML = require('../../../fixtures/bpmn/collaboration.bpmn');
|
2016-08-18 07:08:00 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
describe('features/editor-actions', function() {
|
|
|
|
|
|
|
|
describe('#moveToOrigin', function() {
|
|
|
|
|
|
|
|
function testMoveToOrigin(xml) {
|
|
|
|
|
|
|
|
return function() {
|
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
beforeEach(bootstrapModeler(xml, {
|
|
|
|
modules: [
|
|
|
|
bpmnEditorActionsModule,
|
|
|
|
modelingModule,
|
|
|
|
coreModule
|
|
|
|
]
|
|
|
|
}));
|
|
|
|
|
2016-08-18 07:08:00 +00:00
|
|
|
|
|
|
|
it('should move to origin', inject(function(editorActions) {
|
2019-08-19 08:39:20 +00:00
|
|
|
|
2016-08-18 07:08:00 +00:00
|
|
|
// given
|
|
|
|
var elements = editorActions.trigger('selectElements'),
|
|
|
|
boundingBox;
|
|
|
|
|
|
|
|
// when
|
|
|
|
editorActions.trigger('moveToOrigin');
|
|
|
|
|
|
|
|
boundingBox = getBBox(elements);
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(pick(boundingBox, [ 'x', 'y' ])).to.eql({ x: 0, y: 0 });
|
|
|
|
}));
|
2018-01-24 19:25:28 +00:00
|
|
|
|
2016-08-18 07:08:00 +00:00
|
|
|
};
|
2018-01-24 19:25:28 +00:00
|
|
|
|
2016-08-18 07:08:00 +00:00
|
|
|
}
|
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
|
2016-08-18 07:08:00 +00:00
|
|
|
describe('single process', testMoveToOrigin(basicXML));
|
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
|
2016-08-18 07:08:00 +00:00
|
|
|
describe('collaboration', testMoveToOrigin(collaborationXML));
|
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
|
2017-01-09 13:30:39 +00:00
|
|
|
describe('subprocesses', function() {
|
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
beforeEach(bootstrapModeler(basicXML, {
|
|
|
|
modules: [
|
|
|
|
bpmnEditorActionsModule,
|
|
|
|
modelingModule,
|
|
|
|
coreModule
|
|
|
|
]
|
|
|
|
}));
|
2017-01-09 13:30:39 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
it('should ignore children of subprocesses', inject(
|
|
|
|
function(editorActions, elementRegistry) {
|
2019-08-19 08:39:20 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
// given
|
|
|
|
var startEvent = elementRegistry.get('StartEvent_3'),
|
|
|
|
startEventParent = getParent(startEvent);
|
2017-01-09 13:30:39 +00:00
|
|
|
|
2018-01-24 19:25:28 +00:00
|
|
|
// when
|
|
|
|
editorActions.trigger('moveToOrigin');
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(getParent(startEvent)).to.equal(startEventParent);
|
|
|
|
}
|
|
|
|
));
|
2017-01-09 13:30:39 +00:00
|
|
|
|
|
|
|
});
|
|
|
|
|
2016-08-18 07:08:00 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
});
|