diff --git a/source/engine/traverse.js b/source/engine/traverse.js index d162054c5..fc71e87db 100644 --- a/source/engine/traverse.js +++ b/source/engine/traverse.js @@ -91,9 +91,12 @@ let fillVariableNode = (rules, rule) => (parseResult) => { ? null // pas moyen de calculer car il n'y a pas de formule, elle restera donc nulle : parsedRule.nodeValue, // la valeur du calcul fait foi explanation = parsedRule, - missingVariables = variableIsCalculable ? [] : (nodeValue == null ? [dottedName] : []) + missingVariables = variableIsCalculable ? [] : [dottedName] - let collectMissing = node => variableIsCalculable ? collectNodeMissing(parsedRule) : node.missingVariables + let collectMissing = node => + nodeValue != null ? // notamment si situationValue != null + [] : + variableIsCalculable ? collectNodeMissing(parsedRule) : node.missingVariables let result = cached ? cached : { ...rewriteNode(node,nodeValue,explanation,collectMissing), diff --git a/test/generateQuestions.test.js b/test/generateQuestions.test.js index 7bfb8c6f6..7c1b55f48 100644 --- a/test/generateQuestions.test.js +++ b/test/generateQuestions.test.js @@ -93,6 +93,19 @@ describe('collectMissingVariables', function() { expect(result).to.deep.equal({}) }); + it('should not report missing variables when "une possibilité" was answered', function() { + let mySelector = (name) => ({"top . trois":"ko"})[name] + + let rawRules = [ + {nom: "startHere", formule: "trois", espace: "top"}, + {nom: "trois", formule: {"une possibilité":["ko"]}, espace: "top"}], + rules = rawRules.map(enrichRule), + situation = analyseTopDown(rules,"startHere")(mySelector), + result = collectMissingVariables()(mySelector,situation) + + expect(result).to.deep.equal({}) + }); + it('should report missing variables in switch statements', function() { let rawRules = [ { nom: "startHere", formule: {"aiguillage numérique": {