2018-04-02 19:01:53 +00:00
|
|
|
import {
|
|
|
|
bootstrapModeler,
|
|
|
|
inject
|
|
|
|
} from 'test/TestHelper';
|
2016-06-07 06:46:45 +00:00
|
|
|
|
2018-04-02 19:01:53 +00:00
|
|
|
import modelingModule from 'lib/features/modeling';
|
|
|
|
import coreModule from 'lib/core';
|
2014-08-22 13:20:48 +00:00
|
|
|
|
|
|
|
|
2019-04-09 12:35:48 +00:00
|
|
|
var testModules = [ coreModule, modelingModule ];
|
|
|
|
|
|
|
|
|
2014-08-22 13:20:48 +00:00
|
|
|
describe('features/modeling - #removeShape', function() {
|
|
|
|
|
2015-03-31 12:17:15 +00:00
|
|
|
var diagramXML = require('../../../fixtures/bpmn/sequence-flows.bpmn');
|
2014-08-22 13:20:48 +00:00
|
|
|
|
|
|
|
beforeEach(bootstrapModeler(diagramXML, { modules: testModules }));
|
|
|
|
|
|
|
|
describe('shape handling', function() {
|
|
|
|
|
|
|
|
it('should execute', inject(function(elementRegistry, modeling) {
|
|
|
|
|
|
|
|
// given
|
2014-11-17 16:36:22 +00:00
|
|
|
var taskShape = elementRegistry.get('Task_1'),
|
2014-08-22 13:20:48 +00:00
|
|
|
task = taskShape.businessObject;
|
|
|
|
|
|
|
|
// when
|
|
|
|
modeling.removeShape(taskShape);
|
|
|
|
|
|
|
|
// then
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(task.$parent).to.be.null;
|
2014-08-22 13:20:48 +00:00
|
|
|
}));
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
describe('undo support', function() {
|
|
|
|
|
|
|
|
it('should undo', inject(function(elementRegistry, modeling, commandStack) {
|
|
|
|
|
|
|
|
// given
|
2014-11-17 16:36:22 +00:00
|
|
|
var taskShape = elementRegistry.get('Task_1'),
|
2014-08-22 13:20:48 +00:00
|
|
|
task = taskShape.businessObject,
|
|
|
|
parent = task.$parent;
|
|
|
|
|
|
|
|
// when
|
|
|
|
modeling.removeShape(taskShape);
|
|
|
|
commandStack.undo();
|
|
|
|
|
|
|
|
// then
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(task.$parent).to.eql(parent);
|
2014-08-22 13:20:48 +00:00
|
|
|
}));
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
describe('redo support', function() {
|
|
|
|
|
|
|
|
it('redo', inject(function(elementRegistry, modeling, commandStack) {
|
|
|
|
|
|
|
|
// given
|
2014-11-17 16:36:22 +00:00
|
|
|
var taskShape = elementRegistry.get('Task_1'),
|
2015-03-31 12:17:15 +00:00
|
|
|
task = taskShape.businessObject;
|
2014-08-22 13:20:48 +00:00
|
|
|
|
|
|
|
// when
|
|
|
|
modeling.removeShape(taskShape);
|
|
|
|
commandStack.undo();
|
|
|
|
commandStack.redo();
|
|
|
|
|
|
|
|
// then
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(task.$parent).to.be.null;
|
2014-08-22 13:20:48 +00:00
|
|
|
}));
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
2019-04-09 12:35:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
describe('features/modeling - #removeShape', function() {
|
|
|
|
|
|
|
|
var diagramXML = require('./DeleteShape.cropping.bpmn');
|
|
|
|
|
|
|
|
beforeEach(bootstrapModeler(diagramXML, { modules: testModules }));
|
|
|
|
|
|
|
|
|
|
|
|
it('should crop waypoints on undo/redo', inject(
|
|
|
|
function(elementRegistry, commandStack, modeling) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var taskShape = elementRegistry.get('Task_A'),
|
|
|
|
sequenceFlowConnection = elementRegistry.get('SequenceFlow_1'),
|
|
|
|
incomingFlow = taskShape.incoming[0],
|
|
|
|
outgoingFlow = taskShape.outgoing[0],
|
|
|
|
expectedStart = incomingFlow.waypoints[0],
|
|
|
|
expectedEnd = outgoingFlow.waypoints[1];
|
|
|
|
|
|
|
|
// when
|
|
|
|
modeling.removeShape(taskShape);
|
|
|
|
commandStack.undo();
|
|
|
|
commandStack.redo();
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(sequenceFlowConnection).to.have.waypoints([ expectedStart, expectedEnd ]);
|
|
|
|
}
|
|
|
|
));
|
|
|
|
|
|
|
|
});
|