2018-04-02 19:01:53 +00:00
|
|
|
import {
|
|
|
|
bootstrapModeler,
|
|
|
|
inject
|
|
|
|
} from 'test/TestHelper';
|
2015-08-31 12:59:29 +00:00
|
|
|
|
2018-04-02 19:01:53 +00:00
|
|
|
import modelingModule from 'lib/features/modeling';
|
|
|
|
import coreModule from 'lib/core';
|
2015-08-31 12:59:29 +00:00
|
|
|
|
|
|
|
|
2015-10-15 21:50:15 +00:00
|
|
|
describe('features/modeling - lanes - flowNodeRefs', function() {
|
2015-08-31 12:59:29 +00:00
|
|
|
|
|
|
|
var diagramXML = require('./flowNodeRefs.bpmn');
|
|
|
|
|
|
|
|
var testModules = [ coreModule, modelingModule ];
|
|
|
|
|
|
|
|
beforeEach(bootstrapModeler(diagramXML, { modules: testModules }));
|
|
|
|
|
|
|
|
|
|
|
|
describe('should unwire during move', function() {
|
|
|
|
|
|
|
|
it('execute', inject(function(elementRegistry, modeling) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var taskShape = elementRegistry.get('Task_A'),
|
|
|
|
task = taskShape.businessObject,
|
|
|
|
sourceLaneShape = elementRegistry.get('Lane'),
|
|
|
|
sourceLane = sourceLaneShape.businessObject,
|
|
|
|
targetParticipantShape = elementRegistry.get('Participant_B');
|
|
|
|
|
|
|
|
// when
|
|
|
|
modeling.moveElements([ taskShape ], { x: 0, y: +200 }, targetParticipantShape);
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(sourceLane.flowNodeRef).not.to.contain(task);
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('undo', inject(function(elementRegistry, commandStack, modeling) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var taskShape = elementRegistry.get('Task_A'),
|
|
|
|
task = taskShape.businessObject,
|
|
|
|
sourceLaneShape = elementRegistry.get('Lane'),
|
|
|
|
sourceLane = sourceLaneShape.businessObject,
|
|
|
|
targetParticipantShape = elementRegistry.get('Participant_B');
|
|
|
|
|
|
|
|
modeling.moveElements([ taskShape ], { x: 0, y: +200 }, targetParticipantShape);
|
|
|
|
|
|
|
|
// when
|
|
|
|
commandStack.undo();
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(sourceLane.flowNodeRef).to.contain(task);
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('redo', inject(function(elementRegistry, commandStack, modeling) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var taskShape = elementRegistry.get('Task_A'),
|
|
|
|
task = taskShape.businessObject,
|
|
|
|
sourceLaneShape = elementRegistry.get('Lane'),
|
|
|
|
sourceLane = sourceLaneShape.businessObject,
|
|
|
|
targetParticipantShape = elementRegistry.get('Participant_B');
|
|
|
|
|
|
|
|
modeling.moveElements([ taskShape ], { x: 0, y: +200 }, targetParticipantShape);
|
|
|
|
|
|
|
|
// when
|
|
|
|
commandStack.undo();
|
|
|
|
commandStack.redo();
|
|
|
|
|
|
|
|
// then
|
2018-05-03 14:37:24 +00:00
|
|
|
expect(sourceLane.flowNodeRef).not.to.contain(task);
|
2015-08-31 12:59:29 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
describe('should wire during move', function() {
|
|
|
|
|
|
|
|
it('execute', inject(function(elementRegistry, modeling) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var taskShape = elementRegistry.get('Task_B'),
|
|
|
|
task = taskShape.businessObject,
|
|
|
|
targetLaneShape = elementRegistry.get('Lane'),
|
|
|
|
targetLane = targetLaneShape.businessObject;
|
|
|
|
|
|
|
|
// when
|
|
|
|
modeling.moveElements([ taskShape ], { x: 0, y: -200 }, targetLaneShape);
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(targetLane.flowNodeRef).to.contain(task);
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('undo', inject(function(elementRegistry, commandStack, modeling) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var taskShape = elementRegistry.get('Task_B'),
|
|
|
|
task = taskShape.businessObject,
|
|
|
|
targetLaneShape = elementRegistry.get('Lane'),
|
|
|
|
targetLane = targetLaneShape.businessObject;
|
|
|
|
|
|
|
|
modeling.moveElements([ taskShape ], { x: 0, y: -200 }, targetLaneShape);
|
|
|
|
|
|
|
|
// when
|
|
|
|
commandStack.undo();
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(targetLane.flowNodeRef).not.to.contain(task);
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('redo', inject(function(elementRegistry, commandStack, modeling) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var taskShape = elementRegistry.get('Task_B'),
|
|
|
|
task = taskShape.businessObject,
|
|
|
|
targetLaneShape = elementRegistry.get('Lane'),
|
|
|
|
targetLane = targetLaneShape.businessObject;
|
|
|
|
|
|
|
|
modeling.moveElements([ taskShape ], { x: 0, y: -200 }, targetLaneShape);
|
|
|
|
|
|
|
|
// when
|
|
|
|
commandStack.undo();
|
|
|
|
commandStack.redo();
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(targetLane.flowNodeRef).to.contain(task);
|
|
|
|
}));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
describe('should unwire during delete', function() {
|
|
|
|
|
|
|
|
it('execute', inject(function(elementRegistry, modeling) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var taskShape = elementRegistry.get('Task_A'),
|
|
|
|
task = taskShape.businessObject,
|
|
|
|
parentLaneShape = elementRegistry.get('Lane'),
|
|
|
|
parentLane = parentLaneShape.businessObject;
|
|
|
|
|
|
|
|
// when
|
|
|
|
modeling.removeElements([ taskShape ]);
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(parentLane.flowNodeRef).not.to.contain(task);
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('undo', inject(function(elementRegistry, commandStack, modeling) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var taskShape = elementRegistry.get('Task_A'),
|
|
|
|
task = taskShape.businessObject,
|
|
|
|
parentLaneShape = elementRegistry.get('Lane'),
|
|
|
|
parentLane = parentLaneShape.businessObject;
|
|
|
|
|
|
|
|
modeling.removeElements([ taskShape ]);
|
|
|
|
|
|
|
|
// when
|
|
|
|
commandStack.undo();
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(parentLane.flowNodeRef).to.contain(task);
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('redo', inject(function(elementRegistry, commandStack, modeling) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var taskShape = elementRegistry.get('Task_A'),
|
|
|
|
task = taskShape.businessObject,
|
|
|
|
parentLaneShape = elementRegistry.get('Lane'),
|
|
|
|
parentLane = parentLaneShape.businessObject;
|
|
|
|
|
|
|
|
modeling.removeElements([ taskShape ]);
|
|
|
|
|
|
|
|
// when
|
|
|
|
commandStack.undo();
|
|
|
|
commandStack.redo();
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(parentLane.flowNodeRef).not.to.contain(task);
|
|
|
|
}));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
describe('should wire during create', function() {
|
|
|
|
|
|
|
|
it('execute', inject(function(elementRegistry, modeling) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var taskShape, task,
|
|
|
|
parentLaneShape = elementRegistry.get('Lane'),
|
|
|
|
parentLane = parentLaneShape.businessObject;
|
|
|
|
|
|
|
|
// when
|
2019-08-07 13:17:28 +00:00
|
|
|
taskShape = modeling.createShape({ type: 'bpmn:Task' }, { x: 500, y: 150 }, parentLaneShape);
|
2015-08-31 12:59:29 +00:00
|
|
|
task = taskShape.businessObject;
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(parentLane.flowNodeRef).to.contain(task);
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('undo', inject(function(elementRegistry, commandStack, modeling) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var taskShape, task,
|
|
|
|
parentLaneShape = elementRegistry.get('Lane'),
|
|
|
|
parentLane = parentLaneShape.businessObject;
|
|
|
|
|
2019-08-07 13:17:28 +00:00
|
|
|
taskShape = modeling.createShape({ type: 'bpmn:Task' }, { x: 500, y: 150 }, parentLaneShape);
|
2015-08-31 12:59:29 +00:00
|
|
|
task = taskShape.businessObject;
|
|
|
|
|
|
|
|
// when
|
|
|
|
commandStack.undo();
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(parentLane.flowNodeRef).not.to.contain(task);
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('redo', inject(function(elementRegistry, commandStack, modeling) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var taskShape, task,
|
|
|
|
parentLaneShape = elementRegistry.get('Lane'),
|
|
|
|
parentLane = parentLaneShape.businessObject;
|
|
|
|
|
2019-08-07 13:17:28 +00:00
|
|
|
taskShape = modeling.createShape({ type: 'bpmn:Task' }, { x: 500, y: 150 }, parentLaneShape);
|
2015-08-31 12:59:29 +00:00
|
|
|
task = taskShape.businessObject;
|
|
|
|
|
|
|
|
// when
|
|
|
|
commandStack.undo();
|
|
|
|
commandStack.redo();
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(parentLane.flowNodeRef).to.contain(task);
|
|
|
|
}));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
it('should unwire moving multiple', inject(function(elementRegistry, modeling) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var taskShape = elementRegistry.get('Task_A'),
|
|
|
|
task = taskShape.businessObject,
|
|
|
|
eventShape = elementRegistry.get('Event'),
|
|
|
|
event = eventShape.businessObject,
|
|
|
|
targetParticipantShape = elementRegistry.get('Participant_B'),
|
|
|
|
sourceLaneShape = elementRegistry.get('Lane'),
|
|
|
|
sourceLane = sourceLaneShape.businessObject;
|
|
|
|
|
|
|
|
// when
|
|
|
|
modeling.moveElements([ taskShape, eventShape ], { x: 0, y: +200 }, targetParticipantShape);
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(sourceLane.flowNodeRef).not.to.contain(task);
|
|
|
|
expect(sourceLane.flowNodeRef).not.to.contain(event);
|
|
|
|
}));
|
|
|
|
|
2019-10-09 08:32:27 +00:00
|
|
|
|
|
|
|
it('should not create duplicate refs on attaching / detaching', inject(function(elementRegistry, modeling) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var eventID = 'IntermediateThrowEvent',
|
|
|
|
throwEvent = elementRegistry.get(eventID),
|
|
|
|
task1 = elementRegistry.get('Task_1'),
|
|
|
|
task2 = elementRegistry.get('Task_2'),
|
|
|
|
lane1 = elementRegistry.get('Participant_C_Lane_1').businessObject,
|
|
|
|
lane2 = elementRegistry.get('Participant_C_Lane_2').businessObject;
|
|
|
|
|
|
|
|
// when
|
|
|
|
modeling.moveElements([ throwEvent ], { x: -280, y: 30 }, task1, { attach: true });
|
|
|
|
|
|
|
|
var boundaryEvent = elementRegistry.get(eventID);
|
|
|
|
|
|
|
|
modeling.moveElements([ boundaryEvent ], { x: 0, y: 150 }, task2, { attach: true });
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(lane1.flowNodeRef).not.to.contain(boundaryEvent.businessObject);
|
|
|
|
expect(lane2.flowNodeRef).to.contain(boundaryEvent.businessObject);
|
|
|
|
expect(lane1.flowNodeRef).to.have.length(1);
|
|
|
|
expect(lane2.flowNodeRef).to.have.length(2);
|
|
|
|
}));
|
2015-08-31 12:59:29 +00:00
|
|
|
});
|