From 89719de3be50d9270227fd04216f7f19f0d018a2 Mon Sep 17 00:00:00 2001 From: Nico Rehwaldt Date: Mon, 25 Mar 2019 16:17:31 +0100 Subject: [PATCH] feat(import): render DataInput and DataOutput labels Related to #951 Related to camunda/camunda-modeler#1324 --- lib/util/LabelUtil.js | 2 + .../spec/import/elements/DataInputOutput.bpmn | 74 +++++++++++++++++++ .../import/elements/DataInputOutputSpec.js | 56 ++++++++++++++ 3 files changed, 132 insertions(+) create mode 100644 test/spec/import/elements/DataInputOutput.bpmn create mode 100644 test/spec/import/elements/DataInputOutputSpec.js diff --git a/lib/util/LabelUtil.js b/lib/util/LabelUtil.js index d0756b17..27dbb0c9 100644 --- a/lib/util/LabelUtil.js +++ b/lib/util/LabelUtil.js @@ -24,6 +24,8 @@ export function isLabelExternal(semantic) { is(semantic, 'bpmn:Gateway') || is(semantic, 'bpmn:DataStoreReference') || is(semantic, 'bpmn:DataObjectReference') || + is(semantic, 'bpmn:DataInput') || + is(semantic, 'bpmn:DataOutput') || is(semantic, 'bpmn:SequenceFlow') || is(semantic, 'bpmn:MessageFlow'); } diff --git a/test/spec/import/elements/DataInputOutput.bpmn b/test/spec/import/elements/DataInputOutput.bpmn new file mode 100644 index 00000000..78843c5c --- /dev/null +++ b/test/spec/import/elements/DataInputOutput.bpmn @@ -0,0 +1,74 @@ + + + + + + + DataInput + + + DataOutput + + + + + + + + _9628422b-85a6-4857-8c14-7289b9fd9a8a + + + _29b8c649-e2a0-4dd3-804b-567e8cc71718 + + + + DataInput + _9628422b-85a6-4857-8c14-7289b9fd9a8a + + + _29b8c649-e2a0-4dd3-804b-567e8cc71718 + DataOutput + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/spec/import/elements/DataInputOutputSpec.js b/test/spec/import/elements/DataInputOutputSpec.js new file mode 100644 index 00000000..6b8b28be --- /dev/null +++ b/test/spec/import/elements/DataInputOutputSpec.js @@ -0,0 +1,56 @@ +import { + bootstrapViewer, + inject +} from 'test/TestHelper'; + + +describe('import - data input/output', function() { + + describe('should import external labels', function() { + + it('with di', function(done) { + + var xml = require('./DataInputOutput.bpmn'); + + // given + bootstrapViewer(xml).call(this, function(err) { + + // when + inject(function(elementRegistry) { + + var inputLabel = elementRegistry.get('DataInput').label, + outputLabel = elementRegistry.get('DataOutput').label; + + var inputLabelCenter = getCenter(inputLabel), + outputCenter = getCenter(outputLabel); + + // then + expect(inputLabelCenter.x).to.be.within(110, 130); + expect(inputLabelCenter.y).to.be.within(150, 170); + expect(inputLabel.width).to.be.above(20); + expect(inputLabel.height).to.be.above(10); + + expect(outputCenter.x).to.be.within(290, 310); + expect(outputCenter.y).to.be.within(190, 210); + expect(outputLabel.width).to.be.above(20); + expect(outputLabel.height).to.be.above(10); + + done(err); + })(); + + }); + }); + + }); + +}); + + +// helper //////////////// + +function getCenter(element) { + return { + x: element.x + Math.ceil(element.width / 2), + y: element.y + Math.ceil(element.height / 2) + }; +} \ No newline at end of file