mirror of
https://github.com/sartography/bpmn-js.git
synced 2025-02-18 11:56:30 +00:00
parent
0b8f0465f0
commit
e78e4c94a3
@ -9,3 +9,7 @@ TestHelper.insertCSS('bpmn-embedded.css', require('../assets/bpmn-font/css/bpmn-
|
|||||||
TestHelper.insertCSS('diagram-js-testing.css',
|
TestHelper.insertCSS('diagram-js-testing.css',
|
||||||
'.test-container .result { height: 500px; }' + '.test-container > div'
|
'.test-container .result { height: 500px; }' + '.test-container > div'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// add suite specific matchers
|
||||||
|
global.chai.use(require('./matchers/Bounds'));
|
132
test/matchers/Bounds.js
Normal file
132
test/matchers/Bounds.js
Normal file
@ -0,0 +1,132 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
var pick = require('lodash/object/pick');
|
||||||
|
|
||||||
|
|
||||||
|
var BOUNDS_ATTRS = [ 'x', 'y', 'width', 'height' ],
|
||||||
|
POSITION_ATTRS = [ 'x', 'y' ],
|
||||||
|
DIMENSION_ATTRS = [ 'width', 'height' ];
|
||||||
|
|
||||||
|
function getBounds(s) {
|
||||||
|
|
||||||
|
if ('bounds' in s) {
|
||||||
|
s = s.bounds;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TLBR object
|
||||||
|
if ('top' in s) {
|
||||||
|
return {
|
||||||
|
x: s.left,
|
||||||
|
y: s.top,
|
||||||
|
width: s.right - s.left,
|
||||||
|
height: s.bottom - s.top
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// { x, y, width, height } object
|
||||||
|
else {
|
||||||
|
return pick(s, BOUNDS_ATTRS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
module.exports = function(chai, utils) {
|
||||||
|
|
||||||
|
var Assertion = chai.Assertion;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A simple bounds matcher, that verifies an element
|
||||||
|
* has the correct { x, y, width, height }.
|
||||||
|
*
|
||||||
|
* Unwraps `element.bounds` (BPMNDI) if present.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
*
|
||||||
|
* expect(di.label).to.have.bounds({ x: 100, y: 100, width: 10, height: 20 });
|
||||||
|
* expect(shape).to.have.bounds({ top: 100, left: 0, right: 200, bottom: 50 });
|
||||||
|
*
|
||||||
|
* @param {Bounds|TLBR} exp
|
||||||
|
*/
|
||||||
|
Assertion.addMethod('bounds', function(exp) {
|
||||||
|
var obj = this._obj;
|
||||||
|
|
||||||
|
var objectBounds = getBounds(obj),
|
||||||
|
expectedBounds = getBounds(exp);
|
||||||
|
|
||||||
|
BOUNDS_ATTRS.forEach(function(attr) {
|
||||||
|
var bounds = new Assertion(objectBounds[attr]);
|
||||||
|
|
||||||
|
bounds.assert(
|
||||||
|
objectBounds[attr] == expectedBounds[attr],
|
||||||
|
'expected <' + obj.id + '#' + attr + '> to equal #{exp} but got #{act}',
|
||||||
|
'expected <' + obj.id + '#' + attr + '> to not equal #{exp}',
|
||||||
|
expectedBounds[attr],
|
||||||
|
objectBounds[attr]
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A simple dimensions matcher, that verifies an element
|
||||||
|
* has the correct { width, height }.
|
||||||
|
*
|
||||||
|
* Unwraps `element.bounds` (BPMNDI) if present.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
*
|
||||||
|
* expect(di.label).to.have.dimensions({ width: 10, height: 20 });
|
||||||
|
*
|
||||||
|
* @param {Dimensions} exp
|
||||||
|
*/
|
||||||
|
Assertion.addMethod('dimensions', function(exp) {
|
||||||
|
var obj = this._obj;
|
||||||
|
|
||||||
|
var objectBounds = getBounds(obj),
|
||||||
|
expectedBounds = getBounds(exp);
|
||||||
|
|
||||||
|
DIMENSION_ATTRS.forEach(function(attr) {
|
||||||
|
var bounds = new Assertion(objectBounds[attr]);
|
||||||
|
|
||||||
|
bounds.assert(
|
||||||
|
objectBounds[attr] == expectedBounds[attr],
|
||||||
|
'expected <' + obj.id + '#' + attr + '> to equal #{exp} but got #{act}',
|
||||||
|
'expected <' + obj.id + '#' + attr + '> to not equal #{exp}',
|
||||||
|
expectedBounds[attr],
|
||||||
|
objectBounds[attr]
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A simple position matcher, that verifies an element
|
||||||
|
* has the correct { x, y }.
|
||||||
|
*
|
||||||
|
* Unwraps `element.bounds` (BPMNDI) if present.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
*
|
||||||
|
* expect(taskShape).to.have.position({ x: 100, y: 150 });
|
||||||
|
*
|
||||||
|
* @param {Point} exp
|
||||||
|
*/
|
||||||
|
Assertion.addMethod('position', function(exp) {
|
||||||
|
var obj = this._obj;
|
||||||
|
|
||||||
|
var objectBounds = getBounds(obj),
|
||||||
|
expectedBounds = getBounds(exp);
|
||||||
|
|
||||||
|
POSITION_ATTRS.forEach(function(attr) {
|
||||||
|
var bounds = new Assertion(objectBounds[attr]);
|
||||||
|
|
||||||
|
bounds.assert(
|
||||||
|
objectBounds[attr] == expectedBounds[attr],
|
||||||
|
'expected <' + obj.id + '#' + attr + '> to equal #{exp} but got #{act}',
|
||||||
|
'expected <' + obj.id + '#' + attr + '> to not equal #{exp}',
|
||||||
|
expectedBounds[attr],
|
||||||
|
objectBounds[attr]
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
};
|
@ -29,7 +29,7 @@ describe('features/auto-resize', function() {
|
|||||||
var task,
|
var task,
|
||||||
participant,
|
participant,
|
||||||
startEvent,
|
startEvent,
|
||||||
expectedBounds;
|
originalBounds;
|
||||||
|
|
||||||
beforeEach(bootstrapModeler(diagramXML, { modules: testModules }));
|
beforeEach(bootstrapModeler(diagramXML, { modules: testModules }));
|
||||||
|
|
||||||
@ -39,9 +39,9 @@ describe('features/auto-resize', function() {
|
|||||||
participant = elementRegistry.get('Participant_1');
|
participant = elementRegistry.get('Participant_1');
|
||||||
startEvent = elementRegistry.get('StartEvent_1');
|
startEvent = elementRegistry.get('StartEvent_1');
|
||||||
|
|
||||||
expectedBounds = getBounds(participant);
|
originalBounds = getBounds(participant);
|
||||||
|
|
||||||
expect(expectedBounds).to.eql({ x: 247, y: 160, width: 371, height: 178 });
|
expect(originalBounds).to.eql({ x: 247, y: 160, width: 371, height: 178 });
|
||||||
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@ -55,9 +55,9 @@ describe('features/auto-resize', function() {
|
|||||||
modeling.moveElements([task], { x: 100, y: 0 }, participant);
|
modeling.moveElements([task], { x: 100, y: 0 }, participant);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assign(expectedBounds, { width: 525 });
|
var expectedBounds = assign(originalBounds, { width: 525 });
|
||||||
|
|
||||||
expect(getBounds(participant)).to.eql(expectedBounds);
|
expect(participant).to.have.bounds(expectedBounds);
|
||||||
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@ -68,9 +68,9 @@ describe('features/auto-resize', function() {
|
|||||||
modeling.moveElements([task], { x: 0, y: -50 }, participant);
|
modeling.moveElements([task], { x: 0, y: -50 }, participant);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assign(expectedBounds, { y: 99, height: 239 });
|
var expectedBounds = assign(originalBounds, { y: 99, height: 239 });
|
||||||
|
|
||||||
expect(getBounds(participant)).to.eql(expectedBounds);
|
expect(participant).to.have.bounds(expectedBounds);
|
||||||
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@ -81,9 +81,9 @@ describe('features/auto-resize', function() {
|
|||||||
modeling.moveElements([task], { x: 0, y: 50 }, participant);
|
modeling.moveElements([task], { x: 0, y: 50 }, participant);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assign(expectedBounds, { height: 239 });
|
var expectedBounds = assign(originalBounds, { height: 239 });
|
||||||
|
|
||||||
expect(getBounds(participant)).to.eql(expectedBounds);
|
expect(participant).to.have.bounds(expectedBounds);
|
||||||
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@ -94,9 +94,9 @@ describe('features/auto-resize', function() {
|
|||||||
modeling.moveElements([startEvent], { x: -100, y: 0 }, participant);
|
modeling.moveElements([startEvent], { x: -100, y: 0 }, participant);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assign(expectedBounds, { x: 122, width: 496 });
|
var expectedBounds = assign(originalBounds, { x: 122, width: 496 });
|
||||||
|
|
||||||
expect(getBounds(participant)).to.eql(expectedBounds);
|
expect(participant).to.have.bounds(expectedBounds);
|
||||||
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@ -107,9 +107,9 @@ describe('features/auto-resize', function() {
|
|||||||
modeling.moveElements([task], { x: 50, y: 50 }, participant);
|
modeling.moveElements([task], { x: 50, y: 50 }, participant);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assign(expectedBounds, { width: 475, height: 239 });
|
var expectedBounds = assign(originalBounds, { width: 475, height: 239 });
|
||||||
|
|
||||||
expect(getBounds(participant)).to.eql(expectedBounds);
|
expect(participant).to.have.bounds(expectedBounds);
|
||||||
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@ -120,7 +120,7 @@ describe('features/auto-resize', function() {
|
|||||||
modeling.moveElements([startEvent], { x: -100, y: -100 }, participant);
|
modeling.moveElements([startEvent], { x: -100, y: -100 }, participant);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expect(getBounds(participant)).to.eql({ x: 122, y: 71, width: 496, height: 267 });
|
expect(participant).to.have.bounds({ x: 122, y: 71, width: 496, height: 267 });
|
||||||
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@ -132,7 +132,7 @@ describe('features/auto-resize', function() {
|
|||||||
modeling.moveElements([task], { x: 300, y: 0 }, participant);
|
modeling.moveElements([task], { x: 300, y: 0 }, participant);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expect(getBounds(participant)).to.eql(expectedBounds);
|
expect(participant).to.have.bounds(originalBounds);
|
||||||
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@ -144,9 +144,9 @@ describe('features/auto-resize', function() {
|
|||||||
modeling.moveElements([task], { x: 0, y: 49 }, participant);
|
modeling.moveElements([task], { x: 0, y: 49 }, participant);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assign(expectedBounds, { height: 238 });
|
var expectedBounds = assign(originalBounds, { height: 238 });
|
||||||
|
|
||||||
expect(getBounds(participant)).to.eql(expectedBounds);
|
expect(participant).to.have.bounds(expectedBounds);
|
||||||
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@ -158,7 +158,7 @@ describe('features/auto-resize', function() {
|
|||||||
modeling.moveElements([task], { x: 0, y: 47 }, participant);
|
modeling.moveElements([task], { x: 0, y: 47 }, participant);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expect(getBounds(participant)).to.eql(expectedBounds);
|
expect(participant).to.have.bounds(originalBounds);
|
||||||
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@ -170,7 +170,7 @@ describe('features/auto-resize', function() {
|
|||||||
commandStack.undo();
|
commandStack.undo();
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expect(getBounds(participant)).to.eql(expectedBounds);
|
expect(participant).to.have.bounds(originalBounds);
|
||||||
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@ -183,7 +183,7 @@ describe('features/auto-resize', function() {
|
|||||||
commandStack.redo();
|
commandStack.redo();
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expect(getBounds(participant)).to.eql({ x: 122, y: 71, width: 496, height: 267 });
|
expect(participant).to.have.bounds({ x: 122, y: 71, width: 496, height: 267 });
|
||||||
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@ -192,16 +192,15 @@ describe('features/auto-resize', function() {
|
|||||||
|
|
||||||
describe('after appending', function(){
|
describe('after appending', function(){
|
||||||
|
|
||||||
|
|
||||||
it('should expand the bottom right edges', inject(function(modeling) {
|
it('should expand the bottom right edges', inject(function(modeling) {
|
||||||
|
|
||||||
// when
|
// when
|
||||||
modeling.appendShape(task, { type: 'bpmn:Task' }, { x: 660, y: 350 }, participant);
|
modeling.appendShape(task, { type: 'bpmn:Task' }, { x: 660, y: 350 }, participant);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assign(expectedBounds, { width: 563, height: 290 });
|
var expectedBounds = assign(originalBounds, { width: 563, height: 290 });
|
||||||
|
|
||||||
expect(getBounds(participant)).to.eql(expectedBounds);
|
expect(participant).to.have.bounds(expectedBounds);
|
||||||
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@ -215,7 +214,7 @@ describe('features/auto-resize', function() {
|
|||||||
commandStack.undo();
|
commandStack.undo();
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expect(getBounds(participant)).to.eql(expectedBounds);
|
expect(participant).to.have.bounds(originalBounds);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
@ -230,9 +229,9 @@ describe('features/auto-resize', function() {
|
|||||||
commandStack.redo();
|
commandStack.redo();
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assign(expectedBounds, { width: 563 });
|
var expectedBounds = assign(originalBounds, { width: 563 });
|
||||||
|
|
||||||
expect(getBounds(participant)).to.eql(expectedBounds);
|
expect(participant).to.have.bounds(expectedBounds);
|
||||||
|
|
||||||
expect(task2).to.be.defined;
|
expect(task2).to.be.defined;
|
||||||
expect(task.outgoing).not.to.be.empty;
|
expect(task.outgoing).not.to.be.empty;
|
||||||
@ -256,7 +255,7 @@ describe('features/auto-resize', function() {
|
|||||||
modeling.createShape(laneAttrs, { x: 280, y: 200 }, participant);
|
modeling.createShape(laneAttrs, { x: 280, y: 200 }, participant);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expect(getBounds(participant)).to.eql(expectedBounds);
|
expect(participant).to.have.bounds(originalBounds);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -278,7 +277,7 @@ describe('features/auto-resize', function() {
|
|||||||
modeling.createShape({ type: 'bpmn:Task' }, { x: 600, y: 320 }, laneShape);
|
modeling.createShape({ type: 'bpmn:Task' }, { x: 600, y: 320 }, laneShape);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expect(getBounds(laneShape)).to.eql({ x: 307, y: 160, width: 443, height: 260});
|
expect(laneShape).to.have.bounds({ x: 307, y: 160, width: 443, height: 260});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -4,6 +4,9 @@
|
|||||||
|
|
||||||
var find = require('lodash/collection/find');
|
var find = require('lodash/collection/find');
|
||||||
|
|
||||||
|
var assign = require('lodash/object/assign');
|
||||||
|
|
||||||
|
|
||||||
var modelingModule = require('../../../../lib/features/modeling'),
|
var modelingModule = require('../../../../lib/features/modeling'),
|
||||||
coreModule = require('../../../../lib/core');
|
coreModule = require('../../../../lib/core');
|
||||||
|
|
||||||
@ -39,10 +42,8 @@ describe('features/modeling - append shape', function() {
|
|||||||
|
|
||||||
// given
|
// given
|
||||||
var startEventShape = elementRegistry.get('StartEvent_1');
|
var startEventShape = elementRegistry.get('StartEvent_1');
|
||||||
var subProcessShape = elementRegistry.get('SubProcess_1');
|
|
||||||
|
|
||||||
var startEvent = startEventShape.businessObject,
|
var startEvent = startEventShape.businessObject;
|
||||||
subProcess = subProcessShape.businessObject;
|
|
||||||
|
|
||||||
// when
|
// when
|
||||||
var targetShape = modeling.appendShape(startEventShape, { type: 'bpmn:Task' }),
|
var targetShape = modeling.appendShape(startEventShape, { type: 'bpmn:Task' }),
|
||||||
@ -52,10 +53,7 @@ describe('features/modeling - append shape', function() {
|
|||||||
expect(target.di).to.be.defined;
|
expect(target.di).to.be.defined;
|
||||||
expect(target.di.$parent).to.eql(startEvent.di.$parent);
|
expect(target.di.$parent).to.eql(startEvent.di.$parent);
|
||||||
|
|
||||||
expect(target.di.bounds.x).to.equal(targetShape.x);
|
expect(target.di).to.have.bounds(targetShape);
|
||||||
expect(target.di.bounds.y).to.equal(targetShape.y);
|
|
||||||
expect(target.di.bounds.width).to.equal(targetShape.width);
|
|
||||||
expect(target.di.bounds.height).to.equal(targetShape.height);
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
@ -65,8 +63,7 @@ describe('features/modeling - append shape', function() {
|
|||||||
var startEventShape = elementRegistry.get('StartEvent_1');
|
var startEventShape = elementRegistry.get('StartEvent_1');
|
||||||
var subProcessShape = elementRegistry.get('SubProcess_1');
|
var subProcessShape = elementRegistry.get('SubProcess_1');
|
||||||
|
|
||||||
var startEvent = startEventShape.businessObject,
|
var subProcess = subProcessShape.businessObject;
|
||||||
subProcess = subProcessShape.businessObject;
|
|
||||||
|
|
||||||
// when
|
// when
|
||||||
var targetShape = modeling.appendShape(startEventShape, { type: 'bpmn:Task' }),
|
var targetShape = modeling.appendShape(startEventShape, { type: 'bpmn:Task' }),
|
||||||
@ -83,14 +80,9 @@ describe('features/modeling - append shape', function() {
|
|||||||
|
|
||||||
// given
|
// given
|
||||||
var startEventShape = elementRegistry.get('StartEvent_1');
|
var startEventShape = elementRegistry.get('StartEvent_1');
|
||||||
var subProcessShape = elementRegistry.get('SubProcess_1');
|
|
||||||
|
|
||||||
var startEvent = startEventShape.businessObject,
|
|
||||||
subProcess = subProcessShape.businessObject;
|
|
||||||
|
|
||||||
// when
|
// when
|
||||||
var targetShape = modeling.appendShape(startEventShape, { type: 'bpmn:EndEvent' }),
|
var targetShape = modeling.appendShape(startEventShape, { type: 'bpmn:EndEvent' });
|
||||||
target = targetShape.businessObject;
|
|
||||||
|
|
||||||
var label = targetShape.label;
|
var label = targetShape.label;
|
||||||
|
|
||||||
@ -98,10 +90,7 @@ describe('features/modeling - append shape', function() {
|
|||||||
expect(label).to.be.defined;
|
expect(label).to.be.defined;
|
||||||
expect(elementRegistry.get(label.id)).to.be.defined;
|
expect(elementRegistry.get(label.id)).to.be.defined;
|
||||||
|
|
||||||
expect(label.x).to.equal(441);
|
expect(label).to.have.bounds(assign({ x: 441, y: 278 }, LabelUtil.DEFAULT_LABEL_SIZE));
|
||||||
expect(label.y).to.equal(278);
|
|
||||||
expect(label.width).to.equal(LabelUtil.DEFAULT_LABEL_SIZE.width);
|
|
||||||
expect(label.height).to.equal(LabelUtil.DEFAULT_LABEL_SIZE.height);
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
@ -109,10 +98,6 @@ describe('features/modeling - append shape', function() {
|
|||||||
|
|
||||||
// given
|
// given
|
||||||
var startEventShape = elementRegistry.get('StartEvent_1');
|
var startEventShape = elementRegistry.get('StartEvent_1');
|
||||||
var subProcessShape = elementRegistry.get('SubProcess_1');
|
|
||||||
|
|
||||||
var startEvent = startEventShape.businessObject,
|
|
||||||
subProcess = subProcessShape.businessObject;
|
|
||||||
|
|
||||||
// when
|
// when
|
||||||
var targetShape = modeling.appendShape(startEventShape, { type: 'bpmn:EndEvent' }),
|
var targetShape = modeling.appendShape(startEventShape, { type: 'bpmn:EndEvent' }),
|
||||||
@ -121,10 +106,7 @@ describe('features/modeling - append shape', function() {
|
|||||||
// then
|
// then
|
||||||
expect(target.di.label).to.be.defined;
|
expect(target.di.label).to.be.defined;
|
||||||
|
|
||||||
expect(target.di.label.bounds.x).to.equal(targetShape.label.x);
|
expect(target.di.label).to.have.bounds(targetShape.label);
|
||||||
expect(target.di.label.bounds.y).to.equal(targetShape.label.y);
|
|
||||||
expect(target.di.label.bounds.width).to.equal(targetShape.label.width);
|
|
||||||
expect(target.di.label.bounds.height).to.equal(targetShape.label.height);
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -160,11 +142,10 @@ describe('features/modeling - append shape', function() {
|
|||||||
it('should undo add to parent', inject(function(elementRegistry, modeling, commandStack) {
|
it('should undo add to parent', inject(function(elementRegistry, modeling, commandStack) {
|
||||||
|
|
||||||
// given
|
// given
|
||||||
var startEventShape = elementRegistry.get('StartEvent_1');
|
var startEventShape = elementRegistry.get('StartEvent_1'),
|
||||||
var subProcessShape = elementRegistry.get('SubProcess_1');
|
subProcessShape = elementRegistry.get('SubProcess_1');
|
||||||
|
|
||||||
var startEvent = startEventShape.businessObject,
|
var subProcess = subProcessShape.businessObject;
|
||||||
subProcess = subProcessShape.businessObject;
|
|
||||||
|
|
||||||
var targetShape = modeling.appendShape(startEventShape, { type: 'bpmn:Task' }),
|
var targetShape = modeling.appendShape(startEventShape, { type: 'bpmn:Task' }),
|
||||||
target = targetShape.businessObject;
|
target = targetShape.businessObject;
|
||||||
@ -181,8 +162,8 @@ describe('features/modeling - append shape', function() {
|
|||||||
it('should undo add shape label', inject(function(elementRegistry, modeling, commandStack) {
|
it('should undo add shape label', inject(function(elementRegistry, modeling, commandStack) {
|
||||||
|
|
||||||
// given
|
// given
|
||||||
var startEventShape = elementRegistry.get('StartEvent_1');
|
var startEventShape = elementRegistry.get('StartEvent_1'),
|
||||||
var subProcessShape = elementRegistry.get('SubProcess_1');
|
subProcessShape = elementRegistry.get('SubProcess_1');
|
||||||
|
|
||||||
var startEvent = startEventShape.businessObject,
|
var startEvent = startEventShape.businessObject,
|
||||||
subProcess = subProcessShape.businessObject;
|
subProcess = subProcessShape.businessObject;
|
||||||
@ -276,11 +257,7 @@ describe('features/modeling - append shape', function() {
|
|||||||
var startEventShape = elementRegistry.get('StartEvent_1');
|
var startEventShape = elementRegistry.get('StartEvent_1');
|
||||||
var subProcessShape = elementRegistry.get('SubProcess_1');
|
var subProcessShape = elementRegistry.get('SubProcess_1');
|
||||||
|
|
||||||
var startEvent = startEventShape.businessObject,
|
var targetShape = modeling.appendShape(startEventShape, { type: 'bpmn:Task' });
|
||||||
subProcess = subProcessShape.businessObject;
|
|
||||||
|
|
||||||
var targetShape = modeling.appendShape(startEventShape, { type: 'bpmn:Task' }),
|
|
||||||
target = targetShape.businessObject;
|
|
||||||
|
|
||||||
var targetShape2 = modeling.appendShape(targetShape, { type: 'bpmn:UserTask' });
|
var targetShape2 = modeling.appendShape(targetShape, { type: 'bpmn:UserTask' });
|
||||||
|
|
||||||
@ -361,12 +338,11 @@ describe('features/modeling - append shape', function() {
|
|||||||
var startEventShape = elementRegistry.get('StartEvent_1');
|
var startEventShape = elementRegistry.get('StartEvent_1');
|
||||||
var subProcessShape = elementRegistry.get('SubProcess_1');
|
var subProcessShape = elementRegistry.get('SubProcess_1');
|
||||||
|
|
||||||
var startEvent = startEventShape.businessObject,
|
var subProcess = subProcessShape.businessObject;
|
||||||
subProcess = subProcessShape.businessObject;
|
|
||||||
|
|
||||||
// when
|
// when
|
||||||
var targetShape = modeling.appendShape(startEventShape, { type: 'bpmn:ExclusiveGateway' }),
|
var targetShape = modeling.appendShape(startEventShape, { type: 'bpmn:ExclusiveGateway' }),
|
||||||
target = targetShape.businessObject;
|
target = targetShape.businessObject;
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expect(subProcess.get('flowElements')).to.include(target);
|
expect(subProcess.get('flowElements')).to.include(target);
|
||||||
@ -379,8 +355,7 @@ describe('features/modeling - append shape', function() {
|
|||||||
var startEventShape = elementRegistry.get('StartEvent_1');
|
var startEventShape = elementRegistry.get('StartEvent_1');
|
||||||
var subProcessShape = elementRegistry.get('SubProcess_1');
|
var subProcessShape = elementRegistry.get('SubProcess_1');
|
||||||
|
|
||||||
var startEvent = startEventShape.businessObject,
|
var subProcess = subProcessShape.businessObject;
|
||||||
subProcess = subProcessShape.businessObject;
|
|
||||||
|
|
||||||
var targetShape = modeling.appendShape(startEventShape, { type: 'bpmn:ExclusiveGateway' }),
|
var targetShape = modeling.appendShape(startEventShape, { type: 'bpmn:ExclusiveGateway' }),
|
||||||
target = targetShape.businessObject;
|
target = targetShape.businessObject;
|
||||||
|
@ -38,8 +38,10 @@ describe('features/modeling - move shape', function() {
|
|||||||
modeling.moveShape(startEventElement, { x: 0, y: 50 });
|
modeling.moveShape(startEventElement, { x: 0, y: 50 });
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expect(startEvent.di.bounds.x).to.equal(oldPosition.x);
|
expect(startEvent.di).to.have.position({
|
||||||
expect(startEvent.di.bounds.y).to.equal(oldPosition.y + 50);
|
x: oldPosition.x,
|
||||||
|
y: oldPosition.y + 50
|
||||||
|
});
|
||||||
|
|
||||||
var newWaypoints = sequenceFlowElement.waypoints;
|
var newWaypoints = sequenceFlowElement.waypoints;
|
||||||
|
|
||||||
@ -69,8 +71,10 @@ describe('features/modeling - move shape', function() {
|
|||||||
modeling.moveShape(labelElement, { x: 0, y: 50 });
|
modeling.moveShape(labelElement, { x: 0, y: 50 });
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expect(startEvent.di.label.bounds.x).to.equal(oldPosition.x);
|
expect(startEvent.di.label).to.have.position({
|
||||||
expect(startEvent.di.label.bounds.y).to.equal(oldPosition.y + 50);
|
x: oldPosition.x,
|
||||||
|
y: oldPosition.y + 50
|
||||||
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
@ -115,8 +119,7 @@ describe('features/modeling - move shape', function() {
|
|||||||
commandStack.undo();
|
commandStack.undo();
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expect(startEvent.di.bounds.x).to.equal(oldPosition.x);
|
expect(startEvent.di).to.have.position(oldPosition);
|
||||||
expect(startEvent.di.bounds.y).to.equal(oldPosition.y);
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
@ -137,8 +140,7 @@ describe('features/modeling - move shape', function() {
|
|||||||
commandStack.undo();
|
commandStack.undo();
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expect(startEvent.di.label.bounds.x).to.equal(oldPosition.x);
|
expect(startEvent.di.label).to.have.position(oldPosition);
|
||||||
expect(startEvent.di.label.bounds.y).to.equal(oldPosition.y);
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -165,8 +167,7 @@ describe('features/modeling - move shape', function() {
|
|||||||
commandStack.redo();
|
commandStack.redo();
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expect(startEvent.di.bounds.x).to.equal(newPosition.x);
|
expect(startEvent.di).to.have.position(newPosition);
|
||||||
expect(startEvent.di.bounds.y).to.equal(newPosition.y);
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
@ -188,8 +189,7 @@ describe('features/modeling - move shape', function() {
|
|||||||
commandStack.redo();
|
commandStack.redo();
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expect(startEvent.di.label.bounds.x).to.equal(newPosition.x);
|
expect(startEvent.di.label).to.have.position(newPosition);
|
||||||
expect(startEvent.di.label.bounds.y).to.equal(newPosition.y);
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -215,8 +215,10 @@ describe('features/modeling - move shape', function() {
|
|||||||
modeling.moveElements([ startEventElement ], { x: 40, y: -80 });
|
modeling.moveElements([ startEventElement ], { x: 40, y: -80 });
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expect(label.x).to.equal(labelPosition.x + 40);
|
expect(label).to.have.position({
|
||||||
expect(label.y).to.equal(labelPosition.y - 80);
|
x: labelPosition.x + 40,
|
||||||
|
y: labelPosition.y - 80
|
||||||
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
@ -236,8 +238,10 @@ describe('features/modeling - move shape', function() {
|
|||||||
modeling.moveElements([ startEventElement, subProcessElement ], { x: 40, y: -80 });
|
modeling.moveElements([ startEventElement, subProcessElement ], { x: 40, y: -80 });
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expect(flowLabel.x).to.equal(labelPosition.x + 40);
|
expect(flowLabel).to.have.position({
|
||||||
expect(flowLabel.y).to.equal(labelPosition.y - 80);
|
x: labelPosition.x + 40,
|
||||||
|
y: labelPosition.y - 80
|
||||||
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
@ -261,8 +265,7 @@ describe('features/modeling - move shape', function() {
|
|||||||
commandStack.undo();
|
commandStack.undo();
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expect(label.x).to.equal(labelPosition.x);
|
expect(label).to.have.position(labelPosition);
|
||||||
expect(label.y).to.equal(labelPosition.y);
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
@ -284,8 +287,7 @@ describe('features/modeling - move shape', function() {
|
|||||||
commandStack.undo();
|
commandStack.undo();
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expect(flowLabel.x).to.equal(labelPosition.x);
|
expect(flowLabel).to.have.position(labelPosition);
|
||||||
expect(flowLabel.y).to.equal(labelPosition.y);
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -312,8 +314,10 @@ describe('features/modeling - move shape', function() {
|
|||||||
commandStack.redo();
|
commandStack.redo();
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expect(label.x).to.equal(labelPosition.x + 40);
|
expect(label).to.have.position({
|
||||||
expect(label.y).to.equal(labelPosition.y - 80);
|
x: labelPosition.x + 40,
|
||||||
|
y: labelPosition.y - 80
|
||||||
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
@ -336,8 +340,10 @@ describe('features/modeling - move shape', function() {
|
|||||||
commandStack.redo();
|
commandStack.redo();
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expect(flowLabel.x).to.equal(labelPosition.x + 40);
|
expect(flowLabel).to.have.position({
|
||||||
expect(flowLabel.y).to.equal(labelPosition.y - 80);
|
x: labelPosition.x + 40,
|
||||||
|
y: labelPosition.y - 80
|
||||||
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -51,11 +51,15 @@ describe('features/modeling - create/remove space', function() {
|
|||||||
modeling.createSpace([subProcessElement, endEventElement], [], delta, direction);
|
modeling.createSpace([subProcessElement, endEventElement], [], delta, direction);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expect(subProcess.di.bounds.x).to.equal(subProcOldPos.x + 50);
|
expect(subProcess.di).to.have.position({
|
||||||
expect(subProcess.di.bounds.y).to.equal(subProcOldPos.y);
|
x: subProcOldPos.x + 50,
|
||||||
|
y: subProcOldPos.y
|
||||||
|
});
|
||||||
|
|
||||||
expect(endEvent.di.bounds.x).to.equal(endEventOldPos.x + 50);
|
expect(endEvent.di).to.have.position({
|
||||||
expect(endEvent.di.bounds.y).to.equal(endEventOldPos.y);
|
x: endEventOldPos.x + 50,
|
||||||
|
y: endEventOldPos.y
|
||||||
|
});
|
||||||
|
|
||||||
var diWaypoints = bpmnFactory.createDiWaypoints([
|
var diWaypoints = bpmnFactory.createDiWaypoints([
|
||||||
{ x: 144, y: 230 },
|
{ x: 144, y: 230 },
|
||||||
@ -103,14 +107,20 @@ describe('features/modeling - create/remove space', function() {
|
|||||||
modeling.createSpace([startEventElement ,subProcessElement, endEventElement], [], delta, direction);
|
modeling.createSpace([startEventElement ,subProcessElement, endEventElement], [], delta, direction);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expect(startEvent.di.bounds.x).to.equal(startEventOldPos.x);
|
expect(startEvent.di).to.have.position({
|
||||||
expect(startEvent.di.bounds.y).to.equal(startEventOldPos.y + 50);
|
x: startEventOldPos.x,
|
||||||
|
y: startEventOldPos.y + 50
|
||||||
|
});
|
||||||
|
|
||||||
expect(subProcess.di.bounds.x).to.equal(subProcOldPos.x);
|
expect(subProcess.di).to.have.position({
|
||||||
expect(subProcess.di.bounds.y).to.equal(subProcOldPos.y + 50);
|
x: subProcOldPos.x,
|
||||||
|
y: subProcOldPos.y + 50
|
||||||
|
});
|
||||||
|
|
||||||
expect(endEvent.di.bounds.x).to.equal(endEventOldPos.x);
|
expect(endEvent.di).to.have.position({
|
||||||
expect(endEvent.di.bounds.y).to.equal(endEventOldPos.y + 50);
|
x: endEventOldPos.x,
|
||||||
|
y: endEventOldPos.y + 50
|
||||||
|
});
|
||||||
|
|
||||||
var diWaypoints = bpmnFactory.createDiWaypoints([
|
var diWaypoints = bpmnFactory.createDiWaypoints([
|
||||||
{ x: 144, y: 280 },
|
{ x: 144, y: 280 },
|
||||||
@ -150,11 +160,15 @@ describe('features/modeling - create/remove space', function() {
|
|||||||
modeling.createSpace([subProcessElement, endEventElement], [], delta, direction);
|
modeling.createSpace([subProcessElement, endEventElement], [], delta, direction);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expect(subProcess.di.bounds.x).to.equal(subProcOldPos.x - 50);
|
expect(subProcess.di).to.have.position({
|
||||||
expect(subProcess.di.bounds.y).to.equal(subProcOldPos.y);
|
x: subProcOldPos.x - 50,
|
||||||
|
y: subProcOldPos.y
|
||||||
|
});
|
||||||
|
|
||||||
expect(endEvent.di.bounds.x).to.equal(endEventOldPos.x - 50);
|
expect(endEvent.di).to.have.position({
|
||||||
expect(endEvent.di.bounds.y).to.equal(endEventOldPos.y);
|
x: endEventOldPos.x - 50,
|
||||||
|
y: endEventOldPos.y
|
||||||
|
});
|
||||||
|
|
||||||
var diWaypoints = bpmnFactory.createDiWaypoints([
|
var diWaypoints = bpmnFactory.createDiWaypoints([
|
||||||
{ x: 144, y: 230 },
|
{ x: 144, y: 230 },
|
||||||
@ -209,19 +223,27 @@ describe('features/modeling - create/remove space', function() {
|
|||||||
modeling.createSpace([startEventElement, startEventElement2, taskElement], [subProcessElement], delta, direction);
|
modeling.createSpace([startEventElement, startEventElement2, taskElement], [subProcessElement], delta, direction);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expect(subProcess.di.bounds.x).to.equal(subProcOldPos.x + 50);
|
expect(subProcess.di).to.have.bounds({
|
||||||
expect(subProcess.di.bounds.y).to.equal(subProcOldPos.y);
|
x: subProcOldPos.x + 50,
|
||||||
expect(subProcess.di.bounds.width).to.equal(subProcOldPos.width - 50);
|
y: subProcOldPos.y,
|
||||||
expect(subProcess.di.bounds.height).to.equal(subProcOldPos.height);
|
width: subProcOldPos.width - 50,
|
||||||
|
height: subProcOldPos.height
|
||||||
|
});
|
||||||
|
|
||||||
expect(startEvent.di.bounds.x).to.equal(startEventOldPos.x + 50);
|
expect(startEvent.di).to.have.position({
|
||||||
expect(startEvent.di.bounds.y).to.equal(startEventOldPos.y);
|
x: startEventOldPos.x + 50,
|
||||||
|
y: startEventOldPos.y
|
||||||
|
});
|
||||||
|
|
||||||
expect(startEvent2.di.bounds.x).to.equal(startEventOldPos2.x + 50);
|
expect(startEvent2.di).to.have.position({
|
||||||
expect(startEvent2.di.bounds.y).to.equal(startEventOldPos2.y);
|
x: startEventOldPos2.x + 50,
|
||||||
|
y: startEventOldPos2.y
|
||||||
|
});
|
||||||
|
|
||||||
expect(task.di.bounds.x).to.equal(taskOldPos.x + 50);
|
expect(task.di).to.have.position({
|
||||||
expect(task.di.bounds.y).to.equal(taskOldPos.y);
|
x: taskOldPos.x + 50,
|
||||||
|
y: taskOldPos.y
|
||||||
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -14,13 +14,6 @@ var coreModule = require('../../../../lib/core'),
|
|||||||
moveModule = require('diagram-js/lib/features/move'),
|
moveModule = require('diagram-js/lib/features/move'),
|
||||||
rulesModule = require('../../../../lib/features/rules');
|
rulesModule = require('../../../../lib/features/rules');
|
||||||
|
|
||||||
var pick = require('lodash/object/pick');
|
|
||||||
|
|
||||||
|
|
||||||
function bounds(element) {
|
|
||||||
return pick(element, [ 'width', 'height', 'x', 'y' ]);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
describe('features/snapping - BpmnSnapping', function() {
|
describe('features/snapping - BpmnSnapping', function() {
|
||||||
|
|
||||||
@ -65,7 +58,7 @@ describe('features/snapping - BpmnSnapping', function() {
|
|||||||
var boundaryEvent = elementRegistry.get(task.attachers[0].id);
|
var boundaryEvent = elementRegistry.get(task.attachers[0].id);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expect(bounds(boundaryEvent)).to.eql({ x: 364, y: 167, width: 36, height: 36 });
|
expect(boundaryEvent).to.have.bounds({ x: 364, y: 167, width: 36, height: 36 });
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
@ -86,7 +79,7 @@ describe('features/snapping - BpmnSnapping', function() {
|
|||||||
var boundaryEvent = elementRegistry.get(task.attachers[0].id);
|
var boundaryEvent = elementRegistry.get(task.attachers[0].id);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expect(bounds(boundaryEvent)).to.eql({ x: 364, y: 87, width: 36, height: 36 });
|
expect(boundaryEvent).to.have.bounds({ x: 364, y: 87, width: 36, height: 36 });
|
||||||
}));
|
}));
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -122,7 +115,7 @@ describe('features/snapping - BpmnSnapping', function() {
|
|||||||
dragging.end(canvasEvent({ x: 65, y: 65 }));
|
dragging.end(canvasEvent({ x: 65, y: 65 }));
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expect(bounds(participantShape)).to.eql({
|
expect(participantShape).to.have.bounds({
|
||||||
width: 600, height: 250, x: 18, y: -8
|
width: 600, height: 250, x: 18, y: -8
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
@ -145,7 +138,7 @@ describe('features/snapping - BpmnSnapping', function() {
|
|||||||
dragging.end(canvasEvent({ x: 400, y: 400 }));
|
dragging.end(canvasEvent({ x: 400, y: 400 }));
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expect(bounds(participantShape)).to.eql({
|
expect(participantShape).to.have.bounds({
|
||||||
width: 600, height: 250, x: 100, y: 52
|
width: 600, height: 250, x: 100, y: 52
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
@ -181,7 +174,7 @@ describe('features/snapping - BpmnSnapping', function() {
|
|||||||
dragging.end(canvasEvent({ x: 400, y: 400 }));
|
dragging.end(canvasEvent({ x: 400, y: 400 }));
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expect(bounds(participantShape)).to.eql({
|
expect(participantShape).to.have.bounds({
|
||||||
x: 100, y: 275, width: 600, height: 250
|
x: 100, y: 275, width: 600, height: 250
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
@ -217,7 +210,7 @@ describe('features/snapping - BpmnSnapping', function() {
|
|||||||
dragging.end(canvasEvent({ x: 400, y: 400 }));
|
dragging.end(canvasEvent({ x: 400, y: 400 }));
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expect(bounds(participantShape)).to.eql({
|
expect(participantShape).to.have.bounds({
|
||||||
x: 100, y: 275, width: 600, height: 250
|
x: 100, y: 275, width: 600, height: 250
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
@ -4,13 +4,6 @@ var TestHelper = require('../../../TestHelper');
|
|||||||
|
|
||||||
/* global bootstrapViewer, inject */
|
/* global bootstrapViewer, inject */
|
||||||
|
|
||||||
var pick = require('lodash/object/pick');
|
|
||||||
|
|
||||||
|
|
||||||
function bounds(element) {
|
|
||||||
return pick(element, [ 'x', 'y', 'width', 'height' ]);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
describe('import - labels', function() {
|
describe('import - labels', function() {
|
||||||
|
|
||||||
@ -55,8 +48,8 @@ describe('import - labels', function() {
|
|||||||
sequenceFlow = elementRegistry.get('SequenceFlow_1');
|
sequenceFlow = elementRegistry.get('SequenceFlow_1');
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expect(bounds(endEvent.label)).to.eql({ x: 211, y: 256, width: 119, height: 44 });
|
expect(endEvent.label).to.have.bounds({ x: 211, y: 256, width: 119, height: 44 });
|
||||||
expect(bounds(sequenceFlow.label)).to.eql({ x: 432, y: 317, width: 99, height: 22 });
|
expect(sequenceFlow.label).to.have.bounds({ x: 432, y: 317, width: 99, height: 22 });
|
||||||
|
|
||||||
done();
|
done();
|
||||||
})();
|
})();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user