2019-05-23 20:37:06 +00:00
|
|
|
import {
|
|
|
|
bootstrapModeler,
|
|
|
|
inject
|
|
|
|
} from 'test/TestHelper';
|
|
|
|
|
|
|
|
import connectModule from 'diagram-js/lib/features/connect';
|
|
|
|
import coreModule from 'lib/core';
|
|
|
|
import globalConnectModule from 'diagram-js/lib/features/global-connect';
|
|
|
|
import modelingModule from 'lib/features/modeling';
|
|
|
|
import rulesModule from 'lib/features/rules';
|
|
|
|
import snappingModule from 'lib/features/snapping';
|
|
|
|
|
|
|
|
import { createCanvasEvent as canvasEvent } from '../../../util/MockEvents';
|
|
|
|
|
|
|
|
|
|
|
|
describe('features/snapping - BpmnConnectSnapping', function() {
|
|
|
|
|
|
|
|
var testModules = [
|
|
|
|
connectModule,
|
|
|
|
coreModule,
|
|
|
|
globalConnectModule,
|
|
|
|
modelingModule,
|
|
|
|
rulesModule,
|
|
|
|
snappingModule
|
|
|
|
];
|
|
|
|
|
|
|
|
var diagramXML = require('./BpmnConnectSnapping.bpmn');
|
|
|
|
|
|
|
|
beforeEach(bootstrapModeler(diagramXML, {
|
|
|
|
modules: testModules
|
|
|
|
}));
|
|
|
|
|
|
|
|
beforeEach(inject(function(dragging) {
|
|
|
|
dragging.setOptions({ manual: true });
|
|
|
|
}));
|
|
|
|
|
|
|
|
describe('sequence flow', function() {
|
|
|
|
|
|
|
|
describe('connect', function() {
|
|
|
|
|
2019-06-07 08:45:58 +00:00
|
|
|
it('should snap event if close to target bounds',
|
|
|
|
inject(function(connect, dragging, elementRegistry) {
|
2019-05-23 20:37:06 +00:00
|
|
|
|
|
|
|
// given
|
2019-06-07 08:45:58 +00:00
|
|
|
var boundaryEvent = elementRegistry.get('BoundaryEvent'),
|
|
|
|
subProcess = elementRegistry.get('SubProcess'),
|
|
|
|
subProcessGfx = elementRegistry.getGraphics(subProcess);
|
2019-05-23 20:37:06 +00:00
|
|
|
|
|
|
|
// when
|
2019-06-07 08:45:58 +00:00
|
|
|
connect.start(canvasEvent({ x: 600, y: 300 }), boundaryEvent);
|
2019-05-23 20:37:06 +00:00
|
|
|
|
2019-06-07 08:45:58 +00:00
|
|
|
dragging.hover({ element: subProcess, gfx: subProcessGfx });
|
2019-05-23 20:37:06 +00:00
|
|
|
|
2019-06-07 08:45:58 +00:00
|
|
|
dragging.move(canvasEvent({ x: 400, y: 305 }));
|
2019-05-23 20:37:06 +00:00
|
|
|
|
|
|
|
dragging.end();
|
|
|
|
|
|
|
|
// then
|
2019-06-07 08:45:58 +00:00
|
|
|
var waypoints = boundaryEvent.outgoing[0].waypoints;
|
2019-05-23 20:37:06 +00:00
|
|
|
|
2019-06-07 08:45:58 +00:00
|
|
|
expect(waypoints[3].y).to.eql(280);
|
|
|
|
})
|
|
|
|
);
|
2019-05-23 20:37:06 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
describe('message flow', function() {
|
|
|
|
|
|
|
|
describe('connect', function() {
|
|
|
|
|
|
|
|
it('should snap target', inject(function(connect, dragging, elementRegistry) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var task = elementRegistry.get('Task_1'),
|
|
|
|
intermediateCatchEvent = elementRegistry.get('IntermediateCatchEvent_1'),
|
|
|
|
intermediateCatchEventGfx = elementRegistry.getGraphics(intermediateCatchEvent);
|
|
|
|
|
|
|
|
// when
|
|
|
|
connect.start(canvasEvent({ x: 300, y: 300 }), task);
|
|
|
|
|
|
|
|
dragging.hover({ element: intermediateCatchEvent, gfx: intermediateCatchEventGfx });
|
|
|
|
|
|
|
|
dragging.move(canvasEvent({ x: 210, y: 610 }));
|
|
|
|
|
|
|
|
dragging.end();
|
|
|
|
|
|
|
|
// then
|
|
|
|
var waypoints = task.outgoing[0].waypoints;
|
|
|
|
|
|
|
|
expect(waypoints[3].original).to.eql({ x: 200, y: 600 });
|
|
|
|
}));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
describe('global connect', function() {
|
|
|
|
|
|
|
|
it('should snap source', inject(function(connect, dragging, elementRegistry) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var intermediateThrowEvent = elementRegistry.get('IntermediateThrowEvent_1'),
|
|
|
|
task = elementRegistry.get('Task_1'),
|
|
|
|
taskGfx = elementRegistry.getGraphics(task);
|
|
|
|
|
|
|
|
// when
|
|
|
|
connect.start(null, intermediateThrowEvent, { x: 110, y: 610 });
|
|
|
|
|
|
|
|
dragging.hover({ element: task, gfx: taskGfx });
|
|
|
|
|
|
|
|
dragging.move(canvasEvent({ x: 310, y: 310 }));
|
|
|
|
|
|
|
|
dragging.end();
|
|
|
|
|
|
|
|
// then
|
|
|
|
var waypoints = intermediateThrowEvent.outgoing[0].waypoints;
|
|
|
|
|
|
|
|
expect(waypoints[0].original).to.eql({ x: 100, y: 600 });
|
|
|
|
expect(waypoints[3].original).to.eql({ x: 310, y: 310 }); // NOT snapped
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('should snap target', inject(function(connect, dragging, elementRegistry) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var task = elementRegistry.get('Task_1'),
|
|
|
|
intermediateCatchEvent = elementRegistry.get('IntermediateCatchEvent_1'),
|
|
|
|
intermediateCatchEventGfx = elementRegistry.getGraphics(intermediateCatchEvent);
|
|
|
|
|
|
|
|
// when
|
|
|
|
connect.start(null, task, { x: 310, y: 310 });
|
|
|
|
|
|
|
|
dragging.hover({ element: intermediateCatchEvent, gfx: intermediateCatchEventGfx });
|
|
|
|
|
|
|
|
dragging.move(canvasEvent({ x: 210, y: 610 }));
|
|
|
|
|
|
|
|
dragging.end();
|
|
|
|
|
|
|
|
// then
|
|
|
|
var waypoints = task.outgoing[0].waypoints;
|
|
|
|
|
|
|
|
expect(waypoints[0].original).to.eql({ x: 310, y: 310 }); // NOT snapped
|
|
|
|
expect(waypoints[3].original).to.eql({ x: 200, y: 600 });
|
|
|
|
}));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|