diff --git a/source/engine/evaluation.js b/source/engine/evaluation.js index 6a6a2eee7..3ca441a6a 100644 --- a/source/engine/evaluation.js +++ b/source/engine/evaluation.js @@ -23,7 +23,7 @@ export let evaluateArray = (reducer, start, nullable = true) => (situationGate, values = R.pluck("nodeValue",explanation), nodeValue = (nullable && R.any(R.equals(null),values)) ? null : R.reduce(reducer, start, values) - let collectMissing = node => R.chain(collectNodeMissing,node.explanation) + let collectMissing = node => node.nodeValue == null ? R.chain(collectNodeMissing,node.explanation) : [] return rewriteNode(node,nodeValue,explanation,collectMissing) } diff --git a/test/generateQuestions.test.js b/test/generateQuestions.test.js index 9a5e612c1..cc5a0abb4 100644 --- a/test/generateQuestions.test.js +++ b/test/generateQuestions.test.js @@ -65,6 +65,18 @@ describe('collectMissingVariables', function() { expect(result).to.be.empty }); + it('should not report missing variables when "one of these" short-circuits', function() { + let rawRules = [ + {nom: "startHere", formule: {somme: [2, "deux"]}, espace: "sum"}, + {nom: "deux", formule: "trois", "non applicable si" : {"une de ces conditions": ["3 > 2", "trois"]}, espace: "sum"}, + {nom: "trois", espace: "sum"}], + rules = rawRules.map(enrichRule), + situation = analyseTopDown(rules,"startHere")(stateSelector), + result = collectMissingVariables()(stateSelector,situation) + + expect(result).to.be.empty + }); + }); describe('buildNextSteps', function() {