Skip to content

Commit ea90d11

Browse files
committed
fix: always return variables context in getResultContext
1 parent d4fc562 commit ea90d11

File tree

4 files changed

+92
-22
lines changed

4 files changed

+92
-22
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ All notable changes to [@bpmn-io/variable-resolver](https://github.com/bpmn-io/v
66

77
___Note:__ Yet to be released changes appear here._
88

9+
## 1.3.6
10+
11+
* `FIX`: always return an instance of variables context in `getResultContext` ([#58](https://github.com/bpmn-io/variable-resolver/pull/58))
12+
913
## 1.3.5
1014

1115
* `FIX`: do not try to find unresolved variables of a broken expression ([#50](https://github.com/bpmn-io/variable-resolver/issues/50))

lib/zeebe/util/feelUtility.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ export function getResultContext(expression, variables = {}) {
129129

130130
// This is a hack to get the latest variables from the context tracker
131131
// lezer does not automatically annotate the parse tree with the context
132-
let latestVariables = null;
132+
let latestVariables = contextTracker.start;
133133

134134
const customContextTracker = new ContextTracker({
135135
start: contextTracker.start,
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<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:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bioc="http://bpmn.io/schema/bpmn/biocolor/1.0" xmlns:color="http://www.omg.org/spec/BPMN/non-normative/color/1.0" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.39.0" modeler:executionPlatform="Camunda Cloud" modeler:executionPlatformVersion="8.8.0">
3+
<bpmn:process id="Process_0j5qzil" name="Agent Blueprint (Long Term Memory)" isExecutable="true">
4+
<bpmn:serviceTask id="Task_1" name="Handle customer request">
5+
<bpmn:outgoing>Flow_1imcl82</bpmn:outgoing>
6+
</bpmn:serviceTask>
7+
<bpmn:sequenceFlow id="Flow_1imcl82" sourceRef="Task_1" targetRef="Task_2" />
8+
<bpmn:serviceTask id="Task_2">
9+
<bpmn:extensionElements>
10+
<zeebe:ioMapping>
11+
<zeebe:input source="=..." target="target" />
12+
</zeebe:ioMapping>
13+
</bpmn:extensionElements>
14+
<bpmn:incoming>Flow_1imcl82</bpmn:incoming>
15+
</bpmn:serviceTask>
16+
</bpmn:process>
17+
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
18+
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_0j5qzil">
19+
<bpmndi:BPMNShape id="Activity_1clcfsu_di" bpmnElement="Task_1" bioc:stroke="#0d4372" bioc:fill="#bbdefb" color:background-color="#bbdefb" color:border-color="#0d4372">
20+
<dc:Bounds x="153" y="80" width="100" height="80" />
21+
<bpmndi:BPMNLabel />
22+
</bpmndi:BPMNShape>
23+
<bpmndi:BPMNShape id="Activity_1a52niu_di" bpmnElement="Task_2">
24+
<dc:Bounds x="340" y="80" width="100" height="80" />
25+
</bpmndi:BPMNShape>
26+
<bpmndi:BPMNEdge id="BPMNEdge_06wqta8" bpmnElement="Flow_1imcl82">
27+
<di:waypoint x="253" y="120" />
28+
<di:waypoint x="340" y="120" />
29+
</bpmndi:BPMNEdge>
30+
</bpmndi:BPMNPlane>
31+
</bpmndi:BPMNDiagram>
32+
</bpmn:definitions>

test/spec/zeebe/ZeebeVariableResolver.spec.js

Lines changed: 55 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import complexXML from 'test/fixtures/zeebe/complex.bpmn';
1414
import connectorsXML from 'test/fixtures/zeebe/connectors.bpmn';
1515
import ioMappingsXML from 'test/fixtures/zeebe/ioMappings.bpmn';
1616
import longBrokenExpressionXML from 'test/fixtures/zeebe/long-broken-expression.bpmn';
17+
import immediatelyBrokenExpressionXML from 'test/fixtures/zeebe/immediately-broken-expression.bpmn';
1718

1819
import VariableProvider from 'lib/VariableProvider';
1920
import { getInputOutput } from '../../../lib/base/util/ExtensionElementsUtil';
@@ -1043,32 +1044,65 @@ describe('ZeebeVariableResolver', function() {
10431044

10441045
describe('parsing', function() {
10451046

1046-
beforeEach(bootstrapModeler(longBrokenExpressionXML, {
1047-
container,
1048-
additionalModules: [
1049-
ZeebeVariableResolverModule
1050-
],
1051-
moddleExtensions: {
1052-
zeebe: ZeebeModdle
1053-
}
1054-
}));
1047+
describe('long broken expression', function() {
10551048

1049+
beforeEach(bootstrapModeler(longBrokenExpressionXML, {
1050+
container,
1051+
additionalModules: [
1052+
ZeebeVariableResolverModule
1053+
],
1054+
moddleExtensions: {
1055+
zeebe: ZeebeModdle
1056+
}
1057+
}));
10561058

1057-
it('should NOT error on a long broken expression', inject(async function(elementRegistry, variableResolver) {
10581059

1059-
// given
1060-
const task = elementRegistry.get('Task_1');
1061-
const bo = getBusinessObject(task);
1062-
const input = getInputOutput(bo).inputParameters[1];
1060+
it('should NOT error on a long broken expression', inject(async function(elementRegistry, variableResolver) {
10631061

1064-
// when
1065-
const variables = await variableResolver.getVariablesForElement(bo, input);
1062+
// given
1063+
const task = elementRegistry.get('Task_1');
1064+
const bo = getBusinessObject(task);
10661065

1067-
// then
1068-
expect(variables).to.variableEqual([
1069-
{ name: 'target' }
1070-
]);
1071-
}));
1066+
// when
1067+
const variables = await variableResolver.getVariablesForElement(bo);
1068+
1069+
// then
1070+
expect(variables).to.variableEqual([
1071+
{ name: 'target' }
1072+
]);
1073+
}));
1074+
1075+
});
1076+
1077+
1078+
describe('immediately broken expression', function() {
1079+
1080+
beforeEach(bootstrapModeler(immediatelyBrokenExpressionXML, {
1081+
container,
1082+
additionalModules: [
1083+
ZeebeVariableResolverModule
1084+
],
1085+
moddleExtensions: {
1086+
zeebe: ZeebeModdle
1087+
}
1088+
}));
1089+
1090+
1091+
it('should NOT error on an immediate syntax error', inject(async function(elementRegistry, variableResolver) {
1092+
1093+
// given
1094+
const task = elementRegistry.get('Task_2');
1095+
const bo = getBusinessObject(task);
1096+
1097+
// when
1098+
const variables = await variableResolver.getVariablesForElement(bo);
1099+
1100+
// then
1101+
expect(variables).to.variableEqual([
1102+
{ name: 'target' }
1103+
]);
1104+
}));
1105+
});
10721106
});
10731107

10741108
});

0 commit comments

Comments
 (0)