2014-10-27 11:07:57 +00:00
|
|
|
'use strict';
|
|
|
|
|
2015-01-14 17:48:06 +00:00
|
|
|
var TestHelper = require('../../../TestHelper');
|
2014-10-27 11:07:57 +00:00
|
|
|
|
|
|
|
/* global bootstrapModeler, inject */
|
|
|
|
|
|
|
|
var modelingModule = require('../../../../lib/features/modeling'),
|
|
|
|
coreModule = require('../../../../lib/core');
|
|
|
|
|
|
|
|
|
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
|
|
|
|
expect(task_1.parent).toBe(parent);
|
|
|
|
expect(task_1.businessObject.$parent).toBe(parent.businessObject);
|
|
|
|
}));
|
|
|
|
|
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
|
|
|
|
modeling.moveShapes([ task_1, task_2 ], { x: 0, y: 200 }, parent);
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(task_1.parent).toBe(parent);
|
|
|
|
expect(task_1.businessObject.$parent).toBe(parent.businessObject);
|
|
|
|
expect(task_2.parent).toBe(parent);
|
|
|
|
expect(task_2.businessObject.$parent).toBe(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
|
|
|
describe('connection handling', function() {
|
2014-10-27 11:07:57 +00:00
|
|
|
|
|
|
|
beforeEach(bootstrapModeler(diagramXML, { modules: testModules }));
|
|
|
|
|
|
|
|
|
|
|
|
it('should remove flow if target and source have different parents',
|
2014-11-21 08:19:35 +00:00
|
|
|
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'),
|
|
|
|
flow = elementRegistry.get('ID_Sequenceflow_1');
|
|
|
|
|
|
|
|
// when
|
2014-11-21 08:19:35 +00:00
|
|
|
modeling.moveShapes([ task_1 ], { x: 0, y: 200 }, parent);
|
2014-10-27 11:07:57 +00:00
|
|
|
|
|
|
|
// then
|
|
|
|
expect(flow.parent).toBe(null);
|
|
|
|
expect(flow.businessObject.$parent).toBe(null);
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
2014-11-21 08:19:35 +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
|
|
|
|
|
|
|
// given
|
|
|
|
var task_1 = elementRegistry.get('ID_Task_1'),
|
|
|
|
task_2 = elementRegistry.get('ID_Task_2'),
|
|
|
|
parent = elementRegistry.get('ID_SubProcess_1'),
|
|
|
|
flow = elementRegistry.get('ID_Sequenceflow_1');
|
|
|
|
|
|
|
|
// when
|
2014-11-21 08:19:35 +00:00
|
|
|
modeling.moveShapes([ task_1, task_2 ], { x: 0, y: 250 }, parent);
|
2014-10-27 11:07:57 +00:00
|
|
|
|
|
|
|
// then
|
|
|
|
expect(flow.parent).toBe(parent);
|
|
|
|
expect(flow.businessObject.$parent).toBe(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
|
2014-11-21 08:19:35 +00:00
|
|
|
modeling.moveShapes([ task_1 ], { x: 0, y: 200 }, parent);
|
2014-10-27 11:07:57 +00:00
|
|
|
|
|
|
|
// then
|
|
|
|
expect(task_1.parent).toBe(parent);
|
|
|
|
expect(task_1.businessObject.$parent).toBe(parent.businessObject);
|
|
|
|
|
|
|
|
expect(sequenceFlow.parent).toBe(parent);
|
|
|
|
expect(sequenceFlow.businessObject.$parent).toBe(parent.businessObject);
|
|
|
|
}));
|
2014-11-21 08:19:35 +00:00
|
|
|
|
2014-10-27 11:07:57 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
});
|