2018-04-02 19:01:53 +00:00
|
|
|
import {
|
|
|
|
bootstrapModeler,
|
|
|
|
inject
|
|
|
|
} from 'test/TestHelper';
|
|
|
|
|
|
|
|
import coreModule from 'lib/core';
|
|
|
|
import modelingModule from 'lib/features/modeling';
|
|
|
|
import moveModule from 'diagram-js/lib/features/move';
|
|
|
|
import snappingModule from 'lib/features/snapping';
|
|
|
|
|
|
|
|
import {
|
|
|
|
createCanvasEvent as canvasEvent
|
|
|
|
} from '../../../util/MockEvents';
|
2015-07-13 08:37:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
describe('features/modeling - move', function() {
|
|
|
|
|
|
|
|
var testModules = [ coreModule, modelingModule, moveModule, snappingModule ];
|
|
|
|
|
|
|
|
var testXML = require('../../../fixtures/bpmn/boundary-events.bpmn');
|
|
|
|
|
|
|
|
beforeEach(bootstrapModeler(testXML, { modules: testModules }));
|
|
|
|
|
|
|
|
beforeEach(inject(function(dragging, canvas) {
|
|
|
|
dragging.setOptions({ manual: true });
|
|
|
|
}));
|
|
|
|
|
|
|
|
afterEach(inject(function(dragging) {
|
|
|
|
dragging.setOptions({ manual: false });
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('should not attach label when moving BoundaryEvent', inject(function(elementRegistry, move, dragging) {
|
|
|
|
// given
|
|
|
|
var boundaryEvent = elementRegistry.get('BoundaryEvent_1'),
|
|
|
|
subProcess = elementRegistry.get('SubProcess_1'),
|
|
|
|
label = boundaryEvent.label;
|
|
|
|
|
|
|
|
// when
|
2015-08-24 13:31:47 +00:00
|
|
|
move.start(canvasEvent({ x: 190, y: 355 }), boundaryEvent);
|
2015-07-13 08:37:43 +00:00
|
|
|
|
|
|
|
dragging.hover({
|
|
|
|
element: subProcess,
|
|
|
|
gfx: elementRegistry.getGraphics(subProcess)
|
|
|
|
});
|
|
|
|
|
2015-08-24 13:31:47 +00:00
|
|
|
dragging.move(canvasEvent({ x: 220, y: 240 }));
|
2015-07-13 08:37:43 +00:00
|
|
|
dragging.end();
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(subProcess.attachers).not.to.include(label);
|
|
|
|
expect(subProcess.attachers).to.include(boundaryEvent);
|
|
|
|
|
|
|
|
expect(boundaryEvent.host).to.eql(subProcess);
|
2018-05-03 14:37:24 +00:00
|
|
|
expect(label.host).not.to.exist;
|
2015-07-13 08:37:43 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('should only move label when moving BoundaryEvent and Label',
|
|
|
|
inject(function(elementRegistry, move, dragging, selection) {
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var boundaryEvent = elementRegistry.get('BoundaryEvent_1'),
|
|
|
|
subProcess = elementRegistry.get('SubProcess_1'),
|
|
|
|
label = boundaryEvent.label;
|
2015-07-13 08:37:43 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
selection.select([ boundaryEvent, label ]);
|
2015-07-13 08:37:43 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
move.start(canvasEvent({ x: 190, y: 355 }), boundaryEvent);
|
2015-07-13 08:37:43 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
dragging.hover({
|
|
|
|
element: subProcess,
|
|
|
|
gfx: elementRegistry.getGraphics(subProcess)
|
|
|
|
});
|
2015-07-13 08:37:43 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
dragging.move(canvasEvent({ x: 220, y: 240 }));
|
|
|
|
dragging.end();
|
2015-07-13 08:37:43 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// then
|
|
|
|
expect(subProcess.attachers).not.to.include(label);
|
|
|
|
expect(subProcess.attachers).to.include(boundaryEvent);
|
|
|
|
|
|
|
|
expect(boundaryEvent.host).to.eql(subProcess);
|
2018-05-03 14:37:24 +00:00
|
|
|
expect(label.host).not.to.exist;
|
2016-06-07 06:46:45 +00:00
|
|
|
})
|
|
|
|
);
|
2015-07-13 08:37:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
it('should move BoundaryEvent and Label with parent', inject(function(canvas, elementRegistry, move, dragging) {
|
2016-06-07 06:46:45 +00:00
|
|
|
|
2015-07-13 08:37:43 +00:00
|
|
|
// given
|
|
|
|
var boundaryEvent = elementRegistry.get('BoundaryEvent_1'),
|
|
|
|
subProcess = elementRegistry.get('SubProcess_1'),
|
|
|
|
label = boundaryEvent.label,
|
|
|
|
root = canvas.getRootElement();
|
|
|
|
|
|
|
|
// when
|
2015-08-24 13:31:47 +00:00
|
|
|
move.start(canvasEvent({ x: 190, y: 355 }), subProcess);
|
2015-07-13 08:37:43 +00:00
|
|
|
|
|
|
|
dragging.hover({
|
|
|
|
element: root,
|
|
|
|
gfx: elementRegistry.getGraphics(root)
|
|
|
|
});
|
2015-08-24 13:31:47 +00:00
|
|
|
dragging.move(canvasEvent({ x: 290, y: 455 }));
|
2015-07-13 08:37:43 +00:00
|
|
|
dragging.end();
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(subProcess.x).to.eql(304);
|
|
|
|
expect(subProcess.y).to.eql(178);
|
|
|
|
|
|
|
|
expect(subProcess.attachers).not.to.include(label);
|
|
|
|
expect(subProcess.attachers).to.include(boundaryEvent);
|
|
|
|
|
|
|
|
expect(boundaryEvent.host).to.eql(subProcess);
|
2018-05-03 14:37:24 +00:00
|
|
|
expect(label.host).not.to.exist;
|
2015-07-13 08:37:43 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('should move BoundaryEvent, Label and parent',
|
|
|
|
inject(function(canvas, elementRegistry, move, dragging, selection) {
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var boundaryEvent = elementRegistry.get('BoundaryEvent_1'),
|
|
|
|
subProcess = elementRegistry.get('SubProcess_1'),
|
|
|
|
label = boundaryEvent.label,
|
|
|
|
root = canvas.getRootElement();
|
2015-07-13 08:37:43 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
selection.select([ boundaryEvent, label, subProcess ]);
|
2015-07-13 08:37:43 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
move.start(canvasEvent({ x: 190, y: 355 }), subProcess);
|
2015-07-13 08:37:43 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
dragging.hover({
|
|
|
|
element: root,
|
|
|
|
gfx: elementRegistry.getGraphics(root)
|
|
|
|
});
|
|
|
|
dragging.move(canvasEvent({ x: 290, y: 455 }));
|
|
|
|
dragging.end();
|
2015-07-13 08:37:43 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// then
|
|
|
|
expect(subProcess.x).to.eql(304);
|
|
|
|
expect(subProcess.y).to.eql(178);
|
2015-07-13 08:37:43 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
expect(subProcess.attachers).not.to.include(label);
|
|
|
|
expect(subProcess.attachers).to.include(boundaryEvent);
|
|
|
|
|
|
|
|
expect(boundaryEvent.host).to.eql(subProcess);
|
2018-05-03 14:37:24 +00:00
|
|
|
expect(label.host).not.to.exist;
|
2016-06-07 06:46:45 +00:00
|
|
|
})
|
|
|
|
);
|
2015-07-13 08:37:43 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
});
|