2018-04-02 19:01:53 +00:00
|
|
|
import {
|
|
|
|
bootstrapModeler,
|
|
|
|
inject
|
|
|
|
} from 'test/TestHelper';
|
2015-04-15 07:06:34 +00:00
|
|
|
|
2018-04-02 19:01:53 +00:00
|
|
|
import {
|
|
|
|
createCanvasEvent as canvasEvent
|
|
|
|
} from '../../../util/MockEvents';
|
2015-04-15 07:06:34 +00:00
|
|
|
|
2018-04-02 19:01:53 +00:00
|
|
|
import coreModule from 'lib/core';
|
|
|
|
import snappingModule from 'lib/features/snapping';
|
|
|
|
import modelingModule from 'lib/features/modeling';
|
|
|
|
import createModule from 'diagram-js/lib/features/create';
|
|
|
|
import resizeModule from 'diagram-js/lib/features/resize';
|
|
|
|
import moveModule from 'diagram-js/lib/features/move';
|
|
|
|
import rulesModule from 'lib/features/rules';
|
|
|
|
import connectModule from 'diagram-js/lib/features/connect';
|
2015-04-15 07:06:34 +00:00
|
|
|
|
2015-10-09 23:41:32 +00:00
|
|
|
|
2015-04-15 07:06:34 +00:00
|
|
|
describe('features/snapping - BpmnSnapping', function() {
|
|
|
|
|
2015-10-09 23:41:32 +00:00
|
|
|
var testModules = [
|
|
|
|
coreModule,
|
|
|
|
snappingModule,
|
|
|
|
modelingModule,
|
|
|
|
createModule,
|
|
|
|
rulesModule,
|
2016-07-13 10:57:18 +00:00
|
|
|
moveModule,
|
|
|
|
connectModule
|
2015-10-09 23:41:32 +00:00
|
|
|
];
|
|
|
|
|
2015-07-13 08:37:43 +00:00
|
|
|
describe('on Boundary Events', function() {
|
|
|
|
|
|
|
|
var diagramXML = require('../../../fixtures/bpmn/collaboration/process.bpmn');
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
beforeEach(bootstrapModeler(diagramXML, {
|
|
|
|
modules: testModules
|
|
|
|
}));
|
2015-07-13 08:37:43 +00:00
|
|
|
|
2015-08-24 13:31:47 +00:00
|
|
|
var task, intermediateThrowEvent;
|
2015-07-13 08:37:43 +00:00
|
|
|
|
2015-08-24 14:59:13 +00:00
|
|
|
beforeEach(inject(function(elementFactory, elementRegistry, dragging) {
|
2015-07-13 08:37:43 +00:00
|
|
|
task = elementRegistry.get('Task_1');
|
|
|
|
|
|
|
|
intermediateThrowEvent = elementFactory.createShape({
|
2016-06-07 06:46:45 +00:00
|
|
|
type: 'bpmn:IntermediateThrowEvent'
|
2015-07-13 08:37:43 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
dragging.setOptions({ manual: true });
|
|
|
|
}));
|
|
|
|
|
|
|
|
afterEach(inject(function(dragging) {
|
|
|
|
dragging.setOptions({ manual: false });
|
|
|
|
}));
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
|
2015-07-13 08:37:43 +00:00
|
|
|
it('should snap on create to the bottom',
|
2016-06-07 06:46:45 +00:00
|
|
|
inject(function(canvas, create, dragging, elementRegistry) {
|
2015-07-13 08:37:43 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var taskGfx = canvas.getGraphics(task);
|
2015-07-13 08:37:43 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
create.start(canvasEvent({ x: 0, y: 0 }), intermediateThrowEvent);
|
2015-07-13 08:37:43 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
dragging.hover({ element: task, gfx: taskGfx });
|
2015-07-13 08:37:43 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
dragging.move(canvasEvent({ x: 382, y: 170 }));
|
|
|
|
dragging.end();
|
2015-07-13 08:37:43 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
var boundaryEvent = elementRegistry.get(task.attachers[0].id);
|
2015-07-13 08:37:43 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// then
|
|
|
|
expect(boundaryEvent).to.have.bounds({ x: 364, y: 167, width: 36, height: 36 });
|
|
|
|
})
|
|
|
|
);
|
2015-07-13 08:37:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
it('should snap on create to the left',
|
2016-06-07 06:46:45 +00:00
|
|
|
inject(function(canvas, create, dragging, elementRegistry) {
|
2015-07-13 08:37:43 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var taskGfx = canvas.getGraphics(task);
|
2015-07-13 08:37:43 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
create.start(canvasEvent({ x: 0, y: 0 }), intermediateThrowEvent);
|
2015-07-13 08:37:43 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
dragging.hover({ element: task, gfx: taskGfx });
|
2015-07-13 08:37:43 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
dragging.move(canvasEvent({ x: 382, y: 115 }));
|
|
|
|
dragging.end();
|
2015-07-13 08:37:43 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
var boundaryEvent = elementRegistry.get(task.attachers[0].id);
|
2015-07-13 08:37:43 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// then
|
|
|
|
expect(boundaryEvent).to.have.bounds({ x: 364, y: 87, width: 36, height: 36 });
|
|
|
|
})
|
|
|
|
);
|
2015-07-13 08:37:43 +00:00
|
|
|
|
|
|
|
});
|
2015-04-15 07:06:34 +00:00
|
|
|
|
2015-08-24 13:31:47 +00:00
|
|
|
|
2017-07-14 09:29:41 +00:00
|
|
|
describe('on Sequence Flows', function() {
|
|
|
|
|
|
|
|
var diagramXML = require('./BpmnSnapping.sequenceFlow.bpmn');
|
|
|
|
|
|
|
|
beforeEach(bootstrapModeler(diagramXML, {
|
|
|
|
modules: testModules
|
|
|
|
}));
|
|
|
|
|
|
|
|
var sequenceFlow, task;
|
|
|
|
|
|
|
|
beforeEach(inject(function(elementFactory, elementRegistry, dragging) {
|
|
|
|
sequenceFlow = elementRegistry.get('SequenceFlow_1');
|
|
|
|
|
|
|
|
task = elementFactory.createShape({
|
|
|
|
type: 'bpmn:Task'
|
|
|
|
});
|
|
|
|
|
|
|
|
dragging.setOptions({ manual: true });
|
|
|
|
}));
|
|
|
|
|
|
|
|
afterEach(inject(function(dragging) {
|
|
|
|
dragging.setOptions({ manual: false });
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('should snap vertically',
|
|
|
|
inject(function(canvas, create, dragging) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var sequenceFlowGfx = canvas.getGraphics(sequenceFlow);
|
|
|
|
|
|
|
|
// when
|
|
|
|
create.start(canvasEvent({ x: 0, y: 0 }), task);
|
|
|
|
|
|
|
|
dragging.hover({ element: sequenceFlow, gfx: sequenceFlowGfx });
|
|
|
|
|
|
|
|
dragging.move(canvasEvent({ x: 300, y: 245 }));
|
|
|
|
dragging.end();
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(task.x).to.eql(254);
|
|
|
|
})
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
it('should snap horizontally',
|
|
|
|
inject(function(canvas, create, dragging) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var sequenceFlowGfx = canvas.getGraphics(sequenceFlow);
|
|
|
|
|
|
|
|
// when
|
|
|
|
create.start(canvasEvent({ x: 0, y: 0 }), task);
|
|
|
|
|
|
|
|
dragging.hover({ element: sequenceFlow, gfx: sequenceFlowGfx });
|
|
|
|
|
|
|
|
dragging.move(canvasEvent({ x: 410, y: 320 }));
|
|
|
|
dragging.end();
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(task.y).to.eql(285);
|
|
|
|
})
|
|
|
|
);
|
2017-12-10 12:48:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
it('should NOT snap shape to first waypoint',
|
|
|
|
inject(function(canvas, elementRegistry, move, dragging) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var shape = elementRegistry.get('StartEvent_1');
|
|
|
|
|
|
|
|
var originalPosition = {
|
|
|
|
x: shape.x,
|
|
|
|
y: shape.y
|
|
|
|
};
|
|
|
|
|
|
|
|
var rootElement = canvas.getRootElement();
|
|
|
|
|
|
|
|
// when
|
|
|
|
move.start(canvasEvent(originalPosition), shape);
|
|
|
|
|
|
|
|
dragging.hover({
|
|
|
|
element: rootElement,
|
|
|
|
gfx: canvas.getGraphics(rootElement)
|
|
|
|
});
|
|
|
|
|
|
|
|
dragging.move(canvasEvent({
|
|
|
|
x: originalPosition.x + 10,
|
|
|
|
y: originalPosition.y
|
|
|
|
}));
|
|
|
|
|
|
|
|
dragging.move(canvasEvent({
|
|
|
|
x: originalPosition.x + 20,
|
|
|
|
y: originalPosition.y - 5
|
|
|
|
}));
|
|
|
|
|
|
|
|
dragging.end();
|
|
|
|
|
|
|
|
// then
|
|
|
|
// no horizontal snap
|
|
|
|
expect(shape.x).to.eql(originalPosition.x + 20);
|
|
|
|
|
|
|
|
// vertical snap though!
|
|
|
|
expect(shape.y).to.eql(originalPosition.y);
|
|
|
|
})
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
it('should NOT snap shape to last waypoint',
|
|
|
|
inject(function(canvas, elementRegistry, move, dragging) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var shape = elementRegistry.get('Task_1');
|
|
|
|
|
|
|
|
var originalPosition = {
|
|
|
|
x: shape.x,
|
|
|
|
y: shape.y
|
|
|
|
};
|
|
|
|
|
|
|
|
var rootElement = canvas.getRootElement();
|
|
|
|
|
|
|
|
// when
|
|
|
|
move.start(canvasEvent(originalPosition), shape);
|
|
|
|
|
|
|
|
dragging.hover({
|
|
|
|
element: rootElement,
|
|
|
|
gfx: canvas.getGraphics(rootElement)
|
|
|
|
});
|
|
|
|
|
|
|
|
dragging.move(canvasEvent({
|
|
|
|
x: originalPosition.x,
|
|
|
|
y: originalPosition.y - 10
|
|
|
|
}));
|
|
|
|
|
|
|
|
dragging.move(canvasEvent({
|
|
|
|
x: originalPosition.x + 5,
|
|
|
|
y: originalPosition.y - 20
|
|
|
|
}));
|
|
|
|
|
|
|
|
dragging.end();
|
|
|
|
|
|
|
|
// then
|
|
|
|
// no vertical snap
|
|
|
|
expect(shape.y).to.eql(originalPosition.y - 20);
|
|
|
|
|
|
|
|
// horizontal snap though!
|
|
|
|
expect(shape.x).to.eql(originalPosition.x);
|
|
|
|
})
|
|
|
|
);
|
2017-07-14 09:29:41 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
2015-06-10 13:58:52 +00:00
|
|
|
describe('on Participant create', function() {
|
2015-04-15 07:06:34 +00:00
|
|
|
|
2015-06-10 13:58:52 +00:00
|
|
|
describe('in non-empty process', function() {
|
2015-04-15 07:06:34 +00:00
|
|
|
|
2015-06-10 13:58:52 +00:00
|
|
|
var diagramXML = require('../../../fixtures/bpmn/collaboration/process.bpmn');
|
2015-04-15 07:06:34 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
beforeEach(bootstrapModeler(diagramXML, {
|
|
|
|
modules: testModules
|
|
|
|
}));
|
2015-04-15 07:06:34 +00:00
|
|
|
|
2015-08-24 13:31:47 +00:00
|
|
|
beforeEach(inject(function(dragging) {
|
2015-06-10 13:58:52 +00:00
|
|
|
dragging.setOptions({ manual: true });
|
|
|
|
}));
|
2015-04-15 07:06:34 +00:00
|
|
|
|
|
|
|
|
2015-06-10 13:58:52 +00:00
|
|
|
it('should snap to process children bounds / top left',
|
2016-06-07 06:46:45 +00:00
|
|
|
inject(function(canvas, create, dragging, elementFactory) {
|
2015-04-15 07:06:34 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var participantShape = elementFactory.createParticipantShape(false),
|
|
|
|
rootElement = canvas.getRootElement(),
|
|
|
|
rootGfx = canvas.getGraphics(rootElement);
|
2015-04-15 07:06:34 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
create.start(canvasEvent({ x: 50, y: 50 }), participantShape);
|
2015-04-15 07:06:34 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
dragging.hover({ element: rootElement, gfx: rootGfx });
|
2015-04-15 07:06:34 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
dragging.move(canvasEvent({ x: 65, y: 65 }));
|
|
|
|
dragging.end(canvasEvent({ x: 65, y: 65 }));
|
2015-04-15 07:06:34 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// then
|
|
|
|
expect(participantShape).to.have.bounds({
|
|
|
|
width: 600, height: 250, x: 18, y: -8
|
|
|
|
});
|
|
|
|
})
|
|
|
|
);
|
2015-04-15 07:06:34 +00:00
|
|
|
|
|
|
|
|
2015-06-10 13:58:52 +00:00
|
|
|
it('should snap to process children bounds / bottom right',
|
2016-06-07 06:46:45 +00:00
|
|
|
inject(function(canvas, create, dragging, elementFactory) {
|
2015-04-15 07:06:34 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var participantShape = elementFactory.createParticipantShape(false),
|
|
|
|
rootElement = canvas.getRootElement(),
|
|
|
|
rootGfx = canvas.getGraphics(rootElement);
|
2015-04-15 07:06:34 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
create.start(canvasEvent({ x: 50, y: 50 }), participantShape);
|
2015-04-15 07:06:34 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
dragging.hover({ element: rootElement, gfx: rootGfx });
|
2015-04-15 07:06:34 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
dragging.move(canvasEvent({ x: 400, y: 400 }));
|
|
|
|
dragging.end(canvasEvent({ x: 400, y: 400 }));
|
2015-04-15 07:06:34 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// then
|
|
|
|
expect(participantShape).to.have.bounds({
|
|
|
|
width: 600, height: 250, x: 100, y: 52
|
|
|
|
});
|
|
|
|
})
|
|
|
|
);
|
2015-04-15 07:06:34 +00:00
|
|
|
|
2015-06-10 13:58:52 +00:00
|
|
|
});
|
2015-04-15 07:06:34 +00:00
|
|
|
|
|
|
|
|
2015-06-10 13:58:52 +00:00
|
|
|
describe('in empty process', function() {
|
2015-04-15 07:06:34 +00:00
|
|
|
|
2015-06-10 13:58:52 +00:00
|
|
|
var diagramXML = require('../../../fixtures/bpmn/collaboration/process-empty.bpmn');
|
2015-04-15 07:06:34 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
beforeEach(bootstrapModeler(diagramXML, {
|
|
|
|
modules: testModules
|
|
|
|
}));
|
2015-04-15 07:06:34 +00:00
|
|
|
|
|
|
|
|
2015-08-24 13:31:47 +00:00
|
|
|
beforeEach(inject(function(dragging) {
|
2015-06-10 13:58:52 +00:00
|
|
|
dragging.setOptions({ manual: true });
|
|
|
|
}));
|
2015-04-15 07:06:34 +00:00
|
|
|
|
|
|
|
|
2015-06-10 13:58:52 +00:00
|
|
|
it('should not snap', inject(function(canvas, create, dragging, elementFactory) {
|
2015-04-15 07:06:34 +00:00
|
|
|
|
2015-06-10 13:58:52 +00:00
|
|
|
// given
|
|
|
|
var participantShape = elementFactory.createParticipantShape(false),
|
|
|
|
rootElement = canvas.getRootElement(),
|
|
|
|
rootGfx = canvas.getGraphics(rootElement);
|
2015-04-15 07:06:34 +00:00
|
|
|
|
2015-06-10 13:58:52 +00:00
|
|
|
// when
|
2015-08-24 13:31:47 +00:00
|
|
|
create.start(canvasEvent({ x: 50, y: 50 }), participantShape);
|
2015-04-15 07:06:34 +00:00
|
|
|
|
2015-06-10 13:58:52 +00:00
|
|
|
dragging.hover({ element: rootElement, gfx: rootGfx });
|
2015-04-15 07:06:34 +00:00
|
|
|
|
2015-08-24 13:31:47 +00:00
|
|
|
dragging.move(canvasEvent({ x: 400, y: 400 }));
|
|
|
|
dragging.end(canvasEvent({ x: 400, y: 400 }));
|
2015-04-15 07:06:34 +00:00
|
|
|
|
2015-06-10 13:58:52 +00:00
|
|
|
// then
|
2015-09-02 12:15:45 +00:00
|
|
|
expect(participantShape).to.have.bounds({
|
2015-06-10 13:58:52 +00:00
|
|
|
x: 100, y: 275, width: 600, height: 250
|
|
|
|
});
|
|
|
|
}));
|
2015-04-15 07:06:34 +00:00
|
|
|
|
2015-06-10 13:58:52 +00:00
|
|
|
});
|
2015-04-15 07:06:34 +00:00
|
|
|
|
|
|
|
|
2015-06-10 13:58:52 +00:00
|
|
|
describe('in collaboration', function() {
|
2015-04-15 07:06:34 +00:00
|
|
|
|
2015-06-10 13:58:52 +00:00
|
|
|
var diagramXML = require('../../../fixtures/bpmn/collaboration/collaboration-participant.bpmn');
|
2015-04-15 07:06:34 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
beforeEach(bootstrapModeler(diagramXML, {
|
|
|
|
modules: testModules
|
|
|
|
}));
|
2015-04-15 07:06:34 +00:00
|
|
|
|
2015-08-24 13:31:47 +00:00
|
|
|
beforeEach(inject(function(dragging) {
|
2015-06-10 13:58:52 +00:00
|
|
|
dragging.setOptions({ manual: true });
|
|
|
|
}));
|
2015-04-15 07:06:34 +00:00
|
|
|
|
|
|
|
|
2016-06-22 15:04:42 +00:00
|
|
|
it('should not snap to diagram contents', inject(function(canvas, create, dragging, elementFactory) {
|
2015-04-15 07:06:34 +00:00
|
|
|
|
2015-06-10 13:58:52 +00:00
|
|
|
// given
|
|
|
|
var participantShape = elementFactory.createParticipantShape(false),
|
|
|
|
rootElement = canvas.getRootElement(),
|
|
|
|
rootGfx = canvas.getGraphics(rootElement);
|
2015-04-15 07:06:34 +00:00
|
|
|
|
2015-06-10 13:58:52 +00:00
|
|
|
// when
|
2015-08-24 13:31:47 +00:00
|
|
|
create.start(canvasEvent({ x: 50, y: 50 }), participantShape);
|
2015-04-15 07:06:34 +00:00
|
|
|
|
2015-06-10 13:58:52 +00:00
|
|
|
dragging.hover({ element: rootElement, gfx: rootGfx });
|
2015-04-15 07:06:34 +00:00
|
|
|
|
2015-08-24 13:31:47 +00:00
|
|
|
dragging.move(canvasEvent({ x: 400, y: 400 }));
|
|
|
|
dragging.end(canvasEvent({ x: 400, y: 400 }));
|
2015-06-10 13:58:52 +00:00
|
|
|
|
|
|
|
// then
|
2015-09-02 12:15:45 +00:00
|
|
|
expect(participantShape).to.have.bounds({
|
2015-06-10 13:58:52 +00:00
|
|
|
x: 100, y: 275, width: 600, height: 250
|
|
|
|
});
|
|
|
|
}));
|
|
|
|
|
2016-06-22 15:04:42 +00:00
|
|
|
|
|
|
|
it('should snap to participant border', inject(function(canvas, create, dragging, elementFactory) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var participantShape = elementFactory.createParticipantShape(false),
|
|
|
|
rootElement = canvas.getRootElement(),
|
|
|
|
rootGfx = canvas.getGraphics(rootElement);
|
|
|
|
|
|
|
|
// when
|
|
|
|
create.start(canvasEvent({ x: 50, y: 50 }), participantShape);
|
|
|
|
|
|
|
|
dragging.hover({ element: rootElement, gfx: rootGfx });
|
|
|
|
|
|
|
|
dragging.move(canvasEvent({ x: 390, y: 400 }));
|
|
|
|
dragging.end(canvasEvent({ x: 390, y: 400 }));
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(participantShape).to.have.bounds({
|
|
|
|
x: 84, y: 275, width: 600, height: 250
|
|
|
|
});
|
|
|
|
}));
|
|
|
|
|
2015-06-10 13:58:52 +00:00
|
|
|
});
|
2015-04-15 07:06:34 +00:00
|
|
|
|
|
|
|
});
|
|
|
|
|
2015-05-05 11:29:28 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
describe('on Participant resize', function() {
|
2015-06-03 15:47:24 +00:00
|
|
|
|
2015-08-24 14:59:13 +00:00
|
|
|
describe('snap min bounds', function() {
|
2015-05-05 11:29:28 +00:00
|
|
|
|
2015-08-24 14:59:13 +00:00
|
|
|
var diagramXML = require('./BpmnSnapping.participant-resize.bpmn');
|
2015-04-28 11:24:55 +00:00
|
|
|
|
2015-10-09 23:41:32 +00:00
|
|
|
var testResizeModules = [
|
|
|
|
coreModule,
|
|
|
|
resizeModule,
|
|
|
|
modelingModule,
|
|
|
|
rulesModule,
|
|
|
|
snappingModule
|
|
|
|
];
|
2015-04-28 11:24:55 +00:00
|
|
|
|
2015-08-24 14:59:13 +00:00
|
|
|
beforeEach(bootstrapModeler(diagramXML, { modules: testResizeModules }));
|
2015-04-28 11:24:55 +00:00
|
|
|
|
2015-06-03 15:47:24 +00:00
|
|
|
|
2015-08-24 14:59:13 +00:00
|
|
|
it('should snap to children from <se>', inject(function(elementRegistry, resize, dragging) {
|
2015-06-03 15:47:24 +00:00
|
|
|
|
|
|
|
var participant = elementRegistry.get('Participant_2');
|
|
|
|
|
2015-08-24 13:31:47 +00:00
|
|
|
resize.activate(canvasEvent({ x: 500, y: 500 }), participant, 'se');
|
|
|
|
dragging.move(canvasEvent({ x: 0, y: 0 }));
|
2015-06-03 15:47:24 +00:00
|
|
|
dragging.end();
|
|
|
|
|
2015-10-09 23:41:32 +00:00
|
|
|
expect(participant.width).to.equal(482);
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(participant.height).to.equal(252);
|
2015-06-03 15:47:24 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
|
2015-08-24 14:59:13 +00:00
|
|
|
it('should snap to children from <nw>', inject(function(elementRegistry, resize, dragging) {
|
2015-06-03 15:47:24 +00:00
|
|
|
|
|
|
|
var participant = elementRegistry.get('Participant_2');
|
|
|
|
|
2015-08-24 13:31:47 +00:00
|
|
|
resize.activate(canvasEvent({ x: 0, y: 0 }), participant, 'nw');
|
|
|
|
dragging.move(canvasEvent({ x: 500, y: 500 }));
|
2015-06-10 13:58:52 +00:00
|
|
|
dragging.end();
|
|
|
|
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(participant.width).to.equal(467);
|
2016-12-01 12:17:44 +00:00
|
|
|
expect(participant.height).to.equal(287);
|
2015-06-10 13:58:52 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
|
2015-08-24 14:59:13 +00:00
|
|
|
it('should snap to min dimensions from <se>', inject(function(elementRegistry, resize, dragging) {
|
2015-06-10 13:58:52 +00:00
|
|
|
|
|
|
|
var participant = elementRegistry.get('Participant_1');
|
|
|
|
|
2015-08-24 13:31:47 +00:00
|
|
|
resize.activate(canvasEvent({ x: 500, y: 500 }), participant, 'se');
|
|
|
|
dragging.move(canvasEvent({ x: 0, y: 0 }));
|
2015-06-10 13:58:52 +00:00
|
|
|
dragging.end();
|
|
|
|
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(participant.width).to.equal(300);
|
2015-10-09 23:41:32 +00:00
|
|
|
expect(participant.height).to.equal(60);
|
2015-06-10 13:58:52 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
|
2015-08-24 14:59:13 +00:00
|
|
|
it('should snap to min dimensions from <nw>', inject(function(elementRegistry, resize, dragging) {
|
2015-06-10 13:58:52 +00:00
|
|
|
|
|
|
|
var participant = elementRegistry.get('Participant_1');
|
|
|
|
|
2015-08-24 13:31:47 +00:00
|
|
|
resize.activate(canvasEvent({ x: 0, y: 0 }), participant, 'nw');
|
|
|
|
dragging.move(canvasEvent({ x: 500, y: 500 }));
|
2015-06-10 13:58:52 +00:00
|
|
|
dragging.end();
|
|
|
|
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(participant.width).to.equal(300);
|
2015-10-09 23:41:32 +00:00
|
|
|
expect(participant.height).to.equal(60);
|
2015-06-10 13:58:52 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
|
2015-08-24 14:59:13 +00:00
|
|
|
it('should snap to min dimensions + children from <se>', inject(function(elementRegistry, resize, dragging) {
|
2015-06-10 13:58:52 +00:00
|
|
|
|
|
|
|
var participant = elementRegistry.get('Participant_3');
|
|
|
|
|
2015-08-24 13:31:47 +00:00
|
|
|
resize.activate(canvasEvent({ x: 500, y: 500 }), participant, 'se');
|
|
|
|
dragging.move(canvasEvent({ x: 0, y: 0 }));
|
2015-06-10 13:58:52 +00:00
|
|
|
dragging.end();
|
|
|
|
|
2015-10-09 23:41:32 +00:00
|
|
|
expect(participant.width).to.equal(305);
|
2015-08-24 14:59:13 +00:00
|
|
|
|
|
|
|
// snap to children rather than min dimensions
|
|
|
|
expect(participant.height).to.equal(143);
|
2015-06-10 13:58:52 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
|
2015-08-24 14:59:13 +00:00
|
|
|
it('should snap to min dimensions + children from <nw>', inject(function(elementRegistry, resize, dragging) {
|
2015-06-10 13:58:52 +00:00
|
|
|
|
|
|
|
var participant = elementRegistry.get('Participant_3');
|
|
|
|
|
2015-08-24 13:31:47 +00:00
|
|
|
resize.activate(canvasEvent({ x: 0, y: 0 }), participant, 'nw');
|
|
|
|
dragging.move(canvasEvent({ x: 500, y: 500 }));
|
2015-06-03 15:47:24 +00:00
|
|
|
dragging.end();
|
|
|
|
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(participant.width).to.equal(353);
|
|
|
|
expect(participant.height).to.equal(177);
|
2015-06-03 15:47:24 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2015-08-24 14:59:13 +00:00
|
|
|
describe('snap child lanes', function() {
|
|
|
|
|
|
|
|
var diagramXML = require('./BpmnSnapping.lanes-resize.bpmn');
|
|
|
|
|
2015-10-09 23:41:32 +00:00
|
|
|
var testResizeModules = [
|
|
|
|
coreModule,
|
|
|
|
resizeModule,
|
|
|
|
modelingModule,
|
|
|
|
rulesModule,
|
|
|
|
snappingModule
|
|
|
|
];
|
2015-08-24 14:59:13 +00:00
|
|
|
|
|
|
|
beforeEach(bootstrapModeler(diagramXML, { modules: testResizeModules }));
|
|
|
|
|
|
|
|
|
|
|
|
it('should snap to child lanes from <nw>', inject(function(elementRegistry, resize, dragging) {
|
|
|
|
|
|
|
|
var participant = elementRegistry.get('Participant');
|
|
|
|
|
|
|
|
resize.activate(canvasEvent({ x: 0, y: 0 }), participant, 'nw');
|
|
|
|
dragging.move(canvasEvent({ x: 500, y: 500 }));
|
|
|
|
dragging.end();
|
|
|
|
|
2015-10-09 23:41:32 +00:00
|
|
|
expect(participant.width).to.equal(563);
|
|
|
|
expect(participant.height).to.equal(223);
|
2015-08-24 14:59:13 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('should snap to nested child lanes from <se>', inject(function(elementRegistry, resize, dragging) {
|
|
|
|
|
|
|
|
var lane = elementRegistry.get('Lane_B_0');
|
|
|
|
|
|
|
|
resize.activate(canvasEvent({ x: 0, y: 0 }), lane, 'se');
|
|
|
|
dragging.move(canvasEvent({ x: -500, y: -500 }));
|
|
|
|
dragging.end();
|
|
|
|
|
2015-10-09 23:41:32 +00:00
|
|
|
expect(lane.width).to.equal(313);
|
|
|
|
expect(lane.height).to.equal(122);
|
2015-08-24 14:59:13 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
describe('on SubProcess resize', function() {
|
|
|
|
|
|
|
|
var diagramXML = require('./BpmnSnapping.subProcess-resize.bpmn');
|
2015-04-28 11:24:55 +00:00
|
|
|
|
2016-03-23 08:28:59 +00:00
|
|
|
var testResizeModules = [
|
|
|
|
coreModule,
|
|
|
|
modelingModule,
|
|
|
|
resizeModule,
|
|
|
|
rulesModule,
|
2016-05-18 05:54:58 +00:00
|
|
|
snappingModule
|
2016-03-23 08:28:59 +00:00
|
|
|
];
|
2015-08-24 14:59:13 +00:00
|
|
|
|
|
|
|
beforeEach(bootstrapModeler(diagramXML, { modules: testResizeModules }));
|
|
|
|
|
|
|
|
|
|
|
|
it('should snap to minimum bounds', inject(function(elementRegistry, resize, dragging) {
|
|
|
|
|
|
|
|
var subProcess = elementRegistry.get('SubProcess');
|
|
|
|
|
|
|
|
resize.activate(canvasEvent({ x: 0, y: 0 }), subProcess, 'se');
|
|
|
|
dragging.move(canvasEvent({ x: -400, y: -400 }));
|
2015-04-28 11:24:55 +00:00
|
|
|
dragging.end();
|
|
|
|
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(subProcess.width).to.equal(140);
|
|
|
|
expect(subProcess.height).to.equal(120);
|
2015-04-28 11:24:55 +00:00
|
|
|
}));
|
|
|
|
|
2015-08-24 14:59:13 +00:00
|
|
|
});
|
2015-04-28 11:24:55 +00:00
|
|
|
|
|
|
|
|
2016-12-01 12:17:44 +00:00
|
|
|
describe('on TextAnnotation resize', function() {
|
|
|
|
|
|
|
|
var diagramXML = require('./BpmnSnapping.textAnnotation-resize.bpmn');
|
|
|
|
|
|
|
|
var testResizeModules = [
|
|
|
|
coreModule,
|
|
|
|
modelingModule,
|
|
|
|
resizeModule,
|
|
|
|
rulesModule,
|
|
|
|
snappingModule
|
|
|
|
];
|
|
|
|
|
|
|
|
beforeEach(bootstrapModeler(diagramXML, { modules: testResizeModules }));
|
|
|
|
|
|
|
|
|
|
|
|
it('should snap to minimum bounds', inject(function(elementRegistry, resize, dragging) {
|
|
|
|
|
|
|
|
var textAnnotation = elementRegistry.get('TextAnnotation');
|
|
|
|
|
|
|
|
resize.activate(canvasEvent({ x: 0, y: 0 }), textAnnotation, 'se');
|
|
|
|
dragging.move(canvasEvent({ x: -400, y: -400 }));
|
|
|
|
dragging.end();
|
|
|
|
|
|
|
|
expect(textAnnotation.width).to.equal(50);
|
|
|
|
expect(textAnnotation.height).to.equal(30);
|
|
|
|
}));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2017-02-13 12:47:00 +00:00
|
|
|
|
2015-09-07 13:07:09 +00:00
|
|
|
describe('labels', function() {
|
|
|
|
|
|
|
|
var diagramXML = require('./BpmnSnapping.labels.bpmn');
|
|
|
|
|
|
|
|
beforeEach(bootstrapModeler(diagramXML, { modules: testModules }));
|
|
|
|
|
|
|
|
it('should snap to start events', inject(function(canvas, elementRegistry, move, dragging) {
|
|
|
|
|
|
|
|
var label = elementRegistry.get('StartEvent_1_label'),
|
|
|
|
rootElement = canvas.getRootElement();
|
|
|
|
|
|
|
|
var originalPosition = { x: label.x, y: label.y };
|
|
|
|
|
2017-02-13 12:47:00 +00:00
|
|
|
move.start(canvasEvent({ x: label.x + 3, y: label.y + 3 }), label);
|
2015-09-07 13:07:09 +00:00
|
|
|
|
|
|
|
dragging.hover({
|
|
|
|
element: rootElement,
|
|
|
|
gfx: elementRegistry.getGraphics(rootElement)
|
|
|
|
});
|
|
|
|
|
2017-02-13 12:47:00 +00:00
|
|
|
dragging.move(canvasEvent({ x: label.x + 4, y: label.y + 40 }));
|
|
|
|
dragging.move(canvasEvent({ x: label.x + 4, y: label.y + 40 }));
|
2015-09-07 13:07:09 +00:00
|
|
|
|
|
|
|
dragging.end();
|
|
|
|
|
2017-02-13 12:47:00 +00:00
|
|
|
expect(label.x).to.be.within(originalPosition.x, originalPosition.x + 1);
|
2015-09-07 13:07:09 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('should snap to boundary events', inject(function(canvas, elementRegistry, move, dragging) {
|
|
|
|
|
|
|
|
var label = elementRegistry.get('BoundaryEvent_1_label'),
|
|
|
|
rootElement = canvas.getRootElement();
|
|
|
|
|
|
|
|
var originalPosition = { x: label.x, y: label.y };
|
|
|
|
|
2017-02-13 12:47:00 +00:00
|
|
|
move.start(canvasEvent({ x: label.x + 2, y: label.y + 2 }), label);
|
2015-09-07 13:07:09 +00:00
|
|
|
|
|
|
|
dragging.hover({
|
|
|
|
element: rootElement,
|
|
|
|
gfx: elementRegistry.getGraphics(rootElement)
|
|
|
|
});
|
|
|
|
|
2017-02-13 12:47:00 +00:00
|
|
|
dragging.move(canvasEvent({ x: label.x + 4, y: label.y + 40 }));
|
|
|
|
dragging.move(canvasEvent({ x: label.x + 4, y: label.y + 40 }));
|
2015-09-07 13:07:09 +00:00
|
|
|
|
|
|
|
dragging.end();
|
|
|
|
|
2017-02-13 12:47:00 +00:00
|
|
|
expect(label.x).to.be.within(originalPosition.x, originalPosition.x + 1);
|
2015-09-07 13:07:09 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('should snap to siblings', inject(function(canvas, elementRegistry, move, dragging) {
|
|
|
|
|
|
|
|
var label = elementRegistry.get('BoundaryEvent_1_label'),
|
2016-10-26 09:26:58 +00:00
|
|
|
task = elementRegistry.get('Task_1'),
|
2015-09-07 13:07:09 +00:00
|
|
|
rootElement = canvas.getRootElement();
|
|
|
|
|
2017-02-13 12:47:00 +00:00
|
|
|
move.start(canvasEvent({ x: label.x + 2, y: label.y + 2 }), label);
|
2015-09-07 13:07:09 +00:00
|
|
|
|
|
|
|
dragging.hover({
|
|
|
|
element: rootElement,
|
|
|
|
gfx: elementRegistry.getGraphics(rootElement)
|
|
|
|
});
|
|
|
|
|
|
|
|
dragging.move(canvasEvent({ x: label.x-23, y: label.y+40 }));
|
|
|
|
dragging.move(canvasEvent({ x: label.x-23, y: label.y+40 }));
|
|
|
|
|
|
|
|
dragging.end();
|
|
|
|
|
2016-10-26 09:26:58 +00:00
|
|
|
var labelCenterX = label.x + Math.ceil(label.width / 2),
|
|
|
|
taskCenterX = task.x + Math.ceil(task.width / 2);
|
|
|
|
|
|
|
|
expect(labelCenterX).to.equal(taskCenterX);
|
2015-09-07 13:07:09 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2016-07-13 10:57:18 +00:00
|
|
|
|
|
|
|
describe('on connect', function() {
|
|
|
|
|
|
|
|
var diagramXML = require('./BpmnSnapping.connect.bpmn');
|
|
|
|
|
|
|
|
beforeEach(bootstrapModeler(diagramXML, { modules: testModules }));
|
|
|
|
|
|
|
|
|
2018-08-22 12:25:05 +00:00
|
|
|
describe('sequence flow', function() {
|
2016-07-13 10:57:18 +00:00
|
|
|
|
2018-08-22 12:25:05 +00:00
|
|
|
it('should snap on global connect', inject(function(connect, dragging, elementRegistry) {
|
2016-07-13 10:57:18 +00:00
|
|
|
|
2018-08-22 12:25:05 +00:00
|
|
|
// given
|
|
|
|
var startEvent = elementRegistry.get('StartEvent_1'),
|
|
|
|
task = elementRegistry.get('Task_1');
|
2016-07-13 10:57:18 +00:00
|
|
|
|
2018-08-22 12:25:05 +00:00
|
|
|
var mid = {
|
|
|
|
x: startEvent.x + startEvent.width / 2,
|
|
|
|
y: startEvent.y + startEvent.height / 2
|
|
|
|
};
|
2016-07-13 10:57:18 +00:00
|
|
|
|
2018-08-22 12:25:05 +00:00
|
|
|
// when
|
|
|
|
connect.start(canvasEvent({ x: mid.x + 10, y: mid.y + 10 }), startEvent);
|
2016-07-13 10:57:18 +00:00
|
|
|
|
2018-08-22 12:25:05 +00:00
|
|
|
dragging.hover({
|
|
|
|
element: task,
|
|
|
|
gfx: elementRegistry.getGraphics(task)
|
|
|
|
});
|
2016-07-13 10:57:18 +00:00
|
|
|
|
2018-08-22 12:25:05 +00:00
|
|
|
dragging.move(canvasEvent({
|
|
|
|
x: task.x + task.width / 2,
|
|
|
|
y: task.y + task.height / 2
|
|
|
|
}));
|
2016-07-13 10:57:18 +00:00
|
|
|
|
2018-08-22 12:25:05 +00:00
|
|
|
dragging.end();
|
|
|
|
|
|
|
|
// then
|
|
|
|
var expected = [
|
2016-07-13 10:57:18 +00:00
|
|
|
{
|
2018-08-22 12:25:05 +00:00
|
|
|
original:
|
|
|
|
{
|
|
|
|
x: startEvent.x + startEvent.width / 2,
|
|
|
|
y: startEvent.y + startEvent.height / 2
|
|
|
|
},
|
|
|
|
x: startEvent.x + startEvent.width,
|
2016-07-13 10:57:18 +00:00
|
|
|
y: startEvent.y + startEvent.height / 2
|
|
|
|
},
|
|
|
|
{
|
2018-08-22 12:25:05 +00:00
|
|
|
original:
|
|
|
|
{
|
|
|
|
x: task.x + task.width / 2,
|
|
|
|
y: task.y + task.height / 2
|
|
|
|
},
|
|
|
|
x: task.x,
|
2016-07-13 10:57:18 +00:00
|
|
|
y: task.y + task.height / 2
|
2018-08-22 12:25:05 +00:00
|
|
|
}
|
|
|
|
];
|
2016-07-13 10:57:18 +00:00
|
|
|
|
2018-08-22 12:25:05 +00:00
|
|
|
expect(startEvent.outgoing[0].waypoints).to.eql(expected);
|
2016-07-13 10:57:18 +00:00
|
|
|
|
2018-08-22 12:25:05 +00:00
|
|
|
}));
|
2016-07-13 10:57:18 +00:00
|
|
|
|
|
|
|
|
2018-08-22 12:25:05 +00:00
|
|
|
it('should snap on connect', inject(function(connect, dragging, elementRegistry) {
|
2016-07-13 10:57:18 +00:00
|
|
|
|
2018-08-22 12:25:05 +00:00
|
|
|
// given
|
|
|
|
var startEvent = elementRegistry.get('StartEvent_1'),
|
|
|
|
task = elementRegistry.get('Task_1');
|
2016-07-13 10:57:18 +00:00
|
|
|
|
2018-08-22 12:25:05 +00:00
|
|
|
var mid = { x: task.x + task.width / 2, y: task.y + task.height / 2 };
|
2016-07-13 10:57:18 +00:00
|
|
|
|
2018-08-22 12:25:05 +00:00
|
|
|
// when
|
|
|
|
connect.start(canvasEvent({ x: 0, y: 0 }), startEvent);
|
2016-07-13 10:57:18 +00:00
|
|
|
|
2018-08-22 12:25:05 +00:00
|
|
|
dragging.hover({
|
|
|
|
element: task,
|
|
|
|
gfx: elementRegistry.getGraphics(task)
|
|
|
|
});
|
2016-07-13 10:57:18 +00:00
|
|
|
|
2018-08-22 12:25:05 +00:00
|
|
|
dragging.move(canvasEvent({ x: mid.x + 10, y: mid.y + 10 }));
|
2016-07-13 10:57:18 +00:00
|
|
|
|
2018-08-22 12:25:05 +00:00
|
|
|
dragging.end();
|
2016-07-13 10:57:18 +00:00
|
|
|
|
2018-08-22 12:25:05 +00:00
|
|
|
// then
|
|
|
|
var expected = [
|
2016-07-13 10:57:18 +00:00
|
|
|
{
|
2018-08-22 12:25:05 +00:00
|
|
|
original:
|
|
|
|
{
|
|
|
|
x: startEvent.x + startEvent.width / 2,
|
|
|
|
y: startEvent.y + startEvent.height / 2
|
|
|
|
},
|
|
|
|
x: startEvent.x + startEvent.width,
|
2016-07-13 10:57:18 +00:00
|
|
|
y: startEvent.y + startEvent.height / 2
|
|
|
|
},
|
|
|
|
{
|
2018-08-22 12:25:05 +00:00
|
|
|
original:
|
|
|
|
{
|
|
|
|
x: task.x + task.width / 2,
|
|
|
|
y: task.y + task.height / 2
|
|
|
|
},
|
|
|
|
x: task.x,
|
2016-07-13 10:57:18 +00:00
|
|
|
y: task.y + task.height / 2
|
2018-08-22 12:25:05 +00:00
|
|
|
}
|
|
|
|
];
|
2016-07-13 10:57:18 +00:00
|
|
|
|
2018-08-22 12:25:05 +00:00
|
|
|
expect(startEvent.outgoing[0].waypoints).to.eql(expected);
|
2016-07-13 10:57:18 +00:00
|
|
|
|
2018-08-22 12:25:05 +00:00
|
|
|
}));
|
2016-07-13 10:57:18 +00:00
|
|
|
|
2018-08-22 12:25:05 +00:00
|
|
|
});
|
2016-07-13 10:57:18 +00:00
|
|
|
|
2018-08-22 12:25:05 +00:00
|
|
|
|
|
|
|
it('should snap data output association', inject(function(connect, dragging, elementRegistry) {
|
2018-04-11 09:53:22 +00:00
|
|
|
|
|
|
|
// given
|
|
|
|
var startEvent = elementRegistry.get('StartEvent_1'),
|
|
|
|
dataObjectReference = elementRegistry.get('DataObjectReference_1');
|
|
|
|
|
|
|
|
var mid = { x: dataObjectReference.x + dataObjectReference.width / 2, y: dataObjectReference.y + dataObjectReference.height / 2 };
|
|
|
|
|
|
|
|
// when
|
|
|
|
connect.start(canvasEvent({ x: 0, y: 0 }), startEvent);
|
|
|
|
|
|
|
|
dragging.hover({
|
|
|
|
element: dataObjectReference,
|
|
|
|
gfx: elementRegistry.getGraphics(dataObjectReference)
|
|
|
|
});
|
|
|
|
|
|
|
|
dragging.move(canvasEvent({ x: mid.x + 10, y: mid.y + 10 }));
|
|
|
|
|
|
|
|
dragging.end();
|
|
|
|
|
|
|
|
// then
|
|
|
|
var expected = [
|
|
|
|
{
|
|
|
|
original:
|
|
|
|
{
|
|
|
|
x: startEvent.x + startEvent.width / 2,
|
|
|
|
y: startEvent.y + startEvent.height / 2
|
|
|
|
},
|
|
|
|
x: startEvent.x + startEvent.width,
|
|
|
|
y: startEvent.y + startEvent.height / 2
|
|
|
|
},
|
|
|
|
{
|
|
|
|
original:
|
|
|
|
{
|
|
|
|
x: dataObjectReference.x + dataObjectReference.width / 2,
|
|
|
|
y: dataObjectReference.y + dataObjectReference.height / 2
|
|
|
|
},
|
|
|
|
x: dataObjectReference.x,
|
|
|
|
y: dataObjectReference.y + dataObjectReference.height / 2
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
expect(startEvent.outgoing[0].waypoints).to.eql(expected);
|
|
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
2018-08-22 12:25:05 +00:00
|
|
|
it('should snap data input association', inject(function(connect, dragging, elementRegistry) {
|
2018-04-11 09:53:22 +00:00
|
|
|
|
|
|
|
// given
|
|
|
|
var dataStoreReference = elementRegistry.get('DataStoreReference_1'),
|
|
|
|
task = elementRegistry.get('Task_2');
|
|
|
|
|
|
|
|
var mid = { x: task.x + task.width / 2, y: task.y + task.height / 2 };
|
|
|
|
|
|
|
|
// when
|
|
|
|
connect.start(canvasEvent({ x: 0, y: 0 }), dataStoreReference);
|
|
|
|
|
|
|
|
dragging.hover({
|
|
|
|
element: task,
|
|
|
|
gfx: elementRegistry.getGraphics(task)
|
|
|
|
});
|
|
|
|
|
|
|
|
dragging.move(canvasEvent({ x: mid.x + 10, y: mid.y + 10 }));
|
|
|
|
|
|
|
|
dragging.end();
|
|
|
|
|
|
|
|
// then
|
|
|
|
var expected = [
|
|
|
|
{
|
|
|
|
original:
|
|
|
|
{
|
|
|
|
x: dataStoreReference.x + dataStoreReference.width / 2,
|
|
|
|
y: dataStoreReference.y + dataStoreReference.height / 2
|
|
|
|
},
|
|
|
|
x: dataStoreReference.x + dataStoreReference.width,
|
|
|
|
y: dataStoreReference.y + dataStoreReference.height / 2
|
|
|
|
},
|
|
|
|
{
|
|
|
|
original:
|
|
|
|
{
|
|
|
|
x: task.x + task.width / 2,
|
|
|
|
y: task.y + task.height / 2
|
|
|
|
},
|
|
|
|
x: task.x,
|
|
|
|
y: task.y + task.height / 2
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
expect(dataStoreReference.outgoing[0].waypoints).to.eql(expected);
|
|
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
2018-08-22 12:25:05 +00:00
|
|
|
describe('message flow', function() {
|
2016-07-13 10:57:18 +00:00
|
|
|
|
2018-08-22 12:25:05 +00:00
|
|
|
it('should NOT snap Task -> Task on global connect', inject(function(connect, dragging, elementRegistry) {
|
2016-07-13 10:57:18 +00:00
|
|
|
|
2018-08-22 12:25:05 +00:00
|
|
|
// given
|
|
|
|
var task1 = elementRegistry.get('Task_1'),
|
|
|
|
task2 = elementRegistry.get('Task_2');
|
2016-07-13 10:57:18 +00:00
|
|
|
|
2018-08-22 12:25:05 +00:00
|
|
|
var task1Mid = { x: task1.x + task1.width / 2, y: task1.y + task1.height / 2 },
|
|
|
|
task2Mid = { x: task2.x + task2.width / 2, y: task2.y + task2.height / 2 };
|
2016-07-13 10:57:18 +00:00
|
|
|
|
2018-08-22 12:25:05 +00:00
|
|
|
// when
|
|
|
|
connect.start(null, task1, { x: 320, y: task1Mid.y + 20 });
|
|
|
|
|
|
|
|
dragging.hover({
|
|
|
|
element: task2,
|
|
|
|
gfx: elementRegistry.getGraphics(task2)
|
|
|
|
});
|
|
|
|
|
|
|
|
dragging.move(canvasEvent({
|
|
|
|
x: 320,
|
|
|
|
y: task2Mid.y - 20
|
|
|
|
}));
|
|
|
|
|
|
|
|
dragging.end();
|
|
|
|
|
|
|
|
// then
|
|
|
|
var expected = [
|
|
|
|
{
|
|
|
|
original:
|
|
|
|
{
|
|
|
|
x: 320,
|
|
|
|
y: task1Mid.y + 20
|
|
|
|
},
|
|
|
|
x: 320,
|
|
|
|
y: task1.y + task1.height
|
|
|
|
},
|
|
|
|
{
|
|
|
|
original:
|
|
|
|
{
|
|
|
|
x: 320,
|
|
|
|
y: task2Mid.y - 20
|
|
|
|
},
|
|
|
|
x: 320,
|
|
|
|
y: task2.y
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
expect(task1.outgoing[0].waypoints).to.eql(expected);
|
2016-07-13 10:57:18 +00:00
|
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
2018-08-22 12:25:05 +00:00
|
|
|
it('should NOT snap Task -> Task on connect', inject(function(connect, dragging, elementRegistry) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var task1 = elementRegistry.get('Task_1'),
|
|
|
|
task2 = elementRegistry.get('Task_2');
|
|
|
|
|
|
|
|
var task1Mid = { x: task1.x + task1.width / 2, y: task1.y + task1.height / 2 },
|
|
|
|
task2Mid = { x: task2.x + task2.width / 2, y: task2.y + task2.height / 2 };
|
|
|
|
|
|
|
|
// when
|
|
|
|
connect.start(canvasEvent({ x: 0, y: 0 }), task1);
|
|
|
|
|
|
|
|
dragging.hover({
|
|
|
|
element: task2,
|
|
|
|
gfx: elementRegistry.getGraphics(task2)
|
|
|
|
});
|
|
|
|
|
|
|
|
dragging.move(canvasEvent({
|
|
|
|
x: task2Mid.x + 20,
|
|
|
|
y: task2Mid.y - 20
|
|
|
|
}));
|
|
|
|
|
|
|
|
dragging.end();
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(task1.outgoing[0].waypoints.length).to.equal(4);
|
|
|
|
|
|
|
|
expect(task1.outgoing[0].waypoints[0]).to.eql({
|
2016-07-13 10:57:18 +00:00
|
|
|
original:
|
|
|
|
{
|
2018-08-22 12:25:05 +00:00
|
|
|
x: task1Mid.x,
|
|
|
|
y: task1Mid.y
|
2016-07-13 10:57:18 +00:00
|
|
|
},
|
2018-08-22 12:25:05 +00:00
|
|
|
x: task1Mid.x,
|
2016-07-13 10:57:18 +00:00
|
|
|
y: task1.y + task1.height
|
2018-08-22 12:25:05 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
expect(task1.outgoing[0].waypoints[3]).to.eql({
|
2016-07-13 10:57:18 +00:00
|
|
|
original:
|
|
|
|
{
|
2018-08-22 12:25:05 +00:00
|
|
|
x: task2Mid.x + 20,
|
2016-07-13 10:57:18 +00:00
|
|
|
y: task2Mid.y - 20
|
|
|
|
},
|
2018-08-22 12:25:05 +00:00
|
|
|
x: task2Mid.x + 20,
|
2016-07-13 10:57:18 +00:00
|
|
|
y: task2.y
|
2018-08-22 12:25:05 +00:00
|
|
|
});
|
2016-07-13 10:57:18 +00:00
|
|
|
|
2018-08-22 12:25:05 +00:00
|
|
|
}));
|
2016-07-13 10:57:18 +00:00
|
|
|
|
|
|
|
|
2018-08-22 12:25:05 +00:00
|
|
|
it('should snap Task -> Event on connect', inject(function(connect, dragging, elementRegistry) {
|
2016-07-13 10:57:18 +00:00
|
|
|
|
2018-08-22 12:25:05 +00:00
|
|
|
// given
|
|
|
|
var task = elementRegistry.get('Task_2'),
|
|
|
|
event = elementRegistry.get('StartEvent_1');
|
2016-07-13 10:57:18 +00:00
|
|
|
|
2018-08-22 12:25:05 +00:00
|
|
|
var taskMid = { x: task.x + task.width / 2, y: task.y + task.height / 2 },
|
|
|
|
eventMid = { x: event.x + event.width / 2, y: event.y + event.height / 2 };
|
2016-07-13 10:57:18 +00:00
|
|
|
|
2018-08-22 12:25:05 +00:00
|
|
|
// when
|
|
|
|
connect.start(canvasEvent({ x: 0, y: 0 }), task);
|
2016-07-13 10:57:18 +00:00
|
|
|
|
2018-08-22 12:25:05 +00:00
|
|
|
dragging.hover({
|
|
|
|
element: event,
|
|
|
|
gfx: elementRegistry.getGraphics(event)
|
|
|
|
});
|
2016-07-13 10:57:18 +00:00
|
|
|
|
2018-08-22 12:25:05 +00:00
|
|
|
dragging.move(canvasEvent({
|
|
|
|
x: eventMid.x + 10,
|
|
|
|
y: eventMid.y - 10
|
|
|
|
}));
|
|
|
|
|
|
|
|
dragging.end();
|
|
|
|
|
|
|
|
// then
|
|
|
|
var connection = task.outgoing[0];
|
|
|
|
|
|
|
|
expect(connection.waypoints.length).to.equal(4);
|
|
|
|
|
|
|
|
expect(connection.waypoints[0]).to.eql({
|
|
|
|
original:
|
|
|
|
{
|
|
|
|
x: taskMid.x,
|
|
|
|
y: taskMid.y
|
|
|
|
},
|
|
|
|
x: taskMid.x,
|
|
|
|
y: task.y
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(connection.waypoints[3]).to.eql({
|
|
|
|
original:
|
|
|
|
{
|
|
|
|
x: eventMid.x,
|
|
|
|
y: eventMid.y
|
|
|
|
},
|
|
|
|
x: eventMid.x,
|
|
|
|
y: event.y + event.height
|
|
|
|
});
|
2016-07-13 10:57:18 +00:00
|
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
2018-08-22 12:25:05 +00:00
|
|
|
it('should snap IntermediateEvent -> Task on global connect', inject(function(connect, dragging, elementRegistry) {
|
2016-07-13 10:57:18 +00:00
|
|
|
|
2018-08-22 12:25:05 +00:00
|
|
|
// given
|
|
|
|
var event = elementRegistry.get('IntermediateEvent'),
|
|
|
|
task = elementRegistry.get('Task_1');
|
2016-07-13 10:57:18 +00:00
|
|
|
|
2018-08-22 12:25:05 +00:00
|
|
|
var eventMid = { x: event.x + event.width / 2, y: event.y + event.height / 2 },
|
|
|
|
taskMid = { x: task.x + task.width / 2, y: task.y + task.height / 2 };
|
2016-07-13 10:57:18 +00:00
|
|
|
|
2018-08-22 12:25:05 +00:00
|
|
|
// when
|
|
|
|
connect.start(null, event, { x: eventMid.x - 10, y: eventMid.y + 10 });
|
|
|
|
|
|
|
|
dragging.hover({
|
|
|
|
element: task,
|
|
|
|
gfx: elementRegistry.getGraphics(task)
|
|
|
|
});
|
|
|
|
|
|
|
|
dragging.move(canvasEvent({
|
|
|
|
x: taskMid.x + 10,
|
|
|
|
y: taskMid.y - 10
|
|
|
|
}));
|
|
|
|
|
|
|
|
dragging.end();
|
|
|
|
|
|
|
|
// then
|
|
|
|
var connection = event.outgoing[0];
|
|
|
|
|
|
|
|
expect(connection.waypoints.length).to.equal(4);
|
|
|
|
|
|
|
|
expect(connection.waypoints[0]).to.eql({
|
|
|
|
original:
|
|
|
|
{
|
|
|
|
x: eventMid.x,
|
|
|
|
y: eventMid.y
|
|
|
|
},
|
|
|
|
x: eventMid.x,
|
|
|
|
y: event.y
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(connection.waypoints[3]).to.eql({
|
|
|
|
original:
|
|
|
|
{
|
|
|
|
x: taskMid.x + 10,
|
|
|
|
y: taskMid.y - 10
|
|
|
|
},
|
|
|
|
x: taskMid.x + 10,
|
|
|
|
y: task.y + task.height
|
|
|
|
});
|
|
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
});
|
2016-07-13 10:57:18 +00:00
|
|
|
|
|
|
|
});
|
|
|
|
|
2015-05-28 07:30:50 +00:00
|
|
|
});
|