chore(test): rework positioning test cases

This commit is contained in:
pedesen 2016-10-26 11:26:58 +02:00
parent 992b988ee9
commit 5916e81222
6 changed files with 54 additions and 33 deletions

View File

@ -1,5 +1,5 @@
<?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:participant id="expanded-pool" name="A" processRef="Process_1" />
<bpmn2:participant id="collapsed-pool" name="A" />

View File

@ -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('[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('[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));

View File

@ -56,51 +56,54 @@ describe('label bounds', function() {
it('should expand width', inject(function(elementRegistry) {
// given
var shape = elementRegistry.get('StartEvent_1');
var shape = elementRegistry.get('StartEvent_1'),
oldLabelWidth = shape.label.width;
// when
updateLabel(shape, 'Foooooooooobar');
// then
// expect the width to be within a range because different browsers...
expect(shape.label.width).to.be.within(82, 84);
expect(shape.label.width).to.be.above(oldLabelWidth);
}));
it('should expand height', inject(function(elementRegistry) {
// given
var shape = elementRegistry.get('StartEvent_1');
var shape = elementRegistry.get('StartEvent_1'),
oldLabelHeight = shape.label.height;
// when
updateLabel(shape, 'Foo\nbar\nbaz');
// 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) {
// given
var shape = elementRegistry.get('StartEvent_1');
var shape = elementRegistry.get('StartEvent_1'),
oldLabelWidth = shape.label.width;
// when
updateLabel(shape, 'i');
// 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) {
// given
var shape = elementRegistry.get('StartEvent_3');
var shape = elementRegistry.get('StartEvent_3'),
oldLabelHeight = shape.label.height;
// when
updateLabel(shape, 'One line');
// 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]),
height = parseInt(matches[2]);
expect(width).to.be.within(43, 45);
expect(height).to.be.within(12, 15);
expect(width).to.equal(shape.label.width);
expect(height).to.equal(shape.label.height);
done();
});
@ -299,8 +302,8 @@ describe('label bounds', function() {
var width = parseInt(matches[1]),
height = parseInt(matches[2]);
expect(width).to.be.within(43, 45);
expect(height).to.be.within(12, 15);
expect(width).to.equal(shape.label.width);
expect(height).to.equal(shape.label.height);
done();
});
@ -312,6 +315,9 @@ describe('label bounds', function() {
var xml = require('./LabelBoundsSpec.simple.bpmn');
// strip windows line breaks (if any)
xml = xml.replace(/\r/g, '');
createModeler(xml, function(err, warnings, modeler) {
if (err) {

View File

@ -249,7 +249,7 @@ describe('modeling - label layouting', function() {
modeling.reconnectStart(connection, shape, { x: 0, y: 0 });
// 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);
}));
@ -265,7 +265,7 @@ describe('modeling - label layouting', function() {
modeling.reconnectEnd(connection, shape, { x: 294, y: 270 });
// 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);
}));
@ -331,7 +331,7 @@ describe('modeling - label layouting', function() {
dragging.end();
// 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);
}));
@ -350,7 +350,7 @@ describe('modeling - label layouting', function() {
dragging.end();
// 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);
}));
@ -374,7 +374,7 @@ describe('modeling - label layouting', function() {
dragging.end();
// 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);
}));
@ -503,7 +503,7 @@ describe('modeling - label layouting', function() {
// then
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);
}));

View File

@ -523,6 +523,7 @@ describe('features/snapping - BpmnSnapping', function() {
it('should snap to siblings', inject(function(canvas, elementRegistry, move, dragging) {
var label = elementRegistry.get('BoundaryEvent_1_label'),
task = elementRegistry.get('Task_1'),
rootElement = canvas.getRootElement();
move.start(canvasEvent({ x: label.x+2, y: label.y+2 }), label);
@ -537,7 +538,10 @@ describe('features/snapping - BpmnSnapping', function() {
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);
}));

View File

@ -5,6 +5,13 @@ require('../../../TestHelper');
/* 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('should import embedded labels', function() {
@ -44,19 +51,22 @@ describe('import - labels', function() {
// when
inject(function(elementRegistry) {
var endEvent = elementRegistry.get('EndEvent_1'),
sequenceFlow = elementRegistry.get('SequenceFlow_1');
var eventLabel = elementRegistry.get('EndEvent_1').label,
sequenceFlowLabel = elementRegistry.get('SequenceFlow_1').label;
var eventLabelCenter = getCenter(eventLabel),
sequenceFlowCenter = getCenter(sequenceFlowLabel);
// then
expect(endEvent.label.x).to.be.within(236, 237);
expect(endEvent.label.y).to.be.within(256, 256);
expect(endEvent.label.width).to.be.within(67, 69);
expect(endEvent.label.height).to.be.within(23, 30);
expect(eventLabelCenter.x).to.be.within(270, 272);
expect(eventLabelCenter.y).to.be.within(268, 270);
expect(eventLabel.width).to.be.above(65);
expect(eventLabel.height).to.be.above(20);
expect(sequenceFlow.label.x).to.be.within(441, 442);
expect(sequenceFlow.label.y).to.be.within(316, 317);
expect(sequenceFlow.label.width).to.be.within(79, 82);
expect(sequenceFlow.label.height).to.be.within(12, 15);
expect(sequenceFlowCenter.x).to.be.within(481, 483);
expect(sequenceFlowCenter.y).to.be.within(323, 325);
expect(sequenceFlowLabel.width).to.be.above(75);
expect(sequenceFlowLabel.height).to.be.above(11);
done();
})();