diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 6e77f0379..ba9bd3226 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -159,6 +159,15 @@ module.exports = { 'prettier', ], plugins: ['@typescript-eslint', 'vitest', 'testing-library'], + rules: { + 'vitest/expect-expect': [ + 'error', + { + assertFunctionNames: ['expect', 'runSimulations'], + additionalTestBlockFunctions: [], + }, + ], + }, }, // Accessibility rules on /site { diff --git a/modele-social/CHANGELOG.md b/modele-social/CHANGELOG.md index 3b7ec56a4..a28b47830 100644 --- a/modele-social/CHANGELOG.md +++ b/modele-social/CHANGELOG.md @@ -3,7 +3,8 @@ ## 2.0.1 - [protection sociale] Ajoute une condition de revenu pour bénéficier de la pension d'invalité pour les salariés -- publicodes : update to 1.0.2 (fix a bug with non applicable & contexte) +- Répare le calcul des cotisations forfaitaires de début d'activité +- publicodes : update to 1.0.4 ## 2.0.0 diff --git a/site/cypress/integration/mon-entreprise/simulateur-independant.ts b/site/cypress/integration/mon-entreprise/simulateur-independant.ts index 9c8f07713..d94fc66a4 100755 --- a/site/cypress/integration/mon-entreprise/simulateur-independant.ts +++ b/site/cypress/integration/mon-entreprise/simulateur-independant.ts @@ -1,4 +1,4 @@ -import { checkA11Y, fr } from '../../support/utils' +import { fr } from '../../support/utils' describe('Simulateur indépendant', { testIsolation: false }, function () { if (!fr) { @@ -18,8 +18,4 @@ describe('Simulateur indépendant', { testIsolation: false }, function () { ) cy.contains('Montant des cotisations forfaitaires').should('not.exist') }) - - it('should be RGAA compliant', function () { - checkA11Y() - }) }) diff --git a/site/cypress/support/utils.ts b/site/cypress/support/utils.ts index 707546f2f..0f1107479 100644 --- a/site/cypress/support/utils.ts +++ b/site/cypress/support/utils.ts @@ -7,7 +7,14 @@ type ViolationType = { export const checkA11Y = () => { cy.injectAxe() - cy.configureAxe({}) + cy.configureAxe({ + rules: [ + { + id: 'color-contrast', + enabled: false, + }, + ], + }) cy.checkA11y( null, null, diff --git a/site/test/conversation.test.ts b/site/test/conversation.test.ts index eae47d1b2..323f27cf0 100644 --- a/site/test/conversation.test.ts +++ b/site/test/conversation.test.ts @@ -13,7 +13,7 @@ describe('conversation', function () { 'top . a': { question: '?', titre: 'a', unité: '€' }, 'top . b': { question: '?', titre: 'b', unité: '€' }, }).evaluate('top . startHere').missingVariables - expect(getNextQuestions(missingVariables)[0]).to.equal('top . a') + expect(getNextQuestions(missingVariables)[0]).toBe('top . a') }) it('should first ask for questions without defaults, then those with defaults', function () { const engine = new Engine({ @@ -45,17 +45,17 @@ describe('conversation', function () { }, }) - expect( - getNextQuestions(engine.evaluate('net').missingVariables)[0] - ).to.equal('brut') + expect(getNextQuestions(engine.evaluate('net').missingVariables)[0]).toBe( + 'brut' + ) engine.setSituation({ brut: 2300, }) - expect( - getNextQuestions(engine.evaluate('net').missingVariables)[0] - ).to.equal('cadre') + expect(getNextQuestions(engine.evaluate('net').missingVariables)[0]).toBe( + 'cadre' + ) }) it('should ask "motif CDD" if "CDD" applies', function () { @@ -70,6 +70,6 @@ describe('conversation', function () { .missingVariables ) - expect(result).to.include('salarié . contrat . CDD . motif') + expect(result).toContain('salarié . contrat . CDD . motif') }) }) diff --git a/site/test/fabrique-social.test.ts b/site/test/fabrique-social.test.ts index e60b050ce..d33031ea5 100644 --- a/site/test/fabrique-social.test.ts +++ b/site/test/fabrique-social.test.ts @@ -11,11 +11,11 @@ describe('Fabrique Social', () => { describe('getSiegeOrFirstEtablissement Function', () => { it('should return siege', () => { const siege = getSiegeOrFirstEtablissement(fabriqueSocialWithSiege) - expect(siege.address).to.equal('23 RUE DE MOGADOR 75009 PARIS 9') + expect(siege.address).toBe('23 RUE DE MOGADOR 75009 PARIS 9') }) it('should return FirstEtablissement', () => { const siege = getSiegeOrFirstEtablissement(fabriqueSocialWithoutSiege) - expect(siege.address).to.equal('4 RUE VOLTAIRE 44000 NANTES') + expect(siege.address).toBe('4 RUE VOLTAIRE 44000 NANTES') }) }) }) diff --git a/site/test/modele-social.test.ts b/site/test/modele-social.test.ts index cc1e7ae01..93e9cd697 100644 --- a/site/test/modele-social.test.ts +++ b/site/test/modele-social.test.ts @@ -7,7 +7,7 @@ describe('modele-social', function () { beforeAll(() => { engine = new Engine(rules) }) - it("ne change pas le montant de l'IR ni des cotisations lorsqu'on verse un forfait mobilités durables ", function () { + it("ne change pas le montant de l'IR ni des cotisations lorsqu'on verse un forfait mobilités durables", function () { expect( engine .setSituation({ 'salarié . contrat . salaire brut': 2300 }) diff --git a/site/test/persistence.test.ts b/site/test/persistence.test.ts index 01af41d60..69f00b55f 100644 --- a/site/test/persistence.test.ts +++ b/site/test/persistence.test.ts @@ -56,13 +56,13 @@ describe('[persistence] When simulation persistence is setup', () => { }) it('saves state in localStorage with all fields', () => { expect(setItemSpy).toHaveBeenCalled() - expect(setItemSpy.mock.calls[0]![1]).to.equal( + expect(setItemSpy.mock.calls[0]![1]).toBe( '{"situation":{"dotted name":"42"},"activeTargetInput":"sometargetinput","foldedSteps":["somestep"]}' ) }) it('saves state in localStorage with a key dependent on the simulation url', () => { expect(setItemSpy).toHaveBeenCalled() - expect(setItemSpy.mock.calls[0]![0]).to.contain('someurl') + expect(setItemSpy.mock.calls[0]![0]).toContain('someurl') }) }) }) @@ -91,20 +91,18 @@ describe('[persistence] When simulation config is set', () => { store.dispatch(loadPreviousSimulation()) }) it('loads url in state', () => { - expect(store.getState().simulation.url).to.eq('/someotherurl') + expect(store.getState().simulation.url).toBe('/someotherurl') }) it('loads situation in state', () => { - expect(store.getState().simulation.situation).to.deep.eq({ + expect(store.getState().simulation.situation).toEqual({ 'dotted name . other': '42', }) }) it('loads activeTargetInput in state', () => { - expect(store.getState().activeTargetInput).to.eq('someothertargetinput') + expect(store.getState().activeTargetInput).toBe('someothertargetinput') }) it('loads foldedSteps in state', () => { - expect(store.getState().simulation.foldedSteps).to.deep.eq([ - 'someotherstep', - ]) + expect(store.getState().simulation.foldedSteps).toEqual(['someotherstep']) }) }) }) diff --git a/site/test/unit-translations.test.js b/site/test/unit-translations.test.js index 44480d1e4..9c6de3810 100644 --- a/site/test/unit-translations.test.js +++ b/site/test/unit-translations.test.js @@ -25,6 +25,6 @@ describe('Tests units', function () { const missingTranslations = units.filter( (unit) => ![...translatedKeys, ...blackList].includes(unit) ) - expect(missingTranslations).to.be.empty + expect(missingTranslations).toHaveLength(0) }) }) diff --git a/site/test/useSearchParamsSimulationSharing.test.js b/site/test/useSearchParamsSimulationSharing.test.js index 55e217ffe..86be55666 100644 --- a/site/test/useSearchParamsSimulationSharing.test.js +++ b/site/test/useSearchParamsSimulationSharing.test.js @@ -19,8 +19,7 @@ describe('identifiant court', () => { ]) it('should be unique amongst rules', () => { - expect(questions.length).to.greaterThan(0) - expect(questions.length).to.eq( + expect(questions).toHaveLength( new Set(questions.map(([, name]) => name)).size ) }) @@ -47,7 +46,7 @@ rule without: dottedNameParamName, '€/an' ).toString() - ).to.equal( + ).toBe( new URLSearchParams( 'panta=2000€/mois&rule without=1000€/mois&unite=€/an' ).toString() @@ -61,7 +60,7 @@ rule without: dottedNameParamName, '€/an' ).toString() - ).to.equal( + ).toBe( new URLSearchParams('rule without={"1":2,"3":{"4":"5"}}').toString() + '&unite=%E2%82%AC%2Fan' ) @@ -69,7 +68,7 @@ rule without: it('handles empty situation with proper defaults', () => { expect( getSearchParams(engine, {}, dottedNameParamName, '€/mois').toString() - ).to.equal('unite=%E2%82%AC%2Fmois') + ).toBe('unite=%E2%82%AC%2Fmois') }) }) @@ -80,7 +79,7 @@ rule without: new URLSearchParams('panta=2000€/mois&rule without=1000€/mois'), dottedNameParamName ) - ).to.deep.equal({ + ).toEqual({ 'rule with': '2000€/mois', 'rule without': '1000€/mois', }) @@ -91,7 +90,7 @@ rule without: new URLSearchParams(''), dottedNameParamName ) - ).to.deep.equal({}) + ).toEqual({}) }) }) })