2020-12-09 11:41:58 +00:00
import rules from 'modele-social'
2021-11-30 16:47:28 +00:00
import { utils } from 'publicodes'
2022-06-23 15:19:07 +00:00
import { describe , expect , it } from 'vitest'
2020-10-08 09:29:07 +00:00
2022-06-23 15:19:07 +00:00
// We skip static cycle test, as it does not separates applicability dependencies from value dependencies.
// The previous version was not handling cycle from applicability at all
// We may need a better algorithm for static cycle detection. But it's not a priority as there is a now a
// functionning cycle detection at runtime
describe . skip ( 'DottedNames graph' , ( ) => {
2020-10-08 09:29:07 +00:00
it ( "shouldn't have cycles" , ( ) => {
2021-11-30 16:47:28 +00:00
const [ cyclesDependencies , dotGraphs ] = utils . cyclicDependencies ( rules )
2021-05-04 17:40:10 +00:00
const dotGraphsToLog = dotGraphs
. map (
( dotGraph ) =>
` 🌀🌀🌀🌀🌀🌀🌀🌀🌀🌀🌀 \n A cycle graph to stare at with Graphviz: \n ${ dotGraph } \n \n `
)
. join ( '\n\n' )
2020-10-08 09:29:07 +00:00
expect (
2020-11-24 16:22:34 +00:00
cyclesDependencies ,
2021-05-04 17:40:10 +00:00
` ${ dotGraphsToLog } \n AT LEAST the following cycles have been found in the rules dependencies graph. \n See below for a representation of each cycle. \n ⬇️ is a node of the cycle. \n \t - ${ cyclesDependencies
2020-10-08 09:29:07 +00:00
. map (
( cycleDependencies , idx ) =>
2021-05-04 17:40:10 +00:00
'#' + idx + ':\n\t\t⬇️ ' + cycleDependencies . join ( '\n\t\t⬇️ ' )
2020-10-08 09:29:07 +00:00
)
. join ( '\n\t- ' ) } \ n \ n `
2021-05-04 17:40:10 +00:00
) . to . deep . equal ( [
[
2022-09-14 13:10:40 +00:00
'dirigeant . rémunération . net . imposable' ,
2021-07-28 11:42:44 +00:00
'dirigeant . auto-entrepreneur . impôt . revenu imposable' ,
2021-05-04 17:40:10 +00:00
"entreprise . chiffre d'affaires" ,
2022-09-14 13:10:40 +00:00
'dirigeant . rémunération . net . après impôt' ,
'dirigeant . rémunération . net' ,
2021-06-30 08:20:42 +00:00
'dirigeant . rémunération . totale' ,
2021-09-14 10:46:48 +00:00
'impôt . montant' ,
2021-06-30 08:20:42 +00:00
'impôt . revenu imposable' ,
2021-05-04 17:40:10 +00:00
] ,
] )
console . warn (
"[ WARNING ] A cycle still exists around `entreprise . chiffre d'affaires` see issue #1524 for a definitive fix."
2020-12-01 09:17:27 +00:00
)
2020-10-08 09:29:07 +00:00
} )
} )