2018-04-02 19:01:53 +00:00
|
|
|
import {
|
|
|
|
bootstrapModeler,
|
|
|
|
inject
|
|
|
|
} from 'test/TestHelper';
|
2014-10-27 11:07:57 +00:00
|
|
|
|
2018-04-02 19:01:53 +00:00
|
|
|
import modelingModule from 'lib/features/modeling';
|
|
|
|
import coreModule from 'lib/core';
|
2014-10-27 11:07:57 +00:00
|
|
|
|
|
|
|
|
2014-11-21 08:19:35 +00:00
|
|
|
describe('features/move - drop', function() {
|
2014-10-27 11:07:57 +00:00
|
|
|
|
2015-03-31 12:17:15 +00:00
|
|
|
var diagramXML = require('../../../fixtures/bpmn/features/drop/drop.bpmn');
|
|
|
|
var diagramXML2 = require('../../../fixtures/bpmn/features/drop/recursive-task.bpmn');
|
2014-10-27 11:07:57 +00:00
|
|
|
|
2014-11-21 08:19:35 +00:00
|
|
|
var testModules = [ coreModule, modelingModule ];
|
2014-10-27 11:07:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
describe('elements', function() {
|
|
|
|
|
|
|
|
beforeEach(bootstrapModeler(diagramXML, { modules: testModules }));
|
|
|
|
|
2014-11-21 08:19:35 +00:00
|
|
|
it('should update parent', inject(function(elementRegistry, modeling) {
|
2014-10-27 11:07:57 +00:00
|
|
|
|
|
|
|
// given
|
|
|
|
var task_1 = elementRegistry.get('ID_Task_1'),
|
|
|
|
parent = elementRegistry.get('ID_SubProcess_1');
|
|
|
|
|
|
|
|
// when
|
|
|
|
modeling.moveShape(task_1, { x: 0, y: 200 }, parent);
|
|
|
|
|
|
|
|
// then
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(task_1.parent).to.eql(parent);
|
|
|
|
expect(task_1.businessObject.$parent).to.eql(parent.businessObject);
|
2014-10-27 11:07:57 +00:00
|
|
|
}));
|
|
|
|
|
2014-11-21 08:19:35 +00:00
|
|
|
|
|
|
|
it('should update parents', inject(function(elementRegistry, modeling) {
|
2014-10-27 11:07:57 +00:00
|
|
|
|
|
|
|
// given
|
2014-11-21 08:19:35 +00:00
|
|
|
var task_1 = elementRegistry.get('ID_Task_1'),
|
2014-10-27 11:07:57 +00:00
|
|
|
task_2 = elementRegistry.get('ID_Task_2'),
|
2014-11-21 08:19:35 +00:00
|
|
|
parent = elementRegistry.get('ID_SubProcess_1');
|
2014-10-27 11:07:57 +00:00
|
|
|
|
|
|
|
// when
|
2015-08-13 08:51:52 +00:00
|
|
|
modeling.moveElements([ task_1, task_2 ], { x: 0, y: 200 }, parent);
|
2014-10-27 11:07:57 +00:00
|
|
|
|
|
|
|
// then
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(task_1.parent).to.eql(parent);
|
|
|
|
expect(task_1.businessObject.$parent).to.eql(parent.businessObject);
|
|
|
|
expect(task_2.parent).to.eql(parent);
|
|
|
|
expect(task_2.businessObject.$parent).to.eql(parent.businessObject);
|
2014-10-27 11:07:57 +00:00
|
|
|
}));
|
|
|
|
|
2014-11-21 08:19:35 +00:00
|
|
|
});
|
2014-10-27 11:07:57 +00:00
|
|
|
|
|
|
|
|
2014-11-21 08:19:35 +00:00
|
|
|
describe('connection handling', function() {
|
2014-10-27 11:07:57 +00:00
|
|
|
|
|
|
|
beforeEach(bootstrapModeler(diagramXML, { modules: testModules }));
|
|
|
|
|
|
|
|
|
2018-01-05 13:32:52 +00:00
|
|
|
it('should remove flow if target and source have different parents', inject(
|
|
|
|
function(elementRegistry, modeling) {
|
2014-10-27 11:07:57 +00:00
|
|
|
|
2018-01-05 13:32:52 +00:00
|
|
|
// given
|
|
|
|
var task_1 = elementRegistry.get('ID_Task_1'),
|
|
|
|
parent = elementRegistry.get('ID_SubProcess_1'),
|
2018-02-27 09:08:31 +00:00
|
|
|
flow = elementRegistry.get('ID_Sequenceflow_1');
|
2014-10-27 11:07:57 +00:00
|
|
|
|
2018-01-05 13:32:52 +00:00
|
|
|
// when
|
|
|
|
modeling.moveElements([ task_1 ], { x: 0, y: 200 }, parent);
|
2014-10-27 11:07:57 +00:00
|
|
|
|
2018-01-05 13:32:52 +00:00
|
|
|
// then
|
|
|
|
expect(flow.parent).to.be.null;
|
|
|
|
expect(flow.businessObject.$parent).to.be.null;
|
|
|
|
}
|
|
|
|
));
|
2014-10-27 11:07:57 +00:00
|
|
|
|
|
|
|
|
2018-01-05 13:32:52 +00:00
|
|
|
it('should update flow parent if target and source have same parents', inject(
|
|
|
|
function(elementRegistry, modeling) {
|
2014-10-27 11:07:57 +00:00
|
|
|
|
2018-01-05 13:32:52 +00:00
|
|
|
// given
|
|
|
|
var task_1 = elementRegistry.get('ID_Task_1'),
|
|
|
|
task_2 = elementRegistry.get('ID_Task_2'),
|
|
|
|
parent = elementRegistry.get('ID_SubProcess_1'),
|
2018-02-27 09:08:31 +00:00
|
|
|
flow = elementRegistry.get('ID_Sequenceflow_1');
|
2014-10-27 11:07:57 +00:00
|
|
|
|
2018-01-05 13:32:52 +00:00
|
|
|
// when
|
|
|
|
modeling.moveElements([ task_1, task_2 ], { x: 0, y: 250 }, parent);
|
2014-10-27 11:07:57 +00:00
|
|
|
|
2018-01-05 13:32:52 +00:00
|
|
|
// then
|
|
|
|
expect(flow.parent).to.eql(parent);
|
|
|
|
expect(flow.businessObject.$parent).to.eql(parent.businessObject);
|
|
|
|
}
|
|
|
|
));
|
2014-11-21 08:19:35 +00:00
|
|
|
|
2014-10-27 11:07:57 +00:00
|
|
|
});
|
|
|
|
|
2014-11-21 08:19:35 +00:00
|
|
|
|
2014-10-27 11:07:57 +00:00
|
|
|
describe('recursion', function() {
|
|
|
|
|
|
|
|
beforeEach(bootstrapModeler(diagramXML2, { modules: testModules }));
|
|
|
|
|
2014-11-21 08:19:35 +00:00
|
|
|
it('should update parent', inject(function(elementRegistry, modeling) {
|
2014-10-27 11:07:57 +00:00
|
|
|
|
|
|
|
// given
|
|
|
|
var task_1 = elementRegistry.get('ID_task_1'),
|
|
|
|
parent = elementRegistry.get('ID_subprocess_1'),
|
|
|
|
sequenceFlow = elementRegistry.get('ID_sequenceflow_1');
|
|
|
|
|
|
|
|
// when
|
2015-08-13 08:51:52 +00:00
|
|
|
modeling.moveElements([ task_1 ], { x: 0, y: 200 }, parent);
|
2014-10-27 11:07:57 +00:00
|
|
|
|
|
|
|
// then
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(task_1.parent).to.eql(parent);
|
|
|
|
expect(task_1.businessObject.$parent).to.eql(parent.businessObject);
|
2014-10-27 11:07:57 +00:00
|
|
|
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(sequenceFlow.parent).to.eql(parent);
|
|
|
|
expect(sequenceFlow.businessObject.$parent).to.eql(parent.businessObject);
|
2014-10-27 11:07:57 +00:00
|
|
|
}));
|
2014-11-21 08:19:35 +00:00
|
|
|
|
2014-10-27 11:07:57 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
});
|