test(modeling): ensure connection is layouted during shape move
This commit is contained in:
parent
4afe3a80ed
commit
c490d4539b
|
@ -30,36 +30,49 @@ describe('features/modeling - move shape', function() {
|
||||||
it('should execute', inject(function(elementRegistry, modeling) {
|
it('should execute', inject(function(elementRegistry, modeling) {
|
||||||
|
|
||||||
// given
|
// given
|
||||||
var startEventShape = elementRegistry.getById('StartEvent_1'),
|
var startEventElement = elementRegistry.getById('StartEvent_1'),
|
||||||
startEvent = startEventShape.businessObject;
|
startEvent = startEventElement.businessObject;
|
||||||
|
|
||||||
|
var sequenceFlowElement = elementRegistry.getById('SequenceFlow_1'),
|
||||||
|
sequenceFlow = sequenceFlowElement.businessObject;
|
||||||
|
|
||||||
var oldPosition = {
|
var oldPosition = {
|
||||||
x: startEventShape.x,
|
x: startEventElement.x,
|
||||||
y: startEventShape.y
|
y: startEventElement.y
|
||||||
};
|
};
|
||||||
|
|
||||||
// when
|
// when
|
||||||
modeling.moveShape(startEventShape, { dx: 0, dy: 50 });
|
modeling.moveShape(startEventElement, { dx: 0, dy: 50 });
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expect(startEvent.di.bounds.x).toBe(oldPosition.x);
|
expect(startEvent.di.bounds.x).toBe(oldPosition.x);
|
||||||
expect(startEvent.di.bounds.y).toBe(oldPosition.y + 50);
|
expect(startEvent.di.bounds.y).toBe(oldPosition.y + 50);
|
||||||
|
|
||||||
|
expect(sequenceFlowElement.waypoints).toDeepEqual([
|
||||||
|
{ original: { x: 370, y: 310 }, x: 386, y: 302 },
|
||||||
|
{ original: { x: 470, y: 260 }, x: 420, y: 285 }
|
||||||
|
]);
|
||||||
|
|
||||||
|
expect(sequenceFlow.di.waypoint).toDeepEqual([
|
||||||
|
{ $type: 'dc:Point', x: 386, y: 302 },
|
||||||
|
{ $type: 'dc:Point', x: 420, y: 285 }
|
||||||
|
]);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
it('should execute on label', inject(function(elementRegistry, modeling) {
|
it('should execute on label', inject(function(elementRegistry, modeling) {
|
||||||
|
|
||||||
// given
|
// given
|
||||||
var labelShape = elementRegistry.getById('StartEvent_1_label'),
|
var labelElement = elementRegistry.getById('StartEvent_1_label'),
|
||||||
startEvent = labelShape.businessObject;
|
startEvent = labelElement.businessObject;
|
||||||
|
|
||||||
var oldPosition = {
|
var oldPosition = {
|
||||||
x: labelShape.x,
|
x: labelElement.x,
|
||||||
y: labelShape.y
|
y: labelElement.y
|
||||||
};
|
};
|
||||||
|
|
||||||
// when
|
// when
|
||||||
modeling.moveShape(labelShape, { dx: 0, dy: 50 });
|
modeling.moveShape(labelElement, { dx: 0, dy: 50 });
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expect(startEvent.di.label.bounds.x).toBe(oldPosition.x);
|
expect(startEvent.di.label.bounds.x).toBe(oldPosition.x);
|
||||||
|
@ -74,15 +87,15 @@ describe('features/modeling - move shape', function() {
|
||||||
it('should undo', inject(function(elementRegistry, commandStack, modeling) {
|
it('should undo', inject(function(elementRegistry, commandStack, modeling) {
|
||||||
|
|
||||||
// given
|
// given
|
||||||
var startEventShape = elementRegistry.getById('StartEvent_1'),
|
var startEventElement = elementRegistry.getById('StartEvent_1'),
|
||||||
startEvent = startEventShape.businessObject;
|
startEvent = startEventElement.businessObject;
|
||||||
|
|
||||||
var oldPosition = {
|
var oldPosition = {
|
||||||
x: startEventShape.x,
|
x: startEventElement.x,
|
||||||
y: startEventShape.y
|
y: startEventElement.y
|
||||||
};
|
};
|
||||||
|
|
||||||
modeling.moveShape(startEventShape, { dx: 0, dy: 50 });
|
modeling.moveShape(startEventElement, { dx: 0, dy: 50 });
|
||||||
|
|
||||||
// when
|
// when
|
||||||
commandStack.undo();
|
commandStack.undo();
|
||||||
|
@ -96,15 +109,15 @@ describe('features/modeling - move shape', function() {
|
||||||
it('should undo on label', inject(function(elementRegistry, commandStack, modeling) {
|
it('should undo on label', inject(function(elementRegistry, commandStack, modeling) {
|
||||||
|
|
||||||
// given
|
// given
|
||||||
var labelShape = elementRegistry.getById('StartEvent_1_label'),
|
var labelElement = elementRegistry.getById('StartEvent_1_label'),
|
||||||
startEvent = labelShape.businessObject;
|
startEvent = labelElement.businessObject;
|
||||||
|
|
||||||
var oldPosition = {
|
var oldPosition = {
|
||||||
x: labelShape.x,
|
x: labelElement.x,
|
||||||
y: labelShape.y
|
y: labelElement.y
|
||||||
};
|
};
|
||||||
|
|
||||||
modeling.moveShape(labelShape, { dx: 0, dy: 50 });
|
modeling.moveShape(labelElement, { dx: 0, dy: 50 });
|
||||||
|
|
||||||
// when
|
// when
|
||||||
commandStack.undo();
|
commandStack.undo();
|
||||||
|
@ -116,4 +129,55 @@ describe('features/modeling - move shape', function() {
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
describe('redo support', function() {
|
||||||
|
|
||||||
|
it('should redo', inject(function(elementRegistry, commandStack, modeling) {
|
||||||
|
|
||||||
|
// given
|
||||||
|
var startEventElement = elementRegistry.getById('StartEvent_1'),
|
||||||
|
startEvent = startEventElement.businessObject;
|
||||||
|
|
||||||
|
|
||||||
|
modeling.moveShape(startEventElement, { dx: 0, dy: 50 });
|
||||||
|
|
||||||
|
var newPosition = {
|
||||||
|
x: startEventElement.x,
|
||||||
|
y: startEventElement.y
|
||||||
|
};
|
||||||
|
|
||||||
|
// when
|
||||||
|
commandStack.undo();
|
||||||
|
commandStack.redo();
|
||||||
|
|
||||||
|
// then
|
||||||
|
expect(startEvent.di.bounds.x).toBe(newPosition.x);
|
||||||
|
expect(startEvent.di.bounds.y).toBe(newPosition.y);
|
||||||
|
}));
|
||||||
|
|
||||||
|
|
||||||
|
it('should redo on label', inject(function(elementRegistry, commandStack, modeling) {
|
||||||
|
|
||||||
|
// given
|
||||||
|
var labelElement = elementRegistry.getById('StartEvent_1_label'),
|
||||||
|
startEvent = labelElement.businessObject;
|
||||||
|
|
||||||
|
modeling.moveShape(labelElement, { dx: 0, dy: 50 });
|
||||||
|
|
||||||
|
var newPosition = {
|
||||||
|
x: labelElement.x,
|
||||||
|
y: labelElement.y
|
||||||
|
};
|
||||||
|
|
||||||
|
// when
|
||||||
|
commandStack.undo();
|
||||||
|
commandStack.redo();
|
||||||
|
|
||||||
|
// then
|
||||||
|
expect(startEvent.di.label.bounds.x).toBe(newPosition.x);
|
||||||
|
expect(startEvent.di.label.bounds.y).toBe(newPosition.y);
|
||||||
|
}));
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
Loading…
Reference in New Issue