Skip to content

Commit ca4bc59

Browse files
committed
test: verify usedBy attaches to correct scope
1 parent c14f11d commit ca4bc59

File tree

2 files changed

+120
-0
lines changed

2 files changed

+120
-0
lines changed
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
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:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_1kvhh4n" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.44.0" modeler:executionPlatform="Camunda Cloud" modeler:executionPlatformVersion="8.7.0">
3+
<bpmn:process id="Process_1" name="Process_1" isExecutable="true">
4+
<bpmn:subProcess id="SubProcess_1" name="SubProcess_1">
5+
<bpmn:extensionElements>
6+
<zeebe:ioMapping>
7+
<zeebe:input target="approved" />
8+
</zeebe:ioMapping>
9+
</bpmn:extensionElements>
10+
<bpmn:outgoing>Flow_03u12aa</bpmn:outgoing>
11+
<bpmn:scriptTask id="Task_2" name="Task_2">
12+
<bpmn:extensionElements>
13+
<zeebe:script expression="=if approved then 1 else 0" resultVariable="taskResult" />
14+
</bpmn:extensionElements>
15+
</bpmn:scriptTask>
16+
</bpmn:subProcess>
17+
<bpmn:sequenceFlow id="Flow_03u12aa" sourceRef="SubProcess_1" targetRef="Task_1" />
18+
<bpmn:scriptTask id="Task_1" name="Task_1">
19+
<bpmn:extensionElements>
20+
<zeebe:script expression="=if approved then &#34;APPROVED&#34; else &#34;NOT APPROVED&#34;" resultVariable="taskResult" />
21+
</bpmn:extensionElements>
22+
<bpmn:incoming>Flow_03u12aa</bpmn:incoming>
23+
</bpmn:scriptTask>
24+
<bpmn:textAnnotation id="TextAnnotation_06v37so">
25+
<bpmn:text>Defines &lt;approved&gt; as local variable</bpmn:text>
26+
</bpmn:textAnnotation>
27+
<bpmn:association id="Association_1vyzo9d" associationDirection="None" sourceRef="SubProcess_1" targetRef="TextAnnotation_06v37so" />
28+
<bpmn:textAnnotation id="TextAnnotation_1gqpt1k">
29+
<bpmn:text>Uses &lt;approved&gt; variable</bpmn:text>
30+
</bpmn:textAnnotation>
31+
<bpmn:association id="Association_1613yyk" associationDirection="None" sourceRef="TextAnnotation_1gqpt1k" targetRef="Task_1" />
32+
<bpmn:association id="Association_15s62zn" associationDirection="None" sourceRef="TextAnnotation_1gqpt1k" targetRef="Task_2" />
33+
</bpmn:process>
34+
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
35+
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1">
36+
<bpmndi:BPMNShape id="Activity_0rpc80a_di" bpmnElement="Task_1">
37+
<dc:Bounds x="570" y="270" width="100" height="80" />
38+
<bpmndi:BPMNLabel />
39+
</bpmndi:BPMNShape>
40+
<bpmndi:BPMNShape id="Activity_13kwa1s_di" bpmnElement="SubProcess_1" isExpanded="true">
41+
<dc:Bounds x="160" y="210" width="350" height="200" />
42+
<bpmndi:BPMNLabel />
43+
</bpmndi:BPMNShape>
44+
<bpmndi:BPMNShape id="Activity_0azqo33_di" bpmnElement="Task_2">
45+
<dc:Bounds x="220" y="270" width="100" height="80" />
46+
</bpmndi:BPMNShape>
47+
<bpmndi:BPMNEdge id="Association_1613yyk_di" bpmnElement="Association_1613yyk">
48+
<di:waypoint x="480" y="530" />
49+
<di:waypoint x="613" y="350" />
50+
</bpmndi:BPMNEdge>
51+
<bpmndi:BPMNEdge id="Association_1vyzo9d_di" bpmnElement="Association_1vyzo9d">
52+
<di:waypoint x="347" y="210" />
53+
<di:waypoint x="355" y="135" />
54+
</bpmndi:BPMNEdge>
55+
<bpmndi:BPMNEdge id="Association_15s62zn_di" bpmnElement="Association_15s62zn">
56+
<di:waypoint x="436" y="530" />
57+
<di:waypoint x="279" y="350" />
58+
</bpmndi:BPMNEdge>
59+
<bpmndi:BPMNShape id="TextAnnotation_06v37so_di" bpmnElement="TextAnnotation_06v37so">
60+
<dc:Bounds x="310" y="80" width="100" height="54.999996185302734" />
61+
<bpmndi:BPMNLabel />
62+
</bpmndi:BPMNShape>
63+
<bpmndi:BPMNShape id="BPMNShape_0u3y3b2" bpmnElement="TextAnnotation_1gqpt1k">
64+
<dc:Bounds x="410" y="530" width="110" height="50" />
65+
<bpmndi:BPMNLabel />
66+
</bpmndi:BPMNShape>
67+
<bpmndi:BPMNEdge id="Flow_03u12aa_di" bpmnElement="Flow_03u12aa">
68+
<di:waypoint x="510" y="310" />
69+
<di:waypoint x="570" y="310" />
70+
</bpmndi:BPMNEdge>
71+
</bpmndi:BPMNPlane>
72+
</bpmndi:BPMNDiagram>
73+
</bpmn:definitions>

test/spec/zeebe/ZeebeVariableResolver.spec.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import subprocessNoOutputMappingXML from 'test/fixtures/zeebe/sub-process.no-out
3131
import longBrokenExpressionXML from 'test/fixtures/zeebe/long-broken-expression.bpmn';
3232
import immediatelyBrokenExpressionXML from 'test/fixtures/zeebe/immediately-broken-expression.bpmn';
3333
import typeResolutionXML from 'test/fixtures/zeebe/type-resolution.bpmn';
34+
import usedVariablesScopesXML from 'test/fixtures/zeebe/used-variables.scopes.bpmn';
3435

3536
import VariableProvider from 'lib/VariableProvider';
3637
import { getInputOutput } from '../../../lib/base/util/ExtensionElementsUtil';
@@ -2602,6 +2603,52 @@ describe('ZeebeVariableResolver', function() {
26022603

26032604
});
26042605

2606+
2607+
describe('used variables - scopes', function() {
2608+
2609+
beforeEach(bootstrapModeler(usedVariablesScopesXML, {
2610+
additionalModules: [
2611+
ZeebeVariableResolverModule
2612+
],
2613+
moddleExtensions: {
2614+
zeebe: ZeebeModdle
2615+
}
2616+
}));
2617+
2618+
2619+
it('should attach <usedBy> to local scope', inject(async function(elementRegistry, variableResolver) {
2620+
2621+
// given
2622+
const subProcess = elementRegistry.get('SubProcess_1');
2623+
2624+
// when
2625+
const variables = await variableResolver.getVariablesForElement(subProcess);
2626+
2627+
// then
2628+
expect(variables).to.variableEqual([
2629+
{ name: 'taskResult' },
2630+
{ name: 'approved', usedBy: [ 'Task_2' ] }
2631+
]);
2632+
}));
2633+
2634+
2635+
it('should attach <usedBy> to global scope', inject(async function(elementRegistry, variableResolver) {
2636+
2637+
// given
2638+
const rootElement = elementRegistry.get('Process_1');
2639+
2640+
// when
2641+
const variables = await variableResolver.getVariablesForElement(rootElement);
2642+
2643+
// then
2644+
expect(variables).to.variableEqual([
2645+
{ name: 'taskResult' },
2646+
{ name: 'approved', usedBy: [ 'Task_1' ] }
2647+
]);
2648+
}));
2649+
2650+
});
2651+
26052652
});
26062653

26072654
// helpers //////////////////////

0 commit comments

Comments
 (0)