mirror of
https://github.com/sartography/bpmn-js.git
synced 2025-02-17 11:26:42 +00:00
chore(test): rework positioning test cases
This commit is contained in:
parent
992b988ee9
commit
5916e81222
@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="_w9Yc0PLSEeOqh_cnoUOA7A" targetNamespace="http://activiti.org/bpmn" exporter="Camunda Modeler" exporterVersion="1.3.0-nightly" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd">
|
<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="_w9Yc0PLSEeOqh_cnoUOA7A" targetNamespace="http://activiti.org/bpmn" exporter="Camunda Modeler" exporterVersion="1.4.0-nightly" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd">
|
||||||
<bpmn2:collaboration id="_Collaboration_2">
|
<bpmn2:collaboration id="_Collaboration_2">
|
||||||
<bpmn2:participant id="expanded-pool" name="A" processRef="Process_1" />
|
<bpmn2:participant id="expanded-pool" name="A" processRef="Process_1" />
|
||||||
<bpmn2:participant id="collapsed-pool" name="A" />
|
<bpmn2:participant id="collapsed-pool" name="A" />
|
||||||
|
@ -447,7 +447,7 @@ describe('features - label-editing', function() {
|
|||||||
|
|
||||||
it('[2 line text] should have element height', testTextboxSizing('text-annotation', 1, 100, 98, twoLineText));
|
it('[2 line text] should have element height', testTextboxSizing('text-annotation', 1, 100, 98, twoLineText));
|
||||||
|
|
||||||
it('[10 line text] should have element height', testTextboxSizing('text-annotation', 1, 100, 98, tenLineText));
|
it('[10 line text] should have element height', testTextboxSizing('text-annotation', 1, { min: 100 }, 98, tenLineText));
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -573,7 +573,8 @@ describe('features - label-editing', function() {
|
|||||||
|
|
||||||
it('[one word] should have fixed width', testTextboxSizing('subprocess-expanded', 1, 200, 20, oneWord));
|
it('[one word] should have fixed width', testTextboxSizing('subprocess-expanded', 1, 200, 20, oneWord));
|
||||||
|
|
||||||
it('[five words] should have fixed width, line break', testTextboxSizing('subprocess-expanded', 1, 200, 20, fiveWords));
|
it('[five words] should have fixed width, line break',
|
||||||
|
testTextboxSizing('subprocess-expanded', 1, 200, 34, 'five yreallyreallyreally loooooong woooords'));
|
||||||
|
|
||||||
it('[long word] should have fixed width', testTextboxSizing('subprocess-expanded', 1, 200, 20, longWord));
|
it('[long word] should have fixed width', testTextboxSizing('subprocess-expanded', 1, 200, 20, longWord));
|
||||||
|
|
||||||
|
@ -56,51 +56,54 @@ describe('label bounds', function() {
|
|||||||
it('should expand width', inject(function(elementRegistry) {
|
it('should expand width', inject(function(elementRegistry) {
|
||||||
|
|
||||||
// given
|
// given
|
||||||
var shape = elementRegistry.get('StartEvent_1');
|
var shape = elementRegistry.get('StartEvent_1'),
|
||||||
|
oldLabelWidth = shape.label.width;
|
||||||
|
|
||||||
// when
|
// when
|
||||||
updateLabel(shape, 'Foooooooooobar');
|
updateLabel(shape, 'Foooooooooobar');
|
||||||
|
|
||||||
// then
|
// then
|
||||||
// expect the width to be within a range because different browsers...
|
expect(shape.label.width).to.be.above(oldLabelWidth);
|
||||||
expect(shape.label.width).to.be.within(82, 84);
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
it('should expand height', inject(function(elementRegistry) {
|
it('should expand height', inject(function(elementRegistry) {
|
||||||
|
|
||||||
// given
|
// given
|
||||||
var shape = elementRegistry.get('StartEvent_1');
|
var shape = elementRegistry.get('StartEvent_1'),
|
||||||
|
oldLabelHeight = shape.label.height;
|
||||||
|
|
||||||
// when
|
// when
|
||||||
updateLabel(shape, 'Foo\nbar\nbaz');
|
updateLabel(shape, 'Foo\nbar\nbaz');
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expect(shape.label.height).to.be.within(36, 45);
|
expect(shape.label.height).to.be.above(oldLabelHeight);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
it('should reduce width', inject(function(elementRegistry) {
|
it('should reduce width', inject(function(elementRegistry) {
|
||||||
// given
|
// given
|
||||||
var shape = elementRegistry.get('StartEvent_1');
|
var shape = elementRegistry.get('StartEvent_1'),
|
||||||
|
oldLabelWidth = shape.label.width;
|
||||||
|
|
||||||
// when
|
// when
|
||||||
updateLabel(shape, 'i');
|
updateLabel(shape, 'i');
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expect(shape.label.width).to.be.within(2, 3);
|
expect(shape.label.width).to.be.below(oldLabelWidth);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
it('should reduce height', inject(function(elementRegistry) {
|
it('should reduce height', inject(function(elementRegistry) {
|
||||||
// given
|
// given
|
||||||
var shape = elementRegistry.get('StartEvent_3');
|
var shape = elementRegistry.get('StartEvent_3'),
|
||||||
|
oldLabelHeight = shape.label.height;
|
||||||
|
|
||||||
// when
|
// when
|
||||||
updateLabel(shape, 'One line');
|
updateLabel(shape, 'One line');
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expect(shape.label.height).to.be.within(12, 15);
|
expect(shape.label.height).to.be.below(oldLabelHeight);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -256,8 +259,8 @@ describe('label bounds', function() {
|
|||||||
var width = parseInt(matches[1]),
|
var width = parseInt(matches[1]),
|
||||||
height = parseInt(matches[2]);
|
height = parseInt(matches[2]);
|
||||||
|
|
||||||
expect(width).to.be.within(43, 45);
|
expect(width).to.equal(shape.label.width);
|
||||||
expect(height).to.be.within(12, 15);
|
expect(height).to.equal(shape.label.height);
|
||||||
|
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
@ -299,8 +302,8 @@ describe('label bounds', function() {
|
|||||||
var width = parseInt(matches[1]),
|
var width = parseInt(matches[1]),
|
||||||
height = parseInt(matches[2]);
|
height = parseInt(matches[2]);
|
||||||
|
|
||||||
expect(width).to.be.within(43, 45);
|
expect(width).to.equal(shape.label.width);
|
||||||
expect(height).to.be.within(12, 15);
|
expect(height).to.equal(shape.label.height);
|
||||||
|
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
@ -312,6 +315,9 @@ describe('label bounds', function() {
|
|||||||
|
|
||||||
var xml = require('./LabelBoundsSpec.simple.bpmn');
|
var xml = require('./LabelBoundsSpec.simple.bpmn');
|
||||||
|
|
||||||
|
// strip windows line breaks (if any)
|
||||||
|
xml = xml.replace(/\r/g, '');
|
||||||
|
|
||||||
createModeler(xml, function(err, warnings, modeler) {
|
createModeler(xml, function(err, warnings, modeler) {
|
||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
|
@ -249,7 +249,7 @@ describe('modeling - label layouting', function() {
|
|||||||
modeling.reconnectStart(connection, shape, { x: 0, y: 0 });
|
modeling.reconnectStart(connection, shape, { x: 0, y: 0 });
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expect(Math.round(connection.label.x)).to.be.within(573, 575);
|
expect(Math.round(connection.label.x)).to.be.within(570, 575);
|
||||||
expect(Math.round(connection.label.y)).to.be.within(138, 139);
|
expect(Math.round(connection.label.y)).to.be.within(138, 139);
|
||||||
|
|
||||||
}));
|
}));
|
||||||
@ -265,7 +265,7 @@ describe('modeling - label layouting', function() {
|
|||||||
modeling.reconnectEnd(connection, shape, { x: 294, y: 270 });
|
modeling.reconnectEnd(connection, shape, { x: 294, y: 270 });
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expect(Math.round(connection.label.x)).to.be.within(258, 260);
|
expect(Math.round(connection.label.x)).to.be.within(257, 260);
|
||||||
expect(Math.round(connection.label.y)).to.be.within(185, 186);
|
expect(Math.round(connection.label.y)).to.be.within(185, 186);
|
||||||
|
|
||||||
}));
|
}));
|
||||||
@ -331,7 +331,7 @@ describe('modeling - label layouting', function() {
|
|||||||
dragging.end();
|
dragging.end();
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expect(Math.round(connection.label.x)).to.be.equal(518);
|
expect(Math.round(connection.label.x)).to.be.within(517, 518);
|
||||||
expect(Math.round(connection.label.y)).to.be.equal(507);
|
expect(Math.round(connection.label.y)).to.be.equal(507);
|
||||||
|
|
||||||
}));
|
}));
|
||||||
@ -350,7 +350,7 @@ describe('modeling - label layouting', function() {
|
|||||||
dragging.end();
|
dragging.end();
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expect(Math.round(connection.label.x)).to.be.within(419, 421);
|
expect(Math.round(connection.label.x)).to.be.within(418, 421);
|
||||||
expect(Math.round(connection.label.y)).to.be.equal(191);
|
expect(Math.round(connection.label.y)).to.be.equal(191);
|
||||||
|
|
||||||
}));
|
}));
|
||||||
@ -374,7 +374,7 @@ describe('modeling - label layouting', function() {
|
|||||||
dragging.end();
|
dragging.end();
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expect(Math.round(connection.label.x)).to.be.within(250, 251);
|
expect(Math.round(connection.label.x)).to.be.within(248, 251);
|
||||||
expect(Math.round(connection.label.y)).to.be.equal(152);
|
expect(Math.round(connection.label.y)).to.be.equal(152);
|
||||||
|
|
||||||
}));
|
}));
|
||||||
@ -503,7 +503,7 @@ describe('modeling - label layouting', function() {
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
expect(connection.label.y - labelPosition.y).to.be.within(-76, -70);
|
expect(connection.label.y - labelPosition.y).to.be.within(-76, -70);
|
||||||
expect(connection.label.x - labelPosition.x).to.be.within(-53, -51);
|
expect(connection.label.x - labelPosition.x).to.be.within(-54, -51);
|
||||||
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
@ -523,6 +523,7 @@ describe('features/snapping - BpmnSnapping', function() {
|
|||||||
it('should snap to siblings', inject(function(canvas, elementRegistry, move, dragging) {
|
it('should snap to siblings', inject(function(canvas, elementRegistry, move, dragging) {
|
||||||
|
|
||||||
var label = elementRegistry.get('BoundaryEvent_1_label'),
|
var label = elementRegistry.get('BoundaryEvent_1_label'),
|
||||||
|
task = elementRegistry.get('Task_1'),
|
||||||
rootElement = canvas.getRootElement();
|
rootElement = canvas.getRootElement();
|
||||||
|
|
||||||
move.start(canvasEvent({ x: label.x+2, y: label.y+2 }), label);
|
move.start(canvasEvent({ x: label.x+2, y: label.y+2 }), label);
|
||||||
@ -537,7 +538,10 @@ describe('features/snapping - BpmnSnapping', function() {
|
|||||||
|
|
||||||
dragging.end();
|
dragging.end();
|
||||||
|
|
||||||
expect(label.x).to.be.within(192, 193);
|
var labelCenterX = label.x + Math.ceil(label.width / 2),
|
||||||
|
taskCenterX = task.x + Math.ceil(task.width / 2);
|
||||||
|
|
||||||
|
expect(labelCenterX).to.equal(taskCenterX);
|
||||||
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
@ -5,6 +5,13 @@ require('../../../TestHelper');
|
|||||||
/* global bootstrapViewer, inject */
|
/* global bootstrapViewer, inject */
|
||||||
|
|
||||||
|
|
||||||
|
function getCenter(element) {
|
||||||
|
return {
|
||||||
|
x: element.x + Math.ceil(element.width / 2),
|
||||||
|
y: element.y + Math.ceil(element.height / 2)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
describe('import - labels', function() {
|
describe('import - labels', function() {
|
||||||
|
|
||||||
describe('should import embedded labels', function() {
|
describe('should import embedded labels', function() {
|
||||||
@ -44,19 +51,22 @@ describe('import - labels', function() {
|
|||||||
// when
|
// when
|
||||||
inject(function(elementRegistry) {
|
inject(function(elementRegistry) {
|
||||||
|
|
||||||
var endEvent = elementRegistry.get('EndEvent_1'),
|
var eventLabel = elementRegistry.get('EndEvent_1').label,
|
||||||
sequenceFlow = elementRegistry.get('SequenceFlow_1');
|
sequenceFlowLabel = elementRegistry.get('SequenceFlow_1').label;
|
||||||
|
|
||||||
|
var eventLabelCenter = getCenter(eventLabel),
|
||||||
|
sequenceFlowCenter = getCenter(sequenceFlowLabel);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expect(endEvent.label.x).to.be.within(236, 237);
|
expect(eventLabelCenter.x).to.be.within(270, 272);
|
||||||
expect(endEvent.label.y).to.be.within(256, 256);
|
expect(eventLabelCenter.y).to.be.within(268, 270);
|
||||||
expect(endEvent.label.width).to.be.within(67, 69);
|
expect(eventLabel.width).to.be.above(65);
|
||||||
expect(endEvent.label.height).to.be.within(23, 30);
|
expect(eventLabel.height).to.be.above(20);
|
||||||
|
|
||||||
expect(sequenceFlow.label.x).to.be.within(441, 442);
|
expect(sequenceFlowCenter.x).to.be.within(481, 483);
|
||||||
expect(sequenceFlow.label.y).to.be.within(316, 317);
|
expect(sequenceFlowCenter.y).to.be.within(323, 325);
|
||||||
expect(sequenceFlow.label.width).to.be.within(79, 82);
|
expect(sequenceFlowLabel.width).to.be.above(75);
|
||||||
expect(sequenceFlow.label.height).to.be.within(12, 15);
|
expect(sequenceFlowLabel.height).to.be.above(11);
|
||||||
|
|
||||||
done();
|
done();
|
||||||
})();
|
})();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user