bpmn-js 0.20.4 → 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/.travis.yml +2 -0
  2. package/lib/draw/BpmnRenderer.js +4 -3
  3. package/lib/features/copy-paste/BpmnCopyPaste.js +22 -19
  4. package/lib/features/label-editing/LabelEditingPreview.js +122 -0
  5. package/lib/features/label-editing/LabelEditingProvider.js +154 -55
  6. package/lib/features/label-editing/cmd/UpdateLabelHandler.js +10 -6
  7. package/lib/features/label-editing/index.js +8 -3
  8. package/lib/features/modeling/BpmnUpdater.js +17 -13
  9. package/lib/features/modeling/ElementFactory.js +36 -19
  10. package/lib/features/modeling/Modeling.js +5 -1
  11. package/lib/features/modeling/behavior/DropOnFlowBehavior.js +50 -16
  12. package/lib/features/modeling/behavior/ReplaceElementBehaviour.js +4 -2
  13. package/lib/features/modeling/behavior/util/LabelLayoutUtil.js +3 -2
  14. package/lib/features/modeling/behavior/util/LineAttachmentUtil.js +36 -30
  15. package/lib/features/rules/BpmnRules.js +29 -11
  16. package/lib/features/snapping/BpmnSnapping.js +22 -6
  17. package/package.json +22 -22
  18. package/test/TestHelper.js +1 -1
  19. package/test/fixtures/bpmn/features/label-editing/labels.bpmn +132 -202
  20. package/test/integration/CustomElementsSpec.js +2 -5
  21. package/test/spec/features/copy-paste/BpmnCopyPasteSpec.js +38 -0
  22. package/test/spec/features/label-editing/LabelEditingPreviewSpec.js +133 -0
  23. package/test/spec/features/label-editing/LabelEditingProviderSpec.js +207 -172
  24. package/test/spec/features/modeling/LabelBoundsSpec.js +3 -1
  25. package/test/spec/features/modeling/LabelLayoutingSpec.js +211 -232
  26. package/test/spec/features/modeling/behavior/DropOnFlowBehavior.bpmn +5 -1
  27. package/test/spec/features/modeling/behavior/DropOnFlowBehaviorSpec.js +174 -1
  28. package/test/spec/features/modeling/behavior/util/LabelLayoutUtilSpec.js +75 -0
  29. package/test/spec/features/modeling/behavior/util/LineAttachmentUtilSpec.js +55 -7
  30. package/test/spec/features/rules/BpmnRulesSpec.js +108 -64
  31. package/test/spec/features/snapping/BpmnSnapping.sequenceFlow.bpmn +41 -0
  32. package/test/spec/features/snapping/BpmnSnappingSpec.js +66 -0
@@ -1,14 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var TestHelper = require('../../../TestHelper');
4
-
5
3
  /* global bootstrapViewer, inject */
6
4
 
7
- TestHelper.insertCSS('diagram-js-label-editing.css',
8
- 'div { box-sizing: border-box; }' +
9
- 'div[contenteditable=true] { line-height: 14px; font-family: Arial; font-size: 12px }'
10
- );
11
-
12
5
 
13
6
  var labelEditingModule = require('../../../../lib/features/label-editing'),
14
7
  coreModule = require('../../../../lib/core'),
@@ -17,6 +10,10 @@ var labelEditingModule = require('../../../../lib/features/label-editing'),
17
10
 
18
11
  var LabelUtil = require('../../../../lib/features/label-editing/LabelUtil');
19
12
 
13
+ var MEDIUM_LINE_HEIGHT = 14;
14
+
15
+ var DELTA = 3;
16
+
20
17
  function triggerKeyEvent(element, event, code) {
21
18
  var e = document.createEvent('Events');
22
19
 
@@ -30,6 +27,13 @@ function triggerKeyEvent(element, event, code) {
30
27
  return element.dispatchEvent(e);
31
28
  }
32
29
 
30
+ function expectBounds(parent, bounds) {
31
+ expect(parent.offsetLeft).to.be.closeTo(bounds.x, DELTA);
32
+ expect(parent.offsetTop).to.be.closeTo(bounds.y, DELTA);
33
+ expect(parent.offsetWidth).to.be.closeTo(bounds.width, DELTA);
34
+ expect(parent.offsetHeight).to.be.closeTo(bounds.height, DELTA);
35
+ }
36
+
33
37
  describe('features - label-editing', function() {
34
38
 
35
39
  var diagramXML = require('../../../fixtures/bpmn/features/label-editing/labels.bpmn');
@@ -44,7 +48,7 @@ describe('features - label-editing', function() {
44
48
  it('should register on dblclick', inject(function(elementRegistry, directEditing, eventBus) {
45
49
 
46
50
  // given
47
- var shape = elementRegistry.get('task-nested-embedded');
51
+ var shape = elementRegistry.get('Task_1');
48
52
 
49
53
  // when
50
54
  eventBus.fire('element.dblclick', { element: shape });
@@ -60,7 +64,7 @@ describe('features - label-editing', function() {
60
64
  it('should cancel on <ESC>', inject(function(elementRegistry, directEditing, eventBus) {
61
65
 
62
66
  // given
63
- var shape = elementRegistry.get('task-nested-embedded'),
67
+ var shape = elementRegistry.get('Task_1'),
64
68
  task = shape.businessObject;
65
69
 
66
70
  var oldName = task.name;
@@ -84,12 +88,12 @@ describe('features - label-editing', function() {
84
88
  it('should complete on drag start', inject(function(elementRegistry, directEditing, dragging) {
85
89
 
86
90
  // given
87
- var shape = elementRegistry.get('task-nested-embedded'),
91
+ var shape = elementRegistry.get('Task_1'),
88
92
  task = shape.businessObject;
89
93
 
90
94
  directEditing.activate(shape);
91
95
 
92
- directEditing._textbox.content.innerText = 'FOO BAR';
96
+ directEditing._textbox.content.textContent = 'FOO BAR';
93
97
 
94
98
  // when
95
99
  dragging.init(null, { x: 0, y: 0 }, 'foo');
@@ -102,7 +106,7 @@ describe('features - label-editing', function() {
102
106
  it('should submit on root element click', inject(function(elementRegistry, directEditing, canvas, eventBus) {
103
107
 
104
108
  // given
105
- var shape = elementRegistry.get('task-nested-embedded'),
109
+ var shape = elementRegistry.get('Task_1'),
106
110
  task = shape.businessObject;
107
111
 
108
112
  // activate
@@ -174,7 +178,7 @@ describe('features - label-editing', function() {
174
178
  it('should update via command stack', function() {
175
179
 
176
180
  // given
177
- var diagramElement = elementRegistry.get('user-task');
181
+ var diagramElement = elementRegistry.get('Task_1');
178
182
 
179
183
  var listenerCalled;
180
184
 
@@ -194,7 +198,7 @@ describe('features - label-editing', function() {
194
198
  it('should undo via command stack', inject(function(commandStack) {
195
199
 
196
200
  // given
197
- var diagramElement = elementRegistry.get('user-task');
201
+ var diagramElement = elementRegistry.get('Task_1');
198
202
 
199
203
  var oldLabel = LabelUtil.getLabel(diagramElement);
200
204
 
@@ -217,7 +221,7 @@ describe('features - label-editing', function() {
217
221
  it('on shape change', function() {
218
222
 
219
223
  // given
220
- var diagramElement = elementRegistry.get('user-task');
224
+ var diagramElement = elementRegistry.get('Task_1');
221
225
 
222
226
  var listenerCalled;
223
227
 
@@ -239,7 +243,7 @@ describe('features - label-editing', function() {
239
243
  it('on connection on change', function() {
240
244
 
241
245
  // given
242
- var diagramElement = elementRegistry.get('sequence-flow-no');
246
+ var diagramElement = elementRegistry.get('SequenceFlow_1');
243
247
 
244
248
  var listenerCalled;
245
249
 
@@ -300,297 +304,328 @@ describe('features - label-editing', function() {
300
304
  }
301
305
 
302
306
 
303
- it('task', directEdit('user-task'));
307
+ it('task', directEdit('Task_1'));
304
308
 
305
309
 
306
- it('gateway', directEdit('exclusive-gateway'));
310
+ it('gateway', directEdit('ExclusiveGateway_1'));
307
311
 
308
- it('gateway via label', directEdit('exclusive-gateway_label'));
312
+ it('gateway via label', directEdit('ExclusiveGateway_1_label'));
309
313
 
310
314
 
311
- it('event', directEdit('intermediate-throw-event'));
315
+ it('event', directEdit('StartEvent_1'));
312
316
 
313
- it('event via label', directEdit('intermediate-throw-event_label'));
317
+ it('event via label', directEdit('StartEvent_1_label'));
314
318
 
315
- it('event without label', directEdit('start-event'));
319
+ it('event without label', directEdit('EndEvent_1'));
316
320
 
317
321
 
318
- it('data store reference', directEdit('data-store-reference'));
322
+ it('data store reference', directEdit('DataStoreReference_1'));
319
323
 
320
- it('data object reference', directEdit('data-object-reference'));
324
+ it('data object reference', directEdit('DataObjectReference_1'));
321
325
 
322
326
 
323
- it('sequenceflow', directEdit('sequence-flow-yes'));
327
+ it('sequenceflow', directEdit('SequenceFlow_1'));
324
328
 
325
- it('sequenceflow without label', directEdit('sequenceflow-unlabeled'));
329
+ it('sequenceflow via label', directEdit('SequenceFlow_1_label'));
326
330
 
327
- it('sequenceflow via label', directEdit('sequence-flow-yes_label'));
331
+ it('sequenceflow without label', directEdit('SequenceFlow_2'));
328
332
 
329
333
 
330
- it('message flow', directEdit('message-flow'));
334
+ it('message flow', directEdit('MessageFlow_1'));
331
335
 
332
- it('message flow via label', directEdit('message-flow_label'));
336
+ it('message flow via label', directEdit('MessageFlow_1_label'));
333
337
 
334
338
 
335
- it('pool', directEdit('expanded-pool'));
339
+ it('pool', directEdit('Participant_1'));
336
340
 
337
- it('pool, collapsed', directEdit('collapsed-pool'));
341
+ it('pool, collapsed', directEdit('Participant_2'));
338
342
 
339
343
 
340
- it('lane with label', directEdit('nested-lane-1-2'));
344
+ it('lane with label', directEdit('Lane_1'));
341
345
 
342
- it('lane without label', directEdit('nested-lane-no-label'));
346
+ it('lane without label', directEdit('Lane_2'));
343
347
 
344
348
  });
345
349
  });
346
350
 
347
351
 
348
- describe('sizing', function() {
352
+ describe('sizes', function() {
349
353
 
350
354
  var testModules = [ labelEditingModule, coreModule, modelingModule ];
351
355
 
352
356
 
353
-
354
- function testTextboxSizing(elementId, zoom, width, height, content) {
355
- return inject(function(canvas, elementRegistry, directEditing) {
356
- // zoom in
357
- canvas.zoom(zoom);
358
- // grab one element
359
- var shape = elementRegistry.get(elementId);
360
- // activate label editing
361
- directEditing.activate(shape);
362
- // grab the textarea
363
- var textbox = directEditing._textbox;
364
- // optionally set content text
365
- if (content) {
366
- textbox.content.innerText = content;
367
- }
368
-
369
- if (width === 'auto') {
370
- width = shape.width;
371
- }
372
-
373
- if (height === 'auto') {
374
- height = shape.height;
375
- }
376
-
377
- // then
378
- if (typeof width === 'object' && width.min) {
379
- expect(textbox.content.offsetWidth).to.be.at.least(width.min);
380
- } else {
381
- expect(textbox.content.offsetWidth).to.be.equal(width);
382
- }
383
-
384
- if (typeof height === 'object' && height.min) {
385
- expect(textbox.content.offsetHeight).to.be.at.least(height.min);
386
- } else {
387
- expect(textbox.content.offsetHeight).to.be.equal(height);
388
- }
389
- });
390
- }
391
-
392
357
  beforeEach(bootstrapViewer(diagramXML, {
393
358
  modules: testModules,
394
359
  canvas: { deferUpdate: false }
395
360
  }));
396
361
 
397
362
 
398
- describe('height', function() {
399
-
400
- var oneLineText = 'One line',
401
- twoLineText = 'Two\nlines',
402
- tenLineText = '1\n2\n3\n4\n5\n6\n7\n8\n9\n0';
363
+ describe('bounds', function() {
403
364
 
404
365
  describe('external labels', function() {
405
366
 
406
- it('[no text] should have min height', testTextboxSizing('start-event', 1, 150, 20));
407
-
408
- it('[1 line text] should be 1 line high', testTextboxSizing('start-event', 1, 150, 20, oneLineText));
367
+ it('[zoom 1] should have fixed width and element height', inject(function(canvas, directEditing, elementRegistry) {
368
+ var zoom = 1;
409
369
 
410
- it('[2 line text] should be 2 line high', testTextboxSizing('start-event', 1, 150, 34, twoLineText));
370
+ canvas.zoom(zoom);
411
371
 
412
- it('[10 line text] should be 10 line high', testTextboxSizing('start-event', 1, 150, 146, tenLineText));
413
-
414
- });
372
+ var startEvent = elementRegistry.get('StartEvent_1');
415
373
 
374
+ var bounds = canvas.getAbsoluteBBox(startEvent.label);
375
+ var mid = {
376
+ x: bounds.x + bounds.width / 2,
377
+ y: bounds.y + bounds.height / 2
378
+ };
416
379
 
417
- describe('internal labels', function() {
380
+ directEditing.activate(startEvent);
418
381
 
419
- it('[no text] should have fixed dimensions', testTextboxSizing('empty-task', 1, 'auto', 'auto'));
382
+ expectBounds(directEditing._textbox.parent, {
383
+ x: mid.x - (45 * zoom),
384
+ y: bounds.y - (7 * zoom),
385
+ width: (90 * zoom),
386
+ height: bounds.height + (5 * zoom) + 7
387
+ });
388
+ }));
420
389
 
421
- it('[1 line text] should have fixed dimensions', testTextboxSizing('empty-task', 1, 'auto', 'auto', oneLineText));
422
390
 
423
- it('[2 line text] should have fixed dimensions', testTextboxSizing('empty-task', 1, 'auto', 'auto', twoLineText));
391
+ it('[zoom 1.5] should have fixed width and element height', inject(function(canvas, directEditing, elementRegistry) {
392
+ var zoom = 1.5;
424
393
 
425
- it('[10 line text] should have fixed dimensions', testTextboxSizing('empty-task', 1, 'auto', 'auto', tenLineText));
426
-
427
- });
394
+ canvas.zoom(zoom);
428
395
 
396
+ var startEvent = elementRegistry.get('StartEvent_1');
429
397
 
430
- describe('sequence flows', function() {
398
+ var bounds = canvas.getAbsoluteBBox(startEvent.label);
399
+ var mid = {
400
+ x: bounds.x + bounds.width / 2,
401
+ y: bounds.y + bounds.height / 2
402
+ };
431
403
 
432
- it('[no text] should have min height', testTextboxSizing('sequenceflow-unlabeled', 1, 150, 20));
404
+ directEditing.activate(startEvent);
433
405
 
434
- it('[1 line text] should be 1 line high', testTextboxSizing('sequenceflow-unlabeled', 1, 150, 20, oneLineText));
406
+ expectBounds(directEditing._textbox.parent, {
407
+ x: mid.x - (45 * zoom),
408
+ y: bounds.y - (7 * zoom),
409
+ width: (90 * zoom),
410
+ height: bounds.height + (5 * zoom) + (7 * zoom)
411
+ });
412
+ }));
435
413
 
436
- it('[2 line text] should be 2 line high', testTextboxSizing('sequenceflow-unlabeled', 1, 150, 34, twoLineText));
414
+ });
437
415
 
438
- it('[10 line text] should be 10 line high', testTextboxSizing('sequenceflow-unlabeled', 1, 150, 146, tenLineText));
439
416
 
440
- });
417
+ describe('internal labels', function() {
441
418
 
419
+ it('[zoom 1] should have element size', inject(function(canvas, directEditing, elementRegistry) {
420
+ var zoom = 1;
442
421
 
443
- describe('text annotation', function() {
422
+ canvas.zoom(zoom);
444
423
 
445
- it('[no text] should have element height', testTextboxSizing('text-annotation', 1, 100, 98));
424
+ var task = elementRegistry.get('Task_1');
446
425
 
447
- it('[1 line text] should have element height', testTextboxSizing('text-annotation', 1, 100, 98, oneLineText));
426
+ var bounds = canvas.getAbsoluteBBox(task);
448
427
 
449
- it('[2 line text] should have element height', testTextboxSizing('text-annotation', 1, 100, 98, twoLineText));
428
+ directEditing.activate(task);
450
429
 
451
- it('[10 line text] should have element height', testTextboxSizing('text-annotation', 1, { min: 100 }, 98, tenLineText));
430
+ expectBounds(directEditing._textbox.parent, bounds);
431
+ }));
452
432
 
453
- });
454
433
 
434
+ it('[zoom 1.5] should have element size', inject(function(canvas, directEditing, elementRegistry) {
435
+ var zoom = 1.5;
455
436
 
456
- describe('expanded sub process', function() {
437
+ canvas.zoom(zoom);
457
438
 
458
- it('[no text] should have min height', testTextboxSizing('subprocess-expanded', 1, 200, 20));
439
+ var task = elementRegistry.get('Task_1');
459
440
 
460
- it('[1 line text] should be 1 line high', testTextboxSizing('subprocess-expanded', 1, 200, 20, oneLineText));
441
+ var bounds = canvas.getAbsoluteBBox(task);
461
442
 
462
- it('[2 line text] should be 2 line high', testTextboxSizing('subprocess-expanded', 1, 200, 34, twoLineText));
443
+ directEditing.activate(task);
463
444
 
464
- it('[10 line text] should be max 3 line high', testTextboxSizing('subprocess-expanded', 1, 200, 48, tenLineText));
445
+ expectBounds(directEditing._textbox.parent, bounds);
446
+ }));
465
447
 
466
448
  });
467
449
 
468
450
 
469
- describe('pools/lanes', function() {
451
+ describe('sequence flows', function() {
470
452
 
471
- it('[no text] should have min height', testTextboxSizing('expanded-pool', 1, 150, 20));
453
+ it('[zoom 1] should have fixed width and element height', inject(function(canvas, directEditing, elementRegistry) {
454
+ var zoom = 1;
472
455
 
473
- it('[1 line text] should be 1 line high', testTextboxSizing('expanded-pool', 1, 150, 20, oneLineText));
456
+ canvas.zoom(zoom);
474
457
 
475
- it('[2 line text] should be 2 line high', testTextboxSizing('expanded-pool', 1, 150, 34, twoLineText));
458
+ var sequenceFlow = elementRegistry.get('SequenceFlow_1');
476
459
 
477
- it('[10 line text] should be max 2 line high', testTextboxSizing('expanded-pool', 1, 150, 34, tenLineText));
460
+ var bounds = canvas.getAbsoluteBBox(sequenceFlow.label);
461
+ var mid = {
462
+ x: bounds.x + bounds.width / 2,
463
+ y: bounds.y + bounds.height / 2
464
+ };
478
465
 
479
- });
466
+ directEditing.activate(sequenceFlow);
480
467
 
481
- });
468
+ expectBounds(directEditing._textbox.parent, {
469
+ x: mid.x - (45 * zoom),
470
+ y: bounds.y - (7 * zoom),
471
+ width: (90 * zoom),
472
+ height: bounds.height + (5 * zoom) + 7
473
+ });
474
+ }));
482
475
 
483
- describe('width', function() {
484
476
 
485
- var oneWord = 'foobar',
486
- fiveWords = 'lorem ipsum dolor foobar foobar',
487
- longWord = 'loremipsumdolorfoobar';
477
+ it('[zoom 1.5] should have fixed width and element height', inject(function(canvas, directEditing, elementRegistry) {
478
+ var zoom = 1.5;
488
479
 
489
- describe('external labels', function() {
480
+ canvas.zoom(zoom);
490
481
 
491
- it('[no text] should have fixed width', testTextboxSizing('start-event', 1, 150, 20));
482
+ var sequenceflow = elementRegistry.get('SequenceFlow_1');
492
483
 
493
- it('[one word] should have fixed width', testTextboxSizing('start-event', 1, 150, 20, oneWord));
484
+ var bounds = canvas.getAbsoluteBBox(sequenceflow.label);
485
+ var mid = {
486
+ x: bounds.x + bounds.width / 2,
487
+ y: bounds.y + bounds.height / 2
488
+ };
494
489
 
495
- it('[five words] should have fixed width, line break', testTextboxSizing('start-event', 1, 150, { min: 34 }, fiveWords));
490
+ directEditing.activate(sequenceflow);
496
491
 
497
- it('[long word] should have fixed width', testTextboxSizing('start-event', 1, 150, { min: 20 }, longWord));
492
+ expectBounds(directEditing._textbox.parent, {
493
+ x: mid.x - (45 * zoom),
494
+ y: bounds.y - (7 * zoom),
495
+ width: (90 * zoom),
496
+ height: bounds.height + (5 * zoom) + (7 * zoom)
497
+ });
498
+ }));
498
499
 
499
500
  });
500
501
 
501
502
 
502
- describe('internal labels', function() {
503
+ describe('text annotations', function() {
503
504
 
504
- it('[no text] should have fixed dimensions (task)', testTextboxSizing('empty-task', 1, 100, 80));
505
+ it('[zoom 1] should have element size', inject(function(canvas, directEditing, elementRegistry) {
506
+ var zoom = 1;
505
507
 
506
- it('[no text] should have fixed dimensions (call activity)', testTextboxSizing('call-activity', 1, 100, 80));
508
+ canvas.zoom(zoom);
507
509
 
508
- it('[no text] should have fixed dimensions (collapsed sub process)', testTextboxSizing('subprocess-collapsed', 1, 100, 80));
510
+ var textAnnotation = elementRegistry.get('TextAnnotation_1');
509
511
 
510
- it('[one word] should have fixed dimensions', testTextboxSizing('empty-task', 1, 100, 80, oneWord));
512
+ var bounds = canvas.getAbsoluteBBox(textAnnotation);
511
513
 
512
- it('[five words] should have fixed dimensions', testTextboxSizing('empty-task', 1, 100, 80, fiveWords));
514
+ directEditing.activate(textAnnotation);
513
515
 
514
- it('[long word] should have fixed dimensions', testTextboxSizing('empty-task', 1, 100, 80, longWord));
516
+ expectBounds(directEditing._textbox.parent, bounds);
517
+ }));
515
518
 
516
- describe('zoom', function() {
517
519
 
518
- it('should have fixed dimensions (low zoom)', testTextboxSizing('empty-task', 0.5, 100, 80, oneWord));
520
+ it('[zoom 1.5] should have element size', inject(function(canvas, directEditing, elementRegistry) {
521
+ var zoom = 1.5;
519
522
 
520
- it('should have fixed dimensions (high zoom)', testTextboxSizing('empty-task', 1.5, 150, 120, oneWord));
523
+ canvas.zoom(zoom);
521
524
 
522
- it('should center text box position (low zoom)', inject(function(canvas, elementRegistry, directEditing) {
525
+ var textAnnotation = elementRegistry.get('TextAnnotation_1');
523
526
 
524
- // given
525
- canvas.zoom(0.5, { x: 0, y: 0 });
527
+ var bounds = canvas.getAbsoluteBBox(textAnnotation);
526
528
 
527
- var shape = elementRegistry.get('empty-task');
529
+ directEditing.activate(textAnnotation);
528
530
 
529
- // when
530
- directEditing.activate(shape);
531
+ expectBounds(directEditing._textbox.parent, bounds);
532
+ }));
531
533
 
532
- // then
533
- var textbox = directEditing._textbox;
534
+ });
534
535
 
535
- expect(textbox.content.offsetLeft).to.equal(211);
536
- expect(textbox.content.offsetTop).to.equal(17);
537
536
 
538
- }));
537
+ describe('expanded sub processes', function() {
539
538
 
540
- });
539
+ it('[zoom 1] should have element width and height to fit text', inject(function(canvas, directEditing, elementRegistry) {
540
+ var zoom = 1;
541
541
 
542
- });
542
+ canvas.zoom(zoom);
543
543
 
544
+ var subProcess = elementRegistry.get('SubProcess_1');
544
545
 
545
- describe('sequence flows', function() {
546
+ var bounds = canvas.getAbsoluteBBox(subProcess);
546
547
 
547
- it('[no text] should have fixed width', testTextboxSizing('sequenceflow-unlabeled', 1, 150, 20));
548
+ directEditing.activate(subProcess);
548
549
 
549
- it('[one word] should have fixed width', testTextboxSizing('sequenceflow-unlabeled', 1, 150, 20, oneWord));
550
+ expectBounds(directEditing._textbox.parent, {
551
+ x: bounds.x,
552
+ y: bounds.y,
553
+ width: bounds.width,
554
+ height: (MEDIUM_LINE_HEIGHT * zoom) + (7 * 2 * zoom)
555
+ });
556
+ }));
550
557
 
551
- it('[five words] should have fixed width, line break', testTextboxSizing('sequenceflow-unlabeled', 1, 150, { min: 34 }, fiveWords));
552
558
 
553
- it('[long word] should have fixed width', testTextboxSizing('sequenceflow-unlabeled', 1, 150, { min: 20 }, longWord));
559
+ it('[zoom 1.5] should have element width and height to fit text', inject(function(canvas, directEditing, elementRegistry) {
560
+ var zoom = 1.5;
554
561
 
555
- });
562
+ canvas.zoom(zoom);
556
563
 
564
+ var subProcess = elementRegistry.get('SubProcess_1');
557
565
 
558
- describe('text annotation', function() {
566
+ var bounds = canvas.getAbsoluteBBox(subProcess);
559
567
 
560
- it('[no text] should have min width', testTextboxSizing('text-annotation', 1, 100, 98));
568
+ directEditing.activate(subProcess);
561
569
 
562
- it('[one word] should have min width', testTextboxSizing('text-annotation', 1, 100, 98, oneWord));
570
+ expectBounds(directEditing._textbox.parent, {
571
+ x: bounds.x,
572
+ y: bounds.y,
573
+ width: bounds.width,
574
+ height: (MEDIUM_LINE_HEIGHT * zoom) + (7 * 2 * zoom)
575
+ });
576
+ }));
563
577
 
564
- it('[five words] should expand width', testTextboxSizing('text-annotation', 1, { min: 176 }, 98, fiveWords));
578
+ });
565
579
 
566
- it('[long word] should expand width', testTextboxSizing('text-annotation', 1, { min: 129 }, 98, longWord));
567
580
 
568
- });
581
+ describe('pools/lanes', function() {
569
582
 
583
+ it('[zoom 1] should have width of element height, height of 30', inject(function(canvas, directEditing, elementRegistry) {
584
+ var zoom = 1;
570
585
 
571
- describe('expanded sub process', function() {
586
+ canvas.zoom(zoom);
572
587
 
573
- it('[no text] should have fixed width', testTextboxSizing('subprocess-expanded', 1, 200, 20));
588
+ var pool = elementRegistry.get('Participant_1');
574
589
 
575
- it('[one word] should have fixed width', testTextboxSizing('subprocess-expanded', 1, 200, 20, oneWord));
590
+ var bounds = canvas.getAbsoluteBBox(pool);
591
+ var mid = {
592
+ x: bounds.x + bounds.width / 2,
593
+ y: bounds.y + bounds.height / 2
594
+ };
576
595
 
577
- it('[five words] should have fixed width, line break',
578
- testTextboxSizing('subprocess-expanded', 1, 200, 34, 'five yreallyreallyreally loooooong woooords'));
596
+ directEditing.activate(pool);
579
597
 
580
- it('[long word] should have fixed width', testTextboxSizing('subprocess-expanded', 1, 200, 20, longWord));
598
+ expectBounds(directEditing._textbox.parent, {
599
+ x: bounds.x - (bounds.height / 2) + (15 * zoom),
600
+ y: mid.y - (30 * zoom) / 2,
601
+ width: bounds.height * zoom,
602
+ height: 30 * zoom
603
+ });
604
+ }));
581
605
 
582
- });
583
606
 
607
+ it('[zoom 1.5] should have width of element height, height of 30', inject(function(canvas, directEditing, elementRegistry) {
608
+ var zoom = 1.5;
584
609
 
585
- describe('pools/lanes', function() {
610
+ canvas.zoom(zoom);
586
611
 
587
- it('[no text] should have fixed width', testTextboxSizing('expanded-pool', 1, 150, 20));
612
+ var pool = elementRegistry.get('Participant_1');
588
613
 
589
- it('[one word] should have fixed width', testTextboxSizing('expanded-pool', 1, 150, 20, oneWord));
614
+ var bounds = canvas.getAbsoluteBBox(pool);
615
+ var mid = {
616
+ x: bounds.x + bounds.width / 2,
617
+ y: bounds.y + bounds.height / 2
618
+ };
590
619
 
591
- it('[five words] should have fixed width, line break', testTextboxSizing('expanded-pool', 1, 150, 34, fiveWords));
620
+ directEditing.activate(pool);
592
621
 
593
- it('[long word] should have fixed width', testTextboxSizing('expanded-pool', 1, 150, { min: 20 }, longWord));
622
+ expectBounds(directEditing._textbox.parent, {
623
+ x: bounds.x - (bounds.height / 2) + (15 * zoom),
624
+ y: mid.y - (30 * zoom) / 2,
625
+ width: bounds.height,
626
+ height: 30 * zoom
627
+ });
628
+ }));
594
629
 
595
630
  });
596
631
 
@@ -6,6 +6,8 @@ var Modeler = require('../../../../lib/Modeler');
6
6
 
7
7
  var TestContainer = require('mocha-test-container-support');
8
8
 
9
+ var DELTA = 2;
10
+
9
11
 
10
12
  describe('label bounds', function() {
11
13
 
@@ -126,7 +128,7 @@ describe('label bounds', function() {
126
128
  // then
127
129
  var expectedX = getExpectedX(shape);
128
130
 
129
- expect(shape.label.x).to.equal(expectedX);
131
+ expect(shape.label.x).to.be.closeTo(expectedX, DELTA);
130
132
  }));
131
133
 
132
134