Skip to content

Commit

Permalink
fix: latest variable in scope
Browse files Browse the repository at this point in the history
  • Loading branch information
abdul99ahad committed Jan 8, 2025
1 parent 64e3b38 commit e23a564
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/zeebe/util/feelUtility.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ function getIoExpression(variable, origin) {
return;
}

const mapping = mappings.filter(mapping => mapping.target === variable.name).pop();
const mapping = mappings.slice().reverse().find(mapping => mapping.target === variable.name);

if (!mapping || !mapping.source) {
return;
Expand Down
19 changes: 19 additions & 0 deletions test/fixtures/zeebe/mappings/scope.bpmn
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<bpmn:participant id="Participant_4" processRef="Process_4" />
<bpmn:participant id="Participant_5" processRef="Process_5" />
<bpmn:participant id="Participant_6" processRef="Process_6" />
<bpmn:participant id="Participant_7" processRef="Process_7" />
</bpmn:collaboration>
<bpmn:process id="Process_1" isExecutable="true">
<bpmn:serviceTask id="scopedContext" name="Scoped Context">
Expand Down Expand Up @@ -76,6 +77,17 @@
</bpmn:extensionElements>
</bpmn:userTask>
</bpmn:process>
<bpmn:process id="Process_7" isExecutable="false">
<bpmn:userTask id="Activity_7" name="User Task">
<bpmn:extensionElements>
<zeebe:ioMapping>
<zeebe:input source="={}" target="foo" />
<zeebe:input source="=&#34;abc&#34;" target="foo" />
<zeebe:input source="=123" target="foo" />
</zeebe:ioMapping>
</bpmn:extensionElements>
</bpmn:userTask>
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Collaboration_0e60zir">
<bpmndi:BPMNShape id="Participant_10jajek_di" bpmnElement="Participant_1" isHorizontal="true">
Expand Down Expand Up @@ -123,6 +135,13 @@
<dc:Bounds x="310" y="1740" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Participant_0hcijo0_di" bpmnElement="Participant_7" isHorizontal="true">
<dc:Bounds x="160" y="1980" width="600" height="250" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_1aor9g3_di" bpmnElement="Activity_7">
<dc:Bounds x="310" y="2060" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
18 changes: 18 additions & 0 deletions test/spec/zeebe/Mappings.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,24 @@ describe('ZeebeVariableResolver - Variable Mappings', function() {
}));


it('should only resolve the latest variable if same name input/output exists', inject(async function(variableResolver, elementRegistry) {

// given
const root = elementRegistry.get('Activity_7');

// when
const variables = await variableResolver.getVariablesForElement(root.businessObject);

// then
expect(variables).to.variableEqual([
{
name: 'foo',
type: 'Number',
info: '123',
}
]);
}));

});


Expand Down

0 comments on commit e23a564

Please sign in to comment.