Skip to content

Commit

Permalink
fix(camunda-cloud): correctly handle missing replace entry
Browse files Browse the repository at this point in the history
Related to #211
  • Loading branch information
nikku committed Dec 5, 2022
1 parent e16ca38 commit 352c007
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ ElementTemplatesReplaceProvider.prototype._addPlainElementEntry = function(eleme

const replaceOption = this._getPlainEntry(element, entries);

if (!replaceOption) {
return;
}

const [
insertIndex,
entry
Expand All @@ -101,7 +105,7 @@ ElementTemplatesReplaceProvider.prototype._getPlainEntry = function(element, ent
} = findReplaceOptions(element) || { };

if (!options) {
return;
return null;
}

const entry = {
Expand Down
36 changes: 30 additions & 6 deletions test/camunda-cloud/ElementTemplatesReplaceProvider.bpmn
Original file line number Diff line number Diff line change
@@ -1,17 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="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:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_1vm12kq" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.5.1-testing-conditional-props" modeler:executionPlatform="Camunda Cloud" modeler:executionPlatformVersion="8.1.0">
<bpmn:process id="Process_0wpf8kh" isExecutable="true">
<bpmn:definitions xmlns:bpmn="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:zeebe="http://camunda.org/schema/zeebe/1.0" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_1vm12kq" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.6.0-nightly.20221201" modeler:executionPlatform="Camunda Cloud" modeler:executionPlatformVersion="8.1.0">
<bpmn:process id="PROCESS" isExecutable="true">
<bpmn:task id="Task_1" />
<bpmn:serviceTask id="ServiceTask_1" />
<bpmn:serviceTask id="ServiceTask_1">
<bpmn:extensionElements>
<zeebe:taskDefinition type="io.camunda:http-json:1" />
<zeebe:ioMapping>
<zeebe:input source="get" target="method" />
<zeebe:input target="url" />
</zeebe:ioMapping>
<zeebe:taskHeaders />
</bpmn:extensionElements>
</bpmn:serviceTask>
<bpmn:subProcess id="SUB_PROCESS" name="SUB_PROCESS">
</bpmn:subProcess>
<bpmn:group id="GROUP" categoryValueRef="CATEGORY_VALUE" />
</bpmn:process>
<bpmn:category id="CATEGORY_1">
<bpmn:categoryValue id="CATEGORY_VALUE" value="GROUP" />
</bpmn:category>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_0wpf8kh">
<bpmndi:BPMNShape id="Activity_1nm250j_di" bpmnElement="Task_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="PROCESS">
<bpmndi:BPMNShape id="Task_1_di" bpmnElement="Task_1">
<dc:Bounds x="160" y="80" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_1gtb80z_di" bpmnElement="ServiceTask_1">
<bpmndi:BPMNShape id="ServiceTask_1_di" bpmnElement="ServiceTask_1">
<dc:Bounds x="300" y="80" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="SUB_PROCESS_di" bpmnElement="SUB_PROCESS" isExpanded="true">
<dc:Bounds x="450" y="180" width="350" height="200" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="GROUP_di" bpmnElement="GROUP">
<dc:Bounds x="160" y="220" width="240" height="170" />
<bpmndi:BPMNLabel>
<dc:Bounds x="260" y="227" width="41" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
31 changes: 31 additions & 0 deletions test/camunda-cloud/ElementTemplatesReplaceProviderSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,37 @@ describe('<ElementTemplatesReplaceProvider>', function() {

});


describe('should handle non-existing replace options', function() {

it('bpmn:Group', inject(function(elementRegistry, selection) {

// given
const group = elementRegistry.get('GROUP');

// when
selection.select(group);

// then
// no error
}));


it('bpmn:SubProcess', inject(function(elementRegistry, selection) {

// given
const subProcess = elementRegistry.get('SUB_PROCESS');

// when
openPopup(subProcess);

// then
const entries = getTemplateEntries();
expect(entries).to.be.empty;
}));

});

});


Expand Down

0 comments on commit 352c007

Please sign in to comment.