diff --git a/mon-entreprise/cypress/integration/mon-entreprise/simulateurs.js b/mon-entreprise/cypress/integration/mon-entreprise/simulateurs.js index e2c322570..325e631f3 100644 --- a/mon-entreprise/cypress/integration/mon-entreprise/simulateurs.js +++ b/mon-entreprise/cypress/integration/mon-entreprise/simulateurs.js @@ -28,13 +28,13 @@ describe('Simulateurs', function() { cy.get(chargeInputSelector).type(1000) } cy.get(inputSelector).each((testedInput, i) => { - cy.wrap(testedInput).type('{selectall}60003') + cy.wrap(testedInput).type('{selectall}60100') cy.wait(1500) cy.contains('Cotisations') cy.get(inputSelector).each(($input, j) => { const val = $input.val().replace(/[\s,.]/g, '') if (i != j) { - expect(val).not.to.be.eq('60003') + expect(val).not.to.be.eq('60100') } expect(val).to.match(/[1-9][\d]{3,6}$/) }) diff --git a/publicodes/source/mecanisms/condition-allof.tsx b/publicodes/source/mecanisms/condition-allof.tsx index ec13b6640..15c37ad22 100644 --- a/publicodes/source/mecanisms/condition-allof.tsx +++ b/publicodes/source/mecanisms/condition-allof.tsx @@ -4,16 +4,28 @@ import { Mecanism } from '../components/mecanisms/common' import { evaluateNode, makeJsx, mergeAllMissing } from '../evaluation' const evaluate = (cache, situation, parsedRules, node) => { - const evaluateOne = child => - evaluateNode(cache, situation, parsedRules, child) - const explanation = map(evaluateOne, node.explanation) - const anyFalse = explanation.find(e => e.nodeValue === false) // court-circuit - const { nodeValue, missingVariables } = anyFalse ?? { - nodeValue: explanation.some(e => e.nodeValue === null) ? null : true, + const [nodeValue, explanation] = node.explanation.reduce( + ([nodeValue, explanation], node) => { + if (nodeValue === false) { + return [nodeValue, [...explanation, node]] + } + const evaluatedNode = evaluateNode(cache, situation, parsedRules, node) + return [ + nodeValue === false || nodeValue === null + ? nodeValue + : evaluatedNode.nodeValue, + [...explanation, evaluatedNode] + ] + }, + [true, []] + ) + + return { + ...node, + nodeValue, + explanation, missingVariables: mergeAllMissing(explanation) } - - return { ...node, nodeValue, explanation, missingVariables } } export const mecanismAllOf = (recurse, v) => {