From 35b67c75824501f1b7bfd6aad05cd27426387b24 Mon Sep 17 00:00:00 2001 From: Abdul Ahad Date: Mon, 23 Dec 2024 20:01:17 +0500 Subject: [PATCH] test: added testcase for input output scope --- test/fixtures/zeebe/mappings/scope.bpmn | 39 ++++++++++++ test/spec/zeebe/Mappings.spec.js | 83 ++++++++++++++++++++++++- 2 files changed, 121 insertions(+), 1 deletion(-) diff --git a/test/fixtures/zeebe/mappings/scope.bpmn b/test/fixtures/zeebe/mappings/scope.bpmn index 2a65f14..684ced0 100644 --- a/test/fixtures/zeebe/mappings/scope.bpmn +++ b/test/fixtures/zeebe/mappings/scope.bpmn @@ -5,6 +5,8 @@ + + @@ -51,6 +53,29 @@ + + + + + + + + + + + + + + + + + + + + + + + @@ -84,6 +109,20 @@ + + + + + + + + + + + + + + diff --git a/test/spec/zeebe/Mappings.spec.js b/test/spec/zeebe/Mappings.spec.js index c005146..7c9fcab 100644 --- a/test/spec/zeebe/Mappings.spec.js +++ b/test/spec/zeebe/Mappings.spec.js @@ -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'); @@ -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: '', + } + ]); + })); + + });