🐛 Corrige les variables manquantes pour les sélections

pull/51/head
Laurent Bossavit 2017-09-19 00:08:39 +02:00
parent 4ba3362528
commit 58e935e791
2 changed files with 6 additions and 4 deletions

View File

@ -337,10 +337,11 @@ let mecanismSelection = (recurse,k,v) => {
let explanation = recurse(v['cherche'])
let evaluate = (situationGate, parsedRules, node) => {
let collectMissing = node => node.explanation.nodeValue ? [] : collectNodeMissing(node.explanation),
let collectMissing = node => collectNodeMissing(node.explanation),
explanation = evaluateNode(situationGate, parsedRules, node.explanation),
dataSource = findRuleByName(parsedRules, dataSourceName),
dataKey = evaluateNode(situationGate, parsedRules, explanation).nodeValue,
data = dataSource ? dataSource['data'] : null,
dataKey = explanation.nodeValue,
dataItems = (data && dataKey && dataSearchField) ? R.filter(item => item[dataSearchField] == dataKey, data) : null,
dataItemValues = dataItems ? R.values(dataItems) : null,
// TODO - over-specific! transform the JSON instead
@ -363,6 +364,7 @@ let mecanismSelection = (recurse,k,v) => {
return {
evaluate,
explanation,
jsx
}
}

View File

@ -265,16 +265,16 @@ describe('buildNextSteps', function() {
});
it('should generate questions from the real rules, experimental version', function() {
let stateSelector = (name) => ({"contrat salarié . type de contrat":"CDI"})[name]
let stateSelector = (name) => ({"contrat salarié . type de contrat":"CDI","entreprise . effectif":"50"})[name]
let rules = realRules.map(enrichRule),
situation = analyseTopDown(rules,"Salaire")(stateSelector),
objectives = getObjectives(stateSelector, situation.root, situation.parsedRules),
missing = collectMissingVariables()(stateSelector,situation),
result = buildNextSteps(stateSelector, rules, situation)
expect(R.path(["question","props","label"])(result[0])).to.equal("Quel est le salaire brut ?")
expect(R.path(["question","props","label"])(result[1])).to.equal("Le salarié a-t-il le statut cadre ?")
expect(R.path(["question","props","label"])(result[2])).to.equal("Quel est l'effectif de l'entreprise ?")
});
});