2015-04-15 07:06:34 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var TestHelper = require('../../../TestHelper');
|
|
|
|
|
|
|
|
/* global bootstrapModeler, inject */
|
|
|
|
|
2015-08-24 13:31:47 +00:00
|
|
|
var canvasEvent = require('../../../util/MockEvents').createCanvasEvent;
|
2015-04-15 07:06:34 +00:00
|
|
|
|
|
|
|
var coreModule = require('../../../../lib/core'),
|
|
|
|
snappingModule = require('../../../../lib/features/snapping'),
|
|
|
|
modelingModule = require('../../../../lib/features/modeling'),
|
|
|
|
createModule = require('diagram-js/lib/features/create'),
|
2015-04-28 11:24:55 +00:00
|
|
|
resizeModule = require('diagram-js/lib/features/resize'),
|
2015-07-13 08:37:43 +00:00
|
|
|
moveModule = require('diagram-js/lib/features/move'),
|
2015-08-19 15:16:21 +00:00
|
|
|
rulesModule = require('../../../../lib/features/rules');
|
2015-04-15 07:06:34 +00:00
|
|
|
|
|
|
|
describe('features/snapping - BpmnSnapping', function() {
|
|
|
|
|
2015-07-13 08:37:43 +00:00
|
|
|
var testModules = [ coreModule, snappingModule, modelingModule, createModule, rulesModule, moveModule ];
|
2015-04-15 07:06:34 +00:00
|
|
|
|
2015-07-13 08:37:43 +00:00
|
|
|
describe('on Boundary Events', function() {
|
|
|
|
|
|
|
|
var diagramXML = require('../../../fixtures/bpmn/collaboration/process.bpmn');
|
|
|
|
|
|
|
|
beforeEach(bootstrapModeler(diagramXML, { modules: testModules }));
|
|
|
|
|
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({
|
|
|
|
type: 'bpmn:IntermediateThrowEvent',
|
|
|
|
});
|
|
|
|
|
|
|
|
dragging.setOptions({ manual: true });
|
|
|
|
}));
|
|
|
|
|
|
|
|
afterEach(inject(function(dragging) {
|
|
|
|
dragging.setOptions({ manual: false });
|
|
|
|
}));
|
|
|
|
|
|
|
|
it('should snap on create to the bottom',
|
|
|
|
inject(function(canvas, create, dragging, elementRegistry) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var taskGfx = canvas.getGraphics(task);
|
|
|
|
|
|
|
|
// when
|
2015-08-24 13:31:47 +00:00
|
|
|
create.start(canvasEvent({ x: 0, y: 0 }), intermediateThrowEvent);
|
2015-07-13 08:37:43 +00:00
|
|
|
|
|
|
|
dragging.hover({ element: task, gfx: taskGfx });
|
|
|
|
|
2015-08-24 13:31:47 +00:00
|
|
|
dragging.move(canvasEvent({ x: 382, y: 170 }));
|
2015-07-13 08:37:43 +00:00
|
|
|
dragging.end();
|
|
|
|
|
|
|
|
var boundaryEvent = elementRegistry.get(task.attachers[0].id);
|
|
|
|
|
|
|
|
// then
|
2015-09-02 12:15:45 +00:00
|
|
|
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',
|
|
|
|
inject(function(canvas, create, dragging, elementRegistry) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var taskGfx = canvas.getGraphics(task);
|
|
|
|
|
|
|
|
// when
|
2015-08-24 13:31:47 +00:00
|
|
|
create.start(canvasEvent({ x: 0, y: 0 }), intermediateThrowEvent);
|
2015-07-13 08:37:43 +00:00
|
|
|
|
|
|
|
dragging.hover({ element: task, gfx: taskGfx });
|
|
|
|
|
2015-08-24 13:31:47 +00:00
|
|
|
dragging.move(canvasEvent({ x: 382, y: 115 }));
|
2015-07-13 08:37:43 +00:00
|
|
|
dragging.end();
|
|
|
|
|
|
|
|
var boundaryEvent = elementRegistry.get(task.attachers[0].id);
|
|
|
|
|
|
|
|
// then
|
2015-09-02 12:15:45 +00:00
|
|
|
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
|
|
|
|
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
|
|
|
|
2015-06-10 13:58:52 +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',
|
|
|
|
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: 65, y: 65 }));
|
|
|
|
dragging.end(canvasEvent({ x: 65, y: 65 }));
|
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
|
|
|
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',
|
|
|
|
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
|
|
|
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
|
|
|
|
2015-06-10 13:58:52 +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
|
|
|
|
2015-06-10 13:58:52 +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-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-05-05 11:29:28 +00:00
|
|
|
|
2015-06-10 13:58:52 +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-08-24 14:59:13 +00:00
|
|
|
var testResizeModules = [ coreModule, resizeModule, 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-07-15 15:22:19 +00:00
|
|
|
expect(participant.width).to.equal(497);
|
|
|
|
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);
|
|
|
|
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);
|
|
|
|
expect(participant.height).to.equal(150);
|
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);
|
|
|
|
expect(participant.height).to.equal(150);
|
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-07-15 15:22:19 +00:00
|
|
|
expect(participant.width).to.equal(320);
|
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');
|
|
|
|
|
|
|
|
var testResizeModules = [ coreModule, resizeModule, rulesModule, snappingModule ];
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
expect(participant.width).to.equal(600);
|
2015-08-25 13:45:44 +00:00
|
|
|
expect(participant.height).to.equal(254);
|
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();
|
|
|
|
|
|
|
|
expect(lane.width).to.equal(570);
|
|
|
|
expect(lane.height).to.equal(118);
|
|
|
|
}));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
describe('on SubProcess resize', function() {
|
|
|
|
|
2015-05-05 11:29:28 +00:00
|
|
|
|
2015-08-24 14:59:13 +00:00
|
|
|
var diagramXML = require('./BpmnSnapping.subProcess-resize.bpmn');
|
2015-04-28 11:24:55 +00:00
|
|
|
|
2015-08-24 14:59:13 +00:00
|
|
|
var testResizeModules = [ coreModule, resizeModule, rulesModule, snappingModule ];
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
2015-08-24 14:59:13 +00:00
|
|
|
describe('on TextAnnotation resize', function() {
|
2015-04-28 11:24:55 +00:00
|
|
|
|
|
|
|
|
2015-08-24 14:59:13 +00:00
|
|
|
var diagramXML = require('./BpmnSnapping.textAnnotation-resize.bpmn');
|
|
|
|
|
|
|
|
var testResizeModules = [ coreModule, resizeModule, rulesModule, snappingModule ];
|
|
|
|
|
|
|
|
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 a TextAnnotation to minimum bounds', inject(function(elementRegistry, resize, dragging) {
|
2015-05-05 11:29:28 +00:00
|
|
|
|
2015-08-24 14:59:13 +00:00
|
|
|
var textAnnotation = elementRegistry.get('TextAnnotation');
|
2015-04-28 11:24:55 +00:00
|
|
|
|
2015-08-24 14:59:13 +00:00
|
|
|
resize.activate(canvasEvent({ x: 0, y: 0 }), textAnnotation, '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(textAnnotation.width).to.equal(50);
|
|
|
|
expect(textAnnotation.height).to.equal(50);
|
2015-04-28 11:24:55 +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 };
|
|
|
|
|
|
|
|
move.start(canvasEvent({ x: label.x+2, y: label.y+2 }), label);
|
|
|
|
|
|
|
|
dragging.hover({
|
|
|
|
element: rootElement,
|
|
|
|
gfx: elementRegistry.getGraphics(rootElement)
|
|
|
|
});
|
|
|
|
|
|
|
|
dragging.move(canvasEvent({ x: label.x+4, y: label.y+40 }));
|
|
|
|
dragging.move(canvasEvent({ x: label.x+4, y: label.y+40 }));
|
|
|
|
|
|
|
|
dragging.end();
|
|
|
|
|
|
|
|
expect(label.x).to.equal(originalPosition.x);
|
|
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
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 };
|
|
|
|
|
|
|
|
move.start(canvasEvent({ x: label.x+2, y: label.y+2 }), label);
|
|
|
|
|
|
|
|
dragging.hover({
|
|
|
|
element: rootElement,
|
|
|
|
gfx: elementRegistry.getGraphics(rootElement)
|
|
|
|
});
|
|
|
|
|
|
|
|
dragging.move(canvasEvent({ x: label.x+4, y: label.y+40 }));
|
|
|
|
dragging.move(canvasEvent({ x: label.x+4, y: label.y+40 }));
|
|
|
|
|
|
|
|
dragging.end();
|
|
|
|
|
|
|
|
expect(label.x).to.equal(originalPosition.x);
|
|
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('should snap to siblings', inject(function(canvas, elementRegistry, move, dragging) {
|
|
|
|
|
|
|
|
var label = elementRegistry.get('BoundaryEvent_1_label'),
|
|
|
|
rootElement = canvas.getRootElement();
|
|
|
|
|
|
|
|
move.start(canvasEvent({ x: label.x+2, y: label.y+2 }), label);
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
expect(label.x).to.equal(161);
|
|
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2015-05-28 07:30:50 +00:00
|
|
|
});
|