Skip to content

Commit

Permalink
fix: do not try and get errors for reports that are not errors
Browse files Browse the repository at this point in the history
  • Loading branch information
philippfromme committed Sep 22, 2023
1 parent 62054cb commit 57dc7a0
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 9 deletions.
16 changes: 10 additions & 6 deletions lib/utils/properties-panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ const TIMER_PROPERTIES = [
*/
export function getErrors(reports, element) {
return reports.reduce((errors, report) => {
if (!element || getBusinessObject(element).get('id') !== report.id) {
const { category } = report;

if (!element
|| getBusinessObject(element).get('id') !== report.id
|| category !== 'error') {
return errors;
}

Expand Down Expand Up @@ -298,10 +302,6 @@ export function getErrorMessage(id, report) {
return 'Cannot be an expression.';
}

if (data.type === ERROR_TYPES.SECRET_EXPRESSION_FORMAT_DEPRECATED) {
return 'Secret expression format deprecated.';
}

if (id === 'isExecutable') {
const { parentNode } = data;

Expand Down Expand Up @@ -384,7 +384,11 @@ export function getErrorMessage(id, report) {
return 'Type must be defined.';
}

if (id === 'messageSubscriptionCorrelationKey') {
if (id === 'messageSubscriptionCorrelationKey'
&& [
ERROR_TYPES.EXTENSION_ELEMENT_REQUIRED,
ERROR_TYPES.PROPERTY_REQUIRED
].includes(data.type)) {
return 'Subscription correlation key must be defined.';
}

Expand Down
43 changes: 43 additions & 0 deletions test/spec/utils/properties-panel-info.bpmn
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?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:zeebe="http://camunda.org/schema/zeebe/1.0" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_192a7nr" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.15.0" modeler:executionPlatform="Camunda Cloud" modeler:executionPlatformVersion="8.2.0">
<bpmn:process id="Process_1" isExecutable="true">
<bpmn:startEvent id="StartEvent_1">
<bpmn:outgoing>SequenceFlow_1</bpmn:outgoing>
</bpmn:startEvent>
<bpmn:task id="Task_1">
<bpmn:extensionElements>
<zeebe:properties>
<zeebe:property value="secrets.FOO" />
</zeebe:properties>
</bpmn:extensionElements>
<bpmn:incoming>SequenceFlow_1</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_2</bpmn:outgoing>
</bpmn:task>
<bpmn:sequenceFlow id="SequenceFlow_1" sourceRef="StartEvent_1" targetRef="Task_1" />
<bpmn:endEvent id="EndEvent_1">
<bpmn:incoming>SequenceFlow_2</bpmn:incoming>
</bpmn:endEvent>
<bpmn:sequenceFlow id="SequenceFlow_2" sourceRef="Task_1" targetRef="EndEvent_1" />
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1">
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
<dc:Bounds x="179" y="99" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_0h1z36w_di" bpmnElement="Task_1">
<dc:Bounds x="270" y="77" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_0qv5l20_di" bpmnElement="EndEvent_1">
<dc:Bounds x="432" y="99" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="Flow_15s2mgu_di" bpmnElement="SequenceFlow_1">
<di:waypoint x="215" y="117" />
<di:waypoint x="270" y="117" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1iq04xt_di" bpmnElement="SequenceFlow_2">
<di:waypoint x="370" y="117" />
<di:waypoint x="432" y="117" />
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
30 changes: 27 additions & 3 deletions test/spec/utils/properties-panel.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
} from './lint-helper';

import propertiesPanelXML from './properties-panel.bpmn';
import propertiesPanelInfoXML from './properties-panel-info.bpmn';
import propertiesPanelPlatformXML from './properties-panel-platform.bpmn';

describe('utils/properties-panel', function() {
Expand Down Expand Up @@ -1590,7 +1591,7 @@ describe('utils/properties-panel', function() {
// then
expect(entryIds).to.eql([ 'messageSubscriptionCorrelationKey' ]);

expectErrorMessage(entryIds[ 0 ], 'Secret expression format deprecated.', report);
expectNoErrorMessage(entryIds[ 0 ], report);
});


Expand Down Expand Up @@ -1622,7 +1623,7 @@ describe('utils/properties-panel', function() {
// then
expect(entryIds).to.eql([ 'ServiceTask_1-input-0-source' ]);

expectErrorMessage(entryIds[ 0 ], 'Secret expression format deprecated.', report);
expectNoErrorMessage(entryIds[ 0 ], report);
});


Expand Down Expand Up @@ -1654,7 +1655,7 @@ describe('utils/properties-panel', function() {
// then
expect(entryIds).to.eql([ 'ServiceTask_1-extensionProperty-0-value' ]);

expectErrorMessage(entryIds[ 0 ], 'Secret expression format deprecated.', report);
expectNoErrorMessage(entryIds[ 0 ], report);
});

});
Expand Down Expand Up @@ -1759,6 +1760,25 @@ describe('utils/properties-panel', function() {
});
});


it('should not return errors for category info', async function() {

// given
const linter = new Linter();

const { root } = await createModdle(propertiesPanelInfoXML);

const reports = await linter.lint(root);

// when
let element = root.rootElements[ 0 ].flowElements.find(({ id }) => id === 'Task_1');

let errors = getErrors(reports, element);

// then
expect(errors).to.be.empty;
});

});

});
Expand Down Expand Up @@ -1825,4 +1845,8 @@ function expectErrorMessage(id, expectedErrorMessage, report) {

// then
expect(errorMessage).to.equal(expectedErrorMessage);
}

function expectNoErrorMessage(id, report) {
expectErrorMessage(id, undefined, report);
}

0 comments on commit 57dc7a0

Please sign in to comment.