Skip to content

Commit 8d34c58

Browse files
committed
fixup: fix tests for originTask instead of targetName
1 parent e793e6a commit 8d34c58

File tree

2 files changed

+14
-66
lines changed

2 files changed

+14
-66
lines changed

lib/zeebe/util/feelUtility.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -704,8 +704,7 @@ function buildConsumedVariables(analysisResults) {
704704
name: inputVar.name,
705705
origin: undefined,
706706
entries: inputVar.entries || [],
707-
usedBy: [ origin ],
708-
provider: [],
707+
usedBy: [ origin ]
709708
};
710709
} else {
711710
if (!consumedVariables[key].usedBy.includes(targetName)) {

test/spec/zeebe/Mappings.spec.js

Lines changed: 13 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -902,12 +902,10 @@ describe('ZeebeVariableResolver - Variable Mappings', function() {
902902
const variables = await variableResolver.getConsumedVariablesForElement(task);
903903

904904
// then
905-
const a = variables.find(v => v.name === 'a');
906-
const b = variables.find(v => v.name === 'b');
907-
expect(a).to.exist;
908-
expect(b).to.exist;
909-
expect(a.usedBy).to.eql([ 'sum' ]);
910-
expect(b.usedBy).to.eql([ 'sum' ]);
905+
expect(variables).to.variableEqual([
906+
{ name: 'a', usedBy: [ 'SimpleTask' ] },
907+
{ name: 'b', usedBy: [ 'SimpleTask' ] }
908+
]);
911909
}));
912910

913911

@@ -923,7 +921,7 @@ describe('ZeebeVariableResolver - Variable Mappings', function() {
923921
expect(variables).to.variableInclude({
924922
name: 'order',
925923
entries: [ { name: 'items' } ],
926-
usedBy: [ 'orderItems' ]
924+
usedBy: [ 'NestedTask' ]
927925
});
928926
}));
929927

@@ -942,20 +940,6 @@ describe('ZeebeVariableResolver - Variable Mappings', function() {
942940
}));
943941

944942

945-
it('should track multiple usedBy targets', inject(async function(variableResolver, elementRegistry) {
946-
947-
// given
948-
const task = elementRegistry.get('MultiInputTask');
949-
950-
// when
951-
const variables = await variableResolver.getConsumedVariablesForElement(task);
952-
953-
// then - y is used in both result1 (=x+y) and result2 (=y+z)
954-
const y = variables.find(v => v.name === 'y');
955-
expect(y.usedBy).to.eql([ 'result1', 'result2' ]);
956-
}));
957-
958-
959943
it('should extract all unique input variables from multiple mappings', inject(async function(variableResolver, elementRegistry) {
960944

961945
// given
@@ -1095,12 +1079,10 @@ describe('ZeebeVariableResolver - Variable Mappings', function() {
10951079
const variables = await variableResolver.getConsumedVariablesForElement(task);
10961080

10971081
// then
1098-
const a = variables.find(v => v.name === 'a');
1099-
const b = variables.find(v => v.name === 'b');
1100-
expect(a).to.exist;
1101-
expect(b).to.exist;
1102-
expect(a.usedBy).to.eql([ 'firstResult' ]);
1103-
expect(b.usedBy).to.eql([ 'firstResult' ]);
1082+
expect(variables).to.variableEqual([
1083+
{ name: 'a', usedBy: [ 'firstTask' ] },
1084+
{ name: 'b', usedBy: [ 'firstTask' ] }
1085+
]);
11041086
}));
11051087

11061088

@@ -1113,28 +1095,10 @@ describe('ZeebeVariableResolver - Variable Mappings', function() {
11131095
const variables = await variableResolver.getConsumedVariablesForElement(task);
11141096

11151097
// then
1116-
const d = variables.find(v => v.name === 'd');
1117-
const f = variables.find(v => v.name === 'f');
1118-
expect(d).to.exist;
1119-
expect(f).to.exist;
1120-
expect(d.usedBy).to.eql([ 'secondResult' ]);
1121-
expect(f.usedBy).to.eql([ 'secondResult' ]);
1122-
}));
1123-
1124-
1125-
it('should associate script task inputs with the task origin', inject(async function(variableResolver, elementRegistry) {
1126-
1127-
// given
1128-
const firstTask = elementRegistry.get('firstTask');
1129-
const secondTask = elementRegistry.get('secondTask');
1130-
1131-
// when
1132-
const firstVars = await variableResolver.getConsumedVariablesForElement(firstTask);
1133-
const secondVars = await variableResolver.getConsumedVariablesForElement(secondTask);
1134-
1135-
// then - a originates from firstTask, d originates from secondTask
1136-
expect(firstVars).to.variableInclude({ name: 'a', origin: [ 'firstTask' ] });
1137-
expect(secondVars).to.variableInclude({ name: 'd', origin: [ 'secondTask' ] });
1098+
expect(variables).to.variableEqual([
1099+
{ name: 'd', usedBy: [ 'secondTask' ] },
1100+
{ name: 'f', usedBy: [ 'secondTask' ] }
1101+
]);
11381102
}));
11391103

11401104

@@ -1400,21 +1364,6 @@ describe('ZeebeVariableResolver - Variable Mappings', function() {
14001364
}));
14011365

14021366

1403-
it('should include usedBy information', inject(async function(variableResolver, elementRegistry) {
1404-
1405-
// given
1406-
const task = elementRegistry.get('SimpleTask');
1407-
1408-
// when
1409-
const requirements = await variableResolver.getConsumedVariablesForElement(task);
1410-
1411-
// then
1412-
const b = requirements.find(v => v.name === 'b');
1413-
expect(b).to.exist;
1414-
expect(b.usedBy).to.eql([ 'sum' ]);
1415-
}));
1416-
1417-
14181367
it('should return consumed variables even when other tasks use the same variable', inject(async function(variableResolver, elementRegistry) {
14191368

14201369
// given - MergedEntriesTask uses 'a' which is also used by SimpleTask

0 commit comments

Comments
 (0)