Skip to content

Commit

Permalink
test: added testcase for input output scope
Browse files Browse the repository at this point in the history
  • Loading branch information
abdul99ahad committed Jan 7, 2025
1 parent fe1ee89 commit 35b67c7
Show file tree
Hide file tree
Showing 2 changed files with 121 additions and 1 deletion.
39 changes: 39 additions & 0 deletions test/fixtures/zeebe/mappings/scope.bpmn
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
<bpmn:participant id="Participant_2" processRef="Process_2" />
<bpmn:participant id="Participant_3" processRef="Process_3" />
<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:collaboration>
<bpmn:process id="Process_1" isExecutable="true">
<bpmn:serviceTask id="scopedContext" name="Scoped Context">
Expand Down Expand Up @@ -51,6 +53,29 @@
</bpmn:extensionElements>
</bpmn:scriptTask>
</bpmn:process>
<bpmn:process id="Process_5" isExecutable="false">
<bpmn:scriptTask id="Activity_5" name="Script Task">
<bpmn:extensionElements>
<zeebe:script expression="={}" resultVariable="foo" />
<zeebe:ioMapping>
<zeebe:input source="=123" target="foo" />
<zeebe:output source="=&#34;bar&#34;" target="foo" />
<zeebe:output target="output" />
</zeebe:ioMapping>
</bpmn:extensionElements>
</bpmn:scriptTask>
</bpmn:process>
<bpmn:process id="Process_6" isExecutable="false">
<bpmn:userTask id="Activity_6" name="User Task">
<bpmn:extensionElements>
<zeebe:ioMapping>
<zeebe:input source="=123" target="foo" />
<zeebe:output source="={}" target="foo" />
<zeebe:output target="output" />
</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 @@ -84,6 +109,20 @@
<dc:Bounds x="280" y="1100" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Participant_08w9t3p_di" bpmnElement="Participant_5" isHorizontal="true">
<dc:Bounds x="160" y="1330" width="600" height="250" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_0jkek8a_di" bpmnElement="Activity_5">
<dc:Bounds x="280" y="1410" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Participant_1cpioa5_di" bpmnElement="Participant_6" isHorizontal="true">
<dc:Bounds x="160" y="1660" width="600" height="250" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_0gwc003_di" bpmnElement="Activity_6">
<dc:Bounds x="310" y="1740" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
83 changes: 82 additions & 1 deletion test/spec/zeebe/Mappings.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,45 @@ describe('ZeebeVariableResolver - Variable Mappings', function() {
}));


it('should only resolve the script result variable if input and result variable names conflict', inject(async function(variableResolver, elementRegistry) {
it('should only resolve the result variable globally given no output exists', inject(async function(variableResolver, elementRegistry) {

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

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

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


it('should only resolve the result variable locally if output exists', inject(async function(variableResolver, elementRegistry) {

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

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

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


it('should only resolve the result variable if input and result variable names conflict', inject(async function(variableResolver, elementRegistry) {

// given
const root = elementRegistry.get('Activity_1');
Expand All @@ -338,6 +376,49 @@ describe('ZeebeVariableResolver - Variable Mappings', function() {
]);
}));


it('should only resolve the output variable if result variable and output names conflict', inject(async function(variableResolver, elementRegistry) {

// given
const root = elementRegistry.get('Activity_5');
const bo = root.businessObject;
const output = getInputOutput(bo).outputParameters[1];

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

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


it('should only resolve the output variable if input and output names conflict', inject(async function(variableResolver, elementRegistry) {

// given
const root = elementRegistry.get('Activity_6');
const bo = root.businessObject;
const output = getInputOutput(bo).outputParameters[1];

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

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


});


Expand Down

0 comments on commit 35b67c7

Please sign in to comment.