diff --git a/test/fixtures/zeebe/used-variables.scopes.bpmn b/test/fixtures/zeebe/used-variables.scopes.bpmn new file mode 100644 index 0000000..e5da4a0 --- /dev/null +++ b/test/fixtures/zeebe/used-variables.scopes.bpmn @@ -0,0 +1,73 @@ + + + + + + + + + + Flow_03u12aa + + + + + + + + + + + + Flow_03u12aa + + + Defines <approved> as local variable + + + + Uses <approved> variable + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/spec/zeebe/ZeebeVariableResolver.spec.js b/test/spec/zeebe/ZeebeVariableResolver.spec.js index f6e3536..d2f3ce3 100644 --- a/test/spec/zeebe/ZeebeVariableResolver.spec.js +++ b/test/spec/zeebe/ZeebeVariableResolver.spec.js @@ -31,6 +31,7 @@ import subprocessNoOutputMappingXML from 'test/fixtures/zeebe/sub-process.no-out import longBrokenExpressionXML from 'test/fixtures/zeebe/long-broken-expression.bpmn'; import immediatelyBrokenExpressionXML from 'test/fixtures/zeebe/immediately-broken-expression.bpmn'; import typeResolutionXML from 'test/fixtures/zeebe/type-resolution.bpmn'; +import usedVariablesScopesXML from 'test/fixtures/zeebe/used-variables.scopes.bpmn'; import VariableProvider from 'lib/VariableProvider'; import { getInputOutput } from '../../../lib/base/util/ExtensionElementsUtil'; @@ -2602,6 +2603,52 @@ describe('ZeebeVariableResolver', function() { }); + + describe('used variables - scopes', function() { + + beforeEach(bootstrapModeler(usedVariablesScopesXML, { + additionalModules: [ + ZeebeVariableResolverModule + ], + moddleExtensions: { + zeebe: ZeebeModdle + } + })); + + + it('should attach to local scope', inject(async function(elementRegistry, variableResolver) { + + // given + const subProcess = elementRegistry.get('SubProcess_1'); + + // when + const variables = await variableResolver.getVariablesForElement(subProcess); + + // then + expect(variables).to.variableEqual([ + { name: 'taskResult' }, + { name: 'approved', usedBy: [ 'Task_2' ] } + ]); + })); + + + it('should attach to global scope', inject(async function(elementRegistry, variableResolver) { + + // given + const rootElement = elementRegistry.get('Process_1'); + + // when + const variables = await variableResolver.getVariablesForElement(rootElement); + + // then + expect(variables).to.variableEqual([ + { name: 'taskResult' }, + { name: 'approved', usedBy: [ 'Task_1' ] } + ]); + })); + + }); + }); // helpers //////////////////////