From 407ededb366b062d6170a31172ee957ec51b0a7c Mon Sep 17 00:00:00 2001 From: maxgfr <25312957+maxgfr@users.noreply.github.com> Date: Sat, 28 Dec 2024 11:34:58 +0100 Subject: [PATCH] fix: modif v2 --- .../pages/outils/[slug].tsx | 2 + .../src/modules/common/Html.tsx | 27 +- .../AgreementInput/AgreementTile.tsx | 57 --- .../AgreementInput/SearchAgreementInput.tsx | 160 ------- .../AgreementSearch/AgreementNoResult.tsx | 135 ------ .../AgreementSearch/AgreementSearch.tsx | 97 ----- .../Agreement/AgreementSearch/index.ts | 3 - .../EnterpriseSearch/EnterpriseSearch.tsx | 133 ------ .../EnterpriseButton.tsx | 71 ---- .../SearchEnterpriseInput.tsx | 172 -------- .../EntrepriseSearchResult.tsx | 133 ------ .../EnterpriseSearch/Location/Search.tsx | 208 --------- .../EnterpriseSearch/Location/searchCities.ts | 37 -- .../EnterpriseSearch/SelectedEnterprise.tsx | 39 -- .../EnterpriseSearch/ShowAgreement.tsx | 41 -- .../EnterpriseSearch/ShowAgreements.tsx | 105 ----- .../Agreement/EnterpriseSearch/index.ts | 3 - .../RouteSelection/RouteSelection.tsx | 127 ------ .../Agreement/RouteSelection/ShowAlert.tsx | 44 -- .../Agreement/RouteSelection/index.ts | 3 - .../components/Agreement/SelectAgreement.tsx | 173 -------- .../__tests__/AgreementSearch.test.tsx | 243 ----------- .../__tests__/EnterpriseSearch.test.tsx | 395 ------------------ .../__tests__/RouteSelection.test.tsx | 145 ------- .../__tests__/SelectAgreement.test.tsx | 108 ----- .../components/Agreement/components/Modal.tsx | 32 -- .../Agreement/components/ResultList.tsx | 88 ---- .../Agreement/components/ShowAlert.tsx | 117 ------ .../Agreement/components/Suggester.ts | 118 ------ .../components/Agreement/form-constants.ts | 4 - .../common/components/Agreement/index.ts | 4 - .../__tests__/handleTrackEvent.test.tsx | 70 ---- .../__tests__/pushAgreementEvents.test.tsx | 255 ----------- .../Agreement/tracking/handleTrackEvent.ts | 49 --- .../components/Agreement/tracking/index.ts | 4 - .../Agreement/tracking/pushAgreementEvents.ts | 78 ---- .../common/components/Agreement/types.ts | 13 - .../components/Feedback/Questionnaire.tsx | 59 --- .../Feedback/QuestionnaireAdvanced.tsx | 112 ----- .../components/Feedback/QuestionnaireEnd.tsx | 19 - .../components/Feedback/QuestionnaireItem.tsx | 114 ----- .../components/Feedback/QuestionnaireText.tsx | 48 --- .../Feedback/__tests__/feedback.test.tsx | 129 ------ .../components/Feedback/__tests__/ui.ts | 53 --- .../common/components/Feedback/index.tsx | 113 ----- .../components/Feedback/introduction.tsx | 22 - .../common/components/Feedback/tracking.ts | 52 --- .../common/components/Informations/index.ts | 1 - .../common/components/RadioQuestion.tsx | 45 +- .../common/components/SelectQuestion.tsx | 81 ++-- .../components/SimulatorLayout/index.tsx | 78 ++-- .../outils/common/components/TextQuestion.tsx | 76 ++-- .../modules/outils/common/components/types.ts | 5 - .../Informations.tsx | 17 +- .../Informations.tsx | 18 +- .../1672-societes-assurances/Informations.tsx | 17 +- .../Informations.tsx | 17 +- .../Informations.tsx | 18 +- .../agreements/2120-banques/Component.tsx | 10 +- .../2148-telecommunications/Informations.tsx | 17 +- .../agreements/2596-coiffure/Informations.tsx | 17 +- .../agreements/ui-customizations/index.ts | 1 - .../agreements/ui-customizations/tooltip.tsx | 10 - .../outils/common/indemnite-depart/index.tsx | 72 ++-- .../Agreement/components/AgreementStep.tsx | 10 +- .../steps/Agreement/index.tsx | 27 +- .../steps/Agreement/store/store.ts | 3 +- .../steps/Agreement/store/types.ts | 2 +- .../Anciennete/components/AbsencePeriod.tsx | 177 +++----- .../Anciennete/components/AbsencePeriods.tsx | 50 ++- .../components/SectionTitleWithTooltip.tsx | 50 --- .../SectionTitleWithTooltip.test.tsx | 18 - .../steps/Anciennete/components/index.ts | 1 - .../steps/Anciennete/store/store.ts | 2 +- .../steps/Anciennete/store/types.ts | 2 +- .../store/validator/absencePeriods.ts | 2 +- .../components}/PubliQuestion.tsx | 50 +-- .../__tests__/PubliQuestion.test.tsx | 2 +- .../steps/Informations/index.tsx | 2 +- .../steps/Informations/store/store.ts | 2 +- .../__tests__/informationToSituation.test.ts | 2 +- .../steps}/Informations/utils/index.ts | 0 .../utils/informationToSituation.ts | 2 +- .../Resultat/components/AbsenceTable.tsx | 5 +- .../Resultat/components/FilledElements.tsx | 5 +- .../__tests__/FilledElements.test.tsx | 2 +- .../steps/Resultat/store/store.ts | 2 +- ...{TooltipSalary.tsx => HighlightSalary.tsx} | 13 +- .../Salaires/components/SalaireTempsPlein.tsx | 37 +- .../steps/Salaires/components/index.ts | 2 +- .../indemnite-depart/steps/Salaires/index.tsx | 21 +- .../steps/Salaires/store/store.ts | 2 +- .../absence-date-onchange-motif.test.tsx | 112 ----- .../absence-date-with-agreement.test.tsx | 116 ----- .../absence-date-without-agreement.test.tsx | 73 ---- .../__tests__/arret-travail.test.tsx | 134 ------ .../__tests__/cc1404.test.tsx | 100 ----- .../__tests__/cc1486.test.tsx | 82 ---- .../__tests__/cc1516.test.tsx | 127 ------ .../__tests__/cc1517.test.tsx | 61 --- .../__tests__/cc1527.test.tsx | 103 ----- .../__tests__/cc16.test.tsx | 227 ---------- .../__tests__/cc1672.test.tsx | 176 -------- .../__tests__/cc1702.test.tsx | 211 ---------- .../__tests__/cc2098.test.tsx | 71 ---- .../__tests__/cc2120.test.tsx | 66 --- .../__tests__/cc2148.test.tsx | 129 ------ .../__tests__/cc2596.test.tsx | 239 ----------- .../__tests__/cc2609.test.tsx | 108 ----- .../__tests__/cc3127.test.tsx | 68 --- .../__tests__/cc3239-reset-data.test.tsx | 96 ----- .../__tests__/cc3239.test.tsx | 235 ----------- .../__tests__/cc3248.test.tsx | 99 ----- .../__tests__/cc44.test.tsx | 287 ------------- .../__tests__/cc573.test.tsx | 67 --- .../__tests__/cc675.test.tsx | 61 --- .../__tests__/cc86.test.tsx | 59 --- .../eligibility-error-result.test.tsx | 138 ------ ...ntation-1-jour-anciennet\303\251.test.tsx" | 41 -- .../indemnite-licenciement-cc-select.test.tsx | 68 --- .../indemnite-licenciement-contract.test.tsx | 47 --- .../__tests__/information.test.tsx | 212 ---------- .../__tests__/no-agreement-result.test.tsx | 128 ------ .../__tests__/notification.test.tsx | 74 ---- .../__tests__/resultat-formules.test.tsx | 141 ------- .../__tests__/salary-validation.test.tsx | 165 -------- .../__tests__/seniority-validation.test.tsx | 230 ---------- .../__tests__/tracking.test.tsx | 287 ------------- ...dation-anciennet\303\251-absence.test.tsx" | 39 -- .../agreements/ui-customizations/index.ts | 1 - .../agreements/ui-customizations/messages.ts | 27 -- .../useIndemniteLicenciementEventEmitter.tsx | 33 -- .../outils/indemnite-licenciement/index.tsx | 82 ---- .../steps/Anciennet\303\251/index.tsx" | 168 -------- .../steps/ContratTravail/index.tsx | 164 -------- .../steps/Introduction/components/Intro.tsx | 19 - .../components/__tests__/Intro.test.tsx | 9 - .../steps/Introduction/components/index.ts | 1 - .../steps/Introduction/index.tsx | 6 - .../steps/Resultat/Eligible.tsx | 247 ----------- .../steps/Resultat/Ineligible.tsx | 39 -- .../steps/Resultat/index.tsx | 15 - .../indemnite-licenciement/steps/index.ts | 4 - .../IndemniteRuptureCoSimulator.tsx | 71 ++-- .../steps/Anciennete/index.tsx | 44 +- .../steps/ContratTravail/index.tsx | 10 +- .../steps/Resultat/Eligible.tsx | 2 +- 147 files changed, 448 insertions(+), 10378 deletions(-) delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/AgreementSearch/AgreementInput/AgreementTile.tsx delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/AgreementSearch/AgreementInput/SearchAgreementInput.tsx delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/AgreementSearch/AgreementNoResult.tsx delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/AgreementSearch/AgreementSearch.tsx delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/AgreementSearch/index.ts delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/EnterpriseSearch/EnterpriseSearch.tsx delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/EnterpriseSearch/EntrepriseSearchInput/EnterpriseButton.tsx delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/EnterpriseSearch/EntrepriseSearchInput/SearchEnterpriseInput.tsx delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/EnterpriseSearch/EntrepriseSearchResult.tsx delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/EnterpriseSearch/Location/Search.tsx delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/EnterpriseSearch/Location/searchCities.ts delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/EnterpriseSearch/SelectedEnterprise.tsx delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/EnterpriseSearch/ShowAgreement.tsx delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/EnterpriseSearch/ShowAgreements.tsx delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/EnterpriseSearch/index.ts delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/RouteSelection/RouteSelection.tsx delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/RouteSelection/ShowAlert.tsx delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/RouteSelection/index.ts delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/SelectAgreement.tsx delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/__tests__/AgreementSearch.test.tsx delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/__tests__/EnterpriseSearch.test.tsx delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/__tests__/RouteSelection.test.tsx delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/__tests__/SelectAgreement.test.tsx delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/components/Modal.tsx delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/components/ResultList.tsx delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/components/ShowAlert.tsx delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/components/Suggester.ts delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/form-constants.ts delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/index.ts delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/tracking/__tests__/handleTrackEvent.test.tsx delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/tracking/__tests__/pushAgreementEvents.test.tsx delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/tracking/handleTrackEvent.ts delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/tracking/index.ts delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/tracking/pushAgreementEvents.ts delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/types.ts delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/common/components/Feedback/Questionnaire.tsx delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/common/components/Feedback/QuestionnaireAdvanced.tsx delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/common/components/Feedback/QuestionnaireEnd.tsx delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/common/components/Feedback/QuestionnaireItem.tsx delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/common/components/Feedback/QuestionnaireText.tsx delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/common/components/Feedback/__tests__/feedback.test.tsx delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/common/components/Feedback/__tests__/ui.ts delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/common/components/Feedback/index.tsx delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/common/components/Feedback/introduction.tsx delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/common/components/Feedback/tracking.ts delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/common/components/Informations/index.ts delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/common/components/types.ts delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/agreements/ui-customizations/tooltip.tsx delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Anciennete/components/SectionTitleWithTooltip.tsx delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Anciennete/components/__tests__/SectionTitleWithTooltip.test.tsx rename packages/code-du-travail-frontend/src/modules/outils/common/{components/Informations => indemnite-depart/steps/Informations/components}/PubliQuestion.tsx (67%) rename packages/code-du-travail-frontend/src/modules/outils/common/{components/Informations => indemnite-depart/steps/Informations/components}/__tests__/PubliQuestion.test.tsx (98%) rename packages/code-du-travail-frontend/src/modules/outils/common/{components => indemnite-depart/steps}/Informations/utils/__tests__/informationToSituation.test.ts (93%) rename packages/code-du-travail-frontend/src/modules/outils/common/{components => indemnite-depart/steps}/Informations/utils/index.ts (100%) rename packages/code-du-travail-frontend/src/modules/outils/common/{components => indemnite-depart/steps}/Informations/utils/informationToSituation.ts (63%) rename packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Salaires/components/{TooltipSalary.tsx => HighlightSalary.tsx} (89%) delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/absence-date-onchange-motif.test.tsx delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/absence-date-with-agreement.test.tsx delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/absence-date-without-agreement.test.tsx delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/arret-travail.test.tsx delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc1404.test.tsx delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc1486.test.tsx delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc1516.test.tsx delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc1517.test.tsx delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc1527.test.tsx delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc16.test.tsx delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc1672.test.tsx delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc1702.test.tsx delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc2098.test.tsx delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc2120.test.tsx delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc2148.test.tsx delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc2596.test.tsx delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc2609.test.tsx delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc3127.test.tsx delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc3239-reset-data.test.tsx delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc3239.test.tsx delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc3248.test.tsx delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc44.test.tsx delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc573.test.tsx delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc675.test.tsx delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc86.test.tsx delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/eligibility-error-result.test.tsx delete mode 100644 "packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/incrementation-1-jour-anciennet\303\251.test.tsx" delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/indemnite-licenciement-cc-select.test.tsx delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/indemnite-licenciement-contract.test.tsx delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/information.test.tsx delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/no-agreement-result.test.tsx delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/notification.test.tsx delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/resultat-formules.test.tsx delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/salary-validation.test.tsx delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/seniority-validation.test.tsx delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/tracking.test.tsx delete mode 100644 "packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/validation-anciennet\303\251-absence.test.tsx" delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/agreements/ui-customizations/index.ts delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/agreements/ui-customizations/messages.ts delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/events/useIndemniteLicenciementEventEmitter.tsx delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/index.tsx delete mode 100644 "packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/steps/Anciennet\303\251/index.tsx" delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/steps/ContratTravail/index.tsx delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/steps/Introduction/components/Intro.tsx delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/steps/Introduction/components/__tests__/Intro.test.tsx delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/steps/Introduction/components/index.ts delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/steps/Introduction/index.tsx delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/steps/Resultat/Eligible.tsx delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/steps/Resultat/Ineligible.tsx delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/steps/Resultat/index.tsx delete mode 100644 packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/steps/index.ts diff --git a/packages/code-du-travail-frontend/pages/outils/[slug].tsx b/packages/code-du-travail-frontend/pages/outils/[slug].tsx index e3437959af..a061cb3d37 100644 --- a/packages/code-du-travail-frontend/pages/outils/[slug].tsx +++ b/packages/code-du-travail-frontend/pages/outils/[slug].tsx @@ -18,6 +18,7 @@ import { HeuresRechercheEmploi, SimulateurIndemnitePrecarite, CalculateurPreavisRetraite, + CalculateurIndemniteLicenciement, } from "../../src/outils"; import { getBySlugTools, @@ -33,6 +34,7 @@ const toolsBySlug = { "preavis-licenciement": DureePreavisLicenciement, "preavis-retraite": CalculateurPreavisRetraite, "procedure-licenciement": DismissalProcess, + "indemnite-licenciement": CalculateurIndemniteLicenciement, }; export interface Props { diff --git a/packages/code-du-travail-frontend/src/modules/common/Html.tsx b/packages/code-du-travail-frontend/src/modules/common/Html.tsx index fb16015420..a057998ba3 100644 --- a/packages/code-du-travail-frontend/src/modules/common/Html.tsx +++ b/packages/code-du-travail-frontend/src/modules/common/Html.tsx @@ -4,13 +4,36 @@ import { xssWrapper } from "../../lib"; type Props = { children: string; as?: string; - inline?: boolean; }; const Html = ({ children, ...props }: Props): JSX.Element => { + if (props.as === "p") { + return ( +

+ ); + } else if (props.as === "span") { + return ( + + ); + } else if (props.as === "div") { + return ( +

+ ); + } return (
{ - onUserAction(UserAction.SelectAgreement, `idcc${agreement.num.toString()}`); - window.parent?.postMessage( - { - name: "agreement", - kind: "select", - extra: { idcc: agreement.num, title: agreement.title }, - }, - "*" - ); - }; - return ( - - - {agreement.contributions - ? "Retrouvez les questions-réponses les plus fréquentes organisées par thème et élaborées par le Ministère du travail concernant cette convention collective" - : "Consultez les dispositions de cette convention collective"} - - - ); -} diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/AgreementSearch/AgreementInput/SearchAgreementInput.tsx b/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/AgreementSearch/AgreementInput/SearchAgreementInput.tsx deleted file mode 100644 index 3d5c3679e1..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/AgreementSearch/AgreementInput/SearchAgreementInput.tsx +++ /dev/null @@ -1,160 +0,0 @@ -import { Label, Text, theme } from "@socialgouv/cdtn-ui"; -import React, { useState } from "react"; -import styled from "styled-components"; -import { formatIdcc } from "@socialgouv/modeles-social"; -import { InfoBulle } from "../../../InfoBulle"; -import { searchAgreements } from "../../../../../conventions/Search/api/agreements.service"; -import { - TrackingProps, - UserAction, -} from "../../../../ConventionCollective/types"; -import { AgreementNoResult } from "../AgreementNoResult"; -import { Agreement } from "../../../../../outils/types"; -import { useCombobox } from "downshift"; -import { - StyledSuggestion, - StyledList, - StyledInput, -} from "../../../../../search/SearchBar"; -import { push as matopush } from "@socialgouv/matomo-next"; - -type Props = { - onSelectAgreement: (agreement: Agreement) => void; - searchResultOverride?: (query: string, results: Agreement[]) => Agreement[]; -} & TrackingProps; - -export const SearchAgreementInput = ({ - onUserAction, - onSelectAgreement, - searchResultOverride, -}: Props): JSX.Element => { - const [query, setQuery] = useState(null); - const [suggestions, setSuggestions] = useState([]); - const [isLoading, setIsLoading] = useState(false); - const [error, setError] = useState(null); - - const { - isOpen, - getMenuProps, - getInputProps, - getLabelProps, - highlightedIndex, - getItemProps, - } = useCombobox({ - items: suggestions, - onInputValueChange: async ({ inputValue }) => { - setIsLoading(true); - setQuery(inputValue); - try { - const results = await searchAgreements(inputValue); - if (inputValue) { - onUserAction(UserAction.SearchAgreement, { query: inputValue }); - } - if (searchResultOverride) { - setSuggestions(searchResultOverride(inputValue, results)); - } else { - setSuggestions(results); - } - } catch (error) { - setError(error); - } finally { - setIsLoading(false); - } - }, - onSelectedItemChange(changes) { - const suggestion: Agreement = changes.selectedItem; - if (suggestion) { - onSelectAgreement(suggestion); - } - }, - itemToString(item) { - return item ? item.shortTitle : ""; - }, - }); - - return ( - <> - - Nom de la convention collective ou son numéro d’identification{" "} - IDCC{" "} - - (champ obligatoire) - - - { - matopush(["trackEvent", "outil", `click_tooltip_cc`]); - }} - > -

- L’Identifiant de la Convention Collective (IDCC) est un numéro unique - de 4 chiffres déterminant chaque convention - collective (Ex  : 1090 ou 1486). -

-

- Attention à ne pas confondre avec les codes APE - (Activité Principale Exercée) ou NAF (Nomenclature des Activités - Françaises) qui sont des numéros composés de 4 chiffres et d’une - lettre dont l’objectif est d’identifier l’activité principale de - l’entreprise (Ex : 4752A). -

-
- - - - - {isOpen && - suggestions.map((item: Agreement, index) => ( - - {item.shortTitle} (IDCC {formatIdcc(item.num)}) - - ))} - - {query !== null && query !== "" && ( - - )} - - ); -}; - -const StyledSearch = styled(StyledInput)` - margin-top: ${theme.spacings.small}; - padding-right: 1.6rem; -`; - -const StyledUl = styled(StyledList)` - position: initial; - border: ${({ hideBorder }) => - hideBorder ? "0px" : `1px solid ${theme.colors.border}`}; - box-shadow: initial; -`; - -const InlineLabel = styled(Label)` - display: inline; -`; diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/AgreementSearch/AgreementNoResult.tsx b/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/AgreementSearch/AgreementNoResult.tsx deleted file mode 100644 index 0da9f4bf1e..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/AgreementSearch/AgreementNoResult.tsx +++ /dev/null @@ -1,135 +0,0 @@ -import { SOURCES } from "@socialgouv/cdtn-utils"; -import { Agreement } from "../../../../outils/types"; -import { - AlertWithIcon, - Button, - Heading, - ScreenReaderOnly, - Section as SectionUi, - Title, - Wrapper, -} from "@socialgouv/cdtn-ui"; -import Link from "next/link"; -import React from "react"; -import Spinner from "react-svg-spinner"; -import styled from "styled-components"; - -import { TrackingProps, UserAction } from "../../../ConventionCollective/types"; -import { Error } from "../../ErrorField"; -import { HelpModal } from "../components/Modal"; - -type Props = { - isLoading: boolean; - error?: any; - data?: Agreement[]; - onUserAction: (action: UserAction) => void; -} & TrackingProps; - -const AgreementNoResult = ({ - isLoading, - error, - data, - onUserAction, -}: Props): JSX.Element => { - function openModalHandler(openModal: () => void) { - onUserAction(UserAction.OpenAgreementHelp); - openModal(); - } - - if (isLoading) { - return ( -
-
- ); - } - if (error) { - if (typeof error === "string") { - return {error}; - } - return
{error}
; - } - - if (data && !data.length) { - return ( -
- 0 résultat - -

- - Aucune convention collective n’a été trouvée - - . -

- Suggestions : -
    -
  • Vérifiez l’orthographe des termes de recherche
  • -
  • - Utilisez la rubrique ci-dessous “Vous ne trouvez pas votre - convention collective ?” -
  • -
-
- - Vous ne trouvez pas votre convention collective ? -
- ( - - )} - > - - Vous ne trouvez pas votre convention collective ? - -

Il peut y avoir plusieurs explications à cela :

-
    -
  • - Votre convention collective a un autre code : si vous le pouvez, - utilisez le numéro Siret de votre entreprise. Ce dernier doit - être présent sur votre bulletin de paie. -
  • -
  • - Votre convention collective a un statut particulier : - administration ou établissements publics, associations, secteur - agricole, La Poste, La Croix Rouge etc. -
  • -
  • - Votre entreprise n’est rattachée à aucune convention collective. -
  • -
- Essayez avec la recherche par entreprise  - - Avec le nom de l’entreprise, il est possible de retrouver la - convention collective associée -
- - - {" "} -
-
-
-
- ); - } - - return <>; -}; - -export { AgreementNoResult }; - -const Section = styled(SectionUi)` - padding-top: 1rem; -`; diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/AgreementSearch/AgreementSearch.tsx b/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/AgreementSearch/AgreementSearch.tsx deleted file mode 100644 index 0324fc8ef1..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/AgreementSearch/AgreementSearch.tsx +++ /dev/null @@ -1,97 +0,0 @@ -import { - Paragraph, - Section as SectionUi, - theme, - Toast, -} from "@socialgouv/cdtn-ui"; -import React from "react"; -import { Field } from "react-final-form"; -import styled from "styled-components"; - -import { TrackingProps } from "../../../ConventionCollective/types"; -import { ErrorField } from "../../ErrorField"; -import { Question } from "../../Question"; -import { required } from "../../validators"; -import { AGREEMENT_NAME } from "../form-constants"; -import ShowAlert from "../components/ShowAlert"; -import { AgreementSupportInfo } from "../types"; -import { SearchAgreementInput } from "./AgreementInput/SearchAgreementInput"; -import { Agreement } from "../../../types"; - -export type Props = { - supportedAgreements: AgreementSupportInfo[]; - selectedAgreement?: Agreement; - onSelectAgreement: (agreement: Agreement | null) => void; - alertAgreementNotSupported?: (string) => JSX.Element; -} & TrackingProps; - -const AgreementSearch = ({ - supportedAgreements, - selectedAgreement, - onSelectAgreement, - onUserAction, - alertAgreementNotSupported, -}: Props): JSX.Element => { - if (selectedAgreement) { - return ( - <> - - Vous avez sélectionné la convention collective :  - - { - event.preventDefault(); - onSelectAgreement(null); - }} - > - {selectedAgreement.shortTitle} - - - - ); - } - return ( -
- - Précisez et sélectionnez votre convention collective - - - -
- ); -}; - -const { spacings } = theme; - -const Section = styled(SectionUi)` - padding-top: 0; - - label { - font-weight: 400; - } -`; -const SelectedAgreement = styled(Toast)` - margin-bottom: ${spacings.base}; -`; - -export default AgreementSearch; diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/AgreementSearch/index.ts b/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/AgreementSearch/index.ts deleted file mode 100644 index 0038e2c23b..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/AgreementSearch/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -import AgreementSearch from "./AgreementSearch"; - -export { AgreementSearch }; diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/EnterpriseSearch/EnterpriseSearch.tsx b/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/EnterpriseSearch/EnterpriseSearch.tsx deleted file mode 100644 index e1e3286799..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/EnterpriseSearch/EnterpriseSearch.tsx +++ /dev/null @@ -1,133 +0,0 @@ -import React, { useState } from "react"; -import { Field } from "react-final-form"; -import { Paragraph, Section as SectionUi } from "@socialgouv/cdtn-ui"; -import { Enterprise } from "../../../../conventions/Search/api/enterprises.service"; -import { TrackingProps } from "../../../ConventionCollective/types"; -import { ErrorField } from "../../ErrorField"; -import { required } from "../../validators"; -import { ENTERPRISE_NAME } from "../form-constants"; -import { AgreementSupportInfo, OnSelectAgreementFn } from "../types"; -import SelectedEnterprise from "./SelectedEnterprise"; -import ShowAgreement from "./ShowAgreement"; -import ShowAgreements from "./ShowAgreements"; -import { - SearchEnterpriseInput, - SearchParams, -} from "./EntrepriseSearchInput/SearchEnterpriseInput"; -import styled from "styled-components"; -import { PublicodesSimulator } from "@socialgouv/modeles-social"; -import { Simulator } from "../../NoticeExample"; -import { Agreement } from "../../../types"; - -export type Props = { - supportedAgreements: AgreementSupportInfo[]; - selectedEnterprise?: Enterprise; - selectedAgreement?: Agreement; - onSelectAgreement: OnSelectAgreementFn; - alertAgreementNotSupported?: (string) => JSX.Element; - isDisabled?: boolean; - setHasSelectedEnterprise?: (hasSelectedEnterprise: boolean) => void; - simulator: Simulator; -} & TrackingProps; - -const EnterpriseSearch = ({ - supportedAgreements, - selectedEnterprise, - onSelectAgreement, - onUserAction, - alertAgreementNotSupported, - isDisabled, - setHasSelectedEnterprise, - simulator, -}: Props): JSX.Element => { - const [enterprise, setEnterprise] = useState( - selectedEnterprise - ); - const [searchParams, setSearchParams] = useState({ - query: "", - }); - - if (enterprise) { - return ( - <> - { - setEnterprise(undefined); - setHasSelectedEnterprise?.(false); - onSelectAgreement(null); - }} - /> - {enterprise.conventions.length === 1 ? ( - - ) : ( - { - onSelectAgreement(agreement, enterprise); - }} - supportedAgreements={supportedAgreements} - alertAgreementNotSupported={alertAgreementNotSupported} - simulator={simulator} - /> - )} - - ); - } - const handleEnterpriseSelection = (enterprise) => { - if (enterprise.conventions.length === 1) { - onSelectAgreement(enterprise.conventions[0], enterprise); - } - setEnterprise(enterprise); - setHasSelectedEnterprise?.(true); - }; - return ( -
- - Précisez et sélectionnez votre entreprise - - - - {!isDisabled && ( -
- ); -}; - -export default EnterpriseSearch; - -const Section = styled(SectionUi)` - padding-top: 0; - - label { - font-weight: 400; - } -`; diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/EnterpriseSearch/EntrepriseSearchInput/EnterpriseButton.tsx b/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/EnterpriseSearch/EntrepriseSearchInput/EnterpriseButton.tsx deleted file mode 100644 index 2e44433f41..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/EnterpriseSearch/EntrepriseSearchInput/EnterpriseButton.tsx +++ /dev/null @@ -1,71 +0,0 @@ -import { Tag, Text, theme } from "@socialgouv/cdtn-ui"; -import React from "react"; -import styled from "styled-components"; - -import { Enterprise } from "../../../../../conventions/Search/api/enterprises.service"; -import { ResultItem } from "../../components/ResultList"; -import Html from "../../../../../common/Html"; -import { - TrackingProps, - UserAction, -} from "../../../../ConventionCollective/types"; - -type CompagnyItemProps = { - enterprise: Enterprise; - isFirst: boolean; - showAddress: boolean; - onClick: (enterprise: Enterprise) => void; -} & TrackingProps; - -export function EnterpriseButton({ - enterprise, - isFirst, - showAddress, - onClick, - onUserAction, -}: CompagnyItemProps): JSX.Element { - const { - matching, - highlightLabel, - activitePrincipale, - address, - siren, - firstMatchingEtablissement, - } = enterprise; - - const clickHandler = () => { - onUserAction(UserAction.SelectEnterprise, { label: highlightLabel, siren }); - onClick(enterprise); - }; - return ( - - {highlightLabel} - {activitePrincipale && ( - Activité : {activitePrincipale} - )} - {!showAddress && matching > 1 ? ( - {matching} établissements - ) : ( - {address || firstMatchingEtablissement?.address} - )} - - ); -} - -const { spacings } = theme; - -const Activity = styled(Text)` - color: ${({ theme }) => theme.altText}; - padding-bottom: ${spacings.xsmall}; -`; - -const ItemButton = styled(ResultItem)` - &:hover ${Activity} { - color: ${({ theme }) => theme.paragraph}; - } -`; - -const Title = styled(Html)` - padding-bottom: ${spacings.xsmall}; - font-weight: 700; -`; diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/EnterpriseSearch/EntrepriseSearchInput/SearchEnterpriseInput.tsx b/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/EnterpriseSearch/EntrepriseSearchInput/SearchEnterpriseInput.tsx deleted file mode 100644 index dbd59c4d4a..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/EnterpriseSearch/EntrepriseSearchInput/SearchEnterpriseInput.tsx +++ /dev/null @@ -1,172 +0,0 @@ -import { Button, icons, Input, Label, Text, theme } from "@socialgouv/cdtn-ui"; -import React, { useState } from "react"; -import styled from "styled-components"; -import { createSuggesterHook } from "../../components/Suggester"; -import { - Enterprise, - searchEnterprises, -} from "../../../../../conventions/Search/api/enterprises.service"; -import { - TrackingProps, - UserAction, -} from "../../../../ConventionCollective/types"; -import { InfoBulle } from "../../../InfoBulle"; -import { EntrepriseSearchResults } from "../EntrepriseSearchResult"; -import { - ApiGeoResultWithSelectedPostCode, - LocationSearchInput, -} from "../Location/Search"; -import { Error } from "../../../ErrorField"; -import { push as matopush } from "@socialgouv/matomo-next"; - -type Props = { - searchParams?: SearchParams; - placeholder?: string; - onSearchParamsChange: (params: SearchParams) => void; - isDisabled?: boolean; - handleEnterpriseSelection: ( - enterprise: Enterprise, - params?: SearchParams - ) => void; -} & TrackingProps; - -export type SearchParams = { - query: string; - apiGeoResult?: ApiGeoResultWithSelectedPostCode; -}; - -export const SearchEnterpriseInput = ({ - searchParams = { query: "" }, - onUserAction, - onSearchParamsChange, - isDisabled, - handleEnterpriseSelection, -}: Props): JSX.Element => { - const useEnterpriseSuggester = createSuggesterHook( - searchEnterprises, - (searchParams) => { - onUserAction(UserAction.SearchEnterprise, searchParams); - } - ); - const state = useEnterpriseSuggester(searchParams); - const [query, setQuery] = useState(searchParams.query); - const [hasLocationSearchError, setHasLocationSearchError] = useState(false); - const [selectedApiGeoResult, setSelectedApiGeoResult] = useState< - ApiGeoResultWithSelectedPostCode | undefined - >(searchParams.apiGeoResult); - - const searchInputHandler = (e) => { - e.preventDefault(); - onSearchParamsChange({ - ...searchParams, - query, - apiGeoResult: selectedApiGeoResult, - }); - }; - - return ( - <> - - - - Nom de votre entreprise ou numéro Siren/Siret - - { - matopush(["trackEvent", "outil", `click_tooltip_entreprise`]); - }} - > -

- Le numéro Siren est un{" "} - numéro unique de 9 chiffres attribué à chaque - entreprise (ex : 401237780). -
- Le numéro Siret est un numéro de 14 chiffres{" "} - unique pour chaque établissement de l'entreprise. Il est - présent sur la fiche de paie du salarié (ex : - 40123778000127). -

-
- - setQuery(e.target.value)} - autoComplete="off" - data-testid="agreement-company-search-input" - disabled={isDisabled} - /> -
- - - -
- {hasLocationSearchError && ( - - Une erreur est survenue lors de la recherche par ville, veuillez - réessayer plus tard. - - )} - - - ); -}; - -const BlockInput = styled(Input)` - width: 100%; -`; - -const BlockInputLeft = styled(BlockInput)` - @media (min-width: ${theme.breakpoints.tablet}) { - input { - border-top-right-radius: 0; - border-bottom-right-radius: 0; - } - } -`; - -const InlineLabel = styled(Label)` - display: inline; - color: ${({ theme, disabled }) => - disabled ? theme.placeholder : theme.paragraph}; -`; - -const Flex = styled.div` - display: flex; - align-items: flex-end; - justify-content: space-between; - @media (max-width: ${theme.breakpoints.mobile}) { - flex-direction: column; - align-items: center; - } -`; - -const Box = styled.div` - flex: 1; - width: 100%; - - & + & { - @media (min-width: ${theme.breakpoints.mobile}) { - flex: 0 1 32rem; - } - @media (max-width: ${theme.breakpoints.mobile}) { - padding-top: ${theme.spacings.xmedium}; - } - } -`; diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/EnterpriseSearch/EntrepriseSearchResult.tsx b/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/EnterpriseSearch/EntrepriseSearchResult.tsx deleted file mode 100644 index 5a9c9a81e6..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/EnterpriseSearch/EntrepriseSearchResult.tsx +++ /dev/null @@ -1,133 +0,0 @@ -import { - Button, - ScreenReaderOnly, - Section as SectionUi, - Title, - Wrapper, -} from "@socialgouv/cdtn-ui"; -import React from "react"; -import Spinner from "react-svg-spinner"; -import styled from "styled-components"; -import { FetchReducerState } from "../components/Suggester"; -import { TrackingProps, UserAction } from "../../../ConventionCollective/types"; -import { Error } from "../../ErrorField"; -import { ListItem, ResultList } from "../components/ResultList"; -import { HelpModal } from "../components/Modal"; -import { Enterprise } from "../../../../conventions/Search/api/enterprises.service"; -import { SearchParams } from "./EntrepriseSearchInput/SearchEnterpriseInput"; -import { EnterpriseButton } from "./EntrepriseSearchInput/EnterpriseButton"; - -type Props = { - handleEnterpriseSelection: ( - enterprise: Enterprise, - params?: SearchParams - ) => void; - state: FetchReducerState; - params: SearchParams; -} & TrackingProps; - -const EntrepriseSearchResults = ({ - handleEnterpriseSelection, - onUserAction, - state, - params, -}: Props): JSX.Element => { - function openModalHandler(openModal: () => void) { - onUserAction(UserAction.OpenEnterpriseHelp); - openModal(); - } - - const isSiret = /^\d{14}$/.test(params.query.replace(/\s/g, "")); - if (state.isLoading) { - return ( -
-
- ); - } - - if (state.error) { - if (typeof state.error === "string") { - return {state.error}; - } - return
{JSON.stringify(state.error)}
; - } - if (!state.data) { - return <>; - } - return state.data.length > 0 ? ( -
- - {state.data.length} résultats - - - {state.data.map((item, index) => { - return ( - - handleEnterpriseSelection(item, params)} - onUserAction={onUserAction} - /> - - ); - })} - -
- ) : ( -
- -

- Aucune entreprise n’a été trouvée. -

- Suggestions : -
    -
  • Vérifiez l’orthographe des termes de recherche
  • -
  • - Utilisez la rubrique ci-dessous “Vous ne trouvez pas votre - entreprise ? Consultez notre aide” -
  • -
-
- - Vous ne trouvez pas votre entreprise ? -
- ( - - )} - > - - Vous ne trouvez pas votre convention collective ? - -

Il peut y avoir plusieurs explications à cela :

-
    -
  • - Votre entreprise a été enregistrée sous un autre nom ou un autre - code : si vous le pouvez, utilisez son numéro Siret. Ce dernier - doit être présent sur votre bulletin de paie. -
  • -
  • - Votre entreprise a un statut particulier : administration ou - établissements publics, associations, secteur agricole, La Poste, - La Croix Rouge etc. ; -
  • -
  • Votre entreprise n’a pas de convention collective.
  • -
-
-
-
- ); -}; - -export { EntrepriseSearchResults }; - -const Section = styled(SectionUi)` - padding-top: 1rem; -`; diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/EnterpriseSearch/Location/Search.tsx b/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/EnterpriseSearch/Location/Search.tsx deleted file mode 100644 index 30fd693ede..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/EnterpriseSearch/Location/Search.tsx +++ /dev/null @@ -1,208 +0,0 @@ -import { Button, icons, Label, Input, Text, theme } from "@socialgouv/cdtn-ui"; -import styled from "styled-components"; -import { useCombobox } from "downshift"; -import { useState } from "react"; -import { ApiGeoResult, searchCities } from "./searchCities"; -import { StyledList, StyledSuggestion } from "../../../../../search/SearchBar"; -import { detectIfPostalCode } from "../../../../../conventions/Search/api/utils"; -import { captureException } from "@sentry/nextjs"; - -const { Search: SearchIcon } = icons; - -type Props = { - selectedApiGeoResult?: ApiGeoResultWithSelectedPostCode; - setSelectedApiGeoResult: ( - apiGeoResult?: ApiGeoResultWithSelectedPostCode - ) => void; - isDisabled?: boolean; - searchInputHandler: (e: React.FormEvent) => void; - setHasLocationSearchError: (hasError: boolean) => void; -}; - -export type ApiGeoResultWithSelectedPostCode = ApiGeoResult & { - selectedPostCode: string[]; -}; - -export const LocationSearchInput = (props: Props) => { - const [suggestions, setSuggestions] = useState([]); - const [postalCode, setPostalCode] = useState( - props.selectedApiGeoResult?.selectedPostCode && - props.selectedApiGeoResult.selectedPostCode.length > 1 - ? props.selectedApiGeoResult.codeDepartement - : props.selectedApiGeoResult?.selectedPostCode[0] - ); - const { - isOpen, - getMenuProps, - getInputProps, - getLabelProps, - highlightedIndex, - getItemProps, - setInputValue, - } = useCombobox({ - items: suggestions, - itemToString, - onInputValueChange: async ({ inputValue }) => { - if (!inputValue) { - props.setSelectedApiGeoResult(undefined); - } - try { - const results = await searchCities(inputValue); - setSuggestions(results); - const isPostalCode = detectIfPostalCode(inputValue); - setPostalCode(isPostalCode ? inputValue : undefined); - props.setHasLocationSearchError(false); - } catch (error) { - console.error(error); - captureException(error); - setSuggestions([]); - props.setHasLocationSearchError(true); - } - }, - selectedItem: props.selectedApiGeoResult, - onSelectedItemChange(changes) { - props.setSelectedApiGeoResult({ - ...changes.selectedItem, - selectedPostCode: postalCode - ? [postalCode] - : changes.selectedItem.codesPostaux, - }); - }, - }); - - function itemToString(item: ApiGeoResult | null) { - const result = item - ? `${item.nom} (${postalCode ?? (item.codesPostaux.length > 1 ? item.codeDepartement : item.codesPostaux[0])})` - : ""; - return result; - } - - const onSearch = (e: React.MouseEvent) => { - if (!props.selectedApiGeoResult) { - setInputValue(""); - } - props.searchInputHandler(e); - }; - - return ( - <> - - Code postal ou ville - {" "} - - (facultatif) - - -
- - - - {isOpen && - suggestions.map((item, index) => ( - - {itemToString(item)} - - ))} - -
- - - Rechercher - - -
- - ); -}; - -const BlockInputRight = styled(Input)` - width: 100%; - input { - padding-right: 6rem; - } - - @media (min-width: ${theme.breakpoints.tablet}) { - input { - border-top-left-radius: 0; - border-bottom-left-radius: 0; - } - } -`; - -const InlineLabel = styled(Label)` - display: inline; - color: ${({ theme, disabled }) => - disabled ? theme.placeholder : theme.paragraph}; -`; - -const InlineText = styled(Text)` - color: ${({ theme, disabled }) => - disabled ? theme.placeholder : theme.paragraph}; -`; - -const InputWithButton = styled.div` - position: relative; -`; -const SubmitIcon = styled(Button)` - @media (min-width: ${theme.breakpoints.mobile}) { - position: absolute; - top: 6px; - right: 6px; - width: 2.5rem; - } - @media (max-width: ${theme.breakpoints.mobile}) { - width: 100%; - margin-top: ${theme.spacings.xmedium}; - box-sizing: inherit; - } - color: ${({ theme }) => theme.white}; - background-color: ${({ theme, disabled }) => - disabled ? theme.placeholder : theme.secondary}; - border-color: ${({ theme, disabled }) => - disabled ? theme.placeholder : theme.secondary}; -`; - -const StyledSearchIcon = styled(SearchIcon)` - @media (max-width: ${theme.breakpoints.mobile}) { - display: none; - } - color: ${({ theme }) => theme.white}; - height: 25px; - width: 25px; -`; - -const MobileOnly = styled.span` - @media (min-width: ${theme.breakpoints.mobile}) { - display: none; - } -`; diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/EnterpriseSearch/Location/searchCities.ts b/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/EnterpriseSearch/Location/searchCities.ts deleted file mode 100644 index 6f8ae95e29..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/EnterpriseSearch/Location/searchCities.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { captureException } from "@sentry/nextjs"; -import { - API_GEO_MAX_SEARCH_RESULTS, - API_GEO_URL, - DEBOUNCE_TIME_MS, -} from "../../../../../config"; -import debounce from "debounce-promise"; - -export type ApiGeoResult = { - code: string; - nom: string; - population: number; - codeDepartement: string; - codesPostaux: string[]; - _score?: number; -}; - -const apiGeoSearchCommunes = async ( - search: string -): Promise => { - const fields = "nom,codesPostaux,population,codeDepartement"; - const response = await Promise.all([ - fetch(`${API_GEO_URL}/communes?nom=${search}&fields=${fields}`), - fetch(`${API_GEO_URL}/communes?codePostal=${search}&fields=${fields}`), - ]); - const apiResults = await Promise.all( - response.map((r) => r.json() as any as ApiGeoResult[]) - ); - const results = [ - ...apiResults[0].slice(0, API_GEO_MAX_SEARCH_RESULTS), - ...apiResults[1], - ]; - const sortedResult = results.sort((a, b) => b.population - a.population); - return sortedResult; -}; - -export const searchCities = debounce(apiGeoSearchCommunes, DEBOUNCE_TIME_MS); diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/EnterpriseSearch/SelectedEnterprise.tsx b/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/EnterpriseSearch/SelectedEnterprise.tsx deleted file mode 100644 index 7bf13bcfa0..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/EnterpriseSearch/SelectedEnterprise.tsx +++ /dev/null @@ -1,39 +0,0 @@ -import { theme, Toast } from "@socialgouv/cdtn-ui"; -import React from "react"; -import styled from "styled-components"; - -import { Enterprise } from "../../../../conventions/Search/api/enterprises.service"; -import { Question } from "../../Question"; - -type Props = { - enterprise: Enterprise; - onRemoveEnterprise: () => void; -}; - -const SelectedEnterprise = ({ - enterprise, - onRemoveEnterprise, -}: Props): JSX.Element => { - return ( - <> - - Vous avez sélectionné l'entreprise :  - - { - event.preventDefault(); - onRemoveEnterprise(); - }} - > - {enterprise.simpleLabel} - - - ); -}; - -export default SelectedEnterprise; - -const Selected = styled(Toast)` - margin-bottom: ${theme.spacings.small}; -`; diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/EnterpriseSearch/ShowAgreement.tsx b/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/EnterpriseSearch/ShowAgreement.tsx deleted file mode 100644 index 3d8bc13fe6..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/EnterpriseSearch/ShowAgreement.tsx +++ /dev/null @@ -1,41 +0,0 @@ -import { formatIdcc, PublicodesSimulator } from "@socialgouv/modeles-social"; -import { Text } from "@socialgouv/cdtn-ui"; -import React from "react"; - -import { Agreement } from "../../../types"; -import { Question } from "../../Question"; -import ShowAlert from "../components/ShowAlert"; -import { AgreementSupportInfo } from "../types"; - -type Props = { - agreement: Agreement; - supportedAgreements: AgreementSupportInfo[]; - alertAgreementNotSupported?: (string) => JSX.Element; - simulator: PublicodesSimulator | "QUESTIONNAIRE"; -}; - -const ShowAgreement = ({ - agreement, - supportedAgreements, - alertAgreementNotSupported, - simulator, -}: Props): JSX.Element => { - return ( - <> - - Une convention collective a été trouvée pour cette entreprise : - - - {agreement.shortTitle} (IDCC {formatIdcc(agreement.num)}) - - - - ); -}; - -export default ShowAgreement; diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/EnterpriseSearch/ShowAgreements.tsx b/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/EnterpriseSearch/ShowAgreements.tsx deleted file mode 100644 index c0ff7e6bc2..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/EnterpriseSearch/ShowAgreements.tsx +++ /dev/null @@ -1,105 +0,0 @@ -import { formatIdcc } from "@socialgouv/modeles-social"; -import { InputRadio, Text } from "@socialgouv/cdtn-ui"; -import React, { useState } from "react"; -import { Field } from "react-final-form"; -import { OnChange } from "react-final-form-listeners"; - -import { Enterprise } from "../../../../conventions/Search/api/enterprises.service"; -import { Agreement } from "../../../types"; -import { ErrorField } from "../../ErrorField"; -import { Question } from "../../Question"; -import { RadioContainer } from "../../stepStyles"; -import { required } from "../../validators"; -import { AGREEMENT_ID_NAME } from "../form-constants"; -import ShowAlert from "../components/ShowAlert"; -import { AgreementSupportInfo } from "../types"; -import { Alert } from "../../../../common/Alert"; -import { Simulator } from "../../NoticeExample"; - -type Props = { - enterprise: Enterprise; - onChange: (enterprise: Enterprise, agreement: Agreement | null) => void; - supportedAgreements: AgreementSupportInfo[]; - alertAgreementNotSupported?: (string) => JSX.Element; - simulator?: Simulator; -}; - -const ShowAgreements = ({ - enterprise, - onChange, - supportedAgreements, - alertAgreementNotSupported, - simulator, -}: Props): JSX.Element => { - const [agreement, setAgreement] = useState(); - - return ( - <> - {enterprise.conventions.length > 0 ? ( - - {enterprise.conventions.length} conventions collectives ont été - trouvées pour cette entreprise, sélectionnez la vôtre :  - - ) : ( - <> - {simulator === Simulator.HEURES_RECHERCHE_EMPLOI || - simulator === Simulator.PREAVIS_DEMISSION ? ( - - ) : ( - - )} - - )} - - {enterprise.conventions.map((agreement) => { - return ( - - {(props) => ( - - {agreement.shortTitle} (IDCC {formatIdcc(agreement.num)}) - - } - id={`agreement-${agreement.id}`} - {...props.input} - /> - )} - - ); - })} - - {(values) => { - const agreementChanged = enterprise?.conventions?.find( - (agreement) => agreement.id.toString() === values.toString() - ); - setAgreement(agreementChanged); - onChange(enterprise, agreementChanged ?? null); - }} - - - - {agreement && ( - - )} - - ); -}; - -export default ShowAgreements; diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/EnterpriseSearch/index.ts b/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/EnterpriseSearch/index.ts deleted file mode 100644 index 432ffb1e35..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/EnterpriseSearch/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -import EnterpriseSearch from "./EnterpriseSearch"; - -export { EnterpriseSearch }; diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/RouteSelection/RouteSelection.tsx b/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/RouteSelection/RouteSelection.tsx deleted file mode 100644 index 9febef0f1b..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/RouteSelection/RouteSelection.tsx +++ /dev/null @@ -1,127 +0,0 @@ -import { InputRadio, Text, Fieldset } from "@socialgouv/cdtn-ui"; -import { FormApi } from "final-form"; -import React from "react"; -import { Field } from "react-final-form"; -import { OnChange } from "react-final-form-listeners"; -import styled from "styled-components"; - -import { ErrorField } from "../../ErrorField"; -import { Question } from "../../Question"; -import { RadioContainer } from "../../stepStyles"; -import { AgreementRoute, FormContent } from "../../type/WizardType"; -import { required } from "../../validators"; -import { ROUTE_NAME } from "../form-constants"; -import ShowAlert from "./ShowAlert"; - -type Props = { - form: FormApi; - canBeSkip: boolean; - onChange: (AgreementRoute) => void; -}; - -const RouteSelection = ({ - form, - onChange, - canBeSkip = true, -}: Props): JSX.Element => { - const values = form.getState().values; - return ( - <> - - - Vous pouvez trouver le nom de votre convention collective sur - votre bulletin de paie. -

- ), - }} - > - Quel est le nom de la convention collective applicable ? -
- - - type="radio" - name={ROUTE_NAME} - value="agreement" - validate={required} - > - {(props) => ( - - Je sais quelle est ma convention collective (je la saisis) - - } - id={`agreement`} - {...props.input} - checked={values.ccn?.selected ?? props.input.checked} - /> - )} - - - type="radio" - name={ROUTE_NAME} - value="enterprise" - validate={required} - > - {(props) => ( - - Je ne sais pas quelle est ma convention collective (je la - recherche) - - } - id={`enterprise`} - {...props.input} - /> - )} - - {canBeSkip && ( - - type="radio" - name={ROUTE_NAME} - value="not-selected" - validate={required} - > - {(props) => ( - - Je ne souhaite pas renseigner ma convention collective (je - passe l'étape) - - } - id={`not-selected`} - {...props.input} - /> - )} - - )} - - {values.ccn && } - - {( - values: AgreementRoute | null | undefined, - _previous: AgreementRoute | null | undefined - ) => { - if (values) { - onChange(values); - } - }} - - -
- - ); -}; - -export default RouteSelection; - -const StyledFieldset = styled(Fieldset)` - display: contents; -`; diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/RouteSelection/ShowAlert.tsx b/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/RouteSelection/ShowAlert.tsx deleted file mode 100644 index 7174d40635..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/RouteSelection/ShowAlert.tsx +++ /dev/null @@ -1,44 +0,0 @@ -import { Alert, Paragraph, theme } from "@socialgouv/cdtn-ui"; -import React from "react"; -import styled from "styled-components"; - -import { AgreementRoute } from "../../type/WizardType"; - -type ShowAlertProps = { - route: AgreementRoute; -}; - -const ShowAlert = ({ route }: ShowAlertProps): JSX.Element => { - return ( - <> - {route === "not-selected" && ( - - - Attention - - - Vous pouvez passer cette étape et poursuivre la simulation qui vous - fournira un résultat basé sur le code du travail. Nous vous - recommandons de renseigner votre convention collective qui peut - prévoir un résultat plus favorable que celui défini par le code du - travail. - - - )} - - ); -}; - -const { spacings } = theme; - -const StyledAlert = styled(Alert)` - margin-top: ${spacings.medium}; - width: 100%; -`; - -export default ShowAlert; diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/RouteSelection/index.ts b/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/RouteSelection/index.ts deleted file mode 100644 index b72d753b83..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/RouteSelection/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -import RouteSelection from "./RouteSelection"; - -export { RouteSelection }; diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/SelectAgreement.tsx b/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/SelectAgreement.tsx deleted file mode 100644 index b6f83b31c1..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/SelectAgreement.tsx +++ /dev/null @@ -1,173 +0,0 @@ -import { FormApi } from "final-form"; -import React, { useCallback, useEffect, useState } from "react"; - -import { Enterprise } from "../../../conventions/Search/api/enterprises.service"; -import { useLocalStorageForAgreement } from "../../../lib/useLocalStorage"; -import { OnUserAction } from "../../ConventionCollective/types"; -import { AgreementRoute, FormContent } from "../type/WizardType"; -import { AgreementSearch } from "./AgreementSearch"; -import { EnterpriseSearch } from "./EnterpriseSearch"; -import { AGREEMENT_NAME, ENTERPRISE_NAME, ROUTE_NAME } from "./form-constants"; -import { RouteSelection } from "./RouteSelection"; -import { handleTrackEvent } from "./tracking"; -import { AgreementSupportInfo, OnSelectAgreementFn } from "./types"; -import { SmallText } from "../stepStyles"; -import { ErrorField } from "../ErrorField"; -import { getCc3239Informations } from "../../publicodes/api"; -import { Agreement } from "../../../outils/types"; -import { Simulator } from "../NoticeExample"; -import { NoEnterprise } from "../../Components/Agreements"; - -export type Props = { - title: string; - form: FormApi; - supportedAgreements: AgreementSupportInfo[]; - onChange?: (oldValue: Agreement | null, newValue: Agreement | null) => void; - defaultSelectedAgreement?: Agreement; - required?: boolean; - note?: string; - alertAgreementNotSupported?: (string) => JSX.Element; - simulator: Simulator; -}; - -const SelectAgreement = ({ - title, - form, - supportedAgreements, - onChange, - defaultSelectedAgreement, - required = false, - note, - alertAgreementNotSupported, - simulator, -}: Props): JSX.Element => { - const [storedConvention, setConvention] = useLocalStorageForAgreement( - defaultSelectedAgreement - ); - const [hasSelectedEnterprise, setHasSelectedEnterprise] = useState(false); - const [enterprise, setEnterprise] = useState( - form.getState().values.ccn?.enterprise - ); - - const onSelectAgreement = useCallback( - (agreement, enterprise) => { - const oldData = storedConvention; - setConvention(agreement); - setEnterprise(enterprise); - if (oldData !== agreement && onChange) { - onChange(storedConvention, agreement); - } - }, - [storedConvention, setConvention, onChange] - ); - - const onUserAction: OnUserAction = (action, extra) => { - handleTrackEvent(title, action, extra); - }; - - useEffect(() => { - form.batch(() => { - form.change(AGREEMENT_NAME, storedConvention); - form.change(ENTERPRISE_NAME, enterprise); - if ( - storedConvention != null && - form.getState().values.ccn?.route === undefined - ) { - form.change(ROUTE_NAME, "agreement" as AgreementRoute); - } - }); - // eslint-disable-next-line - }, [storedConvention, enterprise]); - - const values = form.getState().values; - const onRouteChange = (route: AgreementRoute) => { - switch (route) { - case "not-selected": { - setConvention(undefined); - setEnterprise(undefined); - break; - } - case "agreement": { - setEnterprise(undefined); - break; - } - case "enterprise": { - setConvention(undefined); - break; - } - } - initNoEnterprise(); - }; - - const initNoEnterprise = () => { - if (values.hasNoEnterpriseSelected) { - onSelectAgreement(null); - } - form.change("hasNoEnterpriseSelected", undefined); - }; - - return ( - <> - - {note && {note}} - {values.ccn?.route === "agreement" && ( - - )} - {values.ccn?.route === "enterprise" && ( - <> - { - setHasSelectedEnterprise(hasSelectedEnterprise); - }} - simulator={simulator} - /> - {!hasSelectedEnterprise && !enterprise && ( - { - form.change( - "hasNoEnterpriseSelected", - !values.hasNoEnterpriseSelected - ); - }} - onCheckboxChange={async (isCheckboxChecked) => { - const cc3239 = await getCc3239Informations(); - onSelectAgreement(isCheckboxChecked ? cc3239 : null); - }} - /> - )} - - )} - - - - ); -}; - -export default SelectAgreement; diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/__tests__/AgreementSearch.test.tsx b/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/__tests__/AgreementSearch.test.tsx deleted file mode 100644 index 0265a165fe..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/__tests__/AgreementSearch.test.tsx +++ /dev/null @@ -1,243 +0,0 @@ -import { render } from "@testing-library/react"; -import React from "react"; - -import { EmbeddedForm } from "../../../../../test/TestForm"; -import { Agreement } from "../../../../outils/types"; -import { AgreementSearch } from "../AgreementSearch"; -import type { Props } from "../AgreementSearch/AgreementSearch"; -import { SupportedTypes } from "@socialgouv/modeles-social"; - -const callback: (agreement: Agreement | null) => void = () => { - /* nothing to do */ -}; -const onSelectAgreement = jest.fn(callback); - -const onUserAction = () => { - /* stub */ -}; - -const selectedAgreement: Agreement = { - id: "KALICONT000044594539", - url: "hello.com", - num: 3239, - shortTitle: "Particuliers employeurs et emploi à domicile", - slug: "3239-particuliers-employeurs-et-emploi-a-domicile", - title: "Particuliers employeurs et emploi à domicile", - contributions: false, -}; - -const dataWithoutSelectedAgreement: Props = { - onSelectAgreement, - onUserAction, - supportedAgreements: [], -}; - -const dataWithSelectedAgreement: Props = { - ...dataWithoutSelectedAgreement, - selectedAgreement, -}; - -const dataWithSelectedAgreementNotSupported: Props = { - ...dataWithoutSelectedAgreement, - selectedAgreement, - supportedAgreements: [], -}; -const dataWithSelectedAgreementNotSupportedWithCustomText: Props = { - ...dataWithoutSelectedAgreement, - selectedAgreement, - supportedAgreements: [], - alertAgreementNotSupported: (url: string) => ( -

This is my custom text with the url: {url}

- ), -}; - -const dataWithSelectedAgreementNotFullySupported: Props = { - ...dataWithoutSelectedAgreement, - selectedAgreement, - supportedAgreements: [ - { - fullySupported: SupportedTypes.SOON_SUPPORTED, - idcc: selectedAgreement.num, - }, - ], -}; - -const dataWithSelectedAgreementSupported: Props = { - ...dataWithoutSelectedAgreement, - selectedAgreement, - supportedAgreements: [ - { - fullySupported: SupportedTypes.FULLY_SUPPORTED, - idcc: selectedAgreement.num, - }, - ], -}; - -describe("AgreementSearch", () => { - describe("no selected agreement", () => { - it("should render the mandatory question 'Précisez et sélectionnez votre convention collective'", () => { - const { getByText } = render( - - Step={AgreementSearch} - props={dataWithoutSelectedAgreement} - /> - ); - expect( - getByText(/Précisez et sélectionnez votre convention collective/) - ).toBeInTheDocument(); - expect(getByText("(champ obligatoire)")).toBeInTheDocument(); - }); - - it("should show an input to search the agreement", () => { - const { getByPlaceholderText } = render( - - Step={AgreementSearch} - props={dataWithoutSelectedAgreement} - /> - ); - expect( - getByPlaceholderText("Ex : Transports routiers ou 1486") - ).toBeInTheDocument(); - }); - - it("should show an error when submit without select an agreement", () => { - const { getByText } = render( - - Step={AgreementSearch} - props={dataWithoutSelectedAgreement} - /> - ); - getByText("Submit").click(); - expect( - getByText(/Vous devez sélectionner une convention collective/) - ).toBeDefined(); - }); - }); - - describe("selected agreement", () => { - it("should render the text 'Vous avez sélectionné la convention collective'", () => { - const { getByText } = render( - - Step={AgreementSearch} - props={dataWithSelectedAgreement} - /> - ); - expect( - getByText(/Vous avez sélectionné la convention collective/) - ).toBeInTheDocument(); - }); - - it("should show the agreement short title", () => { - const { getByText } = render( - - Step={AgreementSearch} - props={dataWithSelectedAgreement} - /> - ); - expect(getByText(selectedAgreement.shortTitle)).toBeInTheDocument(); - }); - - it("should show a button to remove the selection", () => { - const { getByRole } = render( - - Step={AgreementSearch} - props={dataWithSelectedAgreement} - /> - ); - const button = getByRole("button", { name: "Fermer" }); - expect(button).toBeInTheDocument(); - }); - - it("should invite the user to click on next to continue the simulation", () => { - const { getByText } = render( - - Step={AgreementSearch} - props={dataWithSelectedAgreement} - /> - ); - expect( - getByText("Cliquez sur Suivant pour poursuivre la simulation.") - ).toBeInTheDocument(); - }); - - it("should not show an error when submit", () => { - const { getByText, queryByText } = render( - - Step={AgreementSearch} - props={dataWithSelectedAgreement} - /> - ); - getByText("Submit").click(); - expect( - queryByText(/Vous devez répondre à cette question/) - ).not.toBeInTheDocument(); - }); - - it("should callback when user remove the selected agreement", () => { - const { getByRole } = render( - - Step={AgreementSearch} - props={dataWithSelectedAgreement} - /> - ); - const button = getByRole("button", { name: "Fermer" }); - button.click(); - expect(onSelectAgreement.mock.calls).toHaveLength(1); - expect(onSelectAgreement.mock.calls[0][0]).toBeNull(); - }); - }); - - describe("selected agreement not supported / not fully supported", () => { - it("should render a warning about the not supported agreement", () => { - const { getByText } = render( - - Step={AgreementSearch} - props={dataWithSelectedAgreementNotSupported} - /> - ); - expect( - getByText(/Convention collective non traitée/) - ).toBeInTheDocument(); - }); - it("should render the alert with custom content provided", () => { - const { getByText } = render( - - Step={AgreementSearch} - props={dataWithSelectedAgreementNotSupportedWithCustomText} - /> - ); - expect( - getByText(/This is my custom text with the url: hello.com/) - ).toBeInTheDocument(); - }); - }); - - describe("selected agreement not fully supported", () => { - it("should render a warning about the not fully supported agreement", () => { - const { getByText } = render( - - Step={AgreementSearch} - props={dataWithSelectedAgreementNotFullySupported} - /> - ); - expect(getByText(/Convention prochainement traitée/)).toBeInTheDocument(); - }); - }); - - describe("selected agreement supported", () => { - it("should not render a warning", () => { - const { queryByText } = render( - - Step={AgreementSearch} - props={dataWithSelectedAgreementSupported} - /> - ); - expect( - queryByText(/Convention collective non traitée/) - ).not.toBeInTheDocument(); - expect( - queryByText(/Convention prochainement traitée/) - ).not.toBeInTheDocument(); - }); - }); -}); diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/__tests__/EnterpriseSearch.test.tsx b/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/__tests__/EnterpriseSearch.test.tsx deleted file mode 100644 index 312bf43e31..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/__tests__/EnterpriseSearch.test.tsx +++ /dev/null @@ -1,395 +0,0 @@ -import { render } from "@testing-library/react"; -import React from "react"; - -import { EmbeddedForm } from "../../../../../test/TestForm"; -import { Enterprise } from "../../../../conventions/Search/api/enterprises.service"; -import { Agreement } from "../../../../outils/types"; -import type { Props } from "../EnterpriseSearch/EnterpriseSearch"; -import EnterpriseSearch from "../EnterpriseSearch/EnterpriseSearch"; -import { EnterpriseAgreement } from "../../../../api/modules/enterprises/types"; -import { Simulator } from "../../NoticeExample"; -import { SupportedTypes } from "@socialgouv/modeles-social"; - -const callback: ( - agreement: Agreement | null, - enterprise?: Enterprise -) => void = () => { - /* nothing to do */ -}; -const onSelectAgreement = jest.fn(callback); -const onUserAction = () => { - /* dummy */ -}; - -const agreement1: EnterpriseAgreement = { - id: "KALICONT000005635093", - url: "hello.com", - num: 2156, - shortTitle: "Grands magasins et magasins populaires", - slug: "2156-grands-magasins-et-magasins-populaires", - title: - "Convention collective nationale des grand magasins et des magasins populaires du 30 juin 2000. Etendue par arrêté du 20 décembre 2001 JORF 19 janvier 2002.", - contributions: true, -}; - -const agreement2: EnterpriseAgreement = { - id: "KALICONT000005635085", - num: 2216, - shortTitle: "Commerce de détail et de gros à prédominance alimentaire", - slug: "2216-commerce-de-detail-et-de-gros-a-predominance-alimentaire", - title: - "Convention collective nationale du commerce de détail et de gros à prédominance alimentaire du 12 juillet 2001. Etendue par arrêté du 26 juillet 2002 JORF 6 août 2002.", - contributions: false, -}; - -const selectedEnterpriseOneAgreement: Enterprise = { - activitePrincipale: - "Commerce de détail en magasin non spécialisé à prédominance alimentaire", - conventions: [agreement1], - etablissements: 335, - highlightLabel: "MONOPRIX EXPLOITATION, PAR ABREVIATION MPX", - label: "MONOPRIX EXPLOITATION, PAR ABREVIATION MPX", - matching: 272, - simpleLabel: "MONOPRIX EXPLOITATION", - siren: "552083297", -}; - -const selectedEnterpriseTwoAgreements: Enterprise = { - activitePrincipale: - "Commerce de détail en magasin non spécialisé à prédominance alimentaire", - conventions: [agreement1, agreement2], - etablissements: 335, - highlightLabel: "MONOPRIX EXPLOITATION, PAR ABREVIATION MPX", - label: "MONOPRIX EXPLOITATION, PAR ABREVIATION MPX", - matching: 272, - simpleLabel: "MONOPRIX EXPLOITATION", - siren: "552083297", -}; - -describe("EnterpriseSearch", () => { - describe("no selected enterprise", () => { - const dataWithoutSelectedEnterprise: Props = { - onSelectAgreement, - onUserAction, - supportedAgreements: [], - simulator: Simulator.HEURES_RECHERCHE_EMPLOI, - }; - - it("should render the mandatory question 'Nom de votre entreprise ou numéro Siren/Siret' and not mandatory 'Code postal ou ville'", () => { - const { getByText } = render( - - Step={EnterpriseSearch} - props={dataWithoutSelectedEnterprise} - /> - ); - expect( - getByText(/Nom de votre entreprise ou numéro Siren\/Siret/) - ).toBeInTheDocument(); - expect(getByText(/Code postal ou ville/)).toBeInTheDocument(); - expect(getByText(/\(facultatif\)/)).toBeInTheDocument(); - }); - - it("should show inputs to search the enterprise", () => { - const { getByPlaceholderText } = render( - - Step={EnterpriseSearch} - props={dataWithoutSelectedEnterprise} - /> - ); - expect( - getByPlaceholderText("Ex : Café de la gare ou 40123778000127") - ).toBeInTheDocument(); - expect( - getByPlaceholderText("Ex : 31000 ou Toulouse") - ).toBeInTheDocument(); - }); - - it("should show an error when submit", () => { - const { getByText, queryByText } = render( - - Step={EnterpriseSearch} - props={dataWithoutSelectedEnterprise} - /> - ); - getByText("Submit").click(); - expect( - queryByText(/Vous devez sélectionner une entreprise/) - ).toBeInTheDocument(); - }); - }); - - describe("selected enterprise with one agreement", () => { - const dataWithSelectedEnterpriseWithOneAgreement: Props = { - onSelectAgreement, - onUserAction, - selectedEnterprise: selectedEnterpriseOneAgreement, - supportedAgreements: [], - simulator: Simulator.HEURES_RECHERCHE_EMPLOI, - }; - - it("should show the default agreement", () => { - const { getByText } = render( - - Step={EnterpriseSearch} - props={dataWithSelectedEnterpriseWithOneAgreement} - /> - ); - expect( - getByText( - /Une convention collective a été trouvée pour cette entreprise/ - ) - ).toBeInTheDocument(); - expect(getByText(new RegExp(agreement1.shortTitle))).toBeInTheDocument(); - }); - - it("should show the enterprise title", () => { - const { getByText } = render( - - Step={EnterpriseSearch} - props={dataWithSelectedEnterpriseWithOneAgreement} - /> - ); - expect( - getByText(new RegExp(selectedEnterpriseOneAgreement.simpleLabel)) - ).toBeInTheDocument(); - }); - - it("should show a button to remove the selection", () => { - const { getByRole } = render( - - Step={EnterpriseSearch} - props={dataWithSelectedEnterpriseWithOneAgreement} - /> - ); - const button = getByRole("button", { name: "Fermer" }); - expect(button).toBeInTheDocument(); - }); - - it("should invite the user to click on next to continue the simulation", () => { - const { getByText } = render( - - Step={EnterpriseSearch} - props={dataWithSelectedEnterpriseWithOneAgreement} - /> - ); - expect( - getByText("Cliquez sur Suivant pour poursuivre la simulation.") - ).toBeInTheDocument(); - }); - - it("should not show an error when submit", () => { - const { getByText, queryByText } = render( - - Step={EnterpriseSearch} - props={dataWithSelectedEnterpriseWithOneAgreement} - /> - ); - getByText("Submit").click(); - expect( - queryByText(/Vous devez répondre à cette question/) - ).not.toBeInTheDocument(); - }); - - it("should callback when user remove the selected enterprise", () => { - onSelectAgreement.mockClear(); - const { getByRole } = render( - - Step={EnterpriseSearch} - props={dataWithSelectedEnterpriseWithOneAgreement} - /> - ); - const button = getByRole("button", { name: "Fermer" }); - button.click(); - expect(onSelectAgreement.mock.calls).toHaveLength(1); - expect(onSelectAgreement.mock.calls[0][0]).toBeNull(); - }); - }); - - describe("selected enterprise with two agreements", () => { - const dataWithSelectedEnterpriseWithTwoAgreements: Props = { - onSelectAgreement, - onUserAction, - selectedEnterprise: selectedEnterpriseTwoAgreements, - supportedAgreements: [], - simulator: Simulator.HEURES_RECHERCHE_EMPLOI, - }; - it("should show the agreements selection", () => { - const { getByText, queryByText } = render( - - Step={EnterpriseSearch} - props={dataWithSelectedEnterpriseWithTwoAgreements} - /> - ); - expect( - getByText( - /2 conventions collectives ont été trouvées pour cette entreprise, sélectionnez la vôtre/ - ) - ).toBeInTheDocument(); - expect(getByText(new RegExp(agreement1.shortTitle))).toBeInTheDocument(); - expect(getByText(new RegExp(agreement2.shortTitle))).toBeInTheDocument(); - expect( - queryByText(/Cliquez sur Suivant pour poursuivre la simulation/) - ).not.toBeInTheDocument(); - }); - - it("should show the enterprise title", () => { - const { getByText } = render( - - Step={EnterpriseSearch} - props={dataWithSelectedEnterpriseWithTwoAgreements} - /> - ); - expect( - getByText(new RegExp(selectedEnterpriseOneAgreement.simpleLabel)) - ).toBeInTheDocument(); - }); - - it("should show a button to remove the selection", () => { - const { getByRole } = render( - - Step={EnterpriseSearch} - props={dataWithSelectedEnterpriseWithTwoAgreements} - /> - ); - const button = getByRole("button", { name: "Fermer" }); - expect(button).toBeInTheDocument(); - }); - - it("should show an error when submit", () => { - const { getByText, queryByText } = render( - - Step={EnterpriseSearch} - props={dataWithSelectedEnterpriseWithTwoAgreements} - /> - ); - getByText("Submit").click(); - expect( - queryByText(/Vous devez répondre à cette question/) - ).toBeInTheDocument(); - }); - - it("should callback when user remove the selected enterprise", () => { - onSelectAgreement.mockClear(); - const { getByRole } = render( - - Step={EnterpriseSearch} - props={dataWithSelectedEnterpriseWithTwoAgreements} - /> - ); - const button = getByRole("button", { name: "Fermer" }); - button.click(); - expect(onSelectAgreement.mock.calls).toHaveLength(1); - expect(onSelectAgreement.mock.calls[0][0]).toBeNull(); - }); - - it("should show the message to continue the simulation when select the agreement", () => { - const { getByText, queryByText } = render( - - Step={EnterpriseSearch} - props={dataWithSelectedEnterpriseWithTwoAgreements} - /> - ); - getByText(/Grands magasins et magasins populaires/).click(); - expect( - queryByText(/Cliquez sur Suivant pour poursuivre la simulation/) - ).toBeInTheDocument(); - }); - }); - - describe("selected agreement not supported / not fully supported", () => { - it("should render a warning about the not supported agreement", () => { - const data: Props = { - onSelectAgreement, - onUserAction, - selectedEnterprise: selectedEnterpriseOneAgreement, - supportedAgreements: [], - simulator: Simulator.HEURES_RECHERCHE_EMPLOI, - }; - const { getByText } = render( - Step={EnterpriseSearch} props={data} /> - ); - expect( - getByText(/Convention collective non traitée/) - ).toBeInTheDocument(); - }); - - it("should render a warning about the not supported agreement (multiple agreements)", () => { - const data: Props = { - onSelectAgreement, - onUserAction, - selectedEnterprise: selectedEnterpriseTwoAgreements, - supportedAgreements: [], - simulator: Simulator.HEURES_RECHERCHE_EMPLOI, - }; - const { getByText } = render( - Step={EnterpriseSearch} props={data} /> - ); - getByText(/Grands magasins et magasins populaires/).click(); - expect( - getByText(/Convention collective non traitée/) - ).toBeInTheDocument(); - }); - - it("should not render a warning about the supported agreement", () => { - const data: Props = { - onSelectAgreement, - onUserAction, - selectedEnterprise: selectedEnterpriseOneAgreement, - supportedAgreements: [ - { - fullySupported: SupportedTypes.FULLY_SUPPORTED, - idcc: selectedEnterpriseOneAgreement.conventions[0].num, - }, - ], - simulator: Simulator.HEURES_RECHERCHE_EMPLOI, - }; - const { queryByText } = render( - Step={EnterpriseSearch} props={data} /> - ); - expect( - queryByText(/Convention collective non traitée/) - ).not.toBeInTheDocument(); - }); - - it("should not render a warning when agreement is supported (multiple agreements)", () => { - const data: Props = { - onSelectAgreement, - onUserAction, - selectedEnterprise: selectedEnterpriseTwoAgreements, - supportedAgreements: [ - { - fullySupported: SupportedTypes.FULLY_SUPPORTED, - idcc: selectedEnterpriseTwoAgreements.conventions[0].num, - }, - ], - simulator: Simulator.HEURES_RECHERCHE_EMPLOI, - }; - const { getByText, queryByText } = render( - Step={EnterpriseSearch} props={data} /> - ); - getByText(/Grands magasins et magasins populaires/).click(); - expect( - queryByText(/Convention collective non traitée/) - ).not.toBeInTheDocument(); - }); - - it("should render the alert with custom content provided", () => { - const data: Props = { - onSelectAgreement, - onUserAction, - selectedEnterprise: selectedEnterpriseOneAgreement, - supportedAgreements: [], - alertAgreementNotSupported: (agreementUrl: string) => ( -

This is my custom text with the url: {agreementUrl}

- ), - simulator: Simulator.HEURES_RECHERCHE_EMPLOI, - }; - const { getByText } = render( - Step={EnterpriseSearch} props={data} /> - ); - expect( - getByText(/This is my custom text with the url: hello.com/) - ).toBeInTheDocument(); - }); - }); -}); diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/__tests__/RouteSelection.test.tsx b/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/__tests__/RouteSelection.test.tsx deleted file mode 100644 index 3e01f2f376..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/__tests__/RouteSelection.test.tsx +++ /dev/null @@ -1,145 +0,0 @@ -import { render } from "@testing-library/react"; -import React from "react"; - -import { EmbeddedInjectedForm } from "../../../../../test/TestForm"; -import { RouteSelection } from "../RouteSelection"; - -describe("RouteSelection: Skip the agreement selection", () => { - describe("without data in form", () => { - it("should render the mandatory question 'Je ne souhaite pas renseigner ma convention collective.'", () => { - const { getByText } = render( - - ); - expect( - getByText(/Je ne souhaite pas renseigner ma convention collective/) - ).toBeInTheDocument(); - expect(getByText("(obligatoire)")).toBeInTheDocument(); - }); - - it("should show all routes", () => { - const { getByText } = render( - - ); - expect( - getByText(/Je sais quelle est ma convention collective/) - ).toBeInTheDocument(); - expect( - getByText(/Je ne sais pas quelle est ma convention collective/) - ).toBeInTheDocument(); - expect( - getByText(/Je ne souhaite pas renseigner ma convention collective/) - ).toBeInTheDocument(); - }); - - it("should show an alert when submit without select an option", () => { - const { getByText } = render( - - ); - getByText("Submit").click(); - expect(getByText(/Vous devez répondre à cette question/)).toBeDefined(); - }); - - it("should show an alert when select to skip the agreement selection", () => { - const { getByText } = render( - {}, - }} - /> - ); - getByText( - /Je ne souhaite pas renseigner ma convention collective/ - ).click(); - - expect( - getByText( - /Vous pouvez passer cette étape et poursuivre la simulation qui vous fournira un résultat basé sur le code du travail./ - ) - ).toBeInTheDocument(); - }); - - it("should not show an alert when select to search the agreement selection", () => { - const { getByText, queryByText } = render( - {}, - }} - /> - ); - getByText(/Je sais quelle est ma convention collective/).click(); - - expect(queryByText(/À noter/)).not.toBeInTheDocument(); - }); - - it("should not show an alert when select i don't know my agreement", () => { - const { getByText, queryByText } = render( - {}, - }} - /> - ); - getByText(/Je ne sais pas quelle est ma convention collective/).click(); - - expect(queryByText(/À noter/)).not.toBeInTheDocument(); - }); - }); - - describe("with data in form (come back on the step)", () => { - it("should show an alert when skip the agreement selection selected", () => { - const { getByText, getByRole } = render( - - ); - - expect( - getByRole("radio", { - checked: true, - name: /Je ne souhaite pas renseigner ma convention collective/, - }) - ).toBeInTheDocument(); - expect( - getByText( - /Vous pouvez passer cette étape et poursuivre la simulation qui vous fournira un résultat basé sur le code du travail./ - ) - ).toBeInTheDocument(); - }); - }); - - it("should not show an alert when search the agreement selected", () => { - const { queryByText, getByRole } = render( - - ); - - expect( - getByRole("radio", { - checked: true, - name: /Je sais quelle est ma convention collective/, - }) - ).toBeInTheDocument(); - expect(queryByText(/À noter/)).not.toBeInTheDocument(); - }); - - it("should not show the skip option", () => { - const { queryByText, getAllByRole } = render( - - ); - - expect(getAllByRole("radio")).toHaveLength(2); - expect( - queryByText(/Je ne souhaite pas renseigner/) - ).not.toBeInTheDocument(); - }); -}); diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/__tests__/SelectAgreement.test.tsx b/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/__tests__/SelectAgreement.test.tsx deleted file mode 100644 index 3d4fa008a2..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/__tests__/SelectAgreement.test.tsx +++ /dev/null @@ -1,108 +0,0 @@ -import { render } from "@testing-library/react"; -import React from "react"; - -import { EmbeddedInjectedForm } from "../../../../../test/TestForm"; -import { Agreement } from "../../../../outils/types"; -import { FormContent } from "../../type/WizardType"; -import { SelectAgreement } from "../index"; -import type { Props } from "../SelectAgreement"; -import { Simulator } from "../../NoticeExample"; - -const selectedAgreement: Agreement = { - id: "KALICONT000044594539", - num: 3239, - shortTitle: "Particuliers employeurs et emploi à domicile", - slug: "3239-particuliers-employeurs-et-emploi-a-domicile", - title: "Particuliers employeurs et emploi à domicile", - contributions: false, -}; - -describe("SelectAgreement", () => { - describe("no preselected agreement (in local storage)", () => { - it("should render the form without prechecked option", () => { - const { getByRole } = render( - > - Step={SelectAgreement} - props={{ - supportedAgreements: [], - title: "Outil", - simulator: Simulator.HEURES_RECHERCHE_EMPLOI, - }} - /> - ); - expect( - getByRole("radio", { - checked: false, - name: /Je ne souhaite pas renseigner ma convention collective/, - }) - ).toBeInTheDocument(); - expect( - getByRole("radio", { - checked: false, - name: /Je sais quelle est ma convention collective/, - }) - ).toBeInTheDocument(); - expect( - getByRole("radio", { - checked: false, - name: /Je ne sais pas quelle est ma convention collective/, - }) - ).toBeInTheDocument(); - }); - it("should not show skip option & show message if passed in param", () => { - const { getByRole, getByText, queryByText } = render( - > - Step={SelectAgreement} - props={{ - supportedAgreements: [], - title: "Outil", - required: true, - note: "This is my note", - simulator: Simulator.HEURES_RECHERCHE_EMPLOI, - }} - /> - ); - expect( - queryByText(/Je ne souhaite pas renseigner ma convention collective/) - ).not.toBeInTheDocument(); - expect( - getByRole("radio", { - checked: false, - name: /Je sais quelle est ma convention collective/, - }) - ).toBeInTheDocument(); - expect( - getByRole("radio", { - checked: false, - name: /Je ne sais pas quelle est ma convention collective/, - }) - ).toBeInTheDocument(); - expect(getByText(/This is my note/)).toBeInTheDocument(); - }); - }); - - describe("preselected agreement (in local storage)", () => { - it("should render the route 'Je connais ma convention collective' by default with the selected agreements", () => { - const { getByText, getByRole } = render( - > - Step={SelectAgreement} - props={{ - defaultSelectedAgreement: selectedAgreement, - supportedAgreements: [], - title: "Outil", - simulator: Simulator.HEURES_RECHERCHE_EMPLOI, - }} - /> - ); - expect( - getByRole("radio", { - checked: true, - name: /Je sais quelle est ma convention collective/, - }) - ).toBeInTheDocument(); - expect( - getByText(/Particuliers employeurs et emploi à domicile/) - ).toBeInTheDocument(); - }); - }); -}); diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/components/Modal.tsx b/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/components/Modal.tsx deleted file mode 100644 index c370846ddd..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/components/Modal.tsx +++ /dev/null @@ -1,32 +0,0 @@ -import { Modal } from "@socialgouv/cdtn-ui"; -import React, { useState } from "react"; - -type Props = { - title: string; - renderButton: (openModel: () => void) => JSX.Element; - children: React.ReactNode; -}; - -export function HelpModal({ - title, - renderButton, - children, -}: Props): JSX.Element { - const [isModalOpen, setModalOpen] = useState(false); - const openModal = () => { - setModalOpen(true); - }; - - const closeModal = () => { - setModalOpen(false); - }; - - return ( - <> - {renderButton(openModal)} - - {children} - - - ); -} diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/components/ResultList.tsx b/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/components/ResultList.tsx deleted file mode 100644 index 43a339b696..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/components/ResultList.tsx +++ /dev/null @@ -1,88 +0,0 @@ -import { Button, theme, ViewMore, Wrapper } from "@socialgouv/cdtn-ui"; -import React, { ReactNode } from "react"; -import styled from "styled-components"; - -type Props = { - query: string; - children: ReactNode; -}; - -export function ResultList({ query, children }: Props): JSX.Element { - const viewMoreButton = (onClick) => ( - - Voir plus - - ); - - return ( - - - {children} - - - ); -} - -export const ListItem = (props: any) => { - return ( -
  • - {props.children} -
  • - ); -}; - -const Li = styled.li` - margin-left: 0; - - & + &::before { - content: ""; - display: block; - margin: 0 ${theme.spacings.xmedium}; - border-top: 1px solid ${({ theme }) => theme.border}; - } -`; - -const WrapperNoPadding = styled(Wrapper)` - padding: 0; -`; - -const ViewMoreButton = styled(Button)` - margin-top: ${theme.spacings.base}; - margin-bottom: ${theme.spacings.base}; - @media (max-width: ${theme.breakpoints.mobile}) { - flex: 1 0 auto; - } -`; - -export const ResultItem = styled.button.attrs({ - type: "button", -})` - display: block; - appearance: none; - width: 100%; - background-color: transparent; - font-weight: 500; - border: none; - font-size: ${theme.fonts.sizes.default}; - padding: ${({ small }) => - small ? theme.spacings.xsmall : theme.spacings.medium} - ${theme.spacings.xmedium}; - color: ${({ theme }) => theme.paragraph}; - text-align: left; - text-decoration: none; - cursor: pointer; - position: relative; - - &:active, - &:focus, - &:hover, - &[aria-selected="true"] { - color: ${({ theme }) => theme.title}; - background-color: ${({ theme }) => theme.bgTertiary}; - } -`; diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/components/ShowAlert.tsx b/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/components/ShowAlert.tsx deleted file mode 100644 index 1902f911ac..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/components/ShowAlert.tsx +++ /dev/null @@ -1,117 +0,0 @@ -import { Alert, Paragraph, Text, theme } from "@socialgouv/cdtn-ui"; -import React from "react"; - -import { AgreementSupportInfo } from "../types"; -import { Agreement } from "../../../types"; -import styled from "styled-components"; -import { - PublicodesSimulator, - SupportedTypes, -} from "@socialgouv/modeles-social"; - -type Props = { - currentAgreement: Agreement; - supportedAgreements: AgreementSupportInfo[]; - alertAgreementNotSupported?: (string) => JSX.Element; - simulator?: PublicodesSimulator | "QUESTIONNAIRE"; -}; - -const ShowAlert = ({ - currentAgreement, - supportedAgreements, - alertAgreementNotSupported, - simulator = PublicodesSimulator.PREAVIS_RETRAITE, -}: Props): JSX.Element => { - const idccInfo = supportedAgreements.find( - (item) => item.idcc == currentAgreement.num - ); - if (!idccInfo || idccInfo.fullySupported === SupportedTypes.NEVER_SUPPORTED) { - return ( - <> - - {simulator !== "QUESTIONNAIRE" && ( - - Convention collective non traitée - - )} - {alertAgreementNotSupported ? ( - alertAgreementNotSupported(currentAgreement.url) - ) : ( - <> - - La convention collective sélectionnée n'est pas traitée par - nos services. - - - Vous pouvez tout de même poursuivre la simulation qui vous - fournira un résultat basé sur le code du travail. - - - )} - - {!alertAgreementNotSupported && ( - - Cliquez sur Suivant pour poursuivre la simulation. - - )} - - ); - } - if (idccInfo.fullySupported === SupportedTypes.SOON_SUPPORTED) { - return ( - <> - - - Convention prochainement traitée - - - {simulator === PublicodesSimulator.PREAVIS_RETRAITE ? ( - <> - Cette convention collective n'est pas encore traitée par - nos services mais le sera très prochainement. Vous pouvez - poursuivre la simulation pour connaître la durée prévue par le - code du travail mais nous vous conseillons de vérifier si votre - convention collective prévoit un délai plus favorable qui vous - serait applicable. - - ) : ( - <> - Cette convention collective n'est pas encore traitée par - nos services mais le sera très prochainement. Vous pouvez - poursuivre la simulation pour connaître le montant prévu par le - code du travail mais nous vous conseillons de vérifier si votre - convention collective prévoit un montant plus favorable pour le - salarié. - - )} - - - - Cliquez sur Suivant pour poursuivre la simulation. - - - ); - } - - return simulator !== "QUESTIONNAIRE" ? ( - - Cliquez sur Suivant pour poursuivre la simulation. - - ) : ( - <> - ); -}; - -export default ShowAlert; - -const StyledAlert = styled(Alert)` - margin-top: ${theme.spacings.small}; -`; -const StyledParagraph = styled(Paragraph)` - margin-top: ${theme.spacings.large}; -`; diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/components/Suggester.ts b/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/components/Suggester.ts deleted file mode 100644 index a5879f0321..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/components/Suggester.ts +++ /dev/null @@ -1,118 +0,0 @@ -import { Reducer, useEffect, useReducer } from "react"; -import { SearchParams } from "../EnterpriseSearch/EntrepriseSearchInput/SearchEnterpriseInput"; - -export enum Status { - idle = "idle", - loading = "loading", - success = "success", - error = "error", -} - -export enum Actions { - reset = "reset", - init = "init", - success = "success", - failure = "failure", -} - -export type FecthActions = - | { type: Actions.init } - | { type: Actions.reset } - | { type: Actions.success; payload: A } - | { type: Actions.failure; payload: Error }; - -export type FetchReducerState = { - isError: boolean; - isLoading: boolean; - data?: A; - error?: Error; -}; - -const dataFetchReducer = ( - state: FetchReducerState, - action: FecthActions -): FetchReducerState => { - switch (action.type) { - case Actions.init: - return { - isError: false, - isLoading: true, - }; - case Actions.reset: - return { - ...state, - data: undefined, - error: undefined, - isError: false, - isLoading: false, - }; - case Actions.success: - return { - ...state, - data: action.payload, - isError: false, - isLoading: false, - }; - case Actions.failure: - return { - ...state, - error: action.payload, - isError: true, - isLoading: false, - }; - default: - throw new Error(`Actions ${action["type"]} is not implemented`); - } -}; - -type Fetcher = (searchParams: SearchParams) => Promise; - -/** - * a factory function that return a suggesterHook that - * use fetcher to return result - * @param fetcher an async function that should receive only one argument - * @param onResult callback when new results are found - * @returns a hook function - */ -export function createSuggesterHook( - fetcher: Fetcher, - onResult: (searchParams: SearchParams) => void -) { - return function (searchParams: SearchParams): FetchReducerState { - const [state, dispatch] = useReducer< - Reducer, FecthActions> - >(dataFetchReducer, { - isError: false, - isLoading: false, - }); - useEffect(() => { - let shouldCancel = false; - - async function fetchData() { - if (!searchParams.query) { - dispatch({ type: Actions.reset }); - return; - } - dispatch({ type: Actions.init }); - try { - const results = await fetcher(searchParams); - if (shouldCancel) { - return; - } - - onResult(searchParams); - - dispatch({ payload: results, type: Actions.success }); - } catch (error) { - dispatch({ payload: error, type: Actions.failure }); - } - } - - fetchData(); - return () => { - shouldCancel = true; - }; - }, [JSON.stringify(searchParams)]); - return state; - }; -} diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/form-constants.ts b/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/form-constants.ts deleted file mode 100644 index 46da50d2a5..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/form-constants.ts +++ /dev/null @@ -1,4 +0,0 @@ -export const ROUTE_NAME = "ccn.route"; -export const AGREEMENT_NAME = "ccn.selected"; -export const AGREEMENT_ID_NAME = "ccn.selected.id"; -export const ENTERPRISE_NAME = "ccn.enterprise"; diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/index.ts b/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/index.ts deleted file mode 100644 index ed063a6c05..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -import SelectAgreement from "./SelectAgreement"; -import { pushAgreementEvents } from "./tracking"; - -export { pushAgreementEvents, SelectAgreement }; diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/tracking/__tests__/handleTrackEvent.test.tsx b/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/tracking/__tests__/handleTrackEvent.test.tsx deleted file mode 100644 index eb95139308..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/tracking/__tests__/handleTrackEvent.test.tsx +++ /dev/null @@ -1,70 +0,0 @@ -import { - MatomoBaseEvent, - MatomoSearchAgreementCategory, -} from "../../../../../lib"; -import { push as matopush } from "@socialgouv/matomo-next"; -import { UserAction } from "../../../../ConventionCollective/types"; -import { handleTrackEvent } from "../index"; - -jest.mock("@socialgouv/matomo-next", () => ({ - push: jest.fn(), -})); - -describe("Handle event on user action", () => { - beforeEach(() => { - const ma = matopush as jest.MockedFunction; - ma.mockReset(); - }); - - describe("user searching an enterprise", () => { - it("should send a matomo event", () => { - const pageTitle = "Préavis de retraite"; - const extra = { - query: "company", - }; - handleTrackEvent(pageTitle, UserAction.SearchEnterprise, extra); - expect(matopush).toHaveBeenCalledTimes(1); - expect(matopush).toHaveBeenCalledWith([ - MatomoBaseEvent.TRACK_EVENT, - MatomoSearchAgreementCategory.ENTERPRISE_SEARCH, - pageTitle, - JSON.stringify(extra), - ]); - }); - }); - - describe("user searching an agreement", () => { - it("should send a matomo event", () => { - const pageTitle = "Préavis de retraite"; - const extra = { - query: "Boulangerie", - }; - handleTrackEvent(pageTitle, UserAction.SearchAgreement, extra); - expect(matopush).toHaveBeenCalledTimes(1); - expect(matopush).toHaveBeenCalledWith([ - MatomoBaseEvent.TRACK_EVENT, - MatomoSearchAgreementCategory.AGREEMENT_SEARCH, - pageTitle, - JSON.stringify(extra), - ]); - }); - }); - - describe("on user action", () => { - const excludedEvent = [ - UserAction.SearchEnterprise, - UserAction.SearchAgreement, - UserAction.OpenAgreementHelp, - UserAction.OpenEnterpriseHelp, - ]; - const values = Object.values(UserAction).filter( - (action) => !excludedEvent.includes(action) - ); - values.forEach((value) => { - it(`should not send matomo event for user action ${value}`, () => { - handleTrackEvent("Préavis de retraite", value as UserAction); - expect(matopush).toHaveBeenCalledTimes(0); - }); - }); - }); -}); diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/tracking/__tests__/pushAgreementEvents.test.tsx b/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/tracking/__tests__/pushAgreementEvents.test.tsx deleted file mode 100644 index 084d9b434c..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/tracking/__tests__/pushAgreementEvents.test.tsx +++ /dev/null @@ -1,255 +0,0 @@ -import { - Enterprise, - EnterpriseAgreement, -} from "../../../../../conventions/Search/api/enterprises.service"; -import { - MatomoAgreementEvent, - MatomoBaseEvent, - MatomoSearchAgreementCategory, - MatomoSimulatorEvent, -} from "../../../../../lib"; -import { push as matopush } from "@socialgouv/matomo-next"; -import { ConventionCollective } from "../../../type/WizardType"; -import { pushAgreementEvents } from "../index"; - -jest.mock("@socialgouv/matomo-next", () => ({ - push: jest.fn(), -})); - -const agreement: EnterpriseAgreement = { - id: "AGREEMENT_ID", - num: 3239, - shortTitle: "Service à la personne", - slug: "/convention/3239-service-a-la-personne", - title: "Service à la personne", - contributions: false, -}; - -const enterprise: Enterprise = { - activitePrincipale: - "Commerce de détail en magasin non spécialisé à prédominance alimentaire", - conventions: [agreement], - etablissements: 335, - highlightLabel: "MONOPRIX EXPLOITATION, PAR ABREVIATION MPX", - label: "MONOPRIX EXPLOITATION, PAR ABREVIATION MPX", - matching: 272, - simpleLabel: "MONOPRIX EXPLOITATION", - siren: "552083297", -}; - -describe("Push agreement events on click next", () => { - beforeEach(() => { - const ma = matopush as jest.MockedFunction; - ma.mockReset(); - }); - - describe("user without agreement selected", () => { - const data: ConventionCollective = { - route: "not-selected", - }; - it("should send a search type of users matomo event", () => { - const pageTitle = "Préavis de retraite"; - pushAgreementEvents(pageTitle, data, false, false); - expect(matopush).toHaveBeenCalledTimes(1); - expect(matopush).toHaveBeenCalledWith([ - MatomoBaseEvent.TRACK_EVENT, - MatomoSearchAgreementCategory.AGREEMENT_SEARCH_TYPE_OF_USERS, - "click_p3", - pageTitle, - ]); - }); - }); - - describe("user with agreement selected", () => { - const data: ConventionCollective = { - route: "agreement", - selected: agreement, - }; - describe("agreement not treated", () => { - it("should send matomo events", () => { - const pageTitle = "Préavis de retraite"; - pushAgreementEvents(pageTitle, data, false, false); - expect(matopush).toHaveBeenCalledTimes(3); - expect(matopush).toHaveBeenNthCalledWith(1, [ - MatomoBaseEvent.TRACK_EVENT, - MatomoSearchAgreementCategory.AGREEMENT_SEARCH_TYPE_OF_USERS, - "click_p1", - pageTitle, - ]); - expect(matopush).toHaveBeenNthCalledWith(2, [ - MatomoBaseEvent.TRACK_EVENT, - MatomoSearchAgreementCategory.AGREEMENT_SELECT_P1, - pageTitle, - `idcc${agreement.num.toString()}`, - ]); - expect(matopush).toHaveBeenNthCalledWith(3, [ - MatomoBaseEvent.TRACK_EVENT, - MatomoBaseEvent.OUTIL, - MatomoAgreementEvent.CC_UNTREATED, - agreement.num, - ]); - }); - }); - describe("agreement treated", () => { - it("should send matomo events", () => { - const pageTitle = "Préavis de retraite"; - pushAgreementEvents(pageTitle, data, true, false); - expect(matopush).toHaveBeenCalledTimes(3); - expect(matopush).toHaveBeenNthCalledWith(1, [ - MatomoBaseEvent.TRACK_EVENT, - MatomoSearchAgreementCategory.AGREEMENT_SEARCH_TYPE_OF_USERS, - "click_p1", - pageTitle, - ]); - expect(matopush).toHaveBeenNthCalledWith(2, [ - MatomoBaseEvent.TRACK_EVENT, - MatomoSearchAgreementCategory.AGREEMENT_SELECT_P1, - pageTitle, - `idcc${agreement.num.toString()}`, - ]); - expect(matopush).toHaveBeenNthCalledWith(3, [ - MatomoBaseEvent.TRACK_EVENT, - MatomoBaseEvent.OUTIL, - MatomoAgreementEvent.CC_TREATED, - agreement.num, - ]); - }); - }); - }); - - describe("user with enterprise selected", () => { - const data: ConventionCollective = { - enterprise: enterprise, - route: "enterprise", - selected: agreement, - }; - - it("should send matomo events", () => { - const pageTitle = "Préavis de retraite"; - pushAgreementEvents(pageTitle, data, false, false); - expect(matopush).toHaveBeenCalledTimes(4); - expect(matopush).toHaveBeenNthCalledWith(1, [ - MatomoBaseEvent.TRACK_EVENT, - MatomoSearchAgreementCategory.AGREEMENT_SEARCH_TYPE_OF_USERS, - "click_p2", - pageTitle, - ]); - expect(matopush).toHaveBeenNthCalledWith(2, [ - MatomoBaseEvent.TRACK_EVENT, - MatomoSearchAgreementCategory.ENTERPRISE_SELECT, - pageTitle, - JSON.stringify({ label: enterprise.label, siren: enterprise.siren }), - ]); - expect(matopush).toHaveBeenNthCalledWith(3, [ - MatomoBaseEvent.TRACK_EVENT, - MatomoSearchAgreementCategory.AGREEMENT_SELECT_P2, - pageTitle, - `idcc${agreement.num.toString()}`, - ]); - expect(matopush).toHaveBeenNthCalledWith(4, [ - MatomoBaseEvent.TRACK_EVENT, - MatomoBaseEvent.OUTIL, - MatomoAgreementEvent.CC_UNTREATED, - agreement.num, - ]); - }); - }); - - describe("user with no enterprise", () => { - const data: ConventionCollective = { - enterprise: undefined, - route: "enterprise", - selected: agreement, - }; - - it("should send matomo events", () => { - const pageTitle = "Préavis de retraite"; - pushAgreementEvents(pageTitle, data, false, true); - expect(matopush).toHaveBeenCalledTimes(4); - expect(matopush).toHaveBeenNthCalledWith(1, [ - MatomoBaseEvent.TRACK_EVENT, - MatomoSearchAgreementCategory.AGREEMENT_SEARCH_TYPE_OF_USERS, - "click_p2", - pageTitle, - ]); - expect(matopush).toHaveBeenNthCalledWith(2, [ - MatomoBaseEvent.TRACK_EVENT, - MatomoSearchAgreementCategory.AGREEMENT_SELECT_P2, - pageTitle, - `idcc${agreement.num.toString()}`, - ]); - expect(matopush).toHaveBeenNthCalledWith(3, [ - MatomoBaseEvent.TRACK_EVENT, - MatomoBaseEvent.OUTIL, - MatomoAgreementEvent.CC_UNTREATED, - agreement.num, - ]); - expect(matopush).toHaveBeenNthCalledWith(4, [ - MatomoBaseEvent.TRACK_EVENT, - MatomoSearchAgreementCategory.AGREEMENT_SEARCH_TYPE_OF_USERS, - MatomoSimulatorEvent.SELECT_NO_COMPANY, - pageTitle, - ]); - }); - }); - - describe("not tracking", () => { - it("should not send matomo events if agreement is 9999", () => { - const agreement9999: EnterpriseAgreement = { - id: "AGREEMENT_ID", - num: 9999, - shortTitle: "?", - slug: "/convention/9999", - title: "?", - contributions: false, - }; - const pageTitle = "Blabla"; - pushAgreementEvents( - pageTitle, - { - enterprise: { - activitePrincipale: - "Commerce de détail en magasin non spécialisé à prédominance alimentaire", - conventions: [agreement9999], - etablissements: 335, - highlightLabel: - "MONOPRIX EXPLOITATION, PAR ABREVIATION MPX", - label: "MONOPRIX EXPLOITATION, PAR ABREVIATION MPX", - matching: 272, - simpleLabel: "MONOPRIX EXPLOITATION", - siren: "552083297", - }, - route: "enterprise", - selected: agreement9999, - }, - false, - false - ); - expect(matopush).toHaveBeenCalledTimes(4); - expect(matopush).toHaveBeenNthCalledWith(1, [ - MatomoBaseEvent.TRACK_EVENT, - MatomoSearchAgreementCategory.AGREEMENT_SEARCH_TYPE_OF_USERS, - "click_p2", - pageTitle, - ]); - expect(matopush).toHaveBeenNthCalledWith(2, [ - MatomoBaseEvent.TRACK_EVENT, - MatomoSearchAgreementCategory.ENTERPRISE_SELECT, - pageTitle, - JSON.stringify({ label: enterprise.label, siren: enterprise.siren }), - ]); - expect(matopush).toHaveBeenNthCalledWith(3, [ - "trackEvent", - "cc_select_p2", - "Blabla", - "idcc9999", - ]); - expect(matopush).toHaveBeenNthCalledWith(4, [ - "trackEvent", - "outil", - "cc_select_non_traitée", - 9999, - ]); - }); - }); -}); diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/tracking/handleTrackEvent.ts b/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/tracking/handleTrackEvent.ts deleted file mode 100644 index ad535ad912..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/tracking/handleTrackEvent.ts +++ /dev/null @@ -1,49 +0,0 @@ -import { - MatomoBaseEvent, - MatomoSearchAgreementCategory, -} from "../../../../lib"; -import { push as matopush } from "@socialgouv/matomo-next"; -import { UserAction } from "../../../ConventionCollective/types"; - -const handleTrackEvent = ( - title: string, - action: UserAction, - extra?: unknown -): void => { - switch (action) { - case UserAction.OpenAgreementHelp: - matopush([ - MatomoBaseEvent.TRACK_EVENT, - MatomoSearchAgreementCategory.AGREEMENT_SEARCH_HELP, - "click_cc_search_help_p1", - title, - ]); - break; - case UserAction.OpenEnterpriseHelp: - matopush([ - MatomoBaseEvent.TRACK_EVENT, - MatomoSearchAgreementCategory.AGREEMENT_SEARCH_HELP, - "click_cc_search_help_p2", - title, - ]); - break; - case UserAction.SearchEnterprise: - matopush([ - MatomoBaseEvent.TRACK_EVENT, - MatomoSearchAgreementCategory.ENTERPRISE_SEARCH, - title, - JSON.stringify(extra), - ]); - break; - case UserAction.SearchAgreement: - matopush([ - MatomoBaseEvent.TRACK_EVENT, - MatomoSearchAgreementCategory.AGREEMENT_SEARCH, - title, - JSON.stringify(extra), - ]); - break; - } -}; - -export default handleTrackEvent; diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/tracking/index.ts b/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/tracking/index.ts deleted file mode 100644 index 5ff1b74852..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/tracking/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -import handleTrackEvent from "./handleTrackEvent"; -import pushAgreementEvents from "./pushAgreementEvents"; - -export { handleTrackEvent, pushAgreementEvents }; diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/tracking/pushAgreementEvents.ts b/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/tracking/pushAgreementEvents.ts deleted file mode 100644 index 86f0e92e9d..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/tracking/pushAgreementEvents.ts +++ /dev/null @@ -1,78 +0,0 @@ -import { - MatomoAgreementEvent, - MatomoBaseEvent, - MatomoSearchAgreementCategory, - MatomoSimulatorEvent, -} from "../../../../lib"; -import { push as matopush } from "@socialgouv/matomo-next"; -import { ConventionCollective } from "../../type/WizardType"; - -const pushAgreementEvents = ( - simulatorTitle: string, - values: ConventionCollective | undefined, - isAgreementTreated: boolean, - hasNoEnterpriseSelected: boolean -): void => { - if (!values) { - // no agreement section, no event to send. Should never happen. - return; - } - let parcours: MatomoSearchAgreementCategory | undefined = undefined; - let agreementSelect: MatomoSearchAgreementCategory | undefined = undefined; - switch (values.route) { - case "agreement": - parcours = MatomoSearchAgreementCategory.PARCOURS_1; - agreementSelect = MatomoSearchAgreementCategory.AGREEMENT_SELECT_P1; - break; - case "enterprise": - parcours = MatomoSearchAgreementCategory.PARCOURS_2; - agreementSelect = MatomoSearchAgreementCategory.AGREEMENT_SELECT_P2; - break; - case "not-selected": - parcours = MatomoSearchAgreementCategory.PARCOURS_3; - break; - } - matopush([ - MatomoBaseEvent.TRACK_EVENT, - MatomoSearchAgreementCategory.AGREEMENT_SEARCH_TYPE_OF_USERS, - parcours, - simulatorTitle, - ]); - if (values.enterprise) { - matopush([ - MatomoBaseEvent.TRACK_EVENT, - MatomoSearchAgreementCategory.ENTERPRISE_SELECT, - simulatorTitle, - JSON.stringify({ - label: values.enterprise.label, - siren: values.enterprise.siren, - }), - ]); - } - if (values.selected && agreementSelect) { - matopush([ - MatomoBaseEvent.TRACK_EVENT, - agreementSelect, - simulatorTitle, - `idcc${values.selected.num}`, - ]); - matopush([ - MatomoBaseEvent.TRACK_EVENT, - MatomoBaseEvent.OUTIL, - isAgreementTreated - ? MatomoAgreementEvent.CC_TREATED - : MatomoAgreementEvent.CC_UNTREATED, - values.selected.num, - ]); - } - if (hasNoEnterpriseSelected) { - matopush([ - MatomoBaseEvent.TRACK_EVENT, - MatomoSearchAgreementCategory.AGREEMENT_SEARCH_TYPE_OF_USERS, - MatomoSimulatorEvent.SELECT_NO_COMPANY, - simulatorTitle, - ]); - } -}; - -export default pushAgreementEvents; diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/types.ts b/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/types.ts deleted file mode 100644 index 0735b0c708..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/common/components/Agreement/types.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { SupportedTypes } from "@socialgouv/modeles-social"; -import { Enterprise } from "../../../conventions/Search/api/enterprises.service"; -import { Agreement } from "../../../outils/types"; - -export type AgreementSupportInfo = { - fullySupported: SupportedTypes; - idcc: number; -}; - -export type OnSelectAgreementFn = ( - agreement: Agreement | null, - enterprise?: Enterprise -) => void; diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/components/Feedback/Questionnaire.tsx b/packages/code-du-travail-frontend/src/modules/outils/common/components/Feedback/Questionnaire.tsx deleted file mode 100644 index c4a86e33dd..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/common/components/Feedback/Questionnaire.tsx +++ /dev/null @@ -1,59 +0,0 @@ -import styled from "styled-components"; -import { Button, Heading, theme } from "@socialgouv/cdtn-ui"; - -import { QuestionnaireItem } from "./QuestionnaireItem"; -import { - EVENT_ACTION, - EVENT_CATEGORY, - FEEDBACK_RESULT, - trackFeedback, -} from "./tracking"; -import { useState } from "react"; - -type QuestionnaireProps = { - onClick: () => void; - category: EVENT_CATEGORY; -}; - -export const Questionnaire = ({ - onClick, - category, -}: QuestionnaireProps): JSX.Element => { - const [status, setStatus] = useState(); - const [displayError, setDisplayError] = useState(false); - return ( - <> - - Comment s'est passée cette simulation pour vous ? - - { - setStatus(status); - setDisplayError(false); - }} - displayError={displayError} - /> - { - if (!status) { - setDisplayError(true); - } else { - trackFeedback(EVENT_ACTION.GLOBAL, status, category); - onClick(); - } - }} - variant="primary" - > - Envoyer - - - ); -}; - -const StyledButton = styled(Button)` - margin: 0 ${theme.spacings.xmedium}; -`; diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/components/Feedback/QuestionnaireAdvanced.tsx b/packages/code-du-travail-frontend/src/modules/outils/common/components/Feedback/QuestionnaireAdvanced.tsx deleted file mode 100644 index 675021d11e..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/common/components/Feedback/QuestionnaireAdvanced.tsx +++ /dev/null @@ -1,112 +0,0 @@ -import { Button, Heading, theme } from "@socialgouv/cdtn-ui"; -import { QuestionnaireItem } from "./QuestionnaireItem"; -import { QuestionnaireText } from "./QuestionnaireText"; -import styled from "styled-components"; -import { useState } from "react"; -import { - EVENT_ACTION, - EVENT_CATEGORY, - FEEDBACK_RESULT, - trackFeedback, - trackFeedbackText, -} from "./tracking"; -import { useRouter } from "next/router"; - -type QuestionnaireAdvancedProps = { - onClick: () => void; - category: EVENT_CATEGORY; -}; - -export const QuestionnaireAdvanced = ({ - onClick, - category, -}: QuestionnaireAdvancedProps): React.ReactElement => { - const router = useRouter(); - const [statusSimulator, setStatusSimulator] = useState(); - const [statusQuestion, setStatusQuestion] = useState(); - const [statusExplanation, setStatusExplanation] = useState(); - const [feedbackText, setFeedbackText] = useState(); - return ( - <> - - Merci pour votre aide ! Pouvez-vous nous en dire plus ? - -
    - { - setStatusSimulator(status); - }} - dataTestId="simulator" - /> - { - setStatusQuestion(status); - }} - dataTestId="questionClarity" - /> - { - setStatusExplanation(status); - }} - dataTestId="resultClarity" - /> - -
    - { - if (statusSimulator) { - trackFeedback(EVENT_ACTION.EASINESS, statusSimulator, category); - } - if (statusQuestion) { - trackFeedback( - EVENT_ACTION.QUESTION_CLARITY, - statusQuestion, - category - ); - } - if (statusExplanation) { - trackFeedback( - EVENT_ACTION.RESULT_CLARITY, - statusExplanation, - category - ); - } - if (feedbackText) { - trackFeedbackText(feedbackText, router.asPath, category); - } - onClick(); - }} - > - Envoyer - - - ); -}; - -const StyledButton = styled(Button)` - margin: 0 ${theme.spacings.xmedium}; -`; diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/components/Feedback/QuestionnaireEnd.tsx b/packages/code-du-travail-frontend/src/modules/outils/common/components/Feedback/QuestionnaireEnd.tsx deleted file mode 100644 index 1d4b82b08e..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/common/components/Feedback/QuestionnaireEnd.tsx +++ /dev/null @@ -1,19 +0,0 @@ -import { Heading, theme } from "@socialgouv/cdtn-ui"; -import styled from "styled-components"; - -export const QuestionnaireEnd = (): JSX.Element => { - return ( - <> - - Merci pour votre aide ! - - - Votre évaluation sera étudiée au plus vite par nos équipes - - - ); -}; - -const StyledText = styled.p` - padding: 0 ${theme.spacings.medium}; -`; diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/components/Feedback/QuestionnaireItem.tsx b/packages/code-du-travail-frontend/src/modules/outils/common/components/Feedback/QuestionnaireItem.tsx deleted file mode 100644 index 1964061bfc..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/common/components/Feedback/QuestionnaireItem.tsx +++ /dev/null @@ -1,114 +0,0 @@ -import { Button } from "@socialgouv/cdtn-ui"; -import { icons, theme } from "@socialgouv/cdtn-ui"; -import { useState } from "react"; -import styled from "styled-components"; -import { FEEDBACK_RESULT } from "./tracking"; - -type QuestionnaireItemProps = { - badEventValue: FEEDBACK_RESULT; - averageEventValue: FEEDBACK_RESULT; - goodEventValue: FEEDBACK_RESULT; - badText?: string; - averageText?: string; - goodText?: string; - className?: string; - title?: string; - displayError?: boolean; - onChange: (status: FEEDBACK_RESULT) => void; - dataTestId?: string; -}; - -export enum Status { - BAD = "bad", - AVERAGE = "average", - GOOD = "good", -} - -export const QuestionnaireItem = ({ - badEventValue, - averageEventValue, - goodEventValue, - badText, - averageText, - goodText, - className, - title, - displayError, - onChange, - dataTestId, -}: QuestionnaireItemProps): JSX.Element => { - const [status, setStatus] = useState(); - return ( -
    - {title && {title}} - - { - setStatus(Status.BAD); - onChange(badEventValue); - }} - data-testId={`${dataTestId}-bad`} - > - - {badText ?? "Pas bien"} - - { - setStatus(Status.AVERAGE); - onChange(averageEventValue); - }} - data-testId={`${dataTestId}-average`} - > - - {averageText ?? "Moyen"} - - { - setStatus(Status.GOOD); - onChange(goodEventValue); - }} - data-testId={`${dataTestId}-good`} - > - - {goodText ?? "Très bien"} - - - {displayError && ( - Vous devez choisir une des réponses - )} -
    - ); -}; - -const { colors } = theme; - -const ButtonContainer = styled.div` - display: flex; - flex-direction: row; - padding: 6px 0; - max-width: 300px; - justify-content: space-between; -`; - -const StyledButton = styled(Button)` - display: flex; - flex-direction: column; - width: 80px; - height: 60px; - padding: 0; - border: 1px solid ${colors.secondary}; - border-radius: 3px; - font-size: 12px; - font-weight: bold; -`; - -const StyledError = styled.span` - color: ${colors.error}; -`; - -const Div = styled.div` - padding: 0 ${theme.spacings.xmedium} ${theme.spacings.large}; -`; diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/components/Feedback/QuestionnaireText.tsx b/packages/code-du-travail-frontend/src/modules/outils/common/components/Feedback/QuestionnaireText.tsx deleted file mode 100644 index c03a3ed445..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/common/components/Feedback/QuestionnaireText.tsx +++ /dev/null @@ -1,48 +0,0 @@ -import { Textarea, theme } from "@socialgouv/cdtn-ui"; -import styled from "styled-components"; - -type QuestionnaireItemProps = { - className?: string; - title?: string; - placeholder?: string; - onChange: (text: string) => void; - dataTestId?: string; -}; - -export const QuestionnaireText = ({ - className, - title, - placeholder, - onChange, - dataTestId, -}: QuestionnaireItemProps): JSX.Element => { - const maxCharacters = 200; - return ( - - {title && {title}} - onChange(event.target.value)} - data-testid={dataTestId} - /> - {maxCharacters} caractères maximum - - ); -}; - -const StyledContainer = styled.div` - display: flex; - flex-direction: column; - padding: 0 ${theme.spacings.xmedium} ${theme.spacings.large}; -`; - -const StyledTextarea = styled(Textarea)` - width: 420px; - max-width: 100%; -`; - -const MaxCharacterText = styled.p` - margin: 12px 0; - font-size: 14px; -`; diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/components/Feedback/__tests__/feedback.test.tsx b/packages/code-du-travail-frontend/src/modules/outils/common/components/Feedback/__tests__/feedback.test.tsx deleted file mode 100644 index 8b5f3dbb44..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/common/components/Feedback/__tests__/feedback.test.tsx +++ /dev/null @@ -1,129 +0,0 @@ -import { fireEvent, render } from "@testing-library/react"; -import { Feedback } from ".."; -import { ui } from "./ui"; -import { push as matopush } from "@socialgouv/matomo-next"; -import { EVENT_CATEGORY } from "../tracking"; - -jest.mock("@socialgouv/matomo-next", () => { - return { - push: jest.fn(), - }; -}); - -describe("Etant donné un composant Feedback", () => { - beforeEach(() => { - render(); - }); - test("Vérification que l'introduction s'affiche", () => { - expect(ui.introduction.title.query()).toBeInTheDocument(); - expect(ui.introduction.button.query()).toBeInTheDocument(); - }); - describe("Lors d'un clique sur le bouton 'Fermer'", () => { - beforeEach(() => { - fireEvent.click(ui.closeButton.get()); - }); - test("Vérification que le composant ne s'affiche plus", () => { - expect(ui.introduction.title.query()).not.toBeInTheDocument(); - expect(ui.introduction.button.query()).not.toBeInTheDocument(); - }); - }); - describe("Lors d'un clique sur le bouton 'Donner mon avis'", () => { - beforeEach(() => { - fireEvent.click(ui.introduction.button.get()); - }); - test("Vérification que le 1er questionnaire s'affiche bien", () => { - expect(ui.questionnaire1.title.query()).toBeInTheDocument(); - expect(ui.questionnaire1.bad.query()).toBeInTheDocument(); - expect(ui.questionnaire1.average.query()).toBeInTheDocument(); - expect(ui.questionnaire1.good.query()).toBeInTheDocument(); - expect(ui.sendButton.query()).toBeInTheDocument(); - }); - describe("Lors d'un clic directement sur le bouton 'Envoyer'", () => { - beforeEach(() => { - fireEvent.click(ui.sendButton.get()); - }); - test("Vérification que le message d'erreur s'affiche bien", () => { - expect(ui.questionnaire1.requiredError.query()).toBeInTheDocument(); - }); - }); - describe("Lors d'une sélection et clique sur le bouton 'Envoyer'", () => { - beforeEach(() => { - fireEvent.click(ui.questionnaire1.average.get()); - fireEvent.click(ui.sendButton.get()); - }); - test("Vérification du tracking et que le 2e questionnaire s'affiche", () => { - expect(matopush).toHaveBeenCalledWith([ - "trackEvent", - "feedback_simulateurs", - "Comment_s_est_passée_la_simulation", - "moyen", - ]); - - expect(ui.questionnaire2.simulator.title.query()).toBeInTheDocument(); - expect(ui.questionnaire2.simulator.bad.query()).toBeInTheDocument(); - expect(ui.questionnaire2.simulator.average.query()).toBeInTheDocument(); - expect(ui.questionnaire2.simulator.good.query()).toBeInTheDocument(); - - expect( - ui.questionnaire2.questionClarity.title.query() - ).toBeInTheDocument(); - expect( - ui.questionnaire2.questionClarity.bad.query() - ).toBeInTheDocument(); - expect( - ui.questionnaire2.questionClarity.average.query() - ).toBeInTheDocument(); - expect( - ui.questionnaire2.questionClarity.good.query() - ).toBeInTheDocument(); - - expect( - ui.questionnaire2.resultClarity.title.query() - ).toBeInTheDocument(); - expect(ui.questionnaire2.resultClarity.bad.query()).toBeInTheDocument(); - expect( - ui.questionnaire2.resultClarity.average.query() - ).toBeInTheDocument(); - expect( - ui.questionnaire2.resultClarity.good.query() - ).toBeInTheDocument(); - - expect(ui.questionnaire2.more.title.query()).toBeInTheDocument(); - expect(ui.questionnaire2.more.input.query()).toBeInTheDocument(); - }); - describe("Lors d'une sélection et clique sur le bouton 'Envoyer'", () => { - beforeEach(() => { - fireEvent.click(ui.questionnaire2.simulator.bad.get()); - fireEvent.click(ui.questionnaire2.questionClarity.average.get()); - fireEvent.click(ui.questionnaire2.resultClarity.good.get()); - fireEvent.change(ui.questionnaire2.more.input.get(), { - target: { value: "test" }, - }); - fireEvent.click(ui.sendButton.get()); - }); - test("Vérification du tracking et que la fin du questionnaire s'affiche", () => { - expect(matopush).toHaveBeenCalledWith([ - "trackEvent", - "feedback_simulateurs", - "Comment_s_est_passée_la_simulation", - "moyen", - ]); - expect(matopush).toHaveBeenCalledWith([ - "trackEvent", - "feedback_simulateurs", - "Facilité_utilisation_simulateur", - "pas_du_tout", - ]); - expect(matopush).toHaveBeenCalledWith([ - "trackEvent", - "feedback_simulateurs", - "Clarté_questions", - "moyen", - ]); - expect(ui.questionnaireEnd.title.query()).toBeInTheDocument(); - expect(ui.questionnaireEnd.description.query()).toBeInTheDocument(); - }); - }); - }); - }); -}); diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/components/Feedback/__tests__/ui.ts b/packages/code-du-travail-frontend/src/modules/outils/common/components/Feedback/__tests__/ui.ts deleted file mode 100644 index 3ca0dd5542..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/common/components/Feedback/__tests__/ui.ts +++ /dev/null @@ -1,53 +0,0 @@ -import { byTestId, byText } from "testing-library-selector"; - -export const ui = { - closeButton: byTestId("feedbackCloseButton"), - sendButton: byText("Envoyer"), - introduction: { - title: byText("Votre avis sur ce simulateur nous intéresse"), - button: byText("Donner mon avis"), - }, - questionnaire1: { - title: byText(/Comment s'est passée cette simulation pour vous \?/), - bad: byText("Pas bien"), - average: byText("Moyen"), - good: byText("Très bien"), - requiredError: byText("Vous devez choisir une des réponses"), - }, - questionnaire2: { - title: byText(/Merci pour votre aide ! Pouvez-vous nous en dire plus \?/), - simulator: { - title: byText(/Le simulateur était-il facile à utiliser \?/), - bad: byTestId("simulator-bad"), - average: byTestId("simulator-average"), - good: byTestId("simulator-good"), - }, - questionClarity: { - title: byText( - /Les questions étaient-elles claires et compréhensibles \?/ - ), - bad: byTestId("questionClarity-bad"), - average: byTestId("questionClarity-average"), - good: byTestId("questionClarity-good"), - }, - resultClarity: { - title: byText( - /Les explications du résultat obtenu étaient-elles claires et compréhensibles \?/ - ), - bad: byTestId("resultClarity-bad"), - average: byTestId("resultClarity-average"), - good: byTestId("resultClarity-good"), - }, - more: { - title: byText(/Vous souhaitez nous en dire davantage \?/), - input: byTestId("more-input"), - }, - requiredError: byText("Vous devez choisir une des réponses"), - }, - questionnaireEnd: { - title: byText(/Merci pour votre aide !/), - description: byText( - /Votre évaluation sera étudiée au plus vite par nos équipes/ - ), - }, -}; diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/components/Feedback/index.tsx b/packages/code-du-travail-frontend/src/modules/outils/common/components/Feedback/index.tsx deleted file mode 100644 index 6bf4c6a806..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/common/components/Feedback/index.tsx +++ /dev/null @@ -1,113 +0,0 @@ -import styled from "styled-components"; -import { Button, icons, theme } from "@socialgouv/cdtn-ui"; -import { Introduction } from "./introduction"; -import { useState } from "react"; -import { Questionnaire } from "./Questionnaire"; -import { QuestionnaireAdvanced } from "./QuestionnaireAdvanced"; -import { QuestionnaireEnd } from "./QuestionnaireEnd"; -import { EVENT_CATEGORY } from "./tracking"; - -type Props = { - category: EVENT_CATEGORY; -}; - -export const Feedback = ({ category }: Props): JSX.Element => { - const [status, setStatus] = useState< - "questionnaire" | "questionnaireAdvanced" | "questionnaireEnd" - >(); - const [closed, setClosed] = useState(false); - const [position, setPosition] = useState(0); - const [bodyPosition, setBodyPosition] = useState(0); - const closeButton = ( - setClosed(true)} - > - setClosed(true)} - data-testid="feedbackCloseButton" - title="Fermer la modale" - /> - - ); - return !closed ? ( -
    - {!status && ( - - {closeButton} - { - setStatus("questionnaire"); - }} - /> - - )} - {status && ( - { - if (!el) return; - - setPosition(el.getBoundingClientRect().top); - setBodyPosition(document.body.getBoundingClientRect().top); - }} - > - {closeButton} - {status === "questionnaire" && ( - { - setStatus("questionnaireAdvanced"); - }} - category={category} - /> - )} - {status === "questionnaireAdvanced" && ( - { - setStatus("questionnaireEnd"); - window.scrollTo(0, position - bodyPosition - 220); - }} - category={category} - /> - )} - {status === "questionnaireEnd" && } - - )} -
    - ) : ( - <> - ); -}; - -const { colors, box } = theme; - -const Div = styled.div` - display: flex; - justify-content: flex-end; -`; - -const IntroContainer = styled.div` - border: 1px solid ${colors.secondary}; - border-radius: ${box.borderRadius}; - background-color: ${theme.colors.white}; - min-width: 460px; - max-width: 100%; - padding: 0; - position: relative; -`; - -const StyledContainer = styled(IntroContainer)` - width: 520px; - padding: ${theme.spacings.xmedium} 0; -`; - -const CloseButton = styled(Button)` - position: absolute; - top: 8px; - right: 8px; - width: 24px; - color: ${({ theme }) => theme.secondary}; -`; diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/components/Feedback/introduction.tsx b/packages/code-du-travail-frontend/src/modules/outils/common/components/Feedback/introduction.tsx deleted file mode 100644 index daf4f97916..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/common/components/Feedback/introduction.tsx +++ /dev/null @@ -1,22 +0,0 @@ -import styled from "styled-components"; -import { Button, Paragraph, theme } from "@socialgouv/cdtn-ui"; - -type IntroductionProps = { - onClick: () => void; -}; - -export const Introduction = ({ onClick }: IntroductionProps): JSX.Element => { - return ( -
    - - Votre avis sur ce simulateur nous intéresse - - -
    - ); -}; - -const Div = styled.div` - text-align: center; - padding: ${theme.spacings.large}; -`; diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/components/Feedback/tracking.ts b/packages/code-du-travail-frontend/src/modules/outils/common/components/Feedback/tracking.ts deleted file mode 100644 index 9848adb69a..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/common/components/Feedback/tracking.ts +++ /dev/null @@ -1,52 +0,0 @@ -import { MatomoBaseEvent } from "src/lib/matomo"; -import { push as matopush } from "@socialgouv/matomo-next"; - -export enum EVENT_CATEGORY { - indemniteLicenciement = "feedback_simulateurs", - ruptureConventionnelle = "feedback_simulateurs_rupture_co", -} - -export enum EVENT_SUGGESTION { - indemniteLicenciement = "feedback_suggestion", - ruptureConventionnelle = "feedback_suggestion_rupture_co", -} - -export enum EVENT_ACTION { - GLOBAL = "Comment_s_est_passée_la_simulation", - EASINESS = "Facilité_utilisation_simulateur", - QUESTION_CLARITY = "Clarté_questions", - RESULT_CLARITY = "Clarté_résultat", - SUGGESTION = "Suggestion", -} - -export enum FEEDBACK_RESULT { - NOT_GOOD = "pas_bien", - NOT_AT_ALL = "pas_du_tout", - AVERAGE = "moyen", - GOOD = "très_bien", - EASY = "facile", - YES = "oui", -} - -export const trackFeedback = ( - event: EVENT_ACTION, - feedback: FEEDBACK_RESULT, - category: EVENT_CATEGORY -) => { - matopush([MatomoBaseEvent.TRACK_EVENT, category, event, feedback]); -}; - -export const trackFeedbackText = ( - text: string, - url: string, - category: EVENT_CATEGORY -) => { - matopush([ - "trackEvent", - category === EVENT_CATEGORY.indemniteLicenciement - ? EVENT_SUGGESTION.indemniteLicenciement - : EVENT_SUGGESTION.ruptureConventionnelle, - text, - url.replace(/\?.*$/, ""), - ]); -}; diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/components/Informations/index.ts b/packages/code-du-travail-frontend/src/modules/outils/common/components/Informations/index.ts deleted file mode 100644 index 6749274222..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/common/components/Informations/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default as PubliQuestion } from "./PubliQuestion"; diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/components/RadioQuestion.tsx b/packages/code-du-travail-frontend/src/modules/outils/common/components/RadioQuestion.tsx index 678bec2218..a97d79f4f3 100644 --- a/packages/code-du-travail-frontend/src/modules/outils/common/components/RadioQuestion.tsx +++ b/packages/code-du-travail-frontend/src/modules/outils/common/components/RadioQuestion.tsx @@ -1,6 +1,6 @@ import React from "react"; -import { Tooltip } from "./types"; import Html from "src/modules/common/Html"; +import { RadioButtons } from "@codegouvfr/react-dsfr/RadioButtons"; type Question = { label: string; @@ -16,21 +16,18 @@ type Props = { questions: Question[]; showRequired?: boolean; name: string; - tooltip?: Tooltip; subLabel?: string; note?: string; autoFocus?: boolean; }; -export default function RadioQuestion({ +export function RadioQuestion({ selectedOption, onChangeSelectedOption, error, label, questions, - showRequired, name, - tooltip, subLabel, note, autoFocus = false, @@ -41,26 +38,24 @@ export default function RadioQuestion({ return (
    - {/* */} - {label} - {/* */} - {/* {subLabel && {subLabel}} */} - {/* - {questions.map((question, index) => ( - onChange(question.value)} - autoFocus={autoFocus ? index === 0 : false} - /> - ))} - {error && {error}} - */} + {label}} + hintText={subLabel} + options={questions.map((question, index) => ({ + name, + label: question.label, + value: question.value, + id: question.id, + "data-testid": `${name} - ${question.label}`, + nativeInputProps: { + checked: selectedOption === question.value, + onChange: () => onChange(question.value), + autoFocus: autoFocus && index === 0, + }, + }))} + state={error ? "error" : "default"} + stateRelatedMessage={error} + /> {note && {note}}
    ); diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/components/SelectQuestion.tsx b/packages/code-du-travail-frontend/src/modules/outils/common/components/SelectQuestion.tsx index b7b298006d..84d924cc11 100644 --- a/packages/code-du-travail-frontend/src/modules/outils/common/components/SelectQuestion.tsx +++ b/packages/code-du-travail-frontend/src/modules/outils/common/components/SelectQuestion.tsx @@ -1,32 +1,24 @@ import React from "react"; -import { Tooltip } from "./types"; import Html from "src/modules/common/Html"; +import { Select } from "@codegouvfr/react-dsfr/Select"; type Props = { name: string; label: string; subLabel?: string; - tooltip?: Tooltip; options: Record | [string, string][]; - isTooltipOpen?: boolean; - onSwitchTooltip?: () => void; - showRequired?: boolean; error?: string; onChangeSelectedOption: (value: string) => void; selectedOption: string | undefined; autoFocus?: boolean; }; -const SelectQuestion = ({ +export const SelectQuestion = ({ name, label, subLabel, - tooltip, options, - isTooltipOpen, - onSwitchTooltip, error, - showRequired, onChangeSelectedOption, selectedOption, autoFocus = false, @@ -34,11 +26,6 @@ const SelectQuestion = ({ const [optionsArray, setOptionsArray] = React.useState<[string, string][]>( [] ); - const [value, setValue] = React.useState(selectedOption ?? ""); - const onChange = (value: string) => { - setValue(value); - onChangeSelectedOption(value); - }; React.useEffect(() => { if (!Array.isArray(options)) { @@ -48,46 +35,32 @@ const SelectQuestion = ({ } }, [options]); + const handleChange = (event: React.ChangeEvent) => { + onChangeSelectedOption(event.target.value); + }; + return ( -
    -
    - {label} -
    - {subLabel &&

    {subLabel}

    } - {label}} + hint={subLabel} + data-testid={name} + nativeSelectProps={{ + onChange: handleChange, + value: selectedOption ?? "", + id: `input-${name}`, + autoFocus, + }} + state={error ? "error" : "default"} + stateRelatedMessage={error} + > + + {optionsArray.map(([key, label]) => ( + - {optionsArray.map((option) => { - let key, label; - if (Array.isArray(option)) { - [key, label] = option; - } else { - key = label = option; - } - - return ( - - ); - })} - - {error &&
    {error}
    } -
    + ))} + ); }; - -export default SelectQuestion; diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/components/SimulatorLayout/index.tsx b/packages/code-du-travail-frontend/src/modules/outils/common/components/SimulatorLayout/index.tsx index d99ba26e3a..c24e193348 100644 --- a/packages/code-du-travail-frontend/src/modules/outils/common/components/SimulatorLayout/index.tsx +++ b/packages/code-du-travail-frontend/src/modules/outils/common/components/SimulatorLayout/index.tsx @@ -22,7 +22,7 @@ export const SimulatorLayout = (props: Props) => { const [navigationAction, setNavigationAction] = useState< "next" | "prev" | "none" >("none"); - const [currentStepIndex, setStepIndex] = useState(0); + const [stepIndex, setStepIndex] = useState(0); const { steps, title, onStepChange, hiddenStep, simulator } = props; const visibleSteps = useMemo( @@ -30,16 +30,17 @@ export const SimulatorLayout = (props: Props) => { steps.filter((step) => !hiddenStep || !hiddenStep.includes(step.name)), [steps, hiddenStep] ); - const nbTotalSteps = steps.length; - const Step = visibleSteps[currentStepIndex].Component; - const stepName = visibleSteps[currentStepIndex].name; - const nextStepTitle = visibleSteps[currentStepIndex + 1]?.label; + const currentNumStep = stepIndex + 1; + const nbTotalSteps = visibleSteps.length; + const Step = visibleSteps[stepIndex].Component; + const stepName = visibleSteps[stepIndex].label; + const nextStepTitle = visibleSteps[stepIndex + 1]?.label; useEffect(() => { - const currentStepName = visibleSteps[currentStepIndex].name; + const currentStepName = visibleSteps[stepIndex].name; if (doNotTriggerMatomo(currentStepName)) return; emitNextPreviousEvent(title, navigationAction === "prev", currentStepName); - }, [currentStepIndex]); + }, [stepIndex]); const doNotTriggerMatomo = (stepName: string) => navigationAction === "none" || @@ -47,11 +48,11 @@ export const SimulatorLayout = (props: Props) => { simulator === PublicodesSimulator.INDEMNITE_LICENCIEMENT); const onNextStep = () => { - const nextStepIndex = currentStepIndex + 1; + const nextStepIndex = stepIndex + 1; if (nextStepIndex >= visibleSteps.length) { throw Error("Can't show the next step with index more than steps"); } else { - const currentStepName = visibleSteps[currentStepIndex].name; + const currentStepName = visibleSteps[stepIndex].name; const stepChange = onStepChange.find( (validator) => validator.stepName === currentStepName @@ -68,7 +69,7 @@ export const SimulatorLayout = (props: Props) => { setStepIndex(visibleSteps.length - 1); break; case ValidationResponse.Valid: - setStepIndex(currentStepIndex + 1); + setStepIndex(stepIndex + 1); break; } setNavigationAction("next"); @@ -76,7 +77,7 @@ export const SimulatorLayout = (props: Props) => { }; const onPrevStep = () => { - const previousStepIndex = currentStepIndex - 1; + const previousStepIndex = stepIndex - 1; const prevStepName = visibleSteps[previousStepIndex].name; const stepChange = onStepChange.find( (validator) => validator.stepName === prevStepName @@ -86,7 +87,7 @@ export const SimulatorLayout = (props: Props) => { } if (previousStepIndex >= 0) { - setStepIndex(currentStepIndex - 1); + setStepIndex(stepIndex - 1); setNavigationAction("prev"); } else { throw Error("Can't show the previous step with index less than 0"); @@ -109,55 +110,64 @@ export const SimulatorLayout = (props: Props) => { }; const validator = onStepChange.find( - (validator) => validator.stepName === visibleSteps[currentStepIndex].name + (validator) => validator.stepName === visibleSteps[stepIndex].name ); return ( -
    +
    -
    +
    -
    - {currentStepIndex > 1 && ( - )} - {currentStepIndex < nbTotalSteps && ( + {currentNumStep < nbTotalSteps && ( )} - {currentStepIndex === nbTotalSteps && ( - )}
    - {visibleSteps[currentStepIndex].options?.annotation && ( -
    -

    {visibleSteps[currentStepIndex].options?.annotation}

    -
    + {visibleSteps[stepIndex].options?.annotation && ( +

    + {visibleSteps[stepIndex].options?.annotation} +

    )}
    ); diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/components/TextQuestion.tsx b/packages/code-du-travail-frontend/src/modules/outils/common/components/TextQuestion.tsx index dc367edc90..b51b46ce28 100644 --- a/packages/code-du-travail-frontend/src/modules/outils/common/components/TextQuestion.tsx +++ b/packages/code-du-travail-frontend/src/modules/outils/common/components/TextQuestion.tsx @@ -1,84 +1,72 @@ -import React, { FunctionComponent, useEffect, useState } from "react"; -import { Tooltip } from "./types"; +import React, { useEffect, useState } from "react"; import Html from "src/modules/common/Html"; import { xssWrapper } from "src/lib"; +import { Input } from "@codegouvfr/react-dsfr/Input"; type Props = { onChange: (value: string) => void; error?: string; label: string; - tooltip?: Tooltip; inputType?: "date" | "number" | "text"; value: string | number | undefined; - placeholder?: string; subLabel?: string; - smallText?: string; title?: string; - showRequired?: boolean; - icon?: FunctionComponent; id: string; dataTestId?: string; - text?: string; autoFocus?: boolean; }; -export default function TextQuestion({ - tooltip, - inputType, +export function TextQuestion({ + inputType = "text", label, error, value, - placeholder, onChange, - smallText, subLabel, title, - showRequired, - icon, id, dataTestId, - text, autoFocus = false, }: Props) { const [inputRef, setInputRef] = useState(); + useEffect(() => { if (inputRef && error) { inputRef?.focus(); } }, [inputRef, error]); + + const handleChange = (event: React.ChangeEvent) => { + const newValue = + inputType === "date" ? event.target.value : event.target.value; + onChange(newValue); + }; + return ( -
    -

    - {label} -

    - {smallText &&

    {smallText}

    } - {subLabel &&

    {subLabel}

    } -
    - {/* onChange(inputType === "date" ? e : e.target.value)} - invalid={!!error} - placeholder={placeholder} - icon={icon} - text={text} - type={inputType === "date" ? "text" : inputType} - updateOnScrollDisabled - data-testid={dataTestId} - autoFocus={autoFocus} - title={title} - /> */} -
    - {error && ( -

    + {label}} + hintText={subLabel} + nativeInputProps={{ + type: inputType, + id, + name: id, + value: value ?? "", + onChange: handleChange, + autoFocus, + title, + ref: (ref: HTMLInputElement) => setInputRef(ref), + }} + data-testid={dataTestId} + state={error ? "error" : "default"} + stateRelatedMessage={ + error && ( -

    - )} -
    + ) + } + /> ); } diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/components/types.ts b/packages/code-du-travail-frontend/src/modules/outils/common/components/types.ts deleted file mode 100644 index 4466e5bc68..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/common/components/types.ts +++ /dev/null @@ -1,5 +0,0 @@ -export type Tooltip = { - content: JSX.Element; - help?: string; - trackableFn?: (actualVisibility: boolean) => void; -}; diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/agreements/1483-habillement-textiles-commerce-de-detail/Informations.tsx b/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/agreements/1483-habillement-textiles-commerce-de-detail/Informations.tsx index b00e230c69..19c11a0710 100644 --- a/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/agreements/1483-habillement-textiles-commerce-de-detail/Informations.tsx +++ b/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/agreements/1483-habillement-textiles-commerce-de-detail/Informations.tsx @@ -1,10 +1,5 @@ import { useContext } from "react"; -import { Paragraph } from "@socialgouv/cdtn-ui"; -import { - StyledFilledElementSpan, - StyledFilledElementTable, -} from "../../steps/Resultat/components/FilledElements"; import { IndemniteDepartContext, useIndemniteDepartStore } from "../../store"; export default function Agreement1483Informations() { @@ -30,19 +25,17 @@ export default function Agreement1483Informations() { {hasReceivedSalaries === "oui" && (
  • - - Salaires perçus pendant le préavis : - - +

    Salaires perçus pendant le préavis :

    + @@ -61,7 +54,7 @@ export default function Agreement1483Informations() { ))} - +
    Mois Salaire
    - + (primes et avantages en nature inclus) - +
    Dont primes
  • )} diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/agreements/1516-organismes-formation/Informations.tsx b/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/agreements/1516-organismes-formation/Informations.tsx index b82609108b..49d4204e50 100644 --- a/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/agreements/1516-organismes-formation/Informations.tsx +++ b/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/agreements/1516-organismes-formation/Informations.tsx @@ -1,10 +1,4 @@ import { useContext } from "react"; -import { Paragraph } from "@socialgouv/cdtn-ui"; - -import { - StyledFilledElementSpan, - StyledFilledElementTable, -} from "../../steps/Resultat/components/FilledElements"; import { IndemniteDepartContext, useIndemniteDepartStore } from "../../store"; export default function Agreement1516Informations() { @@ -30,19 +24,17 @@ export default function Agreement1516Informations() { {hasReceivedSalaries === "oui" && (
  • - - Salaires perçus pendant le préavis : - - +

    Salaires perçus pendant le préavis :

    + @@ -61,7 +53,7 @@ export default function Agreement1516Informations() { ))} - +
    Mois Salaire
    - + (primes et avantages en nature inclus) - +
    Dont primes
  • )} diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/agreements/1672-societes-assurances/Informations.tsx b/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/agreements/1672-societes-assurances/Informations.tsx index a975724b34..5971f61bd5 100644 --- a/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/agreements/1672-societes-assurances/Informations.tsx +++ b/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/agreements/1672-societes-assurances/Informations.tsx @@ -1,9 +1,4 @@ import React, { useContext } from "react"; -import { Paragraph } from "@socialgouv/cdtn-ui"; -import { - StyledFilledElementSpan, - StyledFilledElementTable, -} from "../../steps/Resultat/components/FilledElements"; import { IndemniteDepartContext, useIndemniteDepartStore } from "../../store"; export default function Agreement1672Informations() { @@ -29,20 +24,18 @@ export default function Agreement1672Informations() { {hasReceivedSalaries === "oui" && (
  • - - Salaires perçus pendant le préavis : - +

    Salaires perçus pendant le préavis :

    - + @@ -57,7 +50,7 @@ export default function Agreement1672Informations() { ))} - +
    Mois Salaire{noticeSalaryPeriods.length > 1 && "s"}
    - + (primes et avantages en nature inclus) - +
  • )} diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/agreements/1702-ouvriers-travaux-public/Informations.tsx b/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/agreements/1702-ouvriers-travaux-public/Informations.tsx index 3c867aa88f..930716dcf2 100644 --- a/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/agreements/1702-ouvriers-travaux-public/Informations.tsx +++ b/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/agreements/1702-ouvriers-travaux-public/Informations.tsx @@ -1,9 +1,4 @@ import React, { useContext } from "react"; -import { Paragraph } from "@socialgouv/cdtn-ui"; -import { - StyledFilledElementSpan, - StyledFilledElementTable, -} from "../../steps/Resultat/components/FilledElements"; import { IndemniteDepartContext, useIndemniteDepartStore } from "../../store"; export default function Agreement1702Informations() { @@ -29,20 +24,18 @@ export default function Agreement1702Informations() { {hasReceivedSalaries === "oui" && (
  • - - Salaires perçus pendant le préavis : - +

    Salaires perçus pendant le préavis :

    - + @@ -57,7 +50,7 @@ export default function Agreement1702Informations() { ))} - +
    Mois Salaire{noticeSalaryPeriods.length > 1 && "s"}
    - + (primes et avantages en nature inclus) - +
  • )} diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/agreements/1740-batiment-region-parisienne/Informations.tsx b/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/agreements/1740-batiment-region-parisienne/Informations.tsx index d3912c199f..9512f82832 100644 --- a/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/agreements/1740-batiment-region-parisienne/Informations.tsx +++ b/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/agreements/1740-batiment-region-parisienne/Informations.tsx @@ -1,10 +1,4 @@ import { useContext } from "react"; -import { Paragraph } from "@socialgouv/cdtn-ui"; - -import { - StyledFilledElementSpan, - StyledFilledElementTable, -} from "../../steps/Resultat/components/FilledElements"; import { IndemniteDepartContext, useIndemniteDepartStore } from "../../store"; export default function Agreement1740Informations() { @@ -30,20 +24,18 @@ export default function Agreement1740Informations() { {hasReceivedSalaries === "oui" && (
  • - - Salaires perçus pendant le préavis : - +

    Salaires perçus pendant le préavis :

    - + @@ -62,7 +54,7 @@ export default function Agreement1740Informations() { ))} - +
    Mois Salaire{noticeSalaryPeriods.length > 1 && "s"}
    - + (primes et avantages en nature inclus) - +
    Dont primes
  • )} diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/agreements/2120-banques/Component.tsx b/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/agreements/2120-banques/Component.tsx index 57cdb9211c..2b98fa4e32 100644 --- a/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/agreements/2120-banques/Component.tsx +++ b/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/agreements/2120-banques/Component.tsx @@ -91,11 +91,11 @@ export default function Agreement2120({ type }: Props) { error={errorSalariesVariablePart} id="salariesVariablePart" dataTestId="salariesVariablePart" - showRequired - text="€" - tooltip={{ - content, - }} + // unit="€" + // tooltip={{ + // content, + // }} + //TODO ATTENTION FAUT IL METTRE LE TOOLTIP ? /> ); } diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/agreements/2148-telecommunications/Informations.tsx b/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/agreements/2148-telecommunications/Informations.tsx index 7df5ca8a40..09d4370b26 100644 --- a/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/agreements/2148-telecommunications/Informations.tsx +++ b/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/agreements/2148-telecommunications/Informations.tsx @@ -1,9 +1,4 @@ import React, { useContext } from "react"; -import { Paragraph } from "@socialgouv/cdtn-ui"; -import { - StyledFilledElementSpan, - StyledFilledElementTable, -} from "../../steps/Resultat/components/FilledElements"; import { IndemniteDepartContext, useIndemniteDepartStore } from "../../store"; export default function Agreement2148Informations() { @@ -29,20 +24,18 @@ export default function Agreement2148Informations() { {hasReceivedSalaries === "oui" && (
  • - - Salaires perçus pendant le préavis : - +

    Salaires perçus pendant le préavis :

    - + @@ -57,7 +50,7 @@ export default function Agreement2148Informations() { ))} - +
    Mois Salaire{noticeSalaryPeriods.length > 1 && "s"}
    - + (primes et avantages en nature inclus) - +
  • )} diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/agreements/2596-coiffure/Informations.tsx b/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/agreements/2596-coiffure/Informations.tsx index c158bc4cd1..54ea1e1521 100644 --- a/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/agreements/2596-coiffure/Informations.tsx +++ b/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/agreements/2596-coiffure/Informations.tsx @@ -1,9 +1,4 @@ import React, { useContext } from "react"; -import { Paragraph } from "@socialgouv/cdtn-ui"; -import { - StyledFilledElementSpan, - StyledFilledElementTable, -} from "../../steps/Resultat/components/FilledElements"; import { IndemniteDepartContext, useIndemniteDepartStore } from "../../store"; export default function Agreement2596Informations() { @@ -29,20 +24,18 @@ export default function Agreement2596Informations() { {hasReceivedSalaries === "oui" && (
  • - - Salaires perçus pendant le préavis : - +

    Salaires perçus pendant le préavis :

    - + @@ -57,7 +50,7 @@ export default function Agreement2596Informations() { ))} - +
    Mois Salaire{noticeSalaryPeriods.length > 1 && "s"}
    - + (primes et avantages en nature inclus) - +
  • )} diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/agreements/ui-customizations/index.ts b/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/agreements/ui-customizations/index.ts index 8c5cc96591..c2e7ea9a13 100644 --- a/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/agreements/ui-customizations/index.ts +++ b/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/agreements/ui-customizations/index.ts @@ -1,2 +1 @@ export * from "./messages"; -export * from "./tooltip"; diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/agreements/ui-customizations/tooltip.tsx b/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/agreements/ui-customizations/tooltip.tsx deleted file mode 100644 index 23741d31ca..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/agreements/ui-customizations/tooltip.tsx +++ /dev/null @@ -1,10 +0,0 @@ -import { Tooltip } from "src/outils/common/Question"; -import { TooltipSalary } from "../../steps/Salaires/components"; - -export const getTooltipSalairesMensuel = ( - agreementNumber?: number -): Tooltip | undefined => { - if (agreementNumber === 3239) return undefined; - - return { content: }; -}; diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/index.tsx b/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/index.tsx index 45637a5928..a9c6a743ed 100644 --- a/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/index.tsx +++ b/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/index.tsx @@ -7,10 +7,9 @@ import { } from "./store"; import { IndemniteDepartType } from "./types"; import { PublicodesSimulator } from "@socialgouv/modeles-social"; -import { Feedback } from "../components/Feedback"; -import { EVENT_CATEGORY } from "../components/Feedback/tracking"; import { Step } from "../components/SimulatorLayout/types"; import { SimulatorLayout } from "../components/SimulatorLayout"; +import { EVENT_CATEGORY } from "src/outils/common/Feedback/tracking"; type SimulateurProps = CalculateurIndemniteProps & { title: string; @@ -73,42 +72,39 @@ const IndemniteDepartSimulator = ({ }; return ( -
    - - {feedbackPopup && } -
    + ); }; diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Agreement/components/AgreementStep.tsx b/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Agreement/components/AgreementStep.tsx index 6f5f857edb..48befe32d0 100644 --- a/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Agreement/components/AgreementStep.tsx +++ b/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Agreement/components/AgreementStep.tsx @@ -60,15 +60,7 @@ export const CommonAgreementStep = ({ selectedOption={route} onChangeSelectedOption={onRouteChange} error={error?.route} - showRequired - tooltip={{ - content: ( -

    - Vous pouvez trouver le nom de votre convention collective sur - votre bulletin de paie. -

    - ), - }} + subLabel="Vous pouvez trouver le nom de votre convention collective sur votre bulletin de paie" autoFocus /> {route === "not-selected" && } diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Agreement/index.tsx b/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Agreement/index.tsx index a967246f65..835b09237a 100644 --- a/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Agreement/index.tsx +++ b/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Agreement/index.tsx @@ -37,19 +37,20 @@ const AgreementStep = (): JSX.Element => { }, [onInitAgreementPage]); return ( - + // + <> ); }; diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Agreement/store/store.ts b/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Agreement/store/store.ts index 67778d0d5c..2f6127d202 100644 --- a/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Agreement/store/store.ts +++ b/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Agreement/store/store.ts @@ -30,8 +30,9 @@ const initialState: Omit< > = { input: { isAgreementSupportedIndemniteLicenciement: false, - hasNoEnterpriseSelected: false, + hasNoEnterpriseSelected: true, informationError: false, + route: "not-selected", }, error: {}, hasBeenSubmit: false, diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Agreement/store/types.ts b/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Agreement/store/types.ts index 32eea8ea46..ae3dfdd8a3 100644 --- a/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Agreement/store/types.ts +++ b/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Agreement/store/types.ts @@ -1,4 +1,3 @@ -import { ValidationResponse } from "../../../../components/Simulator/SimulatorLayout"; import { AgreementRoute } from "src/outils/common/type/WizardType"; import { PublicodesInstance, @@ -6,6 +5,7 @@ import { } from "@socialgouv/modeles-social"; import { Agreement } from "../../../types"; import { Enterprise } from "src/conventions/Search/api/enterprises.service"; +import { ValidationResponse } from "src/modules/outils/common/components/SimulatorLayout/types"; export type CommonAgreementStoreInput = { route?: AgreementRoute; diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Anciennete/components/AbsencePeriod.tsx b/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Anciennete/components/AbsencePeriod.tsx index 766e053f5f..8cf85d4a86 100644 --- a/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Anciennete/components/AbsencePeriod.tsx +++ b/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Anciennete/components/AbsencePeriod.tsx @@ -1,17 +1,9 @@ -import { - Input, - InputDate, - Label, - Select, - Text, - theme, -} from "@socialgouv/cdtn-ui"; +import { Select } from "@codegouvfr/react-dsfr/Select"; +import { Input } from "@codegouvfr/react-dsfr/Input"; import React, { useState } from "react"; -import styled from "styled-components"; import { Motif } from "@socialgouv/modeles-social"; import { AbsenceWithKey } from "./AbsencePeriods"; -import { DelButton } from "src/outils/common/Buttons"; -import { MultiFieldRow } from "src/outils/common/MultiFieldRow"; +import { Button } from "@codegouvfr/react-dsfr/Button"; type Errors = { duration?: string; @@ -57,37 +49,20 @@ const AbsencePeriod = ({ onSelectMotif(key, value); }; - const DurationWrapper = shouldAskAbsenceDate - ? FieldWrapper - : FieldWrapperNoMargin; - return ( - - - - Absence {index + 1} - - - - - - selectMotif(absence.key, e.target.value)} - value={absence?.motif?.label} +
    +
    +

    Absence {index + 1}

    +
    +
    +
    + +
    +
    onSetDurationDate(absence.key, e.target.value)} - invalid={errors?.duration !== undefined} - value={absence?.durationInMonth} - type="number" - name={`${index}.duration`} - aria-label={`${index}.duration`} - updateOnScrollDisabled + label="Durée (en mois)" + state={errors?.duration ? "error" : "default"} + stateRelatedMessage={errors?.duration} + nativeInputProps={{ + id: `${index}.duration`, + type: "number", + onChange: (e) => onSetDurationDate(absence.key, e.target.value), + value: absence?.durationInMonth ?? "", + }} data-testid={`absence-duree-${index}`} /> - {errors?.duration && {errors.duration}} - +
    {shouldAskAbsenceDate && ( - <> - -
    - onSetAbsenceDate(absence.key, e)} - placeholder={"jj/mm/aaaa"} - invalid={errors?.absenceDate !== undefined} - value={absence?.startedAt} - type="text" - name={`${index}.dateAbsence`} - aria-label={`${index}.dateAbsence`} - updateOnScrollDisabled - data-testid={`absence-date-${index}`} - /> - {errors?.absenceDate && ( - {errors.absenceDate} - )} -
    - +
    + onSetAbsenceDate(absence.key, e.target.value), + value: absence?.startedAt ?? "", + }} + data-testid={`absence-date-${index}`} + /> +
    )} {showDeleteButton && ( - onDeleteAbsence(absence.key)}> - Supprimer - +
    + +
    )} - - +
    +
    ); }; export default AbsencePeriod; - -const { breakpoints, spacings } = theme; - -const RelativeDiv = styled.div` - position: relative; -`; - -const RowTitle = styled.div` - margin-bottom: ${spacings.base}; - padding-top: ${spacings.small}; -`; - -const StyledSelect = styled(Select)` - display: flex; -`; - -const FieldWrapper = styled.div` - margin-right: ${spacings.base}; - @media (max-width: ${breakpoints.mobile}) { - margin-right: 0; - margin-bottom: ${spacings.base}; - } -`; - -const FieldWrapperNoMargin = styled.div``; - -const StyledError = styled(Error)` - margin-bottom: 0; -`; - -const StyledDelButton = styled(DelButton)` - margin-top: ${spacings.xsmall}; - @media (max-width: ${breakpoints.mobile}) { - position: absolute; - top: 0; - right: 0; - margin-top: 0; - } -`; diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Anciennete/components/AbsencePeriods.tsx b/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Anciennete/components/AbsencePeriods.tsx index 1a729e9e89..997a6ccb0d 100644 --- a/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Anciennete/components/AbsencePeriods.tsx +++ b/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Anciennete/components/AbsencePeriods.tsx @@ -1,12 +1,10 @@ import { Absence, Motif } from "@socialgouv/modeles-social"; import React, { useEffect } from "react"; -import styled from "styled-components"; +import { Button } from "@codegouvfr/react-dsfr/Button"; +import { Alert } from "@codegouvfr/react-dsfr/Alert"; import AbsencePeriod from "./AbsencePeriod"; import type { AncienneteAbsenceStoreError } from "../store"; -import { AddButton } from "src/outils/common/Buttons"; -import { SmallText } from "src/outils/common/stepStyles"; -import { Question } from "src/outils/common/Question"; type Props = { onChange: (absences: Absence[]) => void; @@ -122,16 +120,15 @@ const AbsencePeriods = ({ }; return ( - <> - {messageMotifExample &&

    {messageMotifExample}

    } - - Quels sont le motif et la durée de ces absences prolongées ? - - - Veuillez créer une ligne différente pour chaque période d’absence (de - plus d’un mois) même si vous avez été absent plusieurs fois pour le même - motif. - +
    + {messageMotifExample &&

    {messageMotifExample}

    } +

    Quels sont le motif et la durée de ces absences prolongées ?

    +

    + Veuillez créer une ligne différente pour chaque période d'absence + (de plus d'un mois) même si vous avez été absent plusieurs fois + pour le même motif. +

    + {localAbsences.map((value, index) => ( ))} - {error?.global && {error.global}} - Ajouter une absence - + + {error?.global && ( + + )} + + +
    ); }; -const StyledError = styled(Error)` - margin-bottom: 0; -`; - export default AbsencePeriods; diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Anciennete/components/SectionTitleWithTooltip.tsx b/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Anciennete/components/SectionTitleWithTooltip.tsx deleted file mode 100644 index 9613892516..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Anciennete/components/SectionTitleWithTooltip.tsx +++ /dev/null @@ -1,50 +0,0 @@ -import React from "react"; -import styled from "styled-components"; -import { theme } from "@socialgouv/cdtn-ui"; -import { SectionTitle } from "src/outils/common/stepStyles"; -import { InfoBulle } from "src/outils/common/InfoBulle"; - -type Props = { - name: string; - tooltip?: any; -}; - -const SectionTitleWithTooltip = ({ tooltip, name }: Props) => { - const [isLocalTooltipOpen, setIsLocalToolTipOpen] = React.useState(false); - - return ( - - {name} - {tooltip && ( - { - tooltip.trackableFn?.(!isLocalTooltipOpen); - setIsLocalToolTipOpen(!isLocalTooltipOpen); - }} - > - {tooltip.content} - - )} - - ); -}; - -export default SectionTitleWithTooltip; - -const { spacings } = theme; - -const StyledContainer = styled.div` - margin-top: ${spacings.large}; - margin-bottom: ${spacings.small}; -`; - -const StyledSectionTitle = styled(SectionTitle)` - display: inline; - margin: 0; - padding: 0; -`; - -const StyledInfoBulle = styled(InfoBulle)` - margin-left: ${spacings.xsmall}; -`; diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Anciennete/components/__tests__/SectionTitleWithTooltip.test.tsx b/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Anciennete/components/__tests__/SectionTitleWithTooltip.test.tsx deleted file mode 100644 index d6251fd208..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Anciennete/components/__tests__/SectionTitleWithTooltip.test.tsx +++ /dev/null @@ -1,18 +0,0 @@ -import { render } from "@testing-library/react"; -import React from "react"; -import SectionTitleWithTooltip from "../SectionTitleWithTooltip"; - -describe("", () => { - it("should render", () => { - expect( - render( - Ceci est un tooltip

    , - }} - /> - ) - ).toBeTruthy(); - }); -}); diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Anciennete/components/index.ts b/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Anciennete/components/index.ts index 3cb120bb90..ad64e65d4a 100644 --- a/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Anciennete/components/index.ts +++ b/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Anciennete/components/index.ts @@ -1,2 +1 @@ export { default as AbsencePeriods } from "./AbsencePeriods"; -export { default as SectionTitleWithTooltip } from "./SectionTitleWithTooltip"; diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Anciennete/store/store.ts b/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Anciennete/store/store.ts index 4e8e8152ea..fc0e556f3a 100644 --- a/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Anciennete/store/store.ts +++ b/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Anciennete/store/store.ts @@ -16,7 +16,7 @@ import { SeniorityFactory, SupportedCc, } from "@socialgouv/modeles-social"; -import { informationToSituation } from "../../../../components/Informations/utils"; +import { informationToSituation } from "../../Informations/utils"; import { ContratTravailStoreSlice } from "../../ContratTravail/store"; import { ValidationResponse } from "src/modules/outils/common/components/SimulatorLayout/types"; import { validateStep } from "./validator"; diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Anciennete/store/types.ts b/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Anciennete/store/types.ts index ed4f38f2ff..731b5d8de2 100644 --- a/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Anciennete/store/types.ts +++ b/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Anciennete/store/types.ts @@ -1,7 +1,7 @@ import { StepData } from "../../../store"; import { OuiNon } from "../../../common"; import { Absence, Motif } from "@socialgouv/modeles-social"; -import { ValidationResponse } from "../../../../components/Simulator/SimulatorLayout"; +import { ValidationResponse } from "src/modules/outils/common/components/SimulatorLayout/types"; export type AncienneteStoreInput = { dateEntree?: string; diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Anciennete/store/validator/absencePeriods.ts b/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Anciennete/store/validator/absencePeriods.ts index b0a504f0f4..12ee4491dd 100644 --- a/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Anciennete/store/validator/absencePeriods.ts +++ b/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Anciennete/store/validator/absencePeriods.ts @@ -6,7 +6,7 @@ import { AncienneteStoreInput, } from "../types"; import { CommonInformationsStoreInput } from "../../../Informations/store"; -import { informationToSituation } from "../../../../../components/Informations/utils"; +import { informationToSituation } from "../../../Informations/utils"; export const getAbsencePeriodsErrors = ( state: AncienneteStoreInput, diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/components/Informations/PubliQuestion.tsx b/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Informations/components/PubliQuestion.tsx similarity index 67% rename from packages/code-du-travail-frontend/src/modules/outils/common/components/Informations/PubliQuestion.tsx rename to packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Informations/components/PubliQuestion.tsx index 5ee1fb3778..7eeee6e05f 100644 --- a/packages/code-du-travail-frontend/src/modules/outils/common/components/Informations/PubliQuestion.tsx +++ b/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Informations/components/PubliQuestion.tsx @@ -1,10 +1,12 @@ import React from "react"; import { Rule, RuleType } from "@socialgouv/modeles-social"; -import { RadioQuestion, SelectQuestion, TextQuestion } from ".."; -import { reverseValues } from "../../publicodes"; -import { eventEmitter, EventType } from "../../indemnite-depart/events"; -import Html from "src/modules/common/Html"; +import { + RadioQuestion, + SelectQuestion, + TextQuestion, +} from "../../../../components"; +import { reverseValues } from "../../../../publicodes"; interface Props { name: string; @@ -16,7 +18,7 @@ interface Props { autoFocus?: boolean; } -const PubliQuestion: React.FC = ({ +export const PubliQuestion: React.FC = ({ name, rule, value, @@ -28,17 +30,10 @@ const PubliQuestion: React.FC = ({ // to avoid collision with other components for YesNoQuestion Math.random().toString(36).substring(2, 15) ); - const { question, titre, cdtn, unité } = rule; - const tooltip = rule.description - ? { - content: {rule.description}, - trackableFn: (visibility: boolean) => { - if (visibility && titre) { - eventEmitter.dispatch(EventType.TRACK_QUESTION, titre); - } - }, - } - : undefined; + const { question, cdtn, description } = rule; + + // cdtn.precision? ???????? //TODO add precision + // unit={rule.unité} // TODO add unit if (!question) { return <>; @@ -53,9 +48,7 @@ const PubliQuestion: React.FC = ({ selectedOption={value} onChangeSelectedOption={onChange} error={error} - tooltip={tooltip} - showRequired - subLabel={cdtn.precision} + subLabel={description} autoFocus={autoFocus} /> ); @@ -77,11 +70,10 @@ const PubliQuestion: React.FC = ({ name={name} label={question} selectedOption={value} - tooltip={tooltip} onChangeSelectedOption={onChange} error={error} showRequired - subLabel={cdtn.precision} + subLabel={description} autoFocus={autoFocus} /> ); @@ -89,15 +81,12 @@ const PubliQuestion: React.FC = ({ return ( @@ -106,14 +95,12 @@ const PubliQuestion: React.FC = ({ return ( @@ -122,20 +109,15 @@ const PubliQuestion: React.FC = ({ return ( ); } }; - -export default PubliQuestion; diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/components/Informations/__tests__/PubliQuestion.test.tsx b/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Informations/components/__tests__/PubliQuestion.test.tsx similarity index 98% rename from packages/code-du-travail-frontend/src/modules/outils/common/components/Informations/__tests__/PubliQuestion.test.tsx rename to packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Informations/components/__tests__/PubliQuestion.test.tsx index 0b2d3871cd..e1ebc25474 100644 --- a/packages/code-du-travail-frontend/src/modules/outils/common/components/Informations/__tests__/PubliQuestion.test.tsx +++ b/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Informations/components/__tests__/PubliQuestion.test.tsx @@ -1,7 +1,7 @@ import { RuleType } from "@socialgouv/modeles-social"; import { render } from "@testing-library/react"; import React from "react"; -import PubliQuestion from "../PubliQuestion"; +import { PubliQuestion } from "../PubliQuestion"; describe("", () => { it("should render", () => { diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Informations/index.tsx b/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Informations/index.tsx index 30f77c91f3..07d0a85f01 100644 --- a/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Informations/index.tsx +++ b/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Informations/index.tsx @@ -1,6 +1,6 @@ import { IndemniteDepartContext, useIndemniteDepartStore } from "../../store"; import { useContext } from "react"; -import { PubliQuestion } from "../../../components/Informations"; +import { PubliQuestion } from "./components/PubliQuestion"; const InformationsStep = (): JSX.Element => { const store = useContext(IndemniteDepartContext); diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Informations/store/store.ts b/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Informations/store/store.ts index 549e63cf76..81964131b3 100644 --- a/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Informations/store/store.ts +++ b/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Informations/store/store.ts @@ -15,7 +15,7 @@ import { } from "@socialgouv/modeles-social"; import { mapToPublicodesSituationForIndemniteLicenciementConventionnel } from "../../../../publicodes"; import { removeDuplicateObject } from "src/lib"; -import { informationToSituation } from "../../../../components/Informations/utils"; +import { informationToSituation } from "../utils"; import { ContratTravailStoreSlice } from "../../ContratTravail/store"; import * as Sentry from "@sentry/nextjs"; import { CommonAgreementStoreSlice } from "../../Agreement/store"; diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/components/Informations/utils/__tests__/informationToSituation.test.ts b/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Informations/utils/__tests__/informationToSituation.test.ts similarity index 93% rename from packages/code-du-travail-frontend/src/modules/outils/common/components/Informations/utils/__tests__/informationToSituation.test.ts rename to packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Informations/utils/__tests__/informationToSituation.test.ts index 358e74da4c..aa72c4bdef 100644 --- a/packages/code-du-travail-frontend/src/modules/outils/common/components/Informations/utils/__tests__/informationToSituation.test.ts +++ b/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Informations/utils/__tests__/informationToSituation.test.ts @@ -1,5 +1,5 @@ +import { PublicodesInformation } from "src/modules/outils/common/indemnite-depart/steps/Informations/store"; import { informationToSituation } from "../informationToSituation"; -import { PublicodesInformation } from "../../../../CommonIndemniteDepart/steps/Informations/store"; describe("Transforme les informations dans le state en un object pour une situation publicodes", () => { test("avec des informations saisies", () => { diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/components/Informations/utils/index.ts b/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Informations/utils/index.ts similarity index 100% rename from packages/code-du-travail-frontend/src/modules/outils/common/components/Informations/utils/index.ts rename to packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Informations/utils/index.ts diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/components/Informations/utils/informationToSituation.ts b/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Informations/utils/informationToSituation.ts similarity index 63% rename from packages/code-du-travail-frontend/src/modules/outils/common/components/Informations/utils/informationToSituation.ts rename to packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Informations/utils/informationToSituation.ts index 6096bff54a..5528fe99a9 100644 --- a/packages/code-du-travail-frontend/src/modules/outils/common/components/Informations/utils/informationToSituation.ts +++ b/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Informations/utils/informationToSituation.ts @@ -1,4 +1,4 @@ -import { PublicodesInformation } from "../../../CommonIndemniteDepart/steps/Informations/store"; +import { PublicodesInformation } from "src/modules/outils/common/indemnite-depart/steps/Informations/store"; export const informationToSituation = ( informationData: Array diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Resultat/components/AbsenceTable.tsx b/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Resultat/components/AbsenceTable.tsx index abf9d703c9..26111505d2 100644 --- a/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Resultat/components/AbsenceTable.tsx +++ b/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Resultat/components/AbsenceTable.tsx @@ -1,4 +1,3 @@ -import { StyledFilledElementTable } from "./FilledElements"; import { Absence } from "@socialgouv/modeles-social"; type Props = { @@ -14,7 +13,7 @@ const AbsenceTable = ({ absencesPeriods }: Props): JSX.Element => { absencesPeriods.filter((item) => item.startedAt !== undefined).length > 0; return ( - + @@ -35,7 +34,7 @@ const AbsenceTable = ({ absencesPeriods }: Props): JSX.Element => { ))} - +
    Motif de l'absence
    ); }; diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Resultat/components/FilledElements.tsx b/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Resultat/components/FilledElements.tsx index 6736d0038a..763ee14403 100644 --- a/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Resultat/components/FilledElements.tsx +++ b/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Resultat/components/FilledElements.tsx @@ -7,8 +7,7 @@ import { generateResultSameSalary, } from "../../../utils/question"; import { formatToEuro } from "src/common/formatToEuro"; -import { SectionTitle } from "src/outils/common/stepStyles"; -import { IndemniteDepartType } from "src/outils/types"; +import { IndemniteDepartType } from "../../../types"; type SituationItem = { text: string; @@ -40,7 +39,7 @@ type Props = { export default function FilledElements(props: Props) { return ( <> - Éléments saisis +

    Éléments saisis

    • Contrat de travail diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Resultat/components/__tests__/FilledElements.test.tsx b/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Resultat/components/__tests__/FilledElements.test.tsx index bc1db648df..2d16671224 100644 --- a/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Resultat/components/__tests__/FilledElements.test.tsx +++ b/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Resultat/components/__tests__/FilledElements.test.tsx @@ -2,7 +2,7 @@ import { render } from "@testing-library/react"; import React from "react"; import FilledElement from "../FilledElements"; import { MotifKeys } from "@socialgouv/modeles-social"; -import { IndemniteDepartType } from "src/outils/types"; +import { IndemniteDepartType } from "../../../../types"; describe("", () => { it("should render", () => { diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Resultat/store/store.ts b/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Resultat/store/store.ts index d8d955b899..24fce1c00b 100644 --- a/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Resultat/store/store.ts +++ b/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Resultat/store/store.ts @@ -24,7 +24,7 @@ import { PublicodesResult } from "@socialgouv/modeles-social/bin"; import { CommonAgreementStoreSlice } from "../../Agreement/store"; import { CommonSituationStoreSlice } from "../../../situationStore"; import { StoreSlice } from "../../../types"; -import { informationToSituation } from "src/modules/outils/common/components/Informations/utils"; +import { informationToSituation } from "src/modules/outils/common/indemnite-depart/steps/Informations/utils"; const initialState: ResultStoreData = { input: { diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Salaires/components/TooltipSalary.tsx b/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Salaires/components/HighlightSalary.tsx similarity index 89% rename from packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Salaires/components/TooltipSalary.tsx rename to packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Salaires/components/HighlightSalary.tsx index 1260c9a75a..bb9b1c9547 100644 --- a/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Salaires/components/TooltipSalary.tsx +++ b/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Salaires/components/HighlightSalary.tsx @@ -1,17 +1,18 @@ +import { fr } from "@codegouvfr/react-dsfr"; import React from "react"; -const TooltipSalary = ({ +const HighlightSalary = ({ agreementNumber, }: { agreementNumber?: number; }): JSX.Element => { return ( - <> -

      +

      + Prendre en compte le salaire fixe et variable (ex : commissions), les primes et avantages en nature. Les éléments de rémunération suivants sont à exclure : -

      +
      • Les remboursements de frais professionnels (exemple : @@ -46,8 +47,8 @@ const TooltipSalary = ({ (exemple : prime d’intéressement, prime de participation)
      - +
      ); }; -export default TooltipSalary; +export default HighlightSalary; diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Salaires/components/SalaireTempsPlein.tsx b/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Salaires/components/SalaireTempsPlein.tsx index 97b6386558..e6442ac0c2 100644 --- a/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Salaires/components/SalaireTempsPlein.tsx +++ b/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Salaires/components/SalaireTempsPlein.tsx @@ -4,7 +4,7 @@ import { Alert } from "@codegouvfr/react-dsfr/Alert"; import { SalaryPeriods } from "@socialgouv/modeles-social"; import React from "react"; import Html from "src/modules/common/Html"; -import { Tooltip } from "src/modules/outils/common/components/types"; +import HighlightSalary from "./HighlightSalary"; type Props = { title: string; @@ -13,10 +13,10 @@ type Props = { onSalariesChange: (salaries: SalaryPeriods[]) => void; error?: string; note?: string; - tooltip?: Tooltip; dataTestidSalaries?: string; noPrime?: boolean; autoFocus?: boolean; + HighLightComponent?: React.ReactNode; }; export const SalaireTempsPlein = ({ @@ -26,9 +26,9 @@ export const SalaireTempsPlein = ({ title, note, subTitle, - tooltip, dataTestidSalaries, noPrime, + HighLightComponent, autoFocus = false, }: Props): JSX.Element => { const [isFirstEdit, setIsFirstEdit] = React.useState(true); @@ -104,12 +104,13 @@ export const SalaireTempsPlein = ({ value: sPeriod.value ?? "", onChange: (e) => onChangeSalaries(index, e.target.value), onBlur: () => setIsFirstEdit(false), - "data-testid": dataTestidSalaries ?? "salary-input", + autoFocus: autoFocus ? index === 0 : false, }} + data-testid={dataTestidSalaries ?? "salary-input"} state={errorsSalaries[`${index}`] ? "error" : "default"} stateRelatedMessage={errorsSalaries[`${index}`]} - hint="€" + hintText="€" />, !noPrime && index < 3 && ( onChangeLocalPrimes(index, e.target.value), - "data-testid": dataTestidSalaries - ? "prime-" + dataTestidSalaries - : "prime-input", }} state={errorsPrimes[`${index}`] ? "error" : "default"} stateRelatedMessage={errorsPrimes[`${index}`]} - hint="€" + data-testid={ + dataTestidSalaries ? "prime-" + dataTestidSalaries : "prime-input" + } + hintText="€" /> ), ]); return ( -
      +
      + {HighLightComponent} @@ -141,11 +143,22 @@ export const SalaireTempsPlein = ({ {subTitle &&

      {subTitle}

      } } - headers={tableHeaders} + headers={tableHeaders + .filter((header) => header !== false) + .map((header, index) => ( + + ))} data={tableData} /> {error && ( - + )} {note &&

      {note}

      } diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Salaires/components/index.ts b/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Salaires/components/index.ts index 0b9138a81a..97f1f41d72 100644 --- a/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Salaires/components/index.ts +++ b/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Salaires/components/index.ts @@ -1,3 +1,3 @@ export { default as SalaireTempsPlein } from "./SalaireTempsPlein"; export { default as TempsPartiel } from "./TempsPartiel"; -export { default as TooltipSalary } from "./TooltipSalary"; +export { default as HighlightSalary } from "./HighlightSalary"; diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Salaires/index.tsx b/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Salaires/index.tsx index 053a8050c9..df76c3b350 100644 --- a/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Salaires/index.tsx +++ b/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Salaires/index.tsx @@ -1,20 +1,17 @@ import React, { useContext } from "react"; import { IndemniteDepartContext, useIndemniteDepartStore } from "../../store"; -import { RadioQuestion, TextQuestion } from "../../../Components"; -import { SalaireTempsPlein, TempsPartiel } from "./components"; +import { HighlightSalary, SalaireTempsPlein, TempsPartiel } from "./components"; import { getSupportedAgreement } from "@socialgouv/modeles-social"; import { IndemniteDepartStepName } from "../.."; import { AgreementsInjector } from "../../agreements"; -import { - getSalairesTempsPleinSubtitle, - getTooltipSalairesMensuel, -} from "../../agreements/ui-customizations"; +import { getSalairesTempsPleinSubtitle } from "../../agreements/ui-customizations"; import { generateSalaireTempsPleinQuestion, generateSameSalaryQuestion, generateSmallText, } from "../../utils/question"; -import { IndemniteDepartType } from "../../../types"; +import { IndemniteDepartType } from "../../types"; +import { RadioQuestion, TextQuestion } from "../../../components"; type Props = { type: IndemniteDepartType; @@ -125,15 +122,13 @@ const StepSalaires = ({ type }: Props) => { {hasSameSalary === "oui" && ( @@ -146,7 +141,11 @@ const StepSalaires = ({ type }: Props) => { salaryPeriods )} subTitle={getSalairesTempsPleinSubtitle(agreement?.num)} - tooltip={getTooltipSalairesMensuel(agreement?.num)} + HighLightComponent={ + agreement?.num === 3239 ? undefined : ( + + ) + } onSalariesChange={onSalariesChange} salaryPeriods={salaryPeriods} error={errorSalaryPeriods} diff --git a/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Salaires/store/store.ts b/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Salaires/store/store.ts index d6fa7764ed..fc1f5b1b98 100644 --- a/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Salaires/store/store.ts +++ b/packages/code-du-travail-frontend/src/modules/outils/common/indemnite-depart/steps/Salaires/store/store.ts @@ -18,10 +18,10 @@ import { IndemniteDepartStepName } from "../../.."; import { computeSalaryPeriods } from "../../../common"; import { CommonAgreementStoreSlice } from "../../Agreement/store"; import { dateToString, deepMergeArray } from "src/lib"; -import parse from "src/modules/outils/common/utils/date"; import { add } from "date-fns"; import { StoreSlice } from "../../../types"; import { ValidationResponse } from "src/modules/outils/common/components/SimulatorLayout/types"; +import { parse } from "src/modules/outils/common/utils"; const initialState: SalairesStoreData = { input: { diff --git a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/absence-date-onchange-motif.test.tsx b/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/absence-date-onchange-motif.test.tsx deleted file mode 100644 index a80fa06f83..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/absence-date-onchange-motif.test.tsx +++ /dev/null @@ -1,112 +0,0 @@ -import { render, RenderResult } from "@testing-library/react"; -import { UserAction } from "../../../common"; -import React from "react"; -import { CalculateurIndemniteLicenciement } from "../../../../src/outils"; -import { ui } from "../../CommonIndemniteDepart/__tests__/ui"; - -jest.spyOn(Storage.prototype, "setItem"); -Storage.prototype.getItem = jest.fn( - () => ` -{ - "num": 2941, - "shortTitle": "Transports routiers et activités auxiliaires du transport", - "id": "KALICONT000005635624", - "title": "Transports routiers et activités auxiliaires du transport", - "url": "https://www.legifrance.gouv.fr/affichIDCC.do?idConvention=KALICONT000005635624", - "slug": "16-transports-routiers-et-activites-auxiliaires-du-transport" -} -` -); - -describe("Indemnité licenciement", () => { - describe("parcours avec la convention collective 2941 pour tester la suppression de la date de l'absence quand on change de catégorie pro", () => { - let rendering: RenderResult; - let userAction: UserAction; - beforeEach(() => { - rendering = render( - - ); - userAction = new UserAction(); - userAction - .click(ui.introduction.startButton.get()) - .click(ui.contract.type.cdi.get()) - .click(ui.contract.fauteGrave.non.get()) - .click(ui.contract.inaptitude.non.get()) - .click(ui.contract.arretTravail.non.get()) - .click(ui.next.get()) - .click(ui.next.get()); - // Validation que l'on est bien sur l'étape ancienneté - expect(ui.activeStep.query()).toHaveTextContent("Ancienneté"); - }); - - test(` - - vérification que la date de l'absence est présente pour le motif Absence pour maladie non pro - - vérification que la date de l'absence saisie apparait dans l'écran résultat - - vérification que la date de l'absence n'est plus présente pour un autre motif - - vérification que la date de l'absence n'apparait plus dans l'écran résultat - `, () => { - // vérification que la date de l'absence est présente pour le motif Absence pour maladie non pro - userAction - .setInput(ui.seniority.startDate.get(), "01/01/2000") - .setInput(ui.seniority.notificationDate.get(), "01/01/2022") - .setInput(ui.seniority.endDate.get(), "01/03/2022") - .click(ui.seniority.hasAbsence.oui.get()) - .changeInputList( - ui.seniority.absences.motif(0).get(), - "Absence pour maladie non professionnelle" - ); - - expect(ui.seniority.absences.date(0).query()).toBeInTheDocument(); - - // vérification que la date de l'absence saisie apparait dans l'écran résultat - userAction - .setInput(ui.seniority.absences.duration(0).get(), "6") - .setInput(ui.seniority.absences.date(0).get(), "01/01/2015") - .click(ui.next.get()) - .click(ui.salary.hasPartialTime.non.get()) - .click(ui.salary.hasSameSalary.oui.get()) - .setInput(ui.salary.sameSalaryValue.get(), "2500") - .click(ui.next.get()); - - expect(ui.activeStep.query()).toHaveTextContent("Indemnité"); - expect(rendering.queryByText("Éléments saisis")).toBeInTheDocument(); - expect( - rendering.queryByText("Absence pour maladie non professionnelle") - ).toBeInTheDocument(); - expect(rendering.queryByTestId("absence-date")).toBeInTheDocument(); - expect(rendering.queryByText("01/01/2015")).toBeInTheDocument(); - - // vérification que la date de l'absence n'est plus présente pour un autre motif - userAction - .click(ui.previous.get()) - .click(ui.previous.get()) - .changeInputList( - ui.seniority.absences.motif(0).get(), - "Congés sans solde" - ); - - expect(ui.activeStep.query()).toHaveTextContent("Ancienneté"); - expect( - rendering.queryByText("Date de début de l'absence") - ).not.toBeInTheDocument(); - // On doit garder les anciennes informations saisies - expect(ui.seniority.absences.motif(0).query()).toHaveValue( - "Congés sans solde" - ); - expect(ui.seniority.absences.duration(0).query()).toHaveValue(6); - expect(ui.seniority.absences.date(0).query()).not.toBeInTheDocument(); - - // vérification que la date de l'absence n'apparait plus dans l'écran résultat - userAction.click(ui.next.get()).click(ui.next.get()); - - expect(ui.activeStep.query()).toHaveTextContent("Indemnité"); - expect(rendering.queryByText("Éléments saisis")).toBeInTheDocument(); - expect(rendering.queryByTestId("absence-date")).not.toBeInTheDocument(); - expect(rendering.queryByText("01/01/2015")).not.toBeInTheDocument(); - }); - }); -}); diff --git a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/absence-date-with-agreement.test.tsx b/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/absence-date-with-agreement.test.tsx deleted file mode 100644 index 83130e65f4..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/absence-date-with-agreement.test.tsx +++ /dev/null @@ -1,116 +0,0 @@ -import { render, RenderResult } from "@testing-library/react"; -import { UserAction } from "../../../common"; -import React from "react"; -import { CalculateurIndemniteLicenciement } from "../../../../src/outils"; -import { ui } from "../../CommonIndemniteDepart/__tests__/ui"; - -jest.spyOn(Storage.prototype, "setItem"); -Storage.prototype.getItem = jest.fn( - () => ` -{ - "num": 16, - "shortTitle": "Transports routiers et activités auxiliaires du transport", - "id": "KALICONT000005635624", - "title": "Transports routiers et activités auxiliaires du transport", - "url": "https://www.legifrance.gouv.fr/affichIDCC.do?idConvention=KALICONT000005635624", - "slug": "16-transports-routiers-et-activites-auxiliaires-du-transport" -} -` -); - -describe("Indemnité licenciement", () => { - describe("parcours avec la convention collective 16 pour tester la date de l'absence", () => { - let rendering: RenderResult; - let userAction: UserAction; - beforeEach(() => { - rendering = render( - - ); - userAction = new UserAction(); - userAction - .click(ui.introduction.startButton.get()) - .click(ui.contract.type.cdi.get()) - .click(ui.contract.fauteGrave.non.get()) - .click(ui.contract.inaptitude.non.get()) - .click(ui.contract.arretTravail.non.get()) - .click(ui.next.get()) - .click(ui.next.get()) - .changeInputList( - ui.information.agreement16.proCategory.get(), - "Ingénieurs et cadres" - ) - .click(ui.information.agreement16.proCategoryHasChanged.oui.get()) - .setInput( - ui.information.agreement16.dateProCategoryChanged.get(), - "01/01/2010" - ) - .setInput(ui.information.agreement16.engineerAge.get(), "38") - .click(ui.next.get()); - // Validation que l'on est bien sur l'étape ancienneté - expect(ui.activeStep.query()).toHaveTextContent("Ancienneté"); - }); - - test(` - On doit demander la date de l'absence puis ne plus la demander quand on change les informations sur le salarié - - vérification que la date de l'absence est présente sur la page information - - vérification que la date de l'absence n'est plus présente après avoir changé les informations du salarié - `, () => { - // vérification que la date de l'absence est présente sur la page information - userAction - .setInput(ui.seniority.startDate.get(), "01/01/2000") - .setInput(ui.seniority.notificationDate.get(), "01/01/2022") - .setInput(ui.seniority.endDate.get(), "01/03/2022") - .click(ui.seniority.hasAbsence.oui.get()) - .changeInputList( - ui.seniority.absences.motif(0).get(), - "Congés sans solde" - ) - .setInput(ui.seniority.absences.duration(0).get(), "6") - .setInput(ui.seniority.absences.date(0).get(), "01/01/2015") - .click(ui.next.get()) - .click(ui.salary.hasPartialTime.non.get()) - .click(ui.salary.hasSameSalary.oui.get()) - .setInput(ui.salary.sameSalaryValue.get(), "2500") - .click(ui.next.get()); - - expect(ui.activeStep.query()).toHaveTextContent("Indemnité"); - expect(rendering.queryByText("Éléments saisis")).toBeInTheDocument(); - expect(rendering.queryByText("Congés sans solde")).toBeInTheDocument(); - expect(rendering.queryByTestId("absence-date")).toBeInTheDocument(); - expect(rendering.queryByText("01/01/2015")).toBeInTheDocument(); - - // vérification que la date de l'absence n'est plus présente après avoir changé les informations du salarié - userAction - .click(ui.previous.get()) - .click(ui.previous.get()) - .click(ui.previous.get()) - .click(ui.information.agreement16.proCategoryHasChanged.non.get()) - .setInput(ui.information.agreement16.engineerAge.get(), "38") - .click(ui.next.get()); - - expect(ui.activeStep.query()).toHaveTextContent("Ancienneté"); - // Il ne doit plus y avoir la date de l'absence - expect( - rendering.queryByText("Date de début de l'absence") - ).not.toBeInTheDocument(); - // On doit garder les anciennes informations saisies - expect(ui.seniority.absences.motif(0).get()).toHaveValue( - "Congés sans solde" - ); - expect(ui.seniority.absences.duration(0).get()).toHaveValue(6); - - // On passe à l'étape Résultat - userAction.click(ui.next.get()).click(ui.next.get()); - expect(ui.activeStep.query()).toHaveTextContent("Indemnité"); - - // On vérifie que la date de l'absence n'est pas présente dans le résultat - expect(rendering.queryByText("Éléments saisis")).toBeInTheDocument(); - expect(rendering.queryByTestId("absence-date")).not.toBeInTheDocument(); - expect(rendering.queryByText("01/01/2015")).not.toBeInTheDocument(); - }); - }); -}); diff --git a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/absence-date-without-agreement.test.tsx b/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/absence-date-without-agreement.test.tsx deleted file mode 100644 index bf91bd6882..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/absence-date-without-agreement.test.tsx +++ /dev/null @@ -1,73 +0,0 @@ -import { render, RenderResult } from "@testing-library/react"; -import { UserAction } from "../../../common"; -import { CalculateurIndemniteLicenciement } from "../../../../src/outils"; -import React from "react"; -import { ui } from "../../CommonIndemniteDepart/__tests__/ui"; - -jest.spyOn(Storage.prototype, "setItem"); -jest.spyOn(Storage.prototype, "getItem"); - -describe("Indemnité licenciement - Validation du comportement avec l'absence de date", () => { - describe("parcours sans convention collective pour tester l'absence de la date de l'absence", () => { - let rendering: RenderResult; - let userAction: UserAction; - beforeEach(() => { - rendering = render( - - ); - userAction = new UserAction(); - userAction - .click(ui.introduction.startButton.get()) - .click(ui.contract.type.cdi.get()) - .click(ui.contract.fauteGrave.non.get()) - .click(ui.contract.inaptitude.non.get()) - .click(ui.contract.arretTravail.non.get()) - .click(ui.next.get()) - .click(ui.agreement.noAgreement.get()) - .click(ui.next.get()); - - // Validation que l'on est bien sur l'étape ancienneté - expect(ui.activeStep.query()).toHaveTextContent("Ancienneté"); - }); - - test("On ne doit pas demander la date de l'absence", () => { - // On renseigne la page ancienneté avec une absence avec une date - userAction - .setInput(ui.seniority.startDate.get(), "01/01/2000") - .setInput(ui.seniority.notificationDate.get(), "01/01/2022") - .setInput(ui.seniority.endDate.get(), "01/03/2022") - .click(ui.next.get()) - .click(ui.seniority.hasAbsence.oui.get()); - - expect( - rendering.queryByText("Date de début de l'absence") - ).not.toBeInTheDocument(); - - userAction - .changeInputList( - ui.seniority.absences.motif(0).get(), - "Congés sans solde" - ) - .setInput(ui.seniority.absences.duration(0).get(), "6") - .click(ui.next.get()); - - // On se rend sur la page information pour vérifier que la date n'est pas présente - expect(ui.activeStep.query()).toHaveTextContent("Salaires"); - userAction - .click(ui.salary.hasPartialTime.non.get()) - .click(ui.salary.hasSameSalary.oui.get()) - .setInput(ui.salary.sameSalaryValue.get(), "2500") - .click(ui.next.get()); - - expect(ui.activeStep.get()).toHaveTextContent("Indemnité"); - // On valide que l'absence est présente avec la date - expect(rendering.queryByText("Éléments saisis")).toBeInTheDocument(); - expect(rendering.queryByText("Congés sans solde")).toBeInTheDocument(); - expect(rendering.queryByTestId("absence-date")).not.toBeInTheDocument(); - }); - }); -}); diff --git a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/arret-travail.test.tsx b/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/arret-travail.test.tsx deleted file mode 100644 index 3acab0e4f9..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/arret-travail.test.tsx +++ /dev/null @@ -1,134 +0,0 @@ -import { render } from "@testing-library/react"; -import React from "react"; -import { CalculateurIndemniteLicenciement } from "../../../../src/outils"; -import { ui } from "../../CommonIndemniteDepart/__tests__/ui"; -import { byText } from "testing-library-selector"; -import { UserAction } from "../../../common"; - -describe("Arrêt de travail", () => { - let userAction: UserAction; - describe("Page contrat de travail: vérification des questions affichées", () => { - beforeEach(async () => { - render( - - ); - userAction = new UserAction(); - userAction.click(ui.introduction.startButton.get()); - userAction.click(ui.contract.type.cdi.get()); - userAction.click(ui.contract.fauteGrave.non.get()); - userAction.click(ui.contract.inaptitude.non.get()); - }); - - test("should display a new question", async () => { - expect(ui.contract.arretTravail.question.query()).toBeInTheDocument(); - }); - - test("should stop because a new question is display", async () => { - userAction.click(ui.next.get()); - expect(ui.agreement.agreement.query()).not.toBeInTheDocument(); - }); - - test("should pass to next step", async () => { - userAction.click(ui.contract.arretTravail.non.get()); - userAction.click(ui.next.get()); - expect(ui.agreement.agreement.query()).toBeInTheDocument(); - }); - - test("should stop because a date question about the 'arret de travail' is asked", async () => { - userAction.click(ui.contract.arretTravail.oui.get()); - userAction.click(ui.next.get()); - expect(ui.agreement.agreement.query()).not.toBeInTheDocument(); - }); - - test("should pass to next step after selecting a date", async () => { - userAction.click(ui.contract.arretTravail.oui.get()); - userAction.setInput(ui.contract.dateArretTravail.get(), "15/09/2022"); - userAction.click(ui.next.get()); - expect(ui.agreement.agreement.query()).toBeInTheDocument(); - }); - - test("user can put an invalid date and then click 'no'", async () => { - userAction.click(ui.contract.arretTravail.oui.get()); - userAction.setInput(ui.contract.dateArretTravail.get(), "15/09/2000"); - userAction.click(ui.next.get()); - userAction.click(ui.agreement.noAgreement.get()); - userAction.click(ui.next.get()); - expect(ui.seniority.startDate.query()).toBeInTheDocument(); - - userAction.setInput(ui.seniority.startDate.get(), "01/01/2022"); - userAction.click(ui.next.get()); - expect( - byText( - "La date de début de contrat doit se situer avant la date d'arrêt de travail indiquée à l'étape n°2" - ).query() - ).toBeInTheDocument(); - userAction.click(ui.previous.get()); - userAction.click(ui.previous.get()); - userAction.click(ui.contract.arretTravail.non.get()); - userAction.click(ui.next.get()); - userAction.click(ui.next.get()); - expect(ui.seniority.startDate.query()).toBeInTheDocument(); - - expect( - byText( - "La date de début de contrat doit se situer avant la date d'arrêt de travail indiquée à l'étape n°2" - ).query() - ).not.toBeInTheDocument(); - }); - }); - - describe("Page salaires: vérification de la liste affichée", () => { - beforeEach(async () => { - render( - - ); - }); - - test("should display with the good number of months at the 'Salaires' step if no inaptitude", async () => { - userAction.click(ui.introduction.startButton.get()); - userAction.click(ui.contract.type.cdi.get()); - userAction.click(ui.contract.fauteGrave.non.get()); - userAction.click(ui.contract.inaptitude.non.get()); - userAction.click(ui.contract.arretTravail.non.get()); - userAction.click(ui.next.get()); - userAction.click(ui.agreement.noAgreement.get()); - userAction.click(ui.next.get()); - userAction.setInput(ui.seniority.startDate.get(), "01/01/2022"); - userAction.setInput(ui.seniority.notificationDate.get(), "01/09/2022"); - userAction.setInput(ui.seniority.endDate.get(), "01/12/2022"); - userAction.click(ui.seniority.hasAbsence.non.get()); - userAction.click(ui.next.get()); - userAction.click(ui.salary.hasPartialTime.non.get()); - userAction.click(ui.salary.hasSameSalary.non.get()); - expect(ui.salary.salaries.queryAll()).toHaveLength(8); - }); - - test("should display with the good number of months at the 'Salaires' step", async () => { - userAction.click(ui.introduction.startButton.get()); - userAction.click(ui.contract.type.cdi.get()); - userAction.click(ui.contract.fauteGrave.non.get()); - userAction.click(ui.contract.inaptitude.non.get()); - userAction.click(ui.contract.arretTravail.oui.get()); - userAction.setInput(ui.contract.dateArretTravail.get(), "01/07/2022"); - userAction.click(ui.next.get()); - userAction.click(ui.agreement.noAgreement.get()); - userAction.click(ui.next.get()); - userAction.setInput(ui.seniority.startDate.get(), "01/01/2022"); - userAction.setInput(ui.seniority.notificationDate.get(), "01/09/2022"); - userAction.setInput(ui.seniority.endDate.get(), "01/12/2022"); - userAction.click(ui.seniority.hasAbsence.non.get()); - userAction.click(ui.next.get()); - userAction.click(ui.salary.hasPartialTime.non.get()); - userAction.click(ui.salary.hasSameSalary.non.get()); - expect(ui.salary.salaries.queryAll()).toHaveLength(6); - }); - }); -}); diff --git a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc1404.test.tsx b/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc1404.test.tsx deleted file mode 100644 index cff623c290..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc1404.test.tsx +++ /dev/null @@ -1,100 +0,0 @@ -import { render } from "@testing-library/react"; -import React from "react"; -import { CalculateurIndemniteLicenciement } from "../../../../src/outils"; -import { ui } from "../../CommonIndemniteDepart/__tests__/ui"; -import { UserAction } from "../../../common"; - -jest.spyOn(Storage.prototype, "setItem"); -Storage.prototype.getItem = jest.fn( - () => `{ - "url":"https://www.legifrance.gouv.fr/affichIDCC.do?idConvention=KALICONT000005635653", - "id":"KALICONT000005635653", - "num":1404, - "shortTitle":"Entreprises de la maintenance, distribution et location de matériels agricoles, de travaux publics, de bâtiment, de manutention, de motoculture de plaisance et activités connexes, dite SDLM", - "slug":"1404-entreprises-de-la-maintenance-distribution-et-location-de-materiels-agrico", - "title":"Entreprises de la maintenance, distribution et location de matériels agricoles, de travaux publics, de bâtiment, de manutention, de motoculture de plaisance et activités connexes, dite SDLM" -}` -); - -describe("Indemnité licenciement - CC 1404", () => { - let userAction: UserAction; - beforeEach(() => { - render( - - ); - userAction = new UserAction(); - userAction.click(ui.introduction.startButton.get()); - userAction.click(ui.contract.type.cdi.get()); - userAction.click(ui.contract.fauteGrave.non.get()); - userAction.click(ui.contract.inaptitude.non.get()); - userAction.click(ui.contract.arretTravail.non.get()); - userAction.click(ui.next.get()); - userAction.click(ui.next.get()); - }); - - test("Vérifier que le CDI classique amène au résultat", () => { - userAction.click(ui.information.agreement1404.cdiOperation.non.get()); - userAction.click(ui.next.get()); - userAction.setInput(ui.seniority.startDate.get(), "01/01/2000"); - userAction.setInput(ui.seniority.notificationDate.get(), "01/01/2022"); - userAction.setInput(ui.seniority.endDate.get(), "01/03/2022"); - userAction.click(ui.seniority.hasAbsence.non.get()); - userAction.click(ui.next.get()); - userAction.click(ui.salary.hasPartialTime.non.get()); - userAction.click(ui.salary.hasSameSalary.oui.get()); - userAction.setInput(ui.salary.sameSalaryValue.get(), "3000"); - userAction.click(ui.next.get()); - expect(ui.activeStep.query()).toHaveTextContent("Indemnité"); - }); - describe("Etant donné un CDI opération", () => { - beforeEach(() => - userAction.click(ui.information.agreement1404.cdiOperation.oui.get()) - ); - describe("Etant donné une ancienneté < 6 mois", () => { - beforeEach(() => - userAction.setInput(ui.information.agreement1404.duree.get(), "5") - ); - test("Vérifier que le licenciement avant fin de la période d'essai amène au résultat", () => { - userAction.click(ui.information.agreement1404.trial.oui.get()); - userAction.click(ui.next.get()); - userAction.setInput(ui.seniority.startDate.get(), "01/01/2022"); - userAction.setInput(ui.seniority.notificationDate.get(), "01/04/2022"); - userAction.setInput(ui.seniority.endDate.get(), "01/05/2022"); - userAction.click(ui.seniority.hasAbsence.non.get()); - userAction.click(ui.next.get()); - expect(ui.activeStep.query()).toHaveTextContent("Indemnité"); - }); - test("Vérifier que le licenciement après fin de la période d'essai amène au résultat", () => { - userAction.click(ui.information.agreement1404.trial.non.get()); - userAction.setInput( - ui.information.agreement1404.salaryTotal.get(), - "50000" - ); - userAction.click(ui.next.get()); - userAction.setInput(ui.seniority.startDate.get(), "01/01/2022"); - userAction.setInput(ui.seniority.notificationDate.get(), "01/04/2022"); - userAction.setInput(ui.seniority.endDate.get(), "01/05/2022"); - userAction.click(ui.seniority.hasAbsence.non.get()); - userAction.click(ui.next.get()); - expect(ui.activeStep.query()).toHaveTextContent("Indemnité"); - }); - }); - test("Vérifier qu'avec plus de 6 mois on arrive au résultat", () => { - userAction.setInput(ui.information.agreement1404.duree.get(), "30"); - userAction.setInput(ui.information.agreement1404.salary1.get(), "100000"); - userAction.setInput(ui.information.agreement1404.salary2.get(), "150000"); - userAction.setInput(ui.information.agreement1404.salary3.get(), "200000"); - userAction.click(ui.next.get()); - userAction.setInput(ui.seniority.startDate.get(), "01/01/2000"); - userAction.setInput(ui.seniority.notificationDate.get(), "01/01/2022"); - userAction.setInput(ui.seniority.endDate.get(), "01/03/2022"); - userAction.click(ui.seniority.hasAbsence.non.get()); - userAction.click(ui.next.get()); - expect(ui.activeStep.query()).toHaveTextContent("Indemnité"); - }); - }); -}); diff --git a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc1486.test.tsx b/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc1486.test.tsx deleted file mode 100644 index 51a0f26d0f..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc1486.test.tsx +++ /dev/null @@ -1,82 +0,0 @@ -import { render } from "@testing-library/react"; -import React from "react"; -import { CalculateurIndemniteLicenciement } from "../.."; -import { ui } from "../../CommonIndemniteDepart/__tests__/ui"; -import { UserAction } from "../../../common"; - -jest.spyOn(Storage.prototype, "setItem"); -Storage.prototype.getItem = jest.fn( - () => ` -{ - "url": "https://www.legifrance.gouv.fr/affichIDCC.do?idConvention=KALICONT000005635173", - "id": "1486", - "num": 1486, - "shortTitle": "Bureaux d'études techniques, cabinets d'ingénieurs-conseils et sociétés de conseils", - "slug": "1486-bureaux-detudes-techniques-cabinets-dingenieurs-conseils-et-societes-de", - "title": "Convention collective nationale des bureaux d'études techniques, des cabinets d'ingénieurs-conseils et des sociétés de conseils du 15 décembre 1987. " -} -` -); - -describe("Indemnité licenciement - CC 1486", () => { - let userAction: UserAction; - beforeEach(() => { - render( - - ); - userAction = new UserAction(); - - userAction - .click(ui.introduction.startButton.get()) - .click(ui.contract.type.cdi.get()) - .click(ui.contract.fauteGrave.non.get()) - .click(ui.contract.inaptitude.non.get()) - .click(ui.contract.arretTravail.non.get()) - .click(ui.next.get()) - .click(ui.next.get()); - }); - test(`Cas nominal`, () => { - userAction - .changeInputList( - ui.information.agreement1486.proCategory.get(), - "Chargés d'enquête intermittents" - ) - .click(ui.information.agreement1486.refus.non.get()) - .click(ui.next.get()) - - .setInput(ui.seniority.startDate.get(), "01/01/2004") - .setInput(ui.seniority.notificationDate.get(), "01/01/2024") - .setInput(ui.seniority.endDate.get(), "01/01/2024") - .click(ui.seniority.hasAbsence.oui.get()) - .changeInputList( - ui.seniority.absences.motif(0).get(), - "Absence pour maladie non professionnelle" - ) - .setInput(ui.seniority.absences.duration(0).get(), "3") - .click(ui.next.get()) - .click(ui.salary.hasPartialTime.non.get()) - .click(ui.salary.hasSameSalary.non.get()) - .setInputs(ui.salary.salaries.getAll(), [ - "3500", - "3350", - "3200", - "3150", - "3300", - "3600", - "3100", - "3200", - "3300", - "3250", - "3100", - "3100", - ]) - .click(ui.next.get()); - - expect(ui.activeStep.query()).toHaveTextContent("Indemnité"); - expect(ui.result.resultat.get()).toHaveTextContent("26 100,00 €"); - }); -}); diff --git a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc1516.test.tsx b/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc1516.test.tsx deleted file mode 100644 index 8028776048..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc1516.test.tsx +++ /dev/null @@ -1,127 +0,0 @@ -import { fireEvent, render, RenderResult } from "@testing-library/react"; -import React from "react"; -import { CalculateurIndemniteLicenciement } from "../.."; -import { ui } from "../../CommonIndemniteDepart/__tests__/ui"; -import { UserAction } from "../../../common"; - -jest.spyOn(Storage.prototype, "setItem"); -Storage.prototype.getItem = jest.fn( - () => ` -{ - "url": "https://www.legifrance.gouv.fr/affichIDCC.do?idConvention=KALICONT000018773893", - "id": "KALICONT000018773893", - "num": 1516, - "shortTitle": "Formation Organismes", - "slug": "1516-formation-organismes", - "title": "Formation Organismes" -} -` -); - -describe("Indemnité licenciement - CC 1516", () => { - let rendering: RenderResult; - let userAction: UserAction; - beforeEach(() => { - rendering = render( - - ); - userAction = new UserAction(); - - userAction - .click(ui.introduction.startButton.get()) - .click(ui.contract.type.cdi.get()) - .click(ui.contract.fauteGrave.non.get()) - .click(ui.contract.inaptitude.non.get()) - .click(ui.contract.arretTravail.non.get()) - .click(ui.next.get()) - .click(ui.next.get()); - }); - test("user is asked for the notice salary", () => { - userAction.setInput(ui.seniority.startDate.get(), "01/01/2018"); - userAction.setInput(ui.seniority.notificationDate.get(), "01/01/2022"); - userAction.setInput(ui.seniority.endDate.get(), "01/06/2022"); - fireEvent.click(ui.seniority.hasAbsence.non.get()); - fireEvent.click(ui.next.get()); - expect(ui.activeStep.query()).toHaveTextContent("Salaires"); - - fireEvent.click(ui.salary.hasPartialTime.non.get()); - fireEvent.click(ui.salary.hasSameSalary.oui.get()); - userAction.setInput(ui.salary.sameSalaryValue.get(), "2500"); - - expect( - rendering.queryByText( - "Connaissez-vous le montant des salaires perçus pendant le préavis ?" - ) - ).toBeInTheDocument(); - fireEvent.click( - ui.salary.agreementWithNoticeSalary.knowingLastSalary.oui.get() - ); - expect( - rendering.queryByText( - "Salaires perçus pendant les 3 derniers mois du préavis" - ) - ).toBeInTheDocument(); - userAction.setInput( - ui.salary.agreementWithNoticeSalary.salaries.getAll()[0], - "4000" - ); - userAction.setInput( - ui.salary.agreementWithNoticeSalary.primes.getAll()[0], - "200" - ); - - fireEvent.click(ui.next.get()); - - expect(ui.activeStep.query()).toHaveTextContent("Indemnité"); - expect(ui.result.resultat.get()).toHaveTextContent("3 548,06 €"); - expect(ui.result.resultTableRows.getAll().length).toBe(3); - expect(ui.result.resultTableRows.getAll()[0]).toHaveTextContent( - "mai 20224000 €" - ); - userAction.click(ui.previous.get()); - - expect( - ui.salary.agreementWithNoticeSalary.salaries.getAll()[0] - ).toHaveValue(4000); - expect(ui.salary.agreementWithNoticeSalary.primes.getAll()[0]).toHaveValue( - 200 - ); - - userAction - .click(ui.salary.agreementWithNoticeSalary.knowingLastSalary.non.get()) - .click(ui.next.get()); - expect(ui.activeStep.query()).toHaveTextContent("Indemnité"); - expect(ui.result.resultat.get()).toHaveTextContent("2 760,42 €"); - expect(ui.result.resultTableRows.queryAll().length).toBe(0); - }); - - test(`user avec arret de travail is not asked for salary`, () => { - userAction - .click(ui.previous.get()) - .click(ui.previous.get()) - .click(ui.contract.arretTravail.oui.get()); - - userAction.setInput(ui.contract.dateArretTravail.get(), "01/01/2022"); - userAction.click(ui.next.get()).click(ui.next.get()); - - userAction.setInput(ui.seniority.startDate.get(), "01/01/2018"); - userAction.setInput(ui.seniority.notificationDate.get(), "01/01/2022"); - userAction.setInput(ui.seniority.endDate.get(), "01/06/2022"); - fireEvent.click(ui.seniority.hasAbsence.non.get()); - fireEvent.click(ui.next.get()); - expect(ui.activeStep.query()).toHaveTextContent("Salaires"); - - fireEvent.click(ui.salary.hasPartialTime.non.get()); - fireEvent.click(ui.salary.hasSameSalary.oui.get()); - userAction.setInput(ui.salary.sameSalaryValue.get(), "2500"); - expect( - rendering.queryByText( - "Connaissez-vous le montant des salaires perçus pendant le préavis ?" - ) - ).not.toBeInTheDocument(); - }); -}); diff --git a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc1517.test.tsx b/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc1517.test.tsx deleted file mode 100644 index cdf109b5f4..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc1517.test.tsx +++ /dev/null @@ -1,61 +0,0 @@ -import { render } from "@testing-library/react"; -import React from "react"; -import { CalculateurIndemniteLicenciement } from "../../../../src/outils"; -import { ui } from "../../CommonIndemniteDepart/__tests__/ui"; -import { UserAction } from "../../../common"; - -jest.spyOn(Storage.prototype, "setItem"); -Storage.prototype.getItem = jest.fn( - () => ` - { - "url":"https://www.legifrance.gouv.fr/affichIDCC.do?idConvention=KALICONT000005635870", - "id":"KALICONT000005635870", - "num":1517, - "shortTitle":"Commerces de détail non alimentaires : antiquités, brocante, galeries d'art (œuvres d'art), arts de la table, coutellerie, droguerie, équipement du foyer, bazars, commerces ménagers, modélisme, jeux, jouets, puérinatalité, maroquinerie, presse et jeux de hasard ou pronostics, produits de la vape", - "slug":"1517-commerces-de-detail-non-alimentaires-antiquites-brocante-galeries-dart", - "title":"Commerces de détail non alimentaires : antiquités, brocante, galeries d'art (œuvres d'art), arts de la table, coutellerie, droguerie, équipement du foyer, bazars, commerces ménagers, modélisme, jeux, jouets, puérinatalité, maroquinerie, presse et jeux de hasard ou pronostics, produits de la vape" - } -` -); - -describe("Indemnité licenciement - CC 1517", () => { - let userAction: UserAction; - beforeEach(async () => { - render( - - ); - - userAction = new UserAction(); - userAction.click(ui.introduction.startButton.get()); - userAction.click(ui.contract.type.cdi.get()); - userAction.click(ui.contract.fauteGrave.non.get()); - userAction.click(ui.contract.inaptitude.non.get()); - userAction.click(ui.contract.arretTravail.non.get()); - userAction.click(ui.next.get()); - userAction.click(ui.next.get()); - }); - test("vérifier l'eligibilite pour ancienneté (entree -> sortie) supérieur à 8 mois", async () => { - userAction.setInput(ui.seniority.startDate.get(), "01/01/2022"); - userAction.setInput(ui.seniority.notificationDate.get(), "15/08/2022"); - userAction.setInput(ui.seniority.endDate.get(), "15/12/2022"); - userAction.click(ui.seniority.hasAbsence.non.get()); - userAction.click(ui.next.get()); - userAction.click(ui.salary.hasPartialTime.non.get()); - userAction.click(ui.salary.hasSameSalary.oui.get()); - userAction.setInput(ui.salary.sameSalaryValue.get(), "3000"); - userAction.click(ui.next.get()); - expect(ui.result.formula.get()).toHaveTextContent("Formule"); - }); - - test("vérifier que la validation date de notif s'applique bien", async () => { - userAction.setInput(ui.seniority.startDate.get(), "01/01/2022"); - userAction.setInput(ui.seniority.endDate.get(), "15/12/2022"); - userAction.click(ui.seniority.hasAbsence.non.get()); - userAction.click(ui.next.get()); - expect(ui.seniority.error.requiredDate.get()).toBeInTheDocument(); - }); -}); diff --git a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc1527.test.tsx b/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc1527.test.tsx deleted file mode 100644 index 3b50bb420c..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc1527.test.tsx +++ /dev/null @@ -1,103 +0,0 @@ -import { render } from "@testing-library/react"; -import React from "react"; -import { CalculateurIndemniteLicenciement } from "../.."; -import { ui } from "../../CommonIndemniteDepart/__tests__/ui"; -import { UserAction } from "../../../common"; - -jest.spyOn(Storage.prototype, "setItem"); -Storage.prototype.getItem = jest.fn( - () => ` -{ - "url": "https://www.legifrance.gouv.fr/affichIDCC.do?idConvention=KALICONT000005635413", - "id": "1527", - "num": 1527, - "shortTitle": "Immobilier : administrateurs de biens, sociétés immobilières, agents immobiliers", - "slug": "1527-immobilier-administrateurs-de-biens-societes-immobilieres-agents-immobi", - "title": "Convention collective nationale de l'immobilier, administrateurs de biens, sociétés immobilières, agents immobiliers, etc. (anciennement cabinets d'administrateurs de biens et des sociétés immobilières), du 9 septembre 1988. Etendue par arrêté du 24 février 1989 JORF 3 mars 1989. Mise à jour par avenant n° 47 du 23 novembre 2010, JORF 18 juillet 2012 " -} -` -); - -describe("Indemnité licenciement - CC 1527", () => { - let userAction: UserAction; - beforeEach(() => { - render( - - ); - userAction = new UserAction(); - - userAction - .click(ui.introduction.startButton.get()) - .click(ui.contract.type.cdi.get()) - .click(ui.contract.fauteGrave.non.get()) - .click(ui.contract.inaptitude.non.get()) - .click(ui.contract.arretTravail.non.get()) - .click(ui.next.get()) - .click(ui.next.get()); - }); - test("cas avec versement de comission", () => { - userAction - .setInput(ui.seniority.startDate.get(), "01/01/2014") - .setInput(ui.seniority.notificationDate.get(), "01/01/2024") - .setInput(ui.seniority.endDate.get(), "01/01/2024") - .click(ui.seniority.hasAbsence.non.get()) - .click(ui.next.get()) - .click(ui.salary.hasPartialTime.non.get()) - .click(ui.salary.hasSameSalary.non.get()) - .setInputs(ui.salary.salaries.getAll(), [ - "2100", - "2100", - "2100", - "1900", - "2090", - "2500", - "2080", - "2000", - "1999", - "1995", - "1990", - "1990", - ]) - .click(ui.salary.agreement1517.hasContractSalary.oui.get()) - .click(ui.next.get()); - - expect(ui.activeStep.query()).toHaveTextContent("Indemnité"); - expect(ui.result.resultat.get()).toHaveTextContent("5 250,00 €"); - expect(ui.result.resultatAgreement.get()).toHaveTextContent("4 777,69 €"); - }); - - test("cas sans versement de comission", () => { - userAction - .setInput(ui.seniority.startDate.get(), "01/01/2014") - .setInput(ui.seniority.notificationDate.get(), "01/01/2024") - .setInput(ui.seniority.endDate.get(), "01/01/2024") - .click(ui.seniority.hasAbsence.non.get()) - .click(ui.next.get()) - .click(ui.salary.hasPartialTime.non.get()) - .click(ui.salary.hasSameSalary.non.get()) - .setInputs(ui.salary.salaries.getAll(), [ - "2100", - "2100", - "2100", - "1900", - "2090", - "2500", - "2080", - "2000", - "1999", - "1995", - "1990", - "1990", - ]) - .click(ui.salary.agreement1517.hasContractSalary.non.get()) - .click(ui.next.get()); - - expect(ui.activeStep.query()).toHaveTextContent("Indemnité"); - expect(ui.result.resultat.get()).toHaveTextContent("5 250,00 €"); - expect(ui.result.resultatAgreement.get()).toHaveTextContent("5 250,00 €"); - }); -}); diff --git a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc16.test.tsx b/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc16.test.tsx deleted file mode 100644 index b19a3d926f..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc16.test.tsx +++ /dev/null @@ -1,227 +0,0 @@ -import { render, RenderResult } from "@testing-library/react"; -import { UserAction } from "../../../common"; -import React from "react"; -import { CalculateurIndemniteLicenciement } from "../../../../src/outils"; -import { ui } from "../../CommonIndemniteDepart/__tests__/ui"; - -jest.spyOn(Storage.prototype, "setItem"); -Storage.prototype.getItem = jest.fn( - () => ` -{ - "num": 16, - "shortTitle": "Transports routiers et activités auxiliaires du transport", - "id": "KALICONT000005635624", - "title": "Transports routiers et activités auxiliaires du transport", - "url": "https://www.legifrance.gouv.fr/affichIDCC.do?idConvention=KALICONT000005635624", - "slug": "16-transports-routiers-et-activites-auxiliaires-du-transport" -} -` -); - -describe("Indemnité licenciement - CC 16", () => { - describe("parcours avec la convention collective pour valider ses spécificités", () => { - let rendering: RenderResult; - let userAction: UserAction; - beforeEach(() => { - rendering = render( - - ); - userAction = new UserAction(); - userAction - .click(ui.introduction.startButton.get()) - .click(ui.contract.type.cdi.get()) - .click(ui.contract.fauteGrave.non.get()) - .click(ui.contract.inaptitude.non.get()) - .click(ui.contract.arretTravail.non.get()) - .click(ui.next.get()) - .click(ui.next.get()) - .changeInputList( - ui.information.agreement16.proCategory.get(), - "Ingénieurs et cadres" - ) - .click(ui.information.agreement16.proCategoryHasChanged.oui.get()) - .setInput( - ui.information.agreement16.dateProCategoryChanged.get(), - "01/01/2010" - ) - .setInput(ui.information.agreement16.engineerAge.get(), "38") - .click(ui.next.get()) - .setInput(ui.seniority.startDate.get(), "01/01/2000") - .setInput(ui.seniority.notificationDate.get(), "01/01/2024") - .setInput(ui.seniority.endDate.get(), "01/03/2024") - .click(ui.seniority.hasAbsence.non.get()) - .click(ui.next.get()); - // Validation que l'on est bien sur l'étape ancienneté - expect(ui.activeStep.query()).toHaveTextContent("Salaires"); - }); - - test("Validation d'un cas avec calculs spécifiques", () => { - userAction - .click(ui.salary.hasPartialTime.non.get()) - .click(ui.salary.hasSameSalary.oui.get()) - .setInput(ui.salary.sameSalaryValue.get(), "2500") - .click(ui.next.get()); - - expect(ui.activeStep.query()).toHaveTextContent("Indemnité"); - expect(ui.result.resultat.get()).toHaveTextContent("21 666,67"); - expect(ui.result.resultatAgreement.get()).toHaveTextContent("21 666,67"); - }); - - test(` - - vérification que l'on demande si le salaire a eu des primes pour un cadre - - vérification que l'on demande si le salaire a eu des primes pour un TAM - - vérification que l'on ne demande pas si le salaire a eu des primes pour un employé - - vérification que l'on ne demande pas si le salaire a eu des primes pour un ouvrier - `, () => { - // vérification que l'on demande si le salaire a eu des primes pour un cadre - userAction - .click(ui.salary.hasPartialTime.non.get()) - .click(ui.salary.hasSameSalary.oui.get()); - - expect( - rendering.queryByText( - "Les salaires indiqués comportent-ils une partie variable ?" - ) - ).not.toBeInTheDocument(); - userAction.click(ui.salary.hasSameSalary.non.get()); - expect( - rendering.queryByText( - "Les salaires indiqués comportent-ils une partie variable ?" - ) - ).toBeInTheDocument(); - expect(ui.salary.variablePart.oui.query()).toBeInTheDocument(); - expect(ui.salary.variablePart.non.query()).toBeInTheDocument(); - - userAction - .setInput(ui.salary.salaries.getAll()[0], "2500") - .click(ui.salary.variablePart.oui.get()) - .click(ui.next.get()); - - expect( - rendering.queryByText( - /Les salaires indiqués comportent une partie variable/ - ) - ).toBeInTheDocument(); - - // vérification que l'on demande si le salaire a eu des primes pour un TAM - userAction - .click(ui.previous.get()) - .click(ui.previous.get()) - .click(ui.previous.get()) - .changeInputList( - ui.information.agreement16.proCategory.get(), - "Technicien et agents de maîtrise (TAM)" - ) - .setInput(ui.information.agreement16.agentAge.get(), "36") - .click(ui.next.get()) - .click(ui.next.get()) - .click(ui.salary.hasSameSalary.oui.get()); - - expect( - rendering.queryByText( - "Les salaires indiqués comportent-ils une partie variable ?" - ) - ).not.toBeInTheDocument(); - userAction.click(ui.salary.hasSameSalary.non.get()); - expect( - rendering.queryByText( - "Les salaires indiqués comportent-ils une partie variable ?" - ) - ).toBeInTheDocument(); - expect(ui.salary.variablePart.oui.query()).toBeInTheDocument(); - expect(ui.salary.variablePart.non.query()).toBeInTheDocument(); - - userAction - .setInput(ui.salary.salaries.getAll()[0], "2500") - .click(ui.salary.variablePart.oui.get()) - .click(ui.next.get()); - - expect( - rendering.queryByText( - /Les salaires indiqués comportent une partie variable/ - ) - ).toBeInTheDocument(); - - // vérification que l'on demande si le salaire a eu des primes pour un employé - userAction - .click(ui.previous.get()) - .click(ui.previous.get()) - .click(ui.previous.get()) - .changeInputList( - ui.information.agreement16.proCategory.get(), - "Employés" - ) - .setInput(ui.information.agreement16.employeeAge.get(), "36") - .click(ui.next.get()) - .click(ui.next.get()) - .click(ui.salary.hasSameSalary.oui.get()); - - expect( - rendering.queryByText( - "Les salaires indiqués comportent-ils une partie variable ?" - ) - ).not.toBeInTheDocument(); - userAction.click(ui.salary.hasSameSalary.non.get()); - expect( - rendering.queryByText( - "Les salaires indiqués comportent-ils une partie variable ?" - ) - ).not.toBeInTheDocument(); - expect(ui.salary.variablePart.oui.query()).not.toBeInTheDocument(); - expect(ui.salary.variablePart.non.query()).not.toBeInTheDocument(); - - userAction - .setInput(ui.salary.salaries.getAll()[0], "2500") - .click(ui.next.get()); - - expect( - rendering.queryByText( - /Les salaires indiqués comportent une partie variable/ - ) - ).not.toBeInTheDocument(); - - // vérification que l'on demande si le salaire a eu des primes pour un ouvrier - userAction - .click(ui.previous.get()) - .click(ui.previous.get()) - .click(ui.previous.get()) - .changeInputList( - ui.information.agreement16.proCategory.get(), - "Ouvriers" - ) - .click(ui.information.agreement16.driveInability.non.get()) - .setInput(ui.information.agreement16.workerAge.get(), "36") - .click(ui.next.get()) - .click(ui.next.get()) - .click(ui.salary.hasSameSalary.oui.get()); - - expect( - rendering.queryByText( - "Les salaires indiqués comportent-ils une partie variable ?" - ) - ).not.toBeInTheDocument(); - userAction.click(ui.salary.hasSameSalary.non.get()); - expect( - rendering.queryByText( - "Les salaires indiqués comportent-ils une partie variable ?" - ) - ).not.toBeInTheDocument(); - expect(ui.salary.variablePart.oui.query()).not.toBeInTheDocument(); - expect(ui.salary.variablePart.non.query()).not.toBeInTheDocument(); - - userAction - .setInput(ui.salary.salaries.getAll()[0], "2500") - .click(ui.next.get()); - - expect( - rendering.queryByText( - /Les salaires indiqués comportent une partie variable/ - ) - ).not.toBeInTheDocument(); - }); - }); -}); diff --git a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc1672.test.tsx b/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc1672.test.tsx deleted file mode 100644 index f616218741..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc1672.test.tsx +++ /dev/null @@ -1,176 +0,0 @@ -import { render, RenderResult } from "@testing-library/react"; -import React from "react"; -import { CalculateurIndemniteLicenciement } from "../.."; -import { ui } from "../../CommonIndemniteDepart/__tests__/ui"; -import { UserAction } from "../../../common"; - -jest.spyOn(Storage.prototype, "setItem"); -Storage.prototype.getItem = jest.fn( - () => ` -{ - "url": "https://www.legifrance.gouv.fr/affichIDCC.do?idConvention=KALICONT000005635918", - "id": "KALICONT000005635918", - "num": 1672, - "shortTitle": "Sociétés d'assurances", - "slug": "1672-societes-dassurances", - "title": "Sociétés d'assurances" -} -` -); - -describe("Indemnité licenciement - CC 1672", () => { - let rendering: RenderResult; - let userAction: UserAction; - beforeEach(() => { - rendering = render( - - ); - userAction = new UserAction(); - - userAction - .click(ui.introduction.startButton.get()) - .click(ui.contract.type.cdi.get()) - .click(ui.contract.fauteGrave.non.get()) - .click(ui.contract.inaptitude.non.get()) - .click(ui.contract.arretTravail.non.get()) - .click(ui.next.get()) - .click(ui.next.get()); - }); - test(`Cas nominal`, () => { - userAction.changeInputList( - ui.information.agreement1672.proCategory.get(), - "Non-cadres (Classes 1 à 4)" - ); - userAction.setInput(ui.information.agreement1672.age.get(), "42"); - userAction.click(ui.next.get()); - - userAction.setInput(ui.seniority.startDate.get(), "01/01/2018"); - userAction.setInput(ui.seniority.notificationDate.get(), "01/01/2022"); - userAction.setInput(ui.seniority.endDate.get(), "01/01/2022"); - userAction.click(ui.seniority.hasAbsence.non.get()); - userAction.click(ui.next.get()); - expect(ui.activeStep.query()).toHaveTextContent("Salaires"); - - userAction.click(ui.salary.hasPartialTime.non.get()); - userAction.click(ui.salary.hasSameSalary.oui.get()); - userAction.setInput(ui.salary.sameSalaryValue.get(), "2500"); - - expect( - rendering.queryByText( - "Connaissez-vous le montant du salaire perçu pendant le préavis ?" - ) - ).not.toBeInTheDocument(); - userAction.click(ui.previous.get()); - userAction.setInput(ui.seniority.endDate.get(), "01/06/2022"); - userAction.click(ui.next.get()); - expect( - rendering.queryByText( - "Connaissez-vous le montant des salaires perçus pendant le préavis ?" - ) - ).toBeInTheDocument(); - userAction.click( - ui.salary.agreementWithNoticeSalary.knowingLastSalary.oui.get() - ); - expect( - rendering.queryByText("Salaires perçus pendant le préavis") - ).toBeInTheDocument(); - userAction.setInput( - ui.salary.agreementWithNoticeSalary.salaries.getAll()[0], - "3000" - ); - - userAction.click(ui.next.get()); - - expect(ui.activeStep.query()).toHaveTextContent("Indemnité"); - expect(ui.result.resultat.get()).toHaveTextContent("3 588,54 €"); - expect(ui.result.resultTableRows.getAll().length).toBe(5); - expect(ui.result.resultTableRows.getAll()[0]).toHaveTextContent( - "mai 20223000 €" - ); - userAction.click(ui.previous.get()); - expect( - ui.salary.agreementWithNoticeSalary.salaries.getAll()[0] - ).toHaveValue(3000); - userAction - .click(ui.salary.agreementWithNoticeSalary.knowingLastSalary.non.get()) - .click(ui.next.get()); - expect(ui.activeStep.query()).toHaveTextContent("Indemnité"); - expect(ui.result.resultat.get()).toHaveTextContent("2 760,42 €"); - expect(ui.result.resultTableRows.queryAll().length).toBe(0); - }); - test(`Cas avec arrêt de travail`, () => { - userAction - .click(ui.previous.get()) - .click(ui.previous.get()) - .click(ui.contract.arretTravail.oui.get()); - - userAction.setInput(ui.contract.dateArretTravail.get(), "01/01/2022"); - userAction.click(ui.next.get()).click(ui.next.get()); - - userAction.changeInputList( - ui.information.agreement1672.proCategory.get(), - "Non-cadres (Classes 1 à 4)" - ); - userAction.setInput(ui.information.agreement1672.age.get(), "42"); - userAction.click(ui.next.get()); - - userAction.setInput(ui.seniority.startDate.get(), "01/01/2018"); - userAction.setInput(ui.seniority.notificationDate.get(), "01/01/2022"); - userAction.setInput(ui.seniority.endDate.get(), "01/06/2022"); - userAction.click(ui.seniority.hasAbsence.non.get()); - userAction.click(ui.next.get()); - expect(ui.activeStep.query()).toHaveTextContent("Salaires"); - - userAction.click(ui.salary.hasPartialTime.non.get()); - userAction.click(ui.salary.hasSameSalary.oui.get()); - userAction.setInput(ui.salary.sameSalaryValue.get(), "2500"); - expect( - rendering.queryByText( - "Connaissez-vous le montant des salaires perçus pendant le préavis ?" - ) - ).not.toBeInTheDocument(); - }); - - test(`Cas spécifique`, () => { - userAction - .changeInputList( - ui.information.agreement1672.proCategory.get(), - "Cadres (Classes 5 à 7)" - ) - .click(ui.information.agreement1672.nonCadreAvant.oui.get()) - .setInput(ui.information.agreement1672.dateDebutCadre.get(), "01/01/1999") - .setInput(ui.information.agreement1672.age.get(), "52") - .click(ui.next.get()) - .setInput(ui.seniority.startDate.get(), "01/01/1994") - .setInput(ui.seniority.notificationDate.get(), "01/01/2024") - .setInput(ui.seniority.endDate.get(), "01/01/2024") - .click(ui.seniority.hasAbsence.non.get()) - .click(ui.next.get()) - .click(ui.salary.hasPartialTime.non.get()) - .click(ui.salary.hasSameSalary.non.get()); - expect(ui.salary.salaries.queryAll()).toHaveLength(12); - - userAction.setInput(ui.salary.salaries.getAll()[0], "2471"); - userAction.setInput(ui.salary.salaries.getAll()[1], "2794"); - userAction.setInput(ui.salary.salaries.getAll()[2], "2859"); - userAction.setInput(ui.salary.salaries.getAll()[3], "2566"); - userAction.setInput(ui.salary.salaries.getAll()[4], "2650"); - userAction.setInput(ui.salary.salaries.getAll()[5], "2842"); - userAction.setInput(ui.salary.salaries.getAll()[6], "2564"); - userAction.setInput(ui.salary.salaries.getAll()[7], "2882"); - userAction.setInput(ui.salary.salaries.getAll()[8], "2718"); - userAction.setInput(ui.salary.salaries.getAll()[9], "2756"); - userAction.setInput(ui.salary.salaries.getAll()[10], "2752"); - userAction.setInput(ui.salary.salaries.getAll()[11], "2512"); - - userAction.click(ui.next.get()); - - expect(ui.activeStep.query()).toHaveTextContent("Indemnité"); - expect(ui.result.resultatAgreement.get()).toHaveTextContent("51 381,03 €"); - expect(ui.result.resultat.get()).toHaveTextContent("51 381,03 €"); - }); -}); diff --git a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc1702.test.tsx b/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc1702.test.tsx deleted file mode 100644 index 89c6d3a60d..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc1702.test.tsx +++ /dev/null @@ -1,211 +0,0 @@ -import { render, RenderResult } from "@testing-library/react"; -import React from "react"; -import { CalculateurIndemniteLicenciement } from "../.."; -import { ui } from "../../CommonIndemniteDepart/__tests__/ui"; -import { UserAction } from "../../../common"; - -jest.spyOn(Storage.prototype, "setItem"); -Storage.prototype.getItem = jest.fn( - () => ` -{ - "url": "https://www.legifrance.gouv.fr/affichIDCC.do?idConvention=KALICONT000005635467", - "id": "KALICONT000005635467", - "num": 1702, - "shortTitle": "Travaux publics (Tome II : Ouvriers)", - "slug": "1702-travaux-publics-tome-ii-ouvriers", - "title": "Travaux publics (Tome II : Ouvriers)" -} -` -); - -describe("Indemnité licenciement - CC 1702", () => { - let rendering: RenderResult; - let userAction: UserAction; - beforeEach(() => { - rendering = render( - - ); - userAction = new UserAction(); - - userAction - .click(ui.introduction.startButton.get()) - .click(ui.contract.type.cdi.get()) - .click(ui.contract.fauteGrave.non.get()) - .click(ui.contract.inaptitude.non.get()) - .click(ui.contract.arretTravail.non.get()) - .click(ui.next.get()) - .click(ui.next.get()); - }); - test(`Autre licenciement`, () => { - userAction - .setInput(ui.information.agreement1702.age.get(), "40") - .click(ui.information.agreement1702.motif.non.get()) - .click(ui.next.get()); - - userAction.setInput(ui.seniority.startDate.get(), "01/01/2018"); - userAction.setInput(ui.seniority.notificationDate.get(), "01/01/2022"); - userAction.setInput(ui.seniority.endDate.get(), "01/01/2022"); - userAction.click(ui.seniority.hasAbsence.non.get()); - userAction.click(ui.next.get()); - expect(ui.activeStep.query()).toHaveTextContent("Salaires"); - - userAction.click(ui.salary.hasPartialTime.non.get()); - userAction.click(ui.salary.hasSameSalary.non.get()); - expect( - rendering.queryByText( - "Indiquez le montant des salaires (en incluant l’indemnité de congés payés, les primes, dont la prime de vacances, et les avantages en nature) dans le premier champ et le montant des primes dans le second champ (uniquement pour les 3 derniers mois)" - ) - ).toBeInTheDocument(); - userAction.click(ui.salary.hasSameSalary.oui.get()); - userAction.setInput(ui.salary.sameSalaryValue.get(), "2500"); - - expect( - rendering.queryByText( - "Connaissez-vous le montant du salaire perçu pendant le préavis ?" - ) - ).not.toBeInTheDocument(); - userAction.click(ui.previous.get()); - userAction.setInput(ui.seniority.endDate.get(), "01/06/2022"); - userAction.click(ui.next.get()); - expect( - rendering.queryByText( - "Connaissez-vous le montant des salaires perçus pendant le préavis ?" - ) - ).toBeInTheDocument(); - userAction.click( - ui.salary.agreementWithNoticeSalary.knowingLastSalary.oui.get() - ); - expect( - rendering.queryByText("Salaires perçus pendant le préavis") - ).toBeInTheDocument(); - userAction.setInput( - ui.salary.agreementWithNoticeSalary.salaries.getAll()[0], - "3000" - ); - - userAction.click(ui.next.get()); - - expect(ui.activeStep.query()).toHaveTextContent("Indemnité"); - expect(ui.result.resultat.get()).toHaveTextContent("2 760,42 €"); - expect(ui.result.resultTableRows.getAll().length).toBe(5); - expect(ui.result.resultTableRows.getAll()[0]).toHaveTextContent( - "mai 20223000 €" - ); - userAction.click(ui.previous.get()); - expect( - ui.salary.agreementWithNoticeSalary.salaries.getAll()[0] - ).toHaveValue(3000); - userAction - .click(ui.salary.agreementWithNoticeSalary.knowingLastSalary.non.get()) - .click(ui.next.get()); - expect(ui.activeStep.query()).toHaveTextContent("Indemnité"); - expect(ui.result.resultat.get()).toHaveTextContent("2 760,42 €"); - expect(ui.result.resultTableRows.queryAll().length).toBe(0); - expect( - rendering.queryByText( - "Le montant de l’indemnité doit être calculé sur la base des salaires (reconstitués) que la salarié aurait dû percevoir au cours des 3 derniers mois précédant la rupture du contrat s’il n’avait pas été en arrêt de travail. Pour simplifier l'utilisation de ce simulateur, la calcul se base ici sur les salaires perçus avant l'arrêt travail et non sur les salaires reconstitués. Le montant de l'indemnité pourrait donc être plus important que celui donné par le simulateur." - ) - ).not.toBeInTheDocument(); - expect( - rendering.queryByText( - /Ce résultat ne prend pas en compte le complément forfaitaire dont bénéficie le salarié en plus du montant de l'indemnité de licenciement/ - ) - ).not.toBeInTheDocument(); - }); - - test(`Autre licenciement avec arret de travail`, () => { - userAction - .click(ui.previous.get()) - .click(ui.previous.get()) - .click(ui.contract.arretTravail.oui.get()); - - userAction.setInput(ui.contract.dateArretTravail.get(), "01/01/2022"); - userAction - .click(ui.next.get()) - .click(ui.next.get()) - .setInput(ui.information.agreement1702.age.get(), "40") - .click(ui.information.agreement1702.motif.non.get()) - .click(ui.next.get()); - - userAction.setInput(ui.seniority.startDate.get(), "01/01/2018"); - userAction.setInput(ui.seniority.notificationDate.get(), "01/01/2022"); - userAction.setInput(ui.seniority.endDate.get(), "01/06/2022"); - userAction.click(ui.seniority.hasAbsence.non.get()); - userAction.click(ui.next.get()); - expect(ui.activeStep.query()).toHaveTextContent("Salaires"); - - userAction.click(ui.salary.hasPartialTime.non.get()); - userAction.click(ui.salary.hasSameSalary.oui.get()); - userAction.setInput(ui.salary.sameSalaryValue.get(), "2500"); - expect( - rendering.queryByText( - "Connaissez-vous le montant des salaires perçus pendant le préavis ?" - ) - ).not.toBeInTheDocument(); - userAction.click(ui.next.get()); - expect(ui.activeStep.query()).toHaveTextContent("Indemnité"); - expect(ui.result.resultat.get()).toHaveTextContent("2 760,42 €"); - }); - - test(`Licenciement économique`, () => { - userAction - .setInput(ui.information.agreement1702.age.get(), "40") - .click(ui.information.agreement1702.motif.oui.get()) - .click(ui.next.get()); - - userAction.setInput(ui.seniority.startDate.get(), "01/01/2018"); - userAction.setInput(ui.seniority.notificationDate.get(), "01/01/2022"); - userAction.setInput(ui.seniority.endDate.get(), "01/01/2022"); - userAction.click(ui.seniority.hasAbsence.non.get()); - userAction.click(ui.next.get()); - expect(ui.activeStep.query()).toHaveTextContent("Salaires"); - - userAction.click(ui.salary.hasPartialTime.non.get()); - userAction.click(ui.salary.hasSameSalary.non.get()); - expect( - rendering.queryByText( - "Indiquez le montant des salaires (en incluant l’indemnité de congés payés, les primes, dont la prime de vacances, et les avantages en nature) dans le premier champ et le montant des primes dans le second champ (uniquement pour les 3 derniers mois)" - ) - ).toBeInTheDocument(); - userAction.click(ui.salary.hasSameSalary.oui.get()); - userAction.setInput(ui.salary.sameSalaryValue.get(), "2500"); - - expect( - rendering.queryByText( - "Connaissez-vous le montant du salaire perçu pendant le préavis ?" - ) - ).not.toBeInTheDocument(); - userAction.click(ui.previous.get()); - userAction.setInput(ui.seniority.endDate.get(), "01/06/2022"); - userAction.click(ui.next.get()); - expect( - rendering.queryByText( - "Connaissez-vous le montant des salaires perçus pendant le préavis ?" - ) - ).toBeInTheDocument(); - userAction.click( - ui.salary.agreementWithNoticeSalary.knowingLastSalary.oui.get() - ); - expect( - rendering.queryByText("Salaires perçus pendant le préavis") - ).toBeInTheDocument(); - userAction.setInput( - ui.salary.agreementWithNoticeSalary.salaries.getAll()[0], - "3000" - ); - - userAction.click(ui.next.get()); - - expect(ui.activeStep.query()).toHaveTextContent("Indemnité"); - expect(ui.result.resultat.get()).toHaveTextContent("2 760,42 €"); - expect( - rendering.queryByText( - /Ce résultat ne prend pas en compte le complément forfaitaire dont bénéficie le salarié en plus du montant de l'indemnité de licenciement/ - ) - ).toBeInTheDocument(); - }); -}); diff --git a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc2098.test.tsx b/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc2098.test.tsx deleted file mode 100644 index 70df5d4a27..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc2098.test.tsx +++ /dev/null @@ -1,71 +0,0 @@ -import { render } from "@testing-library/react"; -import React from "react"; -import { CalculateurIndemniteLicenciement } from "../.."; -import { ui } from "../../CommonIndemniteDepart/__tests__/ui"; -import { UserAction } from "../../../common"; - -jest.spyOn(Storage.prototype, "setItem"); -Storage.prototype.getItem = jest.fn( - () => ` -{ - "url": "https://www.legifrance.gouv.fr/affichIDCC.do?idConvention=KALICONT000005635780", - "id": "2098", - "num": 2098, - "shortTitle": "personnel presta service tertiaire", - "slug": "2098-personnel presta service tertiaire", - "title": "Convention collective nationale de la banque du 10 janvier 2000. Etendue par arrêté du 17 novembre 2004 JORF 11 décembre 2004." -} -` -); - -describe("Indemnité licenciement- CC 2098", () => { - let userAction: UserAction; - test("Inaptitude non pro", () => { - render( - - ); - userAction = new UserAction(); - - userAction - .click(ui.introduction.startButton.get()) - .click(ui.contract.type.cdi.get()) - .click(ui.contract.fauteGrave.non.get()) - .click(ui.contract.inaptitude.oui.get()) - .click(ui.next.get()) - .click(ui.next.get()) - - .click(ui.information.agreement2098.inaptitudeNonPro.get()) - .click(ui.next.get()) - .setInput(ui.seniority.startDate.get(), "01/01/2009") - .setInput(ui.seniority.notificationDate.get(), "01/01/2024") - .setInput(ui.seniority.endDate.get(), "01/01/2024") - .click(ui.seniority.hasAbsence.oui.get()) - .setInput(ui.seniority.absences.duration(0).get(), "8") - .click(ui.next.get()) - .click(ui.salary.hasPartialTime.non.get()) - .click(ui.salary.hasSameSalary.non.get()) - .setInputs(ui.salary.salaries.getAll(), [ - "2266", - "2250", - "2203", - "2199", - "2100", - "2020", - "2010", - "2010", - "1930", - "1890", - "1900", - "1800", - ]) - .click(ui.next.get()); - - expect(ui.activeStep.query()).toHaveTextContent("Indemnité"); - expect(ui.result.resultat.get()).toHaveTextContent("17 668,48 €"); - expect(ui.result.resultatAgreement.get()).toHaveTextContent("9 331,94 €"); - }); -}); diff --git a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc2120.test.tsx b/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc2120.test.tsx deleted file mode 100644 index c8c9c4197c..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc2120.test.tsx +++ /dev/null @@ -1,66 +0,0 @@ -import { fireEvent, render, RenderResult } from "@testing-library/react"; -import React from "react"; -import { CalculateurIndemniteLicenciement } from "../.."; -import { ui } from "../../CommonIndemniteDepart/__tests__/ui"; -import { UserAction } from "../../../common"; - -jest.spyOn(Storage.prototype, "setItem"); -Storage.prototype.getItem = jest.fn( - () => ` -{ - "url": "https://www.legifrance.gouv.fr/affichIDCC.do?idConvention=KALICONT000005635780", - "id": "2120", - "num": 2120, - "shortTitle": "Banque", - "slug": "2120-banque", - "title": "Convention collective nationale de la banque du 10 janvier 2000. Etendue par arrêté du 17 novembre 2004 JORF 11 décembre 2004." -} -` -); - -describe("Indemnité licenciement - CC 2120", () => { - let rendering: RenderResult; - let userAction: UserAction; - beforeEach(() => { - rendering = render( - - ); - userAction = new UserAction(); - - userAction - .click(ui.introduction.startButton.get()) - .click(ui.contract.type.cdi.get()) - .click(ui.contract.fauteGrave.non.get()) - .click(ui.contract.inaptitude.non.get()) - .click(ui.contract.arretTravail.non.get()) - .click(ui.next.get()) - .click(ui.next.get()); - }); - test(`Cas nominal`, () => { - userAction - .changeInputList( - ui.information.agreement2120.proCategory.get(), - "Non-cadres" - ) - .click(ui.information.agreement2120.eco.oui.get()) - .click(ui.next.get()) - - .setInput(ui.seniority.startDate.get(), "01/01/1999") - .setInput(ui.seniority.notificationDate.get(), "01/01/2024") - .setInput(ui.seniority.endDate.get(), "01/01/2024") - .click(ui.seniority.hasAbsence.non.get()) - .click(ui.next.get()) - .click(ui.salary.hasPartialTime.non.get()) - .click(ui.salary.hasSameSalary.oui.get()) - .setInput(ui.salary.sameSalaryValue.get(), "1991") - .setInput(ui.salary.agreement2120.salariesVariablePart.get(), "2000") - .click(ui.next.get()); - - expect(ui.activeStep.query()).toHaveTextContent("Indemnité"); - expect(ui.result.resultat.get()).toHaveTextContent("25 540,67 €"); - }); -}); diff --git a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc2148.test.tsx b/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc2148.test.tsx deleted file mode 100644 index 3e17d3c6ef..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc2148.test.tsx +++ /dev/null @@ -1,129 +0,0 @@ -import { render, RenderResult } from "@testing-library/react"; -import React from "react"; -import { CalculateurIndemniteLicenciement } from "../.."; -import { ui } from "../../CommonIndemniteDepart/__tests__/ui"; -import { UserAction } from "../../../common"; - -jest.spyOn(Storage.prototype, "setItem"); -Storage.prototype.getItem = jest.fn( - () => ` -{ - "url": "https://www.legifrance.gouv.fr/affichIDCC.do?idConvention=KALICONT000005635557", - "id": "KALICONT000005635557", - "num": 2148, - "shortTitle": "Télécommunications", - "slug": "2148-telecommunications", - "title": "Télécommunications" -} -` -); - -describe("Indemnité licenciement - CC 2148", () => { - let rendering: RenderResult; - let userAction: UserAction; - beforeEach(() => { - rendering = render( - - ); - userAction = new UserAction(); - - userAction - .click(ui.introduction.startButton.get()) - .click(ui.contract.type.cdi.get()) - .click(ui.contract.fauteGrave.non.get()) - .click(ui.contract.inaptitude.non.get()) - .click(ui.contract.arretTravail.non.get()) - .click(ui.next.get()) - .click(ui.next.get()); - }); - test(`Cas nominal`, () => { - userAction.setInput(ui.information.agreement2148.age.get(), "42"); - userAction.click(ui.next.get()); - - userAction.setInput(ui.seniority.startDate.get(), "01/01/2018"); - userAction.setInput(ui.seniority.notificationDate.get(), "01/01/2022"); - userAction.setInput(ui.seniority.endDate.get(), "01/01/2022"); - userAction.click(ui.seniority.hasAbsence.non.get()); - userAction.click(ui.next.get()); - expect(ui.activeStep.query()).toHaveTextContent("Salaires"); - - userAction.click(ui.salary.hasPartialTime.non.get()); - userAction.click(ui.salary.hasSameSalary.oui.get()); - userAction.setInput(ui.salary.sameSalaryValue.get(), "2500"); - - expect( - rendering.queryByText( - "Connaissez-vous le montant du salaire perçu pendant le préavis ?" - ) - ).not.toBeInTheDocument(); - userAction.click(ui.previous.get()); - userAction.setInput(ui.seniority.endDate.get(), "01/06/2022"); - userAction.click(ui.next.get()); - expect( - rendering.queryByText( - "Connaissez-vous le montant des salaires perçus pendant le préavis ?" - ) - ).toBeInTheDocument(); - userAction.click( - ui.salary.agreementWithNoticeSalary.knowingLastSalary.oui.get() - ); - expect( - rendering.queryByText("Salaires perçus pendant le préavis") - ).toBeInTheDocument(); - userAction.setInput( - ui.salary.agreementWithNoticeSalary.salaries.getAll()[0], - "3000" - ); - - userAction.click(ui.next.get()); - - expect(ui.activeStep.query()).toHaveTextContent("Indemnité"); - expect(ui.result.resultat.get()).toHaveTextContent("3 900,00 €"); - expect(ui.result.resultTableRows.getAll().length).toBe(5); - expect(ui.result.resultTableRows.getAll()[0]).toHaveTextContent( - "mai 20223000 €" - ); - userAction.click(ui.previous.get()); - expect( - ui.salary.agreementWithNoticeSalary.salaries.getAll()[0] - ).toHaveValue(3000); - userAction - .click(ui.salary.agreementWithNoticeSalary.knowingLastSalary.non.get()) - .click(ui.next.get()); - expect(ui.activeStep.query()).toHaveTextContent("Indemnité"); - expect(ui.result.resultat.get()).toHaveTextContent("3 600,00 €"); - expect(ui.result.resultTableRows.queryAll().length).toBe(0); - }); - test(`Cas avec arrêt de travail`, () => { - userAction - .click(ui.previous.get()) - .click(ui.previous.get()) - .click(ui.contract.arretTravail.oui.get()); - - userAction.setInput(ui.contract.dateArretTravail.get(), "01/01/2022"); - userAction.click(ui.next.get()).click(ui.next.get()); - - userAction.setInput(ui.information.agreement2148.age.get(), "42"); - userAction.click(ui.next.get()); - - userAction.setInput(ui.seniority.startDate.get(), "01/01/2018"); - userAction.setInput(ui.seniority.notificationDate.get(), "01/01/2022"); - userAction.setInput(ui.seniority.endDate.get(), "01/06/2022"); - userAction.click(ui.seniority.hasAbsence.non.get()); - userAction.click(ui.next.get()); - expect(ui.activeStep.query()).toHaveTextContent("Salaires"); - - userAction.click(ui.salary.hasPartialTime.non.get()); - userAction.click(ui.salary.hasSameSalary.oui.get()); - userAction.setInput(ui.salary.sameSalaryValue.get(), "2500"); - expect( - rendering.queryByText( - "Connaissez-vous le montant des salaires perçus pendant le préavis ?" - ) - ).not.toBeInTheDocument(); - }); -}); diff --git a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc2596.test.tsx b/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc2596.test.tsx deleted file mode 100644 index 222333dab6..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc2596.test.tsx +++ /dev/null @@ -1,239 +0,0 @@ -import { render, RenderResult } from "@testing-library/react"; -import React from "react"; -import { CalculateurIndemniteLicenciement } from "../.."; -import { ui } from "../../CommonIndemniteDepart/__tests__/ui"; -import { UserAction } from "../../../common"; - -jest.spyOn(Storage.prototype, "setItem"); -Storage.prototype.getItem = jest.fn( - () => ` -{ - "url": "https://www.legifrance.gouv.fr/affichIDCC.do?idConvention=KALICONT000018773893", - "id": "KALICONT000018773893", - "num": 2596, - "shortTitle": "Coiffure", - "slug": "2596-coiffure", - "title": "Coiffure" -} -` -); - -describe("Indemnité licenciement - CC 2596", () => { - let rendering: RenderResult; - let userAction: UserAction; - beforeEach(() => { - rendering = render( - - ); - userAction = new UserAction(); - - userAction - .click(ui.introduction.startButton.get()) - .click(ui.contract.type.cdi.get()) - .click(ui.contract.fauteGrave.non.get()) - .click(ui.contract.inaptitude.non.get()) - .click(ui.contract.arretTravail.non.get()) - .click(ui.next.get()) - .click(ui.next.get()); - }); - test(`Cadres`, () => { - userAction - .changeInputList(ui.information.agreement2596.proCategory.get(), "Cadres") - .click(ui.next.get()); - - userAction.setInput(ui.seniority.startDate.get(), "01/01/2018"); - userAction.setInput(ui.seniority.notificationDate.get(), "01/01/2022"); - userAction.setInput(ui.seniority.endDate.get(), "01/01/2022"); - userAction.click(ui.seniority.hasAbsence.non.get()); - userAction.click(ui.next.get()); - expect(ui.activeStep.query()).toHaveTextContent("Salaires"); - - userAction.click(ui.salary.hasPartialTime.non.get()); - userAction.click(ui.salary.hasSameSalary.oui.get()); - userAction.setInput(ui.salary.sameSalaryValue.get(), "2500"); - - expect( - rendering.queryByText( - "Connaissez-vous le montant du salaire perçu pendant le préavis ?" - ) - ).not.toBeInTheDocument(); - userAction.click(ui.previous.get()); - userAction.setInput(ui.seniority.endDate.get(), "01/06/2022"); - userAction.click(ui.next.get()); - expect( - rendering.queryByText( - "Connaissez-vous le montant des salaires perçus pendant le préavis ?" - ) - ).toBeInTheDocument(); - userAction.click( - ui.salary.agreementWithNoticeSalary.knowingLastSalary.oui.get() - ); - expect( - rendering.queryByText("Salaires perçus pendant le préavis") - ).toBeInTheDocument(); - userAction.setInput( - ui.salary.agreementWithNoticeSalary.salaries.getAll()[0], - "3000" - ); - - userAction.click(ui.next.get()); - - expect(ui.activeStep.query()).toHaveTextContent("Indemnité"); - expect(ui.result.resultat.get()).toHaveTextContent("2 990,45 €"); - expect(ui.result.resultTableRows.getAll().length).toBe(5); - expect(ui.result.resultTableRows.getAll()[0]).toHaveTextContent( - "mai 20223000 €" - ); - userAction.click(ui.previous.get()); - expect( - ui.salary.agreementWithNoticeSalary.salaries.getAll()[0] - ).toHaveValue(3000); - userAction - .click(ui.salary.agreementWithNoticeSalary.knowingLastSalary.non.get()) - .click(ui.next.get()); - expect(ui.activeStep.query()).toHaveTextContent("Indemnité"); - expect(ui.result.resultat.get()).toHaveTextContent("2 760,42 €"); - expect(ui.result.resultTableRows.queryAll().length).toBe(0); - }); - test(`Cadres moins de 8 mois d'ancienneté`, () => { - userAction - .changeInputList(ui.information.agreement2596.proCategory.get(), "Cadres") - .click(ui.next.get()); - - userAction.setInput(ui.seniority.startDate.get(), "01/01/2022"); - userAction.setInput(ui.seniority.notificationDate.get(), "01/03/2022"); - userAction.setInput(ui.seniority.endDate.get(), "01/03/2022"); - userAction.click(ui.seniority.hasAbsence.non.get()); - userAction.click(ui.next.get()); - expect(ui.activeStep.query()).toHaveTextContent("Salaires"); - - userAction.click(ui.salary.hasPartialTime.non.get()); - userAction.click(ui.salary.hasSameSalary.oui.get()); - userAction.setInput(ui.salary.sameSalaryValue.get(), "2500"); - - userAction.click(ui.next.get()); - - expect(ui.activeStep.query()).toHaveTextContent("Indemnité"); - expect(ui.result.resultat.get()).toHaveTextContent("104,17 €"); - expect(ui.result.resultatLegal.get()).toHaveTextContent("0 €"); - }); - test(`Cadres avec arret de travail`, () => { - userAction - .click(ui.previous.get()) - .click(ui.previous.get()) - .click(ui.contract.arretTravail.oui.get()); - - userAction.setInput(ui.contract.dateArretTravail.get(), "01/01/2022"); - userAction - .click(ui.next.get()) - .click(ui.next.get()) - .changeInputList(ui.information.agreement2596.proCategory.get(), "Cadres") - .click(ui.next.get()); - - userAction.setInput(ui.seniority.startDate.get(), "01/01/2018"); - userAction.setInput(ui.seniority.notificationDate.get(), "01/01/2022"); - userAction.setInput(ui.seniority.endDate.get(), "01/06/2022"); - userAction.click(ui.seniority.hasAbsence.non.get()); - userAction.click(ui.next.get()); - expect(ui.activeStep.query()).toHaveTextContent("Salaires"); - - userAction.click(ui.salary.hasPartialTime.non.get()); - userAction.click(ui.salary.hasSameSalary.oui.get()); - userAction.setInput(ui.salary.sameSalaryValue.get(), "2500"); - expect( - rendering.queryByText( - "Connaissez-vous le montant des salaires perçus pendant le préavis ?" - ) - ).not.toBeInTheDocument(); - }); - test(`Non-cadres`, () => { - userAction - .changeInputList( - ui.information.agreement2596.proCategory.get(), - "Emplois techniques et de coiffeurs" - ) - .click(ui.next.get()); - - userAction.setInput(ui.seniority.startDate.get(), "01/01/2000"); - userAction.setInput(ui.seniority.notificationDate.get(), "01/01/2022"); - userAction.setInput(ui.seniority.endDate.get(), "01/03/2022"); - userAction.click(ui.seniority.hasAbsence.non.get()); - userAction.click(ui.next.get()); - expect(ui.activeStep.query()).toHaveTextContent("Salaires"); - - userAction.click(ui.salary.hasPartialTime.non.get()); - userAction.click(ui.salary.hasSameSalary.oui.get()); - userAction.setInput(ui.salary.sameSalaryValue.get(), "2500"); - - expect( - rendering.queryByText( - "Connaissez-vous le montant des salaires perçus pendant le préavis ?" - ) - ).not.toBeInTheDocument(); - expect( - rendering.queryByText("Salaires perçus pendant le préavis") - ).not.toBeInTheDocument(); - - userAction.click(ui.next.get()); - - expect(ui.activeStep.query()).toHaveTextContent("Indemnité"); - expect(ui.result.resultat.get()).toHaveTextContent("16 388,89 €"); - }); - - test(`Emplois de l'esthétique-cosmétique avec moins de 8 moins d'ancienneté`, () => { - userAction - .changeInputList( - ui.information.agreement2596.proCategory.get(), - "Emplois de l'esthétique-cosmétique" - ) - .click(ui.next.get()); - - userAction.setInput(ui.seniority.startDate.get(), "01/01/2020"); - userAction.setInput(ui.seniority.notificationDate.get(), "01/03/2024"); - userAction.setInput(ui.seniority.endDate.get(), "01/03/2024"); - userAction.click(ui.seniority.hasAbsence.non.get()); - userAction.click(ui.next.get()); - expect(ui.activeStep.query()).toHaveTextContent("Salaires"); - - userAction.click(ui.salary.hasPartialTime.non.get()); - userAction.click(ui.salary.hasSameSalary.oui.get()); - userAction.setInput(ui.salary.sameSalaryValue.get(), "2500"); - - expect( - rendering.queryByText( - "Connaissez-vous le montant des salaires perçus pendant le préavis ?" - ) - ).not.toBeInTheDocument(); - expect( - rendering.queryByText("Salaires perçus pendant le préavis") - ).not.toBeInTheDocument(); - - userAction.click(ui.next.get()); - - expect(ui.activeStep.query()).toHaveTextContent("Indemnité"); - expect(ui.result.resultat.get()).toHaveTextContent("2 604,17 €"); - }); - - test(`Emplois de l'esthétique-cosmétique`, () => { - userAction - .changeInputList( - ui.information.agreement2596.proCategory.get(), - "Emplois de l'esthétique-cosmétique" - ) - .click(ui.next.get()); - - userAction.setInput(ui.seniority.startDate.get(), "01/09/2023"); - userAction.setInput(ui.seniority.notificationDate.get(), "01/03/2024"); - userAction.setInput(ui.seniority.endDate.get(), "01/03/2024"); - userAction.click(ui.seniority.hasAbsence.non.get()); - userAction.click(ui.next.get()); - - expect(ui.activeStep.query()).toHaveTextContent("Indemnité"); - expect(ui.result.legalError.title.query()).toBeInTheDocument(); - expect(ui.result.legalError.seniorityToLow.query()).toBeInTheDocument(); - }); -}); diff --git a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc2609.test.tsx b/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc2609.test.tsx deleted file mode 100644 index 6f0114633a..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc2609.test.tsx +++ /dev/null @@ -1,108 +0,0 @@ -import { render, RenderResult } from "@testing-library/react"; -import React from "react"; -import { CalculateurIndemniteLicenciement } from "../.."; -import { ui } from "../../CommonIndemniteDepart/__tests__/ui"; -import { UserAction } from "../../../common"; - -jest.spyOn(Storage.prototype, "setItem"); -Storage.prototype.getItem = jest.fn( - () => ` -{ - "url": "https://www.legifrance.gouv.fr/affichIDCC.do?idConvention=KALICONT000018773893", - "id": "KALICONT000018773893", - "num": 2609, - "shortTitle": "Bâtiment ETAM", - "slug": "2609-batiment-etam", - "title": "Bâtiment ETAM" -} -` -); - -describe("Indemnité licenciement - CC 2609", () => { - describe("parcours avec la convention collective pour valider ses spécificités", () => { - let rendering: RenderResult; - let userAction: UserAction; - beforeEach(() => { - rendering = render( - - ); - userAction = new UserAction(); - userAction.click(ui.introduction.startButton.get()); - userAction.click(ui.contract.type.cdi.get()); - userAction.click(ui.contract.fauteGrave.non.get()); - userAction.click(ui.contract.inaptitude.non.get()); - userAction.click(ui.contract.arretTravail.non.get()); - userAction.click(ui.next.get()); - userAction.click(ui.next.get()); - expect(ui.activeStep.query()).toHaveTextContent("Informations"); - }); - - test(` - - vérification que l'on demande l'age - - vérification que l'on ne demande pas si le salaire comporte une partie de variable si salaire fixe - - vérification que l'on n'affiche pas la partie variable sur le résultat - - vérification que l'on demande si le salaire comporte une partie de variable si salaires différents - - vérification que l'on affiche la réponse du salaire variable sur l'étape de résultat - `, () => { - // vérification que l'on demande l'age - expect(ui.information.agreement2609.age.query()).toBeInTheDocument(); - - userAction.setInput(ui.information.agreement2609.age.get(), "45"); - userAction.click(ui.next.get()); - userAction.setInput(ui.seniority.startDate.get(), "01/01/2000"); - userAction.setInput(ui.seniority.notificationDate.get(), "01/01/2022"); - userAction.setInput(ui.seniority.endDate.get(), "01/03/2022"); - userAction.click(ui.seniority.hasAbsence.non.get()); - userAction.click(ui.next.get()); - expect(ui.activeStep.query()).toHaveTextContent("Salaires"); - - userAction.click(ui.salary.hasPartialTime.non.get()); - - // vérification que l'on ne demande pas si le salaire comporte une partie de variable si salaire fixe - userAction.click(ui.salary.hasSameSalary.oui.get()); - - expect( - rendering.queryByText( - "Les salaires indiqués comportent-ils une partie variable ?" - ) - ).not.toBeInTheDocument(); - - // vérification que l'on n'affiche pas la partie variable sur le résultat - userAction.setInput(ui.salary.sameSalaryValue.get(), "2500"); - userAction.click(ui.next.get()); - - expect(ui.activeStep.query()).toHaveTextContent("Indemnité"); - expect( - rendering.queryByText( - /Les salaires indiqués comportent une partie variable/ - ) - ).not.toBeInTheDocument(); - - // vérification que l'on demande si le salaire comporte une partie de variable si salaires différents - userAction.click(ui.previous.get()); - userAction.click(ui.salary.hasSameSalary.non.get()); - - expect( - rendering.queryByText( - "Les salaires indiqués comportent-ils une partie variable ?" - ) - ).toBeInTheDocument(); - - // vérification que l'on affiche la réponse du salaire variable sur l'étape de résultat - userAction.setInput(ui.salary.salaries.getAll()[0], "2500"); - userAction.click(ui.salary.variablePart.oui.get()); - userAction.click(ui.next.get()); - - expect(ui.activeStep.query()).toHaveTextContent("Indemnité"); - expect( - rendering.queryByText( - /Les salaires indiqués comportent une partie variable/ - ) - ).toBeInTheDocument(); - }); - }); -}); diff --git a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc3127.test.tsx b/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc3127.test.tsx deleted file mode 100644 index 184e3ab82e..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc3127.test.tsx +++ /dev/null @@ -1,68 +0,0 @@ -import { render, screen } from "@testing-library/react"; -import React from "react"; -import { CalculateurIndemniteLicenciement } from "../.."; -import { ui } from "../../CommonIndemniteDepart/__tests__/ui"; -import { UserAction } from "../../../common"; - -jest.spyOn(Storage.prototype, "setItem"); -Storage.prototype.getItem = jest.fn( - () => ` -{ - "url": "https://www.legifrance.gouv.fr/affichIDCC.do?idConvention=KALICONT000005635467", - "id": "KALICONT000005635467", - "num": 3127, - "shortTitle": "Travaux publics (Tome II : Ouvriers)", - "slug": "1702-travaux-publics-tome-ii-ouvriers", - "title": "Travaux publics (Tome II : Ouvriers)" -} -` -); - -describe("Indemnité licenciement - CC 3127", () => { - let userAction: UserAction; - beforeEach(() => { - render( - - ); - userAction = new UserAction(); - - userAction - .click(ui.introduction.startButton.get()) - .click(ui.contract.type.cdi.get()) - .click(ui.contract.fauteGrave.non.get()) - .click(ui.contract.inaptitude.non.get()) - .click(ui.contract.arretTravail.non.get()) - .click(ui.next.get()) - .click(ui.next.get()); - }); - test(`Cas nominal`, () => { - userAction - .setInput(ui.seniority.startDate.get(), "01/01/2024") - .setInput(ui.seniority.notificationDate.get(), "01/01/2025") - .setInput(ui.seniority.endDate.get(), "01/12/2025") - .click(ui.seniority.hasAbsence.non.get()) - .click(ui.next.get()) - .click(ui.salary.hasPartialTime.non.get()) - .click(ui.salary.hasSameSalary.oui.get()) - .setInput(ui.salary.sameSalaryValue.get(), "2345") - .click(ui.next.get()); - - expect(ui.activeStep.query()).toHaveTextContent("Indemnité"); - expect(ui.result.resultatAgreement.get()).toHaveTextContent("898,92 €"); - - expect( - screen.queryByText( - /Depuis le 11 mars 2023 les périodes d’absence pour congé paternité ne sont plus retirées/ - ) - ).toBeInTheDocument(); - - expect(ui.result.notifications.queryAll()).toHaveLength(1); - expect(ui.result.notification(0).get()).toHaveTextContent( - "Ce montant est exonéré d’impôt sur le revenu et de cotisations sociales sous certaines conditions" - ); - }); -}); diff --git a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc3239-reset-data.test.tsx b/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc3239-reset-data.test.tsx deleted file mode 100644 index 77725af51a..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc3239-reset-data.test.tsx +++ /dev/null @@ -1,96 +0,0 @@ -import { render, screen } from "@testing-library/react"; -import React from "react"; -import { CalculateurIndemniteLicenciement } from "../index"; -import { ui } from "../../CommonIndemniteDepart/__tests__/ui"; -import userEvent from "@testing-library/user-event"; -import { UserAction } from "../../../common"; - -jest.spyOn(Storage.prototype, "setItem"); -Storage.prototype.getItem = jest.fn( - () => ` -{ - "url": "https://www.legifrance.gouv.fr/affichIDCC.do?idConvention=KALICONT000044594539", - "id": "KALICONT000044594539", - "num": 3239, - "shortTitle": "Particuliers employeurs et emploi à domicile", - "slug": "3239-particuliers-employeurs-et-emploi-a-domicile", - "title": "Particuliers employeurs et emploi à domicile" -} -` -); - -describe("Indemnité licenciement - CC 3239 - changement de convention collective", () => { - let userAction: UserAction; - beforeEach(async () => { - render( - - ); - userAction = new UserAction(); - userAction.click(ui.introduction.startButton.get()); - userAction.click(ui.contract.type.cdi.get()); - userAction.click(ui.contract.fauteGrave.non.get()); - userAction.click(ui.contract.inaptitude.non.get()); - userAction.click(ui.contract.arretTravail.non.get()); - userAction.click(ui.next.get()); - userAction.click(ui.next.get()); - userAction.setInput( - ui.information.agreement3239.proCategory.get(), - "'Salarié du particulier employeur'" - ); - userAction.click(ui.next.get()); - userAction.setInput(ui.seniority.startDate.get(), "01/01/2020"); - userAction.setInput(ui.seniority.notificationDate.get(), "15/09/2022"); - userAction.setInput(ui.seniority.endDate.get(), "15/09/2022"); - userAction.click(ui.seniority.hasAbsence.oui.get()); - userEvent.selectOptions( - ui.seniority.absences.motif(0).get(), - "Congé pour convenance personnelle" - ); - userAction.setInput(ui.seniority.absences.duration(0).get(), "6"); - userAction.click(ui.next.get()); - userAction.click(ui.salary.hasSameSalary.oui.get()); - userAction.setInput(ui.salary.sameSalaryValue.get(), "3000"); - userAction.click(ui.next.get()); - expect( - screen.queryByText("Congé pour convenance personnelle") - ).toBeInTheDocument(); - userAction.click(ui.previous.get()); - userAction.click(ui.previous.get()); - userAction.click(ui.previous.get()); - userAction.click(ui.previous.get()); - userAction.click(ui.agreement.noAgreement.get()); - userAction.click(ui.next.get()); - }); - test("vérifier que la question sur la question sur le temps partiel soit affichée et que l'absence spécifique à la 3239 a été supprimée", async () => { - expect(ui.activeStep.query()).toHaveTextContent("Ancienneté"); - expect(ui.seniority.absences.motifs.queryAll()).toHaveLength(1); - expect(ui.seniority.absences.motif(0).get()).not.toHaveValue( - "Congé pour convenance personnelle" - ); - expect(ui.seniority.absences.duration(0).get()).toHaveValue(null); - - userAction.click(ui.next.get()); - expect( - screen.queryByText("Vous devez renseigner tous les champs") - ).toBeInTheDocument(); - - userAction.setInput(ui.seniority.absences.duration(0).get(), "6"); - userAction.click(ui.next.get()); - expect(ui.activeStep.query()).toHaveTextContent("Salaires"); - expect(ui.salary.hasPartialTime.non.query()).toBeInTheDocument(); - userAction.click(ui.salary.hasPartialTime.non.get()); - userAction.click(ui.next.get()); - expect(ui.activeStep.query()).toHaveTextContent("Indemnité"); - expect(ui.result.absences.motif.queryAll()).toHaveLength(1); - expect(ui.result.absences.motif.queryAll()[0]).not.toHaveTextContent( - "Congé pour convenance personnelle" - ); - expect( - screen.queryByText(/Alternance temps plein \/ temps partiel : Non/i) - ).toBeInTheDocument(); - }); -}); diff --git a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc3239.test.tsx b/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc3239.test.tsx deleted file mode 100644 index 4e62e40816..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc3239.test.tsx +++ /dev/null @@ -1,235 +0,0 @@ -import { render, screen } from "@testing-library/react"; -import React from "react"; -import { CalculateurIndemniteLicenciement } from "../index"; -import { ui } from "../../CommonIndemniteDepart/__tests__/ui"; -import { UserAction } from "../../../common"; - -jest.spyOn(Storage.prototype, "setItem"); -Storage.prototype.getItem = jest.fn( - () => ` -{ - "url": "https://www.legifrance.gouv.fr/affichIDCC.do?idConvention=KALICONT000044594539", - "id": "KALICONT000044594539", - "num": 3239, - "shortTitle": "Particuliers employeurs et emploi à domicile", - "slug": "3239-particuliers-employeurs-et-emploi-a-domicile", - "title": "Particuliers employeurs et emploi à domicile" -} -` -); - -describe("Indemnité licenciement - CC 3239", () => { - let userAction: UserAction; - beforeEach(async () => { - render( - - ); - userAction = new UserAction(); - userAction.click(ui.introduction.startButton.get()); - userAction.click(ui.contract.type.cdi.get()); - userAction.click(ui.contract.fauteGrave.non.get()); - userAction.click(ui.contract.inaptitude.non.get()); - userAction.click(ui.contract.arretTravail.non.get()); - userAction.click(ui.next.get()); - userAction.click(ui.next.get()); - }); - test("vérifier l'ineligibilite des ass mat en cas de suspension", async () => { - userAction.changeInputList( - ui.information.agreement3239.proCategory.get(), - "'Assistant maternel'" - ); - userAction.click(ui.information.agreement3239.congeMatSuspension.oui.get()); - userAction.click(ui.next.get()); - expect( - ui.result.legalError.specific.agreement3239.suspendedNotEligible.get() - ).toBeInTheDocument(); - expect( - ui.result.infoWarning.eligibleInfoWarningblock.query() - ).not.toBeInTheDocument(); - expect( - ui.result.infoWarning.ineligibleInfoWarningblock.query() - ).not.toBeInTheDocument(); - }); - test("vérifier l'ineligibilite des ass mat pour ancienneté < 9mois", async () => { - userAction.changeInputList( - ui.information.agreement3239.proCategory.get(), - "'Assistant maternel'" - ); - userAction.click(ui.information.agreement3239.congeMatSuspension.non.get()); - userAction.setInput(ui.information.agreement3239.salaryInput.get(), "3000"); - userAction.click(ui.next.get()); - userAction.setInput(ui.seniority.startDate.get(), "01/01/2022"); - userAction.setInput(ui.seniority.notificationDate.get(), "15/09/2022"); - userAction.setInput(ui.seniority.endDate.get(), "15/09/2022"); - userAction.click(ui.seniority.hasAbsence.non.get()); - userAction.click(ui.next.get()); - expect( - ui.result.legalError.specific.agreement3239.lessThan9month.get() - ).toBeInTheDocument(); - expect( - ui.result.infoWarning.eligibleInfoWarningblock.query() - ).not.toBeInTheDocument(); - expect( - ui.result.infoWarning.ineligibleInfoWarningblock.query() - ).toBeInTheDocument(); - }); - test("vérifier l'eligibilite des autres salariés pour ancienneté compris entre 8 et 9 mois", async () => { - userAction.changeInputList( - ui.information.agreement3239.proCategory.get(), - "'Salarié du particulier employeur'" - ); - userAction.click(ui.next.get()); - userAction.setInput(ui.seniority.startDate.get(), "01/01/2022"); - userAction.setInput(ui.seniority.notificationDate.get(), "15/09/2022"); - userAction.setInput(ui.seniority.endDate.get(), "15/09/2022"); - userAction.click(ui.seniority.hasAbsence.non.get()); - userAction.click(ui.next.get()); - userAction.click(ui.salary.hasSameSalary.oui.get()); - userAction.setInput(ui.salary.sameSalaryValue.get(), "3000"); - userAction.click(ui.next.get()); - expect(ui.result.formula.get()).toHaveTextContent("Formule"); - }); - test("vérifier l'ineligibilite des autres salariés pour ancienneté < 8mois", async () => { - userAction.changeInputList( - ui.information.agreement3239.proCategory.get(), - "'Salarié du particulier employeur'" - ); - userAction.click(ui.next.get()); - userAction.setInput(ui.seniority.startDate.get(), "01/01/2022"); - userAction.setInput(ui.seniority.notificationDate.get(), "01/08/2022"); - userAction.setInput(ui.seniority.endDate.get(), "01/08/2022"); - userAction.click(ui.seniority.hasAbsence.non.get()); - userAction.click(ui.next.get()); - expect(ui.result.legalError.seniorityToLow.get()).toBeInTheDocument(); - expect( - ui.result.infoWarning.ineligibleInfoWarningblock.query() - ).toBeInTheDocument(); - }); - test("vérifier que la CC 3239 n'affecte pas les autres inéligibilités", async () => { - userAction.click(ui.previous.get()); - userAction.click(ui.previous.get()); - userAction.click(ui.contract.type.cdd.get()); - userAction.click(ui.next.get()); - expect( - ui.result.infoWarning.eligibleInfoWarningblock.query() - ).not.toBeInTheDocument(); - expect( - ui.result.infoWarning.ineligibleInfoWarningblock.query() - ).not.toBeInTheDocument(); - userAction.click(ui.previous.get()); - userAction.click(ui.contract.type.cdi.get()); - userAction.click(ui.contract.fauteGrave.oui.get()); - userAction.click(ui.next.get()); - expect( - ui.result.infoWarning.eligibleInfoWarningblock.query() - ).not.toBeInTheDocument(); - expect( - ui.result.infoWarning.ineligibleInfoWarningblock.query() - ).toBeInTheDocument(); - }); - - test("vérifier qu'on a pas la question sur le temps partiel en tant que salarié du particulier employeur", async () => { - userAction.changeInputList( - ui.information.agreement3239.proCategory.get(), - "'Salarié du particulier employeur'" - ); - userAction.click(ui.next.get()); - userAction.setInput(ui.seniority.startDate.get(), "01/01/2022"); - userAction.setInput(ui.seniority.notificationDate.get(), "15/09/2022"); - userAction.setInput(ui.seniority.endDate.get(), "15/09/2022"); - userAction.click(ui.seniority.hasAbsence.non.get()); - userAction.click(ui.next.get()); - expect( - screen.queryByText( - "Y a-t-il eu des périodes d'alternance à temps plein et à temps partiel durant le contrat de travail ?" - ) - ).not.toBeInTheDocument(); - }); - - test("vérifier qu'on affiche pas la notif sur le congé parental", async () => { - userAction.changeInputList( - ui.information.agreement3239.proCategory.get(), - "'Assistant maternel'" - ); - userAction.click(ui.information.agreement3239.congeMatSuspension.non.get()); - userAction.setInput(ui.information.agreement3239.salaryInput.get(), "3000"); - userAction.click(ui.next.get()); - userAction.setInput(ui.seniority.startDate.get(), "01/01/2000"); - userAction.setInput(ui.seniority.notificationDate.get(), "15/09/2022"); - userAction.setInput(ui.seniority.endDate.get(), "15/09/2022"); - userAction.click(ui.seniority.hasAbsence.non.get()); - userAction.click(ui.next.get()); - expect(ui.activeStep.query()).toHaveTextContent("Indemnité"); - expect( - screen.queryByText( - /Depuis le 11 mars 2023 les périodes d’absence pour congé paternité ne sont plus retirées/ - ) - ).not.toBeInTheDocument(); - }); - - test("vérifier le calcul pour un salarié du particulier employeur", async () => { - userAction.changeInputList( - ui.information.agreement3239.proCategory.get(), - "'Salarié du particulier employeur'" - ); - userAction.click(ui.next.get()); - userAction.setInput(ui.seniority.startDate.get(), "01/01/2012"); - userAction.setInput(ui.seniority.notificationDate.get(), "01/01/2024"); - userAction.setInput(ui.seniority.endDate.get(), "01/01/2024"); - userAction.click(ui.seniority.hasAbsence.non.get()); - userAction.click(ui.next.get()); - userAction.click(ui.salary.hasSameSalary.oui.get()); - userAction.setInput(ui.salary.sameSalaryValue.get(), "2100"); - userAction.click(ui.next.get()); - - expect(ui.result.resultat.get()).toHaveTextContent("6 651,92 €"); - - expect(ui.result.sources.queryAll()).toHaveLength(8); - expect(ui.result.source(0).get()).toHaveTextContent("Article 47-1"); - expect(ui.result.source(1).get()).toHaveTextContent("Article 47-2"); - expect(ui.result.source(2).get()).toHaveTextContent("Article 48-1-3-1-1"); - expect(ui.result.source(3).get()).toHaveTextContent("Article 48-1-3-4"); - expect(ui.result.source(4).get()).toHaveTextContent("Article 49"); - expect(ui.result.source(5).get()).toHaveTextContent("Article 60"); - expect(ui.result.source(6).get()).toHaveTextContent("Article 142"); - expect(ui.result.source(7).get()).toHaveTextContent("Article 163-1"); - - expect(ui.result.notifications.queryAll()).toHaveLength(1); - }); - - test("vérifier le calcul pour un assistant maternelle", async () => { - userAction.changeInputList( - ui.information.agreement3239.proCategory.get(), - "'Assistant maternel'" - ); - userAction.click(ui.information.agreement3239.congeMatSuspension.non.get()); - userAction.setInput(ui.information.agreement3239.salaryInput.get(), "5000"); - userAction.click(ui.next.get()); - userAction.setInput(ui.seniority.startDate.get(), "01/01/2020"); - userAction.setInput(ui.seniority.notificationDate.get(), "15/09/2024"); - userAction.setInput(ui.seniority.endDate.get(), "15/09/2024"); - userAction.click(ui.seniority.hasAbsence.non.get()); - userAction.click(ui.next.get()); - - expect(ui.result.resultat.get()).toHaveTextContent("62,50 €"); - - expect(ui.result.sources.queryAll()).toHaveLength(8); - expect(ui.result.source(0).get()).toHaveTextContent("Article 47-1"); - expect(ui.result.source(1).get()).toHaveTextContent("Article 47-2"); - expect(ui.result.source(2).get()).toHaveTextContent("Article 48-1-3-1-1"); - expect(ui.result.source(3).get()).toHaveTextContent("Article 48-1-3-4"); - expect(ui.result.source(4).get()).toHaveTextContent("Article 49"); - expect(ui.result.source(5).get()).toHaveTextContent("Article 60"); - expect(ui.result.source(6).get()).toHaveTextContent("Article 90-1"); - expect(ui.result.source(7).get()).toHaveTextContent("Article 121-1"); - - expect(ui.result.notifications.queryAll()).toHaveLength(2); - expect(ui.result.notification(1).get()).toHaveTextContent( - "Le retrait de l'enfant met fin au contrat de travail de l’assistant maternel" - ); - }); -}); diff --git a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc3248.test.tsx b/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc3248.test.tsx deleted file mode 100644 index 02e71291b5..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc3248.test.tsx +++ /dev/null @@ -1,99 +0,0 @@ -import { render, RenderResult } from "@testing-library/react"; -import { UserAction } from "../../../common"; -import React from "react"; -import { CalculateurIndemniteLicenciement } from "../../../../src/outils"; -import { ui } from "../../CommonIndemniteDepart/__tests__/ui"; - -jest.spyOn(Storage.prototype, "setItem"); -Storage.prototype.getItem = jest.fn( - () => ` -{ - "id": "KALICONT000046993250", - "num": 3248, - "shortTitle": "Convention collective nationale de la métallurgie", - "title": "Convention collective nationale de la métallurgie du 7 février 2022", - "url": "https://www.legifrance.gouv.fr/conv_coll/id/KALICONT000046993250", - "slug": "3248-metallurgie" -} -` -); - -describe("Indemnité licenciement - CC 3248", () => { - describe("parcours avec la convention collective pour valider ses spécificités", () => { - let rendering: RenderResult; - let userAction: UserAction; - beforeEach(() => { - rendering = render( - - ); - userAction = new UserAction(); - userAction - .click(ui.introduction.startButton.get()) - .click(ui.contract.type.cdi.get()) - .click(ui.contract.fauteGrave.non.get()) - .click(ui.contract.inaptitude.non.get()) - .click(ui.contract.arretTravail.non.get()) - .click(ui.next.get()) - .click(ui.next.get()); - }); - - test(`valider les questions`, () => { - // vérification que l'on demande si le salaire a eu des primes pour un cadre - userAction - .changeInputList( - ui.information.agreement3248.proCategory.get(), - "'A, B, C, D ou E'" - ) - .click(ui.information.agreement3248.dayContract.oui.get()) - .click(ui.information.agreement3248.alwaysDayContract.non.get()) - .setInput( - ui.information.agreement3248.dateDayContract.get(), - "01/01/2010" - ) - .click(ui.information.agreement3248.hasBeenCadre.oui.get()) - .setInput(ui.information.agreement3248.age.get(), "61") - .click(ui.information.agreement3248.retirementRight.oui.get()) - .click(ui.information.agreement3248.absencesProlongesRepetes.non.get()) - .click(ui.next.get()) - .setInput(ui.seniority.startDate.get(), "01/01/2000") - .setInput(ui.seniority.notificationDate.get(), "01/01/2023") - .setInput(ui.seniority.endDate.get(), "01/06/2023") - .click(ui.seniority.hasAbsence.non.get()) - .click(ui.next.get()); - // Validation que l'on est bien sur l'étape ancienneté - expect(ui.activeStep.query()).toHaveTextContent("Salaires"); - }); - - test(`scénario complet`, () => { - // vérification que l'on demande si le salaire a eu des primes pour un cadre - userAction - .changeInputList( - ui.information.agreement3248.proCategory.get(), - "'A, B, C, D ou E'" - ) - .click(ui.information.agreement3248.dayContract.oui.get()) - .click(ui.information.agreement3248.alwaysDayContract.oui.get()) - .click(ui.information.agreement3248.hasBeenCadre.non.get()) - .click(ui.information.agreement3248.absencesProlongesRepetes.non.get()) - .click(ui.next.get()) - .setInput(ui.seniority.startDate.get(), "01/01/2021") - .setInput(ui.seniority.notificationDate.get(), "30/06/2024") - .setInput(ui.seniority.endDate.get(), "30/06/2024") - .click(ui.seniority.hasAbsence.non.get()) - .click(ui.next.get()) - .click(ui.salary.hasPartialTime.non.get()) - .click(ui.salary.hasSameSalary.oui.get()) - .setInput(ui.salary.sameSalaryValue.get(), "2668") - .click(ui.next.get()) - .click(ui.result.resultatLegal.get()); - - expect(ui.activeStep.query()).toHaveTextContent("Indemnité"); - expect(ui.result.resultat.get()).toHaveTextContent("3 501,75"); - expect(ui.result.resultatLegal.get()).toHaveTextContent("2 334,50"); - }); - }); -}); diff --git a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc44.test.tsx b/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc44.test.tsx deleted file mode 100644 index ae11f791db..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc44.test.tsx +++ /dev/null @@ -1,287 +0,0 @@ -import { render, screen } from "@testing-library/react"; -import React from "react"; -import { CalculateurIndemniteLicenciement } from "../../../../src/outils"; -import { ui } from "../../CommonIndemniteDepart/__tests__/ui"; -import { UserAction } from "../../../common"; - -jest.spyOn(Storage.prototype, "setItem"); -Storage.prototype.getItem = jest.fn( - () => ` -{ - "url":"https://www.legifrance.gouv.fr/affichIDCC.do?idConvention=KALICONT000005635613", - "id":"KALICONT000005635613", - "num":44, - "shortTitle":"Industries chimiques et connexes", - "slug":"44-industries-chimiques-et-connexes","title":"Industries chimiques et connexes"} -` -); - -describe("Indemnité licenciement - CC 44", () => { - let userAction: UserAction; - describe("parcours avec la convention collective pour valider ses spécificités AVEC PREAVIS", () => { - beforeEach(() => { - render( - - ); - userAction = new UserAction(); - userAction.click(ui.introduction.startButton.get()); - userAction.click(ui.contract.type.cdi.get()); - userAction.click(ui.contract.fauteGrave.non.get()); - userAction.click(ui.contract.inaptitude.non.get()); - userAction.click(ui.contract.arretTravail.non.get()); - userAction.click(ui.next.get()); - userAction.click(ui.next.get()); - userAction.changeInputList( - ui.information.agreement44.proCategory.get(), - "Ouvriers et collaborateurs (Groupes I à III)" - ); - userAction.setInput(ui.information.agreement44.age.get(), "38"); - userAction.click(ui.next.get()); - userAction.setInput(ui.seniority.startDate.get(), "01/01/2000"); - userAction.setInput(ui.seniority.notificationDate.get(), "01/01/2022"); - userAction.setInput(ui.seniority.endDate.get(), "01/03/2022"); - userAction.click(ui.seniority.hasAbsence.non.get()); - userAction.click(ui.next.get()); - // Validation que l'on est bien sur l'étape ancienneté - expect(ui.activeStep.query()).toHaveTextContent("Salaires"); - }); - - test(` - - vérification que l'on demande si le salaire a eu des primes pour un Ouvriers et collaborateurs (Groupes I à III) - - vérification que l'on demande si le salaire a eu des primes pour un Agents de maîtrise et techniciens (Groupe IV) - - vérification que l'on ne demande pas si le salaire a eu des primes pour un Ingénieurs et cadres (Groupe V) - `, () => { - // vérification que l'on demande si le salaire a eu des primes pour un Ouvriers et collaborateurs (Groupes I à III) - userAction.click(ui.salary.hasPartialTime.non.get()); - userAction.click(ui.salary.hasSameSalary.oui.get()); - expect( - screen.queryByText( - "Les salaires indiqués comportent-ils une partie variable ?" - ) - ).not.toBeInTheDocument(); - userAction.click(ui.salary.hasSameSalary.non.get()); - expect( - screen.queryByText( - "Les salaires indiqués comportent-ils une partie variable ?" - ) - ).toBeInTheDocument(); - - // vérification que l'on demande si le salaire a eu des primes pour un Agents de maîtrise et techniciens (Groupe IV) - userAction.click(ui.previous.get()); - userAction.click(ui.previous.get()); - userAction.changeInputList( - ui.information.agreement44.proCategory.get(), - "Agents de maîtrise et techniciens (Groupe IV)" - ); - userAction.setInput(ui.information.agreement44.age.get(), "36"); - userAction.click(ui.next.get()); - userAction.click(ui.next.get()); - userAction.click(ui.salary.hasSameSalary.oui.get()); - expect( - screen.queryByText( - "Les salaires indiqués comportent-ils une partie variable ?" - ) - ).not.toBeInTheDocument(); - userAction.click(ui.salary.hasSameSalary.non.get()); - expect( - screen.queryByText( - "Les salaires indiqués comportent-ils une partie variable ?" - ) - ).toBeInTheDocument(); - - // vérification que l'on demande si le salaire a eu des primes pour un Ingénieurs et cadres (Groupe V) - userAction.click(ui.previous.get()); - userAction.click(ui.previous.get()); - userAction.changeInputList( - ui.information.agreement44.proCategory.get(), - "Ingénieurs et cadres (Groupe V)" - ); - userAction.setInput(ui.information.agreement44.age.get(), "36"); - userAction.click(ui.next.get()); - userAction.click(ui.next.get()); - userAction.click(ui.salary.hasSameSalary.oui.get()); - - expect( - screen.queryByText( - "Les salaires indiqués comportent-ils une partie variable ?" - ) - ).not.toBeInTheDocument(); - userAction.click(ui.salary.hasSameSalary.non.get()); - expect( - screen.queryByText( - "Les salaires indiqués comportent-ils une partie variable ?" - ) - ).not.toBeInTheDocument(); - }); - - test(`Ajout des questions supplémentaires pour le dernier salaire`, () => { - // vérification que l'on demande si le salaire a eu des primes pour un Ouvriers et collaborateurs (Groupes I à III) - userAction.click(ui.salary.hasPartialTime.non.get()); - userAction.click(ui.salary.hasSameSalary.non.get()); - userAction.click(ui.salary.variablePart.non.get()); - expect( - screen.queryByText( - "Connaissez-vous le montant du dernier salaire perçu (préavis inclus) ?" - ) - ).toBeInTheDocument(); - userAction.click(ui.salary.agreement44.knowingLastSalary.oui.get()); - expect( - screen.queryByText("Salaire et primes perçus au cours du dernier mois") - ).toBeInTheDocument(); - userAction.setInput(ui.salary.agreement44.salaries.get(), "2500"); - userAction.setInput(ui.salary.agreement44.primes.get(), "500"); - userAction.click(ui.next.get()); - }); - }); - - describe("parcours avec la convention collective pour valider ses spécificités SANS PREAVIS", () => { - beforeEach(() => { - render( - - ); - userAction = new UserAction(); - userAction.click(ui.introduction.startButton.get()); - userAction.click(ui.contract.type.cdi.get()); - userAction.click(ui.contract.fauteGrave.non.get()); - userAction.click(ui.contract.inaptitude.non.get()); - userAction.click(ui.contract.arretTravail.non.get()); - userAction.click(ui.next.get()); - userAction.click(ui.next.get()); - userAction.changeInputList( - ui.information.agreement44.proCategory.get(), - "Ouvriers et collaborateurs (Groupes I à III)" - ); - userAction.setInput(ui.information.agreement44.age.get(), "40"); - userAction.click(ui.next.get()); - userAction.setInput(ui.seniority.startDate.get(), "01/01/2000"); - userAction.setInput(ui.seniority.notificationDate.get(), "01/01/2023"); - userAction.setInput(ui.seniority.endDate.get(), "01/01/2023"); - userAction.click(ui.seniority.hasAbsence.non.get()); - userAction.click(ui.next.get()); - // Validation que l'on est bien sur l'étape ancienneté - expect(ui.activeStep.query()).toHaveTextContent("Salaires"); - }); - - test("Vérification que la cc est privilégié grâce à un salaire de référence conventionnel import", () => { - userAction.click(ui.salary.hasPartialTime.non.get()); - userAction.click(ui.salary.hasSameSalary.non.get()); - userAction.setInput(ui.salary.salaries.getAll()[0], "10000"); - userAction.setInput(ui.salary.salaries.getAll()[1], "1000"); - userAction.setInput(ui.salary.salaries.getAll()[2], "1000"); - userAction.setInput(ui.salary.salaries.getAll()[3], "1000"); - userAction.setInput(ui.salary.salaries.getAll()[4], "1000"); - userAction.setInput(ui.salary.salaries.getAll()[5], "1000"); - userAction.setInput(ui.salary.salaries.getAll()[6], "1000"); - userAction.setInput(ui.salary.salaries.getAll()[7], "1000"); - userAction.setInput(ui.salary.salaries.getAll()[8], "1000"); - userAction.setInput(ui.salary.salaries.getAll()[9], "1000"); - userAction.setInput(ui.salary.salaries.getAll()[10], "1000"); - userAction.setInput(ui.salary.salaries.getAll()[11], "1000"); - userAction.click(ui.salary.variablePart.non.get()); - userAction.click(ui.next.get()); - expect(ui.activeStep.query()).toHaveTextContent("Indemnité"); - expect(ui.result.resultat.get()).toHaveTextContent("69 000,00 €"); - }); - }); - - describe("parcours avec une date d'arrêt", () => { - beforeEach(() => { - render( - - ); - userAction = new UserAction(); - }); - - test(`ne doit pas afficher la question sur le salaire pour le dernier mois`, () => { - userAction.click(ui.introduction.startButton.get()); - userAction.click(ui.contract.type.cdi.get()); - userAction.click(ui.contract.fauteGrave.non.get()); - userAction.click(ui.contract.inaptitude.non.get()); - userAction.click(ui.contract.arretTravail.oui.get()); - userAction.setInput(ui.contract.dateArretTravail.get(), "01/09/2022"); - userAction.click(ui.next.get()); - userAction.click(ui.next.get()); - userAction.changeInputList( - ui.information.agreement44.proCategory.get(), - "Ouvriers et collaborateurs (Groupes I à III)" - ); - userAction.setInput(ui.information.agreement44.age.get(), "38"); - userAction.click(ui.next.get()); - userAction.setInput(ui.seniority.startDate.get(), "01/01/2000"); - userAction.setInput(ui.seniority.notificationDate.get(), "01/01/2023"); - userAction.setInput(ui.seniority.endDate.get(), "01/03/2023"); - userAction.click(ui.seniority.hasAbsence.non.get()); - userAction.click(ui.next.get()); - userAction.click(ui.salary.hasPartialTime.non.get()); - userAction.click(ui.salary.hasSameSalary.non.get()); - userAction.click(ui.salary.variablePart.non.get()); - expect( - screen.queryByText( - "Connaissez-vous le montant du dernier salaire perçu (préavis inclus) ?" - ) - ).not.toBeInTheDocument(); - }); - }); - - test("parcours avec la convention collective pour valider le résultat", () => { - render( - - ); - const userAction = new UserAction(); - userAction - .click(ui.introduction.startButton.get()) - .click(ui.contract.type.cdi.get()) - .click(ui.contract.fauteGrave.non.get()) - .click(ui.contract.inaptitude.non.get()) - .click(ui.contract.arretTravail.non.get()) - .click(ui.next.get()) - .click(ui.next.get()) - .changeInputList( - ui.information.agreement44.proCategory.get(), - "Ouvriers et collaborateurs (Groupes I à III)" - ) - .setInput(ui.information.agreement44.age.get(), "57") - .click(ui.next.get()) - .setInput(ui.seniority.startDate.get(), "01/01/2019") - .setInput(ui.seniority.notificationDate.get(), "01/01/2024") - .setInput(ui.seniority.endDate.get(), "01/01/2024") - .click(ui.seniority.hasAbsence.non.get()) - .click(ui.next.get()) - .click(ui.salary.hasPartialTime.non.get()) - .click(ui.salary.hasSameSalary.non.get()) - .setInput(ui.salary.salaries.getAll()[0], "3541") - .setInput(ui.salary.salaries.getAll()[1], "3555") - .setInput(ui.salary.salaries.getAll()[2], "3512") - .setInput(ui.salary.salaries.getAll()[3], "3596") - .setInput(ui.salary.salaries.getAll()[4], "3310") - .setInput(ui.salary.salaries.getAll()[5], "3554") - .setInput(ui.salary.salaries.getAll()[6], "3560") - .setInput(ui.salary.salaries.getAll()[7], "3330") - .setInput(ui.salary.salaries.getAll()[8], "3530") - .setInput(ui.salary.salaries.getAll()[9], "3510") - .setInput(ui.salary.salaries.getAll()[10], "3580") - .setInput(ui.salary.salaries.getAll()[11], "3362") - .click(ui.salary.variablePart.oui.get()) - .click(ui.next.get()); - - expect(ui.activeStep.query()).toHaveTextContent("Indemnité"); - expect(ui.result.resultat.get()).toHaveTextContent("12 232,50"); - expect(ui.result.resultatAgreement.get()).toHaveTextContent("12 232,50"); - }); -}); diff --git a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc573.test.tsx b/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc573.test.tsx deleted file mode 100644 index 216dfcbe34..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc573.test.tsx +++ /dev/null @@ -1,67 +0,0 @@ -import { fireEvent, render, RenderResult } from "@testing-library/react"; -import React from "react"; -import { CalculateurIndemniteLicenciement } from "../.."; -import { ui } from "../../CommonIndemniteDepart/__tests__/ui"; -import { UserAction } from "../../../common"; - -jest.spyOn(Storage.prototype, "setItem"); -Storage.prototype.getItem = jest.fn( - () => ` -{ - "url": "https://www.legifrance.gouv.fr/affichIDCC.do?idConvention=KALICONT000005635373", - "id": "0573", - "num": 573, - "shortTitle": "Commerces de gros", - "slug": "573-commerces-de-gros", - "title": "Convention collective nationale de commerces de gros du 23 juin 1970. Etendue par arrêté du 15 juin 1972 JONC 29 août 1972. Mise à jour par accord du 27 septembre 1984 étendu par arrêté du 4 février 1985 JORF 16 février 1985." -} -` -); - -describe("Indemnité licenciement - CC 573", () => { - let rendering: RenderResult; - let userAction: UserAction; - beforeEach(() => { - rendering = render( - - ); - userAction = new UserAction(); - - userAction - .click(ui.introduction.startButton.get()) - .click(ui.contract.type.cdi.get()) - .click(ui.contract.fauteGrave.non.get()) - .click(ui.contract.inaptitude.non.get()) - .click(ui.contract.arretTravail.non.get()) - .click(ui.next.get()) - .click(ui.next.get()); - }); - test(`Cas nominal`, () => { - userAction - .changeInputList( - ui.information.agreement573.proCategory.get(), - "Agents de maîtrise, techniciens et assimilés" - ) - .click(ui.information.agreement573.eco.oui.get()) - .setInput(ui.information.agreement573.age.get(), "57") - .click(ui.next.get()) - - .setInput(ui.seniority.startDate.get(), "01/01/2010") - .setInput(ui.seniority.notificationDate.get(), "01/01/2024") - .setInput(ui.seniority.endDate.get(), "01/01/2024") - .click(ui.seniority.hasAbsence.non.get()) - .click(ui.next.get()) - .click(ui.salary.hasPartialTime.non.get()) - .click(ui.salary.hasSameSalary.oui.get()) - .setInput(ui.salary.sameSalaryValue.get(), "2700") - .click(ui.next.get()); - - expect(ui.activeStep.query()).toHaveTextContent("Indemnité"); - expect(ui.result.resultat.get()).toHaveTextContent("10 350,00 €"); - expect(ui.result.resultatAgreement.get()).toHaveTextContent("9 000,00 €"); - }); -}); diff --git a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc675.test.tsx b/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc675.test.tsx deleted file mode 100644 index 18d9e0ca89..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc675.test.tsx +++ /dev/null @@ -1,61 +0,0 @@ -import { fireEvent, render } from "@testing-library/react"; -import React from "react"; -import { CalculateurIndemniteLicenciement } from "../../../../src/outils"; -import { ui } from "../../CommonIndemniteDepart/__tests__/ui"; -import { UserAction } from "../../../common"; - -jest.spyOn(Storage.prototype, "setItem"); -Storage.prototype.getItem = jest.fn( - () => ` - { - "url": "https://www.legifrance.gouv.fr/affichIDCC.do?idConvention=KALICONT000005635617", - "id": "0675", - "num": 675, - "shortTitle": "Maisons à succursales de vente au détail d'habillement", - "slug": "675-maisons-a-succursales-de-vente-au-detail-dhabillement", - "title": "Convention collective nationale des maisons à succursales de vente au détail d'habillement du 30 juin 1972. Etendue par arrêté du 8 décembre 1972 (JO du 7 janvier 1973).", - "contributions": true - } -` -); - -describe("Indemnité licenciement - CC 675", () => { - let userAction: UserAction; - test("cas spécifique", () => { - render( - - ); - userAction = new UserAction(); - userAction.click(ui.introduction.startButton.get()); - userAction.click(ui.contract.type.cdi.get()); - userAction.click(ui.contract.fauteGrave.non.get()); - userAction.click(ui.contract.inaptitude.non.get()); - userAction.click(ui.contract.arretTravail.non.get()); - userAction.click(ui.next.get()); - userAction.click(ui.next.get()); - userAction.click(ui.next.get()); - userAction.click(ui.next.get()); - userAction.changeInputList( - ui.information.agreement675.proCategory.get(), - "'Employés'" - ); - fireEvent.click(ui.next.get()); - userAction.setInput(ui.seniority.startDate.get(), "01/01/2021"); - userAction.setInput(ui.seniority.notificationDate.get(), "01/01/2024"); - userAction.setInput(ui.seniority.endDate.get(), "01/01/2024"); - fireEvent.click(ui.seniority.hasAbsence.non.get()); - fireEvent.click(ui.next.get()); - fireEvent.click(ui.salary.hasPartialTime.non.get()); - fireEvent.click(ui.salary.hasSameSalary.oui.get()); - userAction.setInput(ui.salary.sameSalaryValue.get(), "1488"); - fireEvent.click(ui.next.get()); - - expect(ui.activeStep.query()).toHaveTextContent("Indemnité"); - expect(ui.result.resultatAgreement.get()).toHaveTextContent("446,40"); - expect(ui.result.resultat.get()).toHaveTextContent("1 116,00"); - }); -}); diff --git a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc86.test.tsx b/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc86.test.tsx deleted file mode 100644 index 8ae83bf534..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/cc86.test.tsx +++ /dev/null @@ -1,59 +0,0 @@ -import { render } from "@testing-library/react"; -import React from "react"; -import { CalculateurIndemniteLicenciement } from "../../../../src/outils"; -import { ui } from "../../CommonIndemniteDepart/__tests__/ui"; -import { UserAction } from "../../../common"; - -jest.spyOn(Storage.prototype, "setItem"); -Storage.prototype.getItem = jest.fn( - () => ` - { - "effectif": 75306, - "cdtnId": "27bbafda66", - "num": 86, - "shortTitle": "Entreprises de la publicité et assimilées", - "id": "KALICONT000005635630", - "title": "Entreprises de la publicité et assimilées", - "url": "https://www.legifrance.gouv.fr/affichIDCC.do?idConvention=KALICONT000005635630", - "slug": "86-entreprises-de-la-publicite-et-assimilees" - } -` -); - -describe("Indemnité licenciement - CC 86", () => { - let userAction: UserAction; - beforeEach(() => { - render( - - ); - userAction = new UserAction(); - }); - - test(`Vérification du fait que le salaire de reference est bien celui issu de la formule de calcul de l'indemnité`, () => { - userAction.click(ui.introduction.startButton.get()); - userAction.click(ui.contract.type.cdi.get()); - userAction.click(ui.contract.fauteGrave.non.get()); - userAction.click(ui.contract.inaptitude.non.get()); - userAction.click(ui.contract.arretTravail.non.get()); - userAction.click(ui.next.get()); - userAction.click(ui.next.get()); - userAction.setInput(ui.seniority.startDate.get(), "01/01/2000"); - userAction.setInput(ui.seniority.notificationDate.get(), "01/01/2022"); - userAction.setInput(ui.seniority.endDate.get(), "01/03/2022"); - userAction.click(ui.seniority.hasAbsence.non.get()); - userAction.click(ui.next.get()); - userAction.click(ui.salary.hasPartialTime.non.get()); - userAction.click(ui.salary.hasSameSalary.non.get()); - userAction.setInput(ui.salary.salaries.getAll()[0], "2500"); - userAction.setInput(ui.salary.salaries.getAll()[0], "25000"); - userAction.click(ui.next.get()); - expect(ui.result.formula.get()).toHaveTextContent("Formule"); - expect(ui.result.formula.get()).toHaveTextContent( - "Sref : Salaire de référence (25000 €)" - ); - }); -}); diff --git a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/eligibility-error-result.test.tsx b/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/eligibility-error-result.test.tsx deleted file mode 100644 index e27e2a346f..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/eligibility-error-result.test.tsx +++ /dev/null @@ -1,138 +0,0 @@ -import { CalculateurIndemniteLicenciement } from "../.."; -import { ui } from "../../CommonIndemniteDepart/__tests__/ui"; - -import { render, fireEvent } from "@testing-library/react"; -import userEvent from "@testing-library/user-event"; -import { UserAction } from "../../../common"; - -jest.spyOn(Storage.prototype, "setItem"); -Storage.prototype.getItem = jest.fn( - () => ` -{ - "num": 16, - "shortTitle": "Transports routiers et activités auxiliaires du transport", - "id": "KALICONT000005635624", - "title": "Transports routiers et activités auxiliaires du transport", - "url": "https://www.legifrance.gouv.fr/affichIDCC.do?idConvention=KALICONT000005635624", - "slug": "16-transports-routiers-et-activites-auxiliaires-du-transport" -} -` -); - -describe(`Tests des erreurs d'éligibilité`, () => { - let userAction = new UserAction(); - beforeEach(() => { - render( - - ); - userAction.click(ui.introduction.startButton.get()); - }); - - test("Vérifier l'affichage de l'erreur légal cdd", () => { - userAction - .click(ui.contract.type.cdi.get()) - .click(ui.next.get()) - .click(ui.contract.type.cdd.get()) - .click(ui.next.get()); - expect(ui.result.legalError.cddLicenciement.query()).toBeInTheDocument(); - expect( - ui.result.infoWarning.eligibleInfoWarningblock.query() - ).not.toBeInTheDocument(); - expect( - ui.result.infoWarning.ineligibleInfoWarningblock.query() - ).not.toBeInTheDocument(); - }); - - test("Vérifier l'affichage de l'erreur légal faute grave", () => { - userAction - .click(ui.contract.type.cdi.get()) - .click(ui.contract.fauteGrave.non.get()) - .click(ui.next.get()) - .click(ui.contract.fauteGrave.oui.get()) - .click(ui.next.get()); - expect( - ui.result.infoWarning.eligibleInfoWarningblock.query() - ).not.toBeInTheDocument(); - expect(ui.result.infoWarning.title.ineligible.query()).toBeInTheDocument(); - expect(ui.result.legalError.fauteGrave.query()).toBeInTheDocument(); - expect(ui.result.infoWarning.message.mayBeCC.query()).toBeInTheDocument(); - }); - - test("Vérifier l'affichage de l'erreur ancienneté < 8 mois", () => { - userAction - .click(ui.contract.type.cdi.get()) - .click(ui.contract.fauteGrave.non.get()) - .click(ui.contract.inaptitude.non.get()) - .click(ui.contract.arretTravail.non.get()) - .click(ui.next.get()) - .click(ui.next.get()) - .changeInputList( - ui.information.agreement16.proCategory.get(), - "Ingénieurs et cadres" - ) - .click(ui.information.agreement16.proCategoryHasChanged.oui.get()) - .setInput( - ui.information.agreement16.dateProCategoryChanged.get(), - "01/01/2010" - ) - .setInput(ui.information.agreement16.engineerAge.get(), "38") - .click(ui.next.get()) - .setInput(ui.seniority.startDate.get(), "01/09/2021") - .setInput(ui.seniority.notificationDate.get(), "01/01/2022") - .click(ui.seniority.hasAbsence.non.get()) - .setInput(ui.seniority.endDate.get(), "01/01/2022") - .click(ui.next.get()); - expect( - ui.result.infoWarning.eligibleInfoWarningblock.query() - ).not.toBeInTheDocument(); - expect(ui.result.infoWarning.title.ineligible.query()).toBeInTheDocument(); - expect(ui.result.legalError.seniorityToLow.query()).toBeInTheDocument(); - expect( - ui.result.infoWarning.message.maybeFirmAgreement.query() - ).toBeInTheDocument(); - }); - - test("Vérifier l'affichage de l'erreur ancienneté < 8 mois quand on revient changer la date de notification", () => { - userAction - .click(ui.contract.type.cdi.get()) - .click(ui.contract.fauteGrave.non.get()) - .click(ui.contract.inaptitude.non.get()) - .click(ui.contract.arretTravail.non.get()) - .click(ui.next.get()) - .click(ui.next.get()) - .changeInputList( - ui.information.agreement16.proCategory.get(), - "Ingénieurs et cadres" - ) - .click(ui.information.agreement16.proCategoryHasChanged.non.get()) - .setInput(ui.information.agreement16.engineerAge.get(), "38") - .click(ui.next.get()) - .setInput(ui.seniority.startDate.get(), "01/01/2024") - .setInput(ui.seniority.notificationDate.get(), "01/10/2024") - .setInput(ui.seniority.endDate.get(), "01/12/2024") - .click(ui.seniority.hasAbsence.non.get()) - .click(ui.next.get()) - .click(ui.salary.hasPartialTime.non.get()) - .click(ui.salary.hasSameSalary.oui.get()) - .setInput(ui.salary.sameSalaryValue.get(), "2000") - .click(ui.next.get()); - expect(ui.activeStep.get()).toHaveTextContent("Indemnité"); - userAction - .click(ui.previous.get()) - .click(ui.previous.get()) - .setInput(ui.seniority.notificationDate.get(), "01/08/2024") - .click(ui.next.get()); - expect( - ui.result.infoWarning.eligibleInfoWarningblock.query() - ).not.toBeInTheDocument(); - expect(ui.result.infoWarning.title.ineligible.query()).toBeInTheDocument(); - expect(ui.result.legalError.seniorityToLow.query()).toBeInTheDocument(); - expect( - ui.result.infoWarning.message.maybeFirmAgreement.query() - ).toBeInTheDocument(); - }); -}); diff --git "a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/incrementation-1-jour-anciennet\303\251.test.tsx" "b/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/incrementation-1-jour-anciennet\303\251.test.tsx" deleted file mode 100644 index 89b997c9b8..0000000000 --- "a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/incrementation-1-jour-anciennet\303\251.test.tsx" +++ /dev/null @@ -1,41 +0,0 @@ -import { render } from "@testing-library/react"; -import React from "react"; -import { CalculateurIndemniteLicenciement } from "../../../../src/outils"; -import { ui } from "../../CommonIndemniteDepart/__tests__/ui"; -import { UserAction } from "../../../common"; - -jest.mock("../../../conventions/Search/api/agreements.service"); -jest.mock("../../../conventions/Search/api/enterprises.service"); - -describe("Page salaire: vérification l'affichage des salaires mensuels", () => { - test("should show 12 month", async () => { - const { getByText } = render( - - ); - const userAction = new UserAction(); - userAction.click(ui.introduction.startButton.get()); - userAction.click(ui.contract.type.cdi.get()); - userAction.click(ui.contract.fauteGrave.non.get()); - userAction.click(ui.contract.inaptitude.non.get()); - userAction.click(ui.contract.arretTravail.non.get()); - userAction.click(ui.next.get()); - userAction.click(ui.agreement.noAgreement.get()); - userAction.click(ui.next.get()); - userAction.setInput(ui.seniority.startDate.get(), "01/01/2022"); - userAction.setInput(ui.seniority.notificationDate.get(), "31/12/2022"); - userAction.setInput(ui.seniority.endDate.get(), "31/12/2022"); - - userAction.click(ui.seniority.hasAbsence.non.get()); - userAction.click(ui.next.get()); - userAction.click(ui.salary.hasPartialTime.non.get()); - userAction.click(ui.salary.hasSameSalary.non.get()); - expect( - getByText(/Salaires mensuels bruts des 12 derniers mois/) - ).toBeInTheDocument(); - expect(getByText(/décembre 2022/)).toBeInTheDocument(); - }); -}); diff --git a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/indemnite-licenciement-cc-select.test.tsx b/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/indemnite-licenciement-cc-select.test.tsx deleted file mode 100644 index 409ca08a94..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/indemnite-licenciement-cc-select.test.tsx +++ /dev/null @@ -1,68 +0,0 @@ -import { CalculateurIndemniteLicenciement } from "../index"; -import { ui } from "../../CommonIndemniteDepart/__tests__/ui"; - -import { fireEvent, render, waitFor } from "@testing-library/react"; -import { UserAction } from "../../../common"; - -jest.mock("../../../conventions/Search/api/agreements.service"); -jest.mock("../../../conventions/Search/api/enterprises.service"); - -describe("Indemnité licenciement - Sélection de CC", () => { - beforeEach(() => { - render( - - ); - fireEvent.click(ui.introduction.startButton.get()); - fireEvent.click(ui.contract.type.cdi.get()); - fireEvent.click(ui.contract.fauteGrave.non.get()); - fireEvent.click(ui.contract.inaptitude.non.get()); - fireEvent.click(ui.contract.arretTravail.non.get()); - fireEvent.click(ui.next.get()); - }); - test("Vérifier la recherche par cc", async () => { - const userAction = new UserAction(); - - userAction - .click(ui.agreement.agreement.get()) - .setInput(ui.agreement.agreementInput.get(), "16") - .click(await waitFor(() => ui.agreement.ccChoice.transport.get())) - .click(ui.next.get()); - - fireEvent.click(ui.previous.get()); - expect(ui.agreement.agreementInputConfirm.query()).toBeInTheDocument(); - expect(ui.agreement.searchItem.agreement16.query()).toBeInTheDocument(); - }); - test("Vérifier la recherche par entreprise", async () => { - fireEvent.click(ui.agreement.unknownAgreement.get()); - expect(ui.agreement.agreementCompanyInputAsk.query()).toBeInTheDocument(); - expect(ui.agreement.agreementCompanyInput.query()).toBeInTheDocument(); - expect(ui.agreement.agreementPostalCodeInput.query()).toBeInTheDocument(); - fireEvent.change(ui.agreement.agreementCompanyInput.get(), { - target: { value: "carrefour" }, - }); - fireEvent.click(ui.agreement.agreementCompanySearchButton.get()); - await waitFor(() => { - fireEvent.click(ui.agreement.searchItem.carrefour.get()); - }); - expect( - ui.agreement.agreementCompanyInputConfirm.query() - ).toBeInTheDocument(); - expect(ui.agreement.ccChoice.commerce.query()).toBeInTheDocument(); - expect(ui.agreement.ccChoice.bureau.query()).toBeInTheDocument(); - fireEvent.click(ui.agreement.ccChoice.commerce.get()); - fireEvent.click(ui.next.get()); - fireEvent.click(ui.previous.get()); - expect( - ui.agreement.agreementCompanyInputConfirm.query() - ).toBeInTheDocument(); - expect(ui.agreement.searchItem.carrefour.query()).toBeInTheDocument(); - }); - test("Vérifier la non sélection d'une cc", () => { - fireEvent.click(ui.agreement.noAgreement.get()); - expect(ui.warning.query()).toBeInTheDocument(); - }); -}); diff --git a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/indemnite-licenciement-contract.test.tsx b/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/indemnite-licenciement-contract.test.tsx deleted file mode 100644 index b36cc05116..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/indemnite-licenciement-contract.test.tsx +++ /dev/null @@ -1,47 +0,0 @@ -import { CalculateurIndemniteLicenciement } from "../../../../src/outils"; -import { UserAction } from "../../../common"; -import { ui } from "../../CommonIndemniteDepart/__tests__/ui"; - -import { render } from "@testing-library/react"; - -test(` - - Vérifier l'affichage de l'intro - - Vérifier l'affichage de la question type contrat - - Vérifier l'affichage de la question faute grave - - Vérifier l'affichage de la question inaptitude -`, async () => { - await render( - - ); - const userAction = new UserAction(); - - // Vérifier l'affichage de l'intro - expect(ui.introduction.startButton.query()).toBeInTheDocument(); - userAction.click(ui.introduction.startButton.get()); - - // Vérifier l'affichage de la question type contrat - expect(ui.contract.type.question.query()).toBeInTheDocument(); - expect(ui.contract.type.cdi.query()).toBeInTheDocument(); - expect(ui.contract.type.cdd.query()).toBeInTheDocument(); - expect(ui.contract.fauteGrave.question.query()).not.toBeInTheDocument(); - expect(ui.contract.fauteGrave.oui.query()).not.toBeInTheDocument(); - expect(ui.contract.fauteGrave.non.query()).not.toBeInTheDocument(); - expect(ui.contract.inaptitude.question.query()).not.toBeInTheDocument(); - expect(ui.contract.inaptitude.oui.query()).not.toBeInTheDocument(); - expect(ui.contract.inaptitude.non.query()).not.toBeInTheDocument(); - userAction.click(ui.contract.type.cdi.get()); - - // Vérifier l'affichage de la question faute grave - expect(ui.contract.fauteGrave.question.query()).toBeInTheDocument(); - expect(ui.contract.fauteGrave.oui.query()).toBeInTheDocument(); - expect(ui.contract.fauteGrave.non.query()).toBeInTheDocument(); - expect(ui.contract.inaptitude.question.query()).not.toBeInTheDocument(); - expect(ui.contract.inaptitude.oui.query()).not.toBeInTheDocument(); - expect(ui.contract.inaptitude.non.query()).not.toBeInTheDocument(); - userAction.click(ui.contract.fauteGrave.non.get()); - - // Vérifier l'affichage de la question inaptitude - expect(ui.contract.inaptitude.question.query()).toBeInTheDocument(); - expect(ui.contract.inaptitude.oui.query()).toBeInTheDocument(); - expect(ui.contract.inaptitude.non.query()).toBeInTheDocument(); -}); diff --git a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/information.test.tsx b/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/information.test.tsx deleted file mode 100644 index 87840aa05c..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/information.test.tsx +++ /dev/null @@ -1,212 +0,0 @@ -import { render, RenderResult, waitFor } from "@testing-library/react"; -import { UserAction } from "../../../common"; -import React from "react"; -import { CalculateurIndemniteLicenciement } from "../index"; -import { ui } from "../../CommonIndemniteDepart/__tests__/ui"; - -jest.spyOn(Storage.prototype, "setItem"); -Storage.prototype.getItem = jest.fn( - () => ` -{ - "num": 16, - "shortTitle": "Transports routiers et activités auxiliaires du transport", - "id": "KALICONT000005635624", - "title": "Transports routiers et activités auxiliaires du transport", - "url": "https://www.legifrance.gouv.fr/affichIDCC.do?idConvention=KALICONT000005635624", - "slug": "16-transports-routiers-et-activites-auxiliaires-du-transport" -} -` -); - -global.fetch = jest.fn(() => - Promise.resolve({ - ok: true, - json: () => - Promise.resolve({ - hits: { - hits: [ - { - _source: { - effectif: 1173, - highlight: { - searchInfo: - "(anciennement conventions collectives “Assistants maternels du particulier employeur” IDCC 2395 et “Salariés du particulier employeur” IDCC 2111).", - title: - "À noter : les informations données sur cette page sont applicables depuis le 01/01/2022", - content: - "Cette convention collective est entrée en vigueur au 01/01/2022 suite à la fusion des conventions collectives “Salariés du particulier employeur (IDCC 2111)” et “Assistants maternels du particulier employeur (IDCC 2395)” qui étaient applicables jusqu’au 31/12/2021.", - }, - cdtnId: "d825ef1df2", - num: 3239, - shortTitle: "Particuliers employeurs et emploi à domicile", - id: "KALICONT000044594539", - title: "Particuliers employeurs et emploi à domicile", - slug: "3239-particuliers-employeurs-et-emploi-a-domicile", - url: "https://www.legifrance.gouv.fr/affichIDCC.do?idConvention=KALICONT000044594539", - }, - }, - ], - }, - }), - }) -) as jest.Mock; - -describe("Indemnité licenciement - Validation de la page information", () => { - describe("parcours avec la convention collective 16 pour valider les erreurs", () => { - let rendering: RenderResult; - let userAction: UserAction; - beforeEach(async () => { - rendering = await render( - - ); - userAction = new UserAction(); - userAction - .click(ui.introduction.startButton.get()) - .click(ui.contract.type.cdi.get()) - .click(ui.contract.fauteGrave.non.get()) - .click(ui.contract.inaptitude.non.get()) - .click(ui.contract.arretTravail.non.get()) - .click(ui.next.get()) - .click(ui.next.get()); - // Validation que l'on est bien sur l'étape ancienneté - expect(ui.activeStep.query()).toHaveTextContent("Informations"); - }); - - test(` - - validation que la première question est affichée - - validation des erreurs sur les champs vides - - validation que le champ suivant s'affiche quand on répond à la question - - validation que les champs sont retirés quand on revient à une question précédente - - validation qu'un champ présent avant soit réinitialisé - - validation que l'on peut valider la page quand tous les champs sont saisis - - validation que l'on n'affiche pas la question suivante tant que la date n'est pas valide - - validation que les infos sont gardées quand on revient sur les étapes précédentes sans changer les infos - - validation que les infos sont effacées quand on change de convention collective - `, async () => { - // validation que la première question est affichée - expect( - rendering.queryByText( - "Quelle est la catégorie professionnelle du salarié ?" - ) - ).toBeInTheDocument(); - - // validation des erreurs sur les champs vides - userAction.click(ui.next.get()); - expect( - rendering.queryByText("Vous devez répondre à cette question") - ).toBeInTheDocument(); - userAction.changeInputList( - ui.information.agreement16.proCategory.get(), - "Ingénieurs et cadres" - ); - expect( - rendering.queryByText( - "Avant d'être cadre, le salarié a-t-il été employé, technicien ou agent de maîtrise dans l’entreprise ?" - ) - ).toBeInTheDocument(); - expect( - rendering.queryAllByText("Vous devez répondre à cette question") - ).toHaveLength(1); - - // validation que les champs sont retirés quand on revient à une question précédente - userAction - .click(ui.information.agreement16.proCategoryHasChanged.oui.get()) - .setInput( - ui.information.agreement16.dateProCategoryChanged.get(), - "01/01/2010" - ) - .setInput(ui.information.agreement16.engineerAge.get(), "38") - .changeInputList( - ui.information.agreement16.proCategory.get(), - "Ouvriers" - ); - - expect(rendering.getAllByTestId("question-label")).toHaveLength(2); - expect( - ui.information.agreement16.driveInability.oui.get() - ).not.toBeChecked(); - expect( - ui.information.agreement16.driveInability.non.get() - ).not.toBeChecked(); - - // validation qu'un champ présent avant soit réinitialisé - userAction - .changeInputList( - ui.information.agreement16.proCategory.get(), - "Employés" - ) - .setInput(ui.information.agreement16.employeeAge.get(), "55") - .changeInputList( - ui.information.agreement16.proCategory.get(), - "Technicien et agents de maîtrise (TAM)" - ); - expect(rendering.getAllByTestId("question-label")).toHaveLength(2); - expect(ui.information.agreement16.agentAge.query()).toHaveValue(null); - - // validation que l'on n'affiche pas la question suivante tant que la date n'est pas valide - userAction - .changeInputList( - ui.information.agreement16.proCategory.get(), - "Ingénieurs et cadres" - ) - .click(ui.information.agreement16.proCategoryHasChanged.oui.get()) - .setInput(ui.information.agreement16.dateProCategoryChanged.get(), "1"); - expect(rendering.getAllByTestId("question-label")).toHaveLength(3); - expect( - ui.information.agreement16.engineerAge.query() - ).not.toBeInTheDocument(); - - // validation que l'on peut valider la page quand tous les champs sont saisis - userAction - .setInput( - ui.information.agreement16.dateProCategoryChanged.get(), - "01/01/2010" - ) - .setInput(ui.information.agreement16.engineerAge.get(), "38") - .click(ui.next.get()); - expect(ui.activeStep.query()).toHaveTextContent("Ancienneté"); - - // validation que les infos sont gardées quand on revient sur les étapes précédentes sans changer les infos - userAction - .click(ui.previous.get()) - .click(ui.previous.get()) - .click(ui.previous.get()) - .click(ui.next.get()) - .click(ui.next.get()); - - expect(rendering.getAllByTestId("question-label")).toHaveLength(4); - expect(ui.information.agreement16.proCategory.get()).toHaveValue( - "'Ingénieurs et cadres'" - ); - expect( - ui.information.agreement16.proCategoryHasChanged.oui.get() - ).toBeChecked(); - expect( - ui.information.agreement16.dateProCategoryChanged.get() - ).toHaveValue("2010-01-01"); - expect(ui.information.agreement16.engineerAge.get()).toHaveValue(38); - - // validation que les infos sont effacées quand on change de convention collective - userAction - .click(ui.previous.get()) - .click(ui.agreement.noAgreement.get()) - .click(ui.agreement.agreement.get()) - .setInput(ui.agreement.agreementInput.get(), "3239") - .click( - await waitFor(() => - rendering.getByText( - "Particuliers employeurs et emploi à domicile (IDCC 3239)" - ) - ) - ) - .click(ui.next.get()); - - expect(rendering.getAllByTestId("question-label")).toHaveLength(1); - expect(ui.information.agreement3239.proCategory.get()).toHaveValue(""); - }); - }); -}); diff --git a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/no-agreement-result.test.tsx b/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/no-agreement-result.test.tsx deleted file mode 100644 index ad133e7dff..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/no-agreement-result.test.tsx +++ /dev/null @@ -1,128 +0,0 @@ -import { render, screen, waitFor } from "@testing-library/react"; -import React from "react"; -import { CalculateurIndemniteLicenciement } from "../../../../src/outils"; -import { ui } from "../../CommonIndemniteDepart/__tests__/ui"; -import { UserAction } from "../../../common"; - -jest.spyOn(Storage.prototype, "setItem"); -Storage.prototype.getItem = jest.fn( - () => ` -{ - "url": "https://www.legifrance.gouv.fr/affichIDCC.do?idConvention=KALICONT000005635173", - "id": "1486", - "num": 1486, - "shortTitle": "Bureaux d'études techniques, cabinets d'ingénieurs-conseils et sociétés de conseils", - "slug": "1486-bureaux-detudes-techniques-cabinets-dingenieurs-conseils-et-societes-de", - "title": "Convention collective nationale des bureaux d'études techniques, des cabinets d'ingénieurs-conseils et des sociétés de conseils du 15 décembre 1987. " -} -` -); -jest.mock("../../../conventions/Search/api/enterprises.service"); - -describe("Indemnité licenciement", () => { - let userAction: UserAction; - describe("parcours avec la convention collective 2596 pour tester le cas où il n'y a pas d'indemnité conventionnel", () => { - beforeEach(() => { - render( - - ); - userAction = new UserAction(); - userAction.click(ui.introduction.startButton.get()); - userAction.click(ui.contract.type.cdi.get()); - userAction.click(ui.contract.fauteGrave.non.get()); - userAction.click(ui.contract.inaptitude.non.get()); - userAction.click(ui.contract.arretTravail.non.get()); - userAction.click(ui.next.get()); - userAction.click(ui.next.get()); - userAction - .changeInputList( - ui.information.agreement1486.proCategory.get(), - "Chargés d'enquête intermittents" - ) - .click(ui.information.agreement1486.refus.non.get()) - .click(ui.next.get()) - - .setInput(ui.seniority.startDate.get(), "01/10/2023") - .setInput(ui.seniority.notificationDate.get(), "01/06/2024") - .setInput(ui.seniority.endDate.get(), "01/06/2024") - .click(ui.seniority.hasAbsence.oui.get()) - .changeInputList( - ui.seniority.absences.motif(0).get(), - "Absence pour maladie non professionnelle" - ) - .setInput(ui.seniority.absences.duration(0).get(), "3") - .click(ui.next.get()) - .click(ui.salary.hasPartialTime.non.get()); - userAction.click(ui.salary.hasSameSalary.oui.get()); - userAction.setInput(ui.salary.sameSalaryValue.get(), "2000"); - userAction.click(ui.next.get()); - // Validation que l'on est bien sur l'étape Indemnité - expect(ui.activeStep.query()).toHaveTextContent("Indemnité"); - }); - - test(` - - vérification que le montant affiché pour la convention collective est "la convention collective ne prévoit pas d'indemnité dans ce cas" - - vérification que le montant pour la convention collective est bien affiché quand il y en a un - `, () => { - // vérification que le montant affiché pour la convention collective est "la convention collective ne prévoit pas d'indemnité dans ce cas" - expect( - screen.queryByText( - "La convention collective ne prévoit pas d'indemnité dans ce cas" - ) - ).toBeInTheDocument(); - - // vérification que le montant pour la convention collective est bien affiché quand il y en a un - userAction.click(ui.previous.get()); - userAction.click(ui.previous.get()); - userAction.setInput(ui.seniority.startDate.get(), "01/01/2020"); - userAction.click(ui.next.get()); - userAction.click(ui.next.get()); - - expect( - screen.queryByText( - "La convention collective ne prévoit pas d'indemnité dans ce cas" - ) - ).not.toBeInTheDocument(); - }); - }); - test(`Le résultat doit être légal si la convention collective a été retirée de la sélection`, async () => { - render( - - ); - userAction = new UserAction(); - userAction - .click(ui.introduction.startButton.get()) - .click(ui.contract.type.cdi.get()) - .click(ui.contract.fauteGrave.non.get()) - .click(ui.contract.inaptitude.non.get()) - .click(ui.contract.arretTravail.non.get()) - .click(ui.next.get()) - .click(ui.agreement.unknownAgreement.get()) - .setInput(ui.agreement.agreementCompanyInput.get(), "bricoman") - .click(ui.agreement.agreementCompanySearchButton.get()) - .click(ui.agreement.agreementCompanySearchButton.get()); - await waitFor(() => { - userAction.click(ui.agreement.searchItem.bricomanie.get()); - }); - userAction - .click(ui.next.get()) - .setInput(ui.seniority.startDate.get(), "01/01/2018") - .setInput(ui.seniority.notificationDate.get(), "01/01/2024") - .setInput(ui.seniority.endDate.get(), "01/01/2024") - .click(ui.seniority.hasAbsence.non.get()) - .click(ui.next.get()) - .click(ui.salary.hasPartialTime.non.get()) - .click(ui.salary.hasSameSalary.oui.get()) - .setInput(ui.salary.sameSalaryValue.get(), "2500") - .click(ui.next.get()); - expect(ui.result.resultatLegal.get()).toHaveTextContent("3 750,00"); - }); -}); diff --git a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/notification.test.tsx b/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/notification.test.tsx deleted file mode 100644 index 3b6a94a4dd..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/notification.test.tsx +++ /dev/null @@ -1,74 +0,0 @@ -import { render, RenderResult } from "@testing-library/react"; -import { UserAction } from "../../../common"; -import { CalculateurIndemniteLicenciement } from "../../../../src/outils"; -import React from "react"; -import { ui } from "../../CommonIndemniteDepart/__tests__/ui"; - -jest.spyOn(Storage.prototype, "setItem"); -Storage.prototype.getItem = jest.fn( - () => ` - { - "effectif": 80901, - "cdtnId": "36c0ef9881", - "num": 2511, - "shortTitle": "Sport", - "id": "KALICONT000017577652", - "title": "Sport", - "url": "https://www.legifrance.gouv.fr/affichIDCC.do?idConvention=KALICONT000017577652", - "slug": "2511-sport" - } -` -); -describe("Indemnité licenciement - Affichage de la notification si le légal et le conventionnel sont égaux", () => { - let rendering: RenderResult; - let userAction: UserAction; - beforeEach(() => { - rendering = render( - - ); - }); - - test("Pour la CC 2511, les formules du légal et du conventionnel sont identiques", () => { - // On renseigne la page ancienneté avec une absence avec une date - userAction = new UserAction(); - // Etape Contrat de travail - userAction - .click(ui.introduction.startButton.get()) - .click(ui.contract.type.cdi.get()) - .click(ui.contract.fauteGrave.non.get()) - .click(ui.contract.inaptitude.non.get()) - .click(ui.contract.arretTravail.non.get()) - .click(ui.next.get()); - // Etape Convention collective - userAction.click(ui.next.get()); - // Etape Ancienneté - userAction - .setInput(ui.seniority.startDate.get(), "01/01/2000") - .setInput(ui.seniority.notificationDate.get(), "01/01/2022") - .setInput(ui.seniority.endDate.get(), "01/03/2022") - .click(ui.seniority.hasAbsence.oui.get()) - .setInput(ui.seniority.absences.duration(0).get(), "2") - .click(ui.next.get()); - - // Etape Salaires - userAction - .click(ui.salary.hasPartialTime.non.get()) - .click(ui.salary.hasSameSalary.oui.get()) - .setInput(ui.salary.sameSalaryValue.get(), "2500") - .click(ui.next.get()); - - // Etape Indemnité - expect(ui.activeStep.get()).toHaveTextContent("Indemnité"); - expect(rendering.queryByText("Éléments saisis")).toBeInTheDocument(); - // On détecte le fait qu'il ait deux notifications. - // La première notification étant celle par défaut, la seconde est celle qu'on souhaite tracker. - expect(ui.result.notifications.queryAll()).toHaveLength(2); - expect(ui.result.notification(0).get()).toHaveTextContent( - "Ce montant est exonéré d’impôt sur le revenu et de cotisations sociales sous certaines conditions" - ); - }); -}); diff --git a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/resultat-formules.test.tsx b/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/resultat-formules.test.tsx deleted file mode 100644 index 46fadc00c8..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/resultat-formules.test.tsx +++ /dev/null @@ -1,141 +0,0 @@ -import { render } from "@testing-library/react"; -import React from "react"; -import { CalculateurIndemniteLicenciement } from "../../../../src/outils"; -import { ui } from "../../CommonIndemniteDepart/__tests__/ui"; -import { byTestId } from "testing-library-selector"; -import { UserAction } from "../../../common"; - -jest.mock("../../../conventions/Search/api/agreements.service"); -jest.mock("../../../conventions/Search/api/enterprises.service"); - -describe("Page résultat: vérification de la formule affichée", () => { - let userAction: UserAction; - describe.each([ - { - inaptitude: false, - startDate: "01/01/2000", - notifDate: "01/03/2022", - endDate: "01/03/2022", - ccNum: 2264, - ccTitle: "Hospitalisation privée", - select: - "infos.contrat salarié - convention collective - hospitalisation privées - indemnité de licenciement - catégorie professionnelle", - selectOption: "Non-cadres", - expectedA1: "A1 : Années d'ancienneté de 10 ans ou moins (10 ans)", - expectedA2: - "A2 : Années d'ancienneté au delà de 10 ans (≈ 12.17 ans : valeur arrondie)", - expectedFormula: - "(15×Sref×A1)+(25×Sref×A2)(\\frac{1}{5} \\times Sref \\times A1) + (\\frac{2}{5} \\times Sref \\times A2)(51​×Sref×A1)+(52​×Sref×A2)", - }, - { - inaptitude: false, - startDate: "01/01/2000", - notifDate: "01/03/2022", - endDate: "01/03/2022", - ccNum: 2596, - ccTitle: "Coiffure", - select: - "infos.contrat salarié - convention collective - coiffure - indemnité de licenciement - catégorie professionnelle", - selectOption: "Cadres", - expectedA1: "A1 : Ancienneté de 10 ans ou moins (10 ans)", - expectedA2: - "A2 : Ancienneté au-delà de 10 ans (≈ 12.17 ans : valeur arrondie)", - expectedFormula: - "(14×Sref×A1)+(13×Sref×A2)(\\frac{1}{4} \\times Sref \\times A1) + (\\frac{1}{3} \\times Sref \\times A2)(41​×Sref×A1)+(31​×Sref×A2)", - }, - { - inaptitude: false, - startDate: "01/01/2022", - notifDate: "31/12/2022", - endDate: "31/12/2022", - ccNum: 2596, - ccTitle: "Coiffure", - select: - "infos.contrat salarié - convention collective - coiffure - indemnité de licenciement - catégorie professionnelle", - selectOption: "Cadres", - expectedA1: "A : Ancienneté totale (1 an)", - expectedA2: "A : Ancienneté totale (1 an)", - expectedFormula: "14×Sref×A", - }, - { - inaptitude: true, - startDate: "01/11/2021", - notifDate: "01/01/2022", - endDate: "01/01/2022", - ccNum: 2596, - ccTitle: "Coiffure", - select: - "infos.contrat salarié - convention collective - coiffure - indemnité de licenciement - catégorie professionnelle", - selectOption: "Cadres", - expectedA1: "A : Ancienneté totale (≈ 0.17 an : valeur arrondie)", - expectedA2: "A : Ancienneté totale (≈ 0.17 an : valeur arrondie)", - expectedFormula: "(14×Sref×A)×2", - }, - ])( - "pour la CC $ccNum avec inaptitude $inaptitude de $startDate à $endDate", - ({ - inaptitude, - startDate, - notifDate, - endDate, - ccNum, - ccTitle, - expectedFormula, - select, - selectOption, - expectedA1, - expectedA2, - }) => { - beforeEach(async () => { - jest.spyOn(Storage.prototype, "setItem"); - Storage.prototype.getItem = jest.fn( - () => `{"num":${ccNum},"shortTitle":"${ccTitle}"}` - ); - - render( - - ); - userAction = new UserAction(); - userAction.click(ui.introduction.startButton.get()); - userAction.click(ui.contract.type.cdi.get()); - userAction.click(ui.contract.fauteGrave.non.get()); - userAction.click( - ui.contract.inaptitude[inaptitude ? "oui" : "non"].get() - ); - !inaptitude && userAction.click(ui.contract.arretTravail.non.get()); - userAction.click(ui.next.get()); - userAction.click(ui.next.get()); - - userAction.changeInputList(byTestId(select).get(), selectOption); - userAction.click(ui.next.get()); - userAction.setInput(ui.seniority.startDate.get(), startDate); - userAction.setInput(ui.seniority.notificationDate.get(), notifDate); - userAction.setInput(ui.seniority.endDate.get(), endDate); - - userAction.click(ui.seniority.hasAbsence.non.get()); - userAction.click(ui.next.get()); - userAction.click(ui.salary.hasPartialTime.non.get()); - userAction.click(ui.salary.hasSameSalary.oui.get()); - userAction.setInput(ui.salary.sameSalaryValue.get(), "2500"); - userAction.click(ui.next.get()); - - // Validation que l'on est bien sur l'étape résultat - expect(ui.activeStep.query()).toHaveTextContent("Indemnité"); - }); - - test("should show formula", async () => { - expect(ui.result.formula.get()).toHaveTextContent("Formule"); - expect(ui.result.formula.get()).toHaveTextContent(expectedFormula); - expect(ui.result.formula.get()).toHaveTextContent(expectedA1); - expect(ui.result.formula.get()).toHaveTextContent(expectedA2); - expect(ui.result.formula.get()).toHaveTextContent( - "Sref : Salaire de référence (2500 €)" - ); - }); - } - ); -}); diff --git a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/salary-validation.test.tsx b/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/salary-validation.test.tsx deleted file mode 100644 index 2c0564c278..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/salary-validation.test.tsx +++ /dev/null @@ -1,165 +0,0 @@ -import { render, screen } from "@testing-library/react"; -import React from "react"; -import { CalculateurIndemniteLicenciement } from "../../../../src/outils"; -import { ui } from "../../CommonIndemniteDepart/__tests__/ui"; -import { UserAction } from "../../../common"; - -jest.spyOn(Storage.prototype, "setItem"); -jest.spyOn(Storage.prototype, "getItem"); - -describe("Indemnité licenciement - Step salaire", () => { - let userAction: UserAction; - describe("validation de la step salaire", () => { - beforeEach(() => { - render( - - ); - userAction = new UserAction(); - userAction.click(ui.introduction.startButton.get()); - userAction.click(ui.contract.type.cdi.get()); - userAction.click(ui.contract.fauteGrave.non.get()); - userAction.click(ui.contract.inaptitude.non.get()); - userAction.click(ui.contract.arretTravail.non.get()); - userAction.click(ui.next.get()); - userAction.click(ui.agreement.noAgreement.get()); - userAction.click(ui.next.get()); - userAction.setInput(ui.seniority.startDate.get(), "01/01/2000"); - userAction.setInput(ui.seniority.notificationDate.get(), "01/01/2022"); - userAction.setInput(ui.seniority.endDate.get(), "01/03/2022"); - userAction.click(ui.seniority.hasAbsence.non.get()); - userAction.click(ui.next.get()); - // Validation que l'on est bien sur l'étape ancienneté - expect(ui.activeStep.query()).toHaveTextContent("Salaires"); - }); - - test(` - - vérification que l'on affiche une erreur si on ne répond pas à la première question - - vérification que l'on affiche un message à noter quand on a des périodes d'alternances - - vérification que le message disparait quand on n'a pas de périodes d'alternances - - vérification que l'on demande si le salaire a été le même sur les 12 derniers mois - - vérification que l'on affiche un champ pour saisir son salaire s'il a été identique - - vérification que l'on affiche un message d'erreur si l'on n'a pas saisi le salaire - - vérification que l'on affiche 12 champs pour saisir son salaire avec 3 champs prime s'il n'a pas été identique - - vérification que l'on affiche un message d'erreur si l'on n'a pas saisi les salaires - - vérification que les primes ne sont pas obligatoires - - vérification que si on indique une prime, les autres ne sont pas obligatoires - - vérification que si l'on change un montant et supprime la prime, on ne bloque pas l'utilisateur - `, () => { - // vérification que l'on affiche une erreur si on ne répond pas à la première question - userAction.click(ui.next.get()); - expect( - screen.queryByText("Vous devez répondre à cette question") - ).toBeInTheDocument(); - - // vérification que l'on affiche un message à noter quand on a des périodes d'alternances - userAction.click(ui.salary.hasPartialTime.oui.get()); - expect(screen.queryByText("À noter")).toBeInTheDocument(); - expect( - screen.queryByText( - "Le calcul de l’indemnité de licenciement dans le cas d’une alternance de temps plein et de temps partiel est actuellement en cours de développement." - ) - ).toBeInTheDocument(); - - // vérification que le message disparait quand on n'a pas de périodes d'alternances - userAction.click(ui.salary.hasPartialTime.non.get()); - expect(screen.queryByText("À noter")).not.toBeInTheDocument(); - - // vérification que l'on demande si le salaire a été le même sur les 12 derniers mois - expect( - screen.queryByText( - "Le salaire mensuel brut a-t-il été le même durant les 12 derniers mois précédant la notification du licenciement ?" - ) - ).toBeInTheDocument(); - - // vérification que l'on affiche un champ pour saisir son salaire s'il a été identique - userAction.click(ui.salary.hasSameSalary.oui.get()); - expect(ui.salary.sameSalaryValue.query()).toBeInTheDocument(); - - // vérification que l'on affiche un message d'erreur si l'on a pas saisi le salaire - userAction.click(ui.next.get()); - expect( - screen.queryByText("Vous devez répondre à cette question") - ).toBeInTheDocument(); - - // vérification que l'on affiche 12 champs pour saisir son salaire avec 3 champs prime s'il n'a pas été identique - userAction.click(ui.salary.hasSameSalary.non.get()); - expect(ui.salary.salaries.queryAll()).toHaveLength(12); - expect(ui.salary.primes.queryAll()).toHaveLength(3); - - // vérification que l'on affiche un message d'erreur si l'on n'a pas saisi les salaires - userAction.click(ui.next.get()); - expect( - screen.queryByText("Vous devez compléter l'ensemble des champs") - ).toBeInTheDocument(); - - // vérification que les primes ne sont pas obligatoires - ui.salary.salaries.getAll().forEach((input) => { - userAction.setInput(input, "1000"); - }); - userAction.click(ui.next.get()); - expect( - screen.queryByText("Vous devez compléter l'ensemble des champs") - ).not.toBeInTheDocument(); - expect(ui.activeStep.query()).toHaveTextContent("Indemnité"); - expect(ui.result.salaryTableRows.getAll().length).toBe(12); - expect(ui.result.salaryTableRows.getAll()[0]).toHaveTextContent( - "décembre 20211 000,00 €" - ); - - // vérification que si on indique une prime, les autres ne sont pas obligatoires - userAction.click(ui.previous.get()); - userAction.setInput(ui.salary.primes.getAll()[1], "100"); - userAction.click(ui.next.get()); - expect(ui.activeStep.query()).toHaveTextContent("Indemnité"); - expect(ui.result.salaryTableRows.getAll().length).toBe(12); - expect(ui.result.salaryTableRows.getAll()[0]).toHaveTextContent( - "décembre 20211 000,00 €" - ); - expect(ui.result.salaryTableRows.getAll()[1]).toHaveTextContent( - "novembre 20211 000,00 €100,00 €" - ); - // vérification que si l'on change un montant et supprime la prime, on ne bloque pas l'utilisateur - userAction.click(ui.previous.get()); - userAction.setInput(ui.salary.salaries.getAll()[2], "1500"); - userAction.setInput(ui.salary.primes.getAll()[1], ""); - userAction.click(ui.next.get()); - expect(ui.activeStep.query()).toHaveTextContent("Indemnité"); - }); - - test("Vérification qu'un salaire ne peut pas être inférieur à 0 dans le champ où on saisit plusieurs salaires pour chaque mois", () => { - userAction.click(ui.salary.hasPartialTime.non.get()); - userAction.click(ui.salary.hasSameSalary.non.get()); - ui.salary.salaries.getAll().forEach((input) => { - userAction.setInput(input, "0"); - }); - userAction.click(ui.next.get()); - expect( - screen.queryByText("Vous devez saisir un montant supérieur à zéro") - ).toBeInTheDocument(); - // Avec les bonnes valeurs - ui.salary.salaries.getAll().forEach((input) => { - userAction.setInput(input, "1000"); - }); - userAction.click(ui.next.get()); - expect(ui.activeStep.query()).toHaveTextContent("Indemnité"); - }); - - test("Vérification qu'un salaire ne peut pas être inférieur à 0 dans le champ où on saisit un seul salaire", () => { - userAction.click(ui.salary.hasPartialTime.non.get()); - userAction.click(ui.salary.hasSameSalary.oui.get()); - userAction.setInput(ui.salary.sameSalaryValue.get(), "0"); - userAction.click(ui.next.get()); - expect( - screen.queryByText("Vous devez saisir un montant supérieur à zéro") - ).toBeInTheDocument(); - // Avec les bonnes valeurs - userAction.setInput(ui.salary.sameSalaryValue.get(), "1000"); - userAction.click(ui.next.get()); - expect(ui.activeStep.query()).toHaveTextContent("Indemnité"); - }); - }); -}); diff --git a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/seniority-validation.test.tsx b/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/seniority-validation.test.tsx deleted file mode 100644 index 2b0df25d4f..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/seniority-validation.test.tsx +++ /dev/null @@ -1,230 +0,0 @@ -import { render, RenderResult } from "@testing-library/react"; -import { UserAction } from "../../../common"; -import React from "react"; -import { CalculateurIndemniteLicenciement } from "../../../../src/outils"; -import { ui } from "../../CommonIndemniteDepart/__tests__/ui"; - -jest.spyOn(Storage.prototype, "setItem"); -Storage.prototype.getItem = jest.fn( - () => ` -{ - "num": 16, - "shortTitle": "Transports routiers et activités auxiliaires du transport", - "id": "KALICONT000005635624", - "title": "Transports routiers et activités auxiliaires du transport", - "url": "https://www.legifrance.gouv.fr/affichIDCC.do?idConvention=KALICONT000005635624", - "slug": "16-transports-routiers-et-activites-auxiliaires-du-transport" -} -` -); - -describe("Indemnité licenciement - Validation des erreurs sur l'étape ancienneté", () => { - describe("parcours avec la convention collective 16 pour valider les erreurs", () => { - let rendering: RenderResult; - let userAction: UserAction; - beforeEach(() => { - rendering = render( - - ); - userAction = new UserAction(); - userAction - .click(ui.introduction.startButton.get()) - .click(ui.contract.type.cdi.get()) - .click(ui.contract.fauteGrave.non.get()) - .click(ui.contract.inaptitude.non.get()) - .click(ui.contract.arretTravail.non.get()) - .click(ui.next.get()) - .click(ui.next.get()) - .changeInputList( - ui.information.agreement16.proCategory.get(), - "Ingénieurs et cadres" - ) - .click(ui.information.agreement16.proCategoryHasChanged.oui.get()) - .setInput( - ui.information.agreement16.dateProCategoryChanged.get(), - "01/01/2010" - ) - .setInput(ui.information.agreement16.engineerAge.get(), "38") - .click(ui.next.get()); - // Validation que l'on est bien sur l'étape ancienneté - expect(ui.activeStep.query()).toHaveTextContent("Ancienneté"); - }); - - test(` - On doit afficher des erreurs à la validation quand les informations sont erronées: - - validation des erreurs sur les champs vides - - validation de l'erreur quand cela fait plus de 18 mois que l'on a quitté l'entreprise - - validation de l'erreur quand on a saisi une date de notification avant la date de d'entrée - - validation de l'erreur quand on a saisi une date de sortie avant la date de notification - - validation de l'erreur quand on a saisi une période (entrée -> notification) inférieure à 8 mois - - validation de l'erreur quand on a saisi une période (entrée -> notification) inférieure à 8 mois et que l'on change la date de fin de contrat - - validation de la disparition de l'erreur quand on a change la période (entrée -> notification) pour plus de 8 mois - - validation de l'erreur quand on a pas répondu à présence de périodes d'absence - - validation de l'erreur quand on a des périodes d'absence mais que l'on a pas saisi le motif de l'absence - - validation de l'erreur quand on a des périodes d'absence mais que l'on a pas saisi la durée et la date de l'absence - - validation de l'erreur quand on a une date d'absence en dehors de la période de présence dans l'entreprise - - validation de l'erreur quand on a une absence qui réduit la période de présence de l'entreprise à moins de 8 mois - - validation de la disparition des erreurs quand on a tout renseigné - `, () => { - // validation des erreurs sur les champs vides - userAction.click(ui.next.get()); - expect( - rendering.queryAllByText("Veuillez saisir cette date") - ).toHaveLength(3); - - userAction.setInput(ui.seniority.startDate.get(), "01/01/0020"); - - expect( - rendering.queryByText("La date de début de contrat est invalide") - ).toBeInTheDocument(); - - userAction.setInput(ui.seniority.startDate.get(), "01/01/272024"); - - expect( - rendering.queryByText("La date de début de contrat est invalide") - ).toBeInTheDocument(); - - // validation de l'erreur quand cela fait plus de 18 mois que l'on a quitté l'entreprise - userAction - .setInput(ui.seniority.startDate.get(), "01/01/2000") - .setInput(ui.seniority.notificationDate.get(), "01/01/2012"); - - expect( - rendering.queryByText( - "La date de notification doit se situer dans les 18 derniers mois" - ) - ).toBeInTheDocument(); - - // validation de l'erreur quand on a saisi une date de notification avant la date de d'entrée - userAction - .setInput(ui.seniority.startDate.get(), "01/03/2022") - .setInput(ui.seniority.notificationDate.get(), "01/01/2022"); - - expect( - rendering.queryByText( - "La date de notification doit se situer après la date de début de contrat" - ) - ).toBeInTheDocument(); - - // validation de l'erreur quand on a saisi une date de sortie avant la date de notification - userAction - .setInput(ui.seniority.startDate.get(), "01/01/2010") - .setInput(ui.seniority.endDate.get(), "01/01/2021"); - - expect( - rendering.queryByText( - "La date de notification doit se situer avant la date de fin de contrat" - ) - ).toBeInTheDocument(); - - userAction - .setInput(ui.seniority.startDate.get(), "01/01/2022") - .setInput(ui.seniority.notificationDate.get(), "01/09/2022") - .setInput(ui.seniority.endDate.get(), "01/10/2022"); - - // validation de l'erreur quand on a pas répondu à présence de périodes d'absence - expect( - rendering.queryByText("Vous devez répondre à cette question") - ).toBeInTheDocument(); - - // validation de l'erreur quand on a des périodes d'absence mais que l'on a pas saisi le motif de l'absence - userAction.click(ui.seniority.hasAbsence.oui.get()); - - expect( - rendering.queryByText("Vous devez renseigner tous les champs") - ).toBeInTheDocument(); - expect( - rendering.queryByText("Date de début de l'absence") - ).toBeInTheDocument(); - - // validation de l'erreur quand on a des périodes d'absence mais que l'on a pas saisi la durée et la date de l'absence - userAction.changeInputList( - ui.seniority.absences.motif(0).get(), - "Congés sans solde" - ); - - expect( - rendering.queryByText("Veuillez saisir la durée de l'absence") - ).toBeInTheDocument(); - expect( - rendering.queryByText("Veuillez saisir la date de l'absence") - ).toBeInTheDocument(); - - userAction.setInput(ui.seniority.absences.duration(0).get(), "6"); - expect( - rendering.queryByText("Veuillez saisir la durée de l'absence") - ).not.toBeInTheDocument(); - - // validation de l'erreur quand on a une date d'absence en dehors de la période de présence dans l'entreprise - userAction.setInput(ui.seniority.absences.date(0).get(), "01/03/1999"); - expect( - rendering.queryByText( - "La date de l'absence doit être comprise entre le 01/01/2022 et le 01/10/2022 (dates de début et de fin de contrat)" - ) - ).toBeInTheDocument(); - - // validation de l'erreur quand on a une absence qui réduit la période de présence de l'entreprise à moins de 8 mois - userAction.setInput(ui.seniority.absences.date(0).get(), "01/02/2022"); - expect( - rendering.queryByText( - "La date de l'absence doit être comprise entre le 01/01/2022 et le 01/10/2022 (dates de début et de fin de contrat)" - ) - ).not.toBeInTheDocument(); - - // validation de la disparition des erreurs quand on a tout renseigné - userAction.setInput(ui.seniority.startDate.get(), "01/02/2000"); - userAction.click(ui.next.get()); - expect(ui.activeStep.query()).toHaveTextContent("Salaires"); - }); - }); - describe("parcours sans la convention collective valider les erreurs", () => { - let rendering: RenderResult; - let userAction: UserAction; - beforeEach(() => { - rendering = render( - - ); - userAction = new UserAction(); - userAction - .click(ui.introduction.startButton.get()) - .click(ui.contract.type.cdi.get()) - .click(ui.contract.fauteGrave.non.get()) - .click(ui.contract.inaptitude.non.get()) - .click(ui.contract.arretTravail.non.get()) - .click(ui.next.get()) - .click(ui.agreement.noAgreement.get()) - .click(ui.next.get()); - // Validation que l'on est bien sur l'étape ancienneté - expect(ui.activeStep.query()).toHaveTextContent("Ancienneté"); - }); - - it("Parcours particulier reproduisant un bug sur l'erreur concernant les 8 mois d'ancienneté", () => { - // validation que l'erreur est toujours présente si je change la période et la durée de l'absence - userAction - .setInput(ui.seniority.startDate.get(), "01/01/2022") - .setInput(ui.seniority.notificationDate.get(), "01/09/2022") - .setInput(ui.seniority.endDate.get(), "01/09/2022") - .click(ui.seniority.hasAbsence.oui.get()) - .setInput(ui.seniority.absences.duration(0).get(), "1") - .click(ui.next.get()) - .click(ui.previous.get()) - .setInput(ui.seniority.notificationDate.get(), "01/10/2022") - .setInput(ui.seniority.endDate.get(), "01/10/2022") - .setInput(ui.seniority.absences.duration(0).get(), "6") - .click(ui.next.get()); - expect( - rendering.queryByText( - /L’indemnité de licenciement n’est pas due lorsque l’ancienneté dans l’entreprise est inférieure à 8 mois./ - ) - ).toBeInTheDocument(); - }); - }); -}); diff --git a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/tracking.test.tsx b/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/tracking.test.tsx deleted file mode 100644 index 47b1369cb6..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/tracking.test.tsx +++ /dev/null @@ -1,287 +0,0 @@ -import { render, waitFor } from "@testing-library/react"; -import React from "react"; -import { CalculateurIndemniteLicenciement } from "../index"; -import { ui } from "../../CommonIndemniteDepart/__tests__/ui"; -import { push } from "@socialgouv/matomo-next"; -import { UserAction } from "../../../common"; - -jest.mock("@socialgouv/matomo-next", () => ({ - push: jest.fn(), -})); -jest.mock("../../../conventions/Search/api/agreements.service"); -jest.mock("../../../conventions/Search/api/enterprises.service"); - -describe("Indemnité licenciement - Tracking", () => { - beforeEach(() => { - render( - - ); - }); - const userAction = new UserAction(); - - test("vérifier le tracking sur la navigation", () => { - jest.spyOn(Storage.prototype, "setItem"); - Storage.prototype.getItem = jest.fn( - () => - `{"num":16,"shortTitle":"Transports routiers et activités auxiliaires du transport"}` - ); - userAction.click(ui.introduction.startButton.get()); - expect(push).toHaveBeenCalledWith([ - "trackEvent", - "outil", - `view_step_Indemnité de licenciement`, - "contrat_travail", - ]); - userAction.click(ui.contract.type.cdi.get()); - userAction.click(ui.contract.fauteGrave.non.get()); - userAction.click(ui.contract.inaptitude.non.get()); - userAction.click(ui.contract.arretTravail.non.get()); - userAction.click(ui.next.get()); - expect(push).toHaveBeenCalledWith([ - "trackEvent", - "outil", - `view_step_Indemnité de licenciement`, - "info_cc", - ]); - userAction.click(ui.next.get()); - expect(push).toHaveBeenCalledWith([ - "trackEvent", - "outil", - `view_step_Indemnité de licenciement`, - "infos", - ]); - userAction.changeInputList( - ui.information.agreement16.proCategory.get(), - "Ingénieurs et cadres" - ); - userAction.click( - ui.information.agreement16.proCategoryHasChanged.oui.get() - ); - userAction.setInput( - ui.information.agreement16.dateProCategoryChanged.get(), - "01/01/2010" - ); - userAction.setInput(ui.information.agreement16.engineerAge.get(), "38"); - userAction.click(ui.next.get()); - expect(push).toHaveBeenCalledWith([ - "trackEvent", - "outil", - `view_step_Indemnité de licenciement`, - "anciennete", - ]); - userAction.setInput(ui.seniority.startDate.get(), "01/01/2022"); - userAction.setInput(ui.seniority.notificationDate.get(), "15/12/2022"); - userAction.setInput(ui.seniority.endDate.get(), "15/12/2022"); - userAction.click(ui.seniority.hasAbsence.non.get()); - userAction.click(ui.next.get()); - expect(push).toHaveBeenCalledWith([ - "trackEvent", - "outil", - `view_step_Indemnité de licenciement`, - "salaires", - ]); - userAction.click(ui.salary.hasPartialTime.non.get()); - userAction.click(ui.salary.hasSameSalary.oui.get()); - userAction.setInput(ui.salary.sameSalaryValue.get(), "3000"); - userAction.click(ui.next.get()); - expect(push).toHaveBeenCalledWith([ - "trackEvent", - "outil", - `view_step_Indemnité de licenciement`, - "results", - ]); - userAction.click(ui.previous.get()); - expect(push).toHaveBeenCalledWith([ - "trackEvent", - "outil", - `click_previous_Indemnité de licenciement`, - "salaires", - ]); - userAction.click(ui.previous.get()); - expect(push).toHaveBeenCalledWith([ - "trackEvent", - "outil", - `click_previous_Indemnité de licenciement`, - "anciennete", - ]); - userAction.click(ui.previous.get()); - expect(push).toHaveBeenCalledWith([ - "trackEvent", - "outil", - `click_previous_Indemnité de licenciement`, - "infos", - ]); - userAction.click(ui.previous.get()); - expect(push).toHaveBeenCalledWith([ - "trackEvent", - "outil", - `click_previous_Indemnité de licenciement`, - "info_cc", - ]); - userAction.click(ui.previous.get()); - expect(push).toHaveBeenCalledWith([ - "trackEvent", - "outil", - `click_previous_Indemnité de licenciement`, - "contrat_travail", - ]); - }); - - test("vérifier le tracking sur la recherche entreprise", async () => { - userAction.click(ui.introduction.startButton.get()); - userAction.click(ui.contract.type.cdi.get()); - userAction.click(ui.contract.fauteGrave.non.get()); - userAction.click(ui.contract.inaptitude.non.get()); - userAction.click(ui.contract.arretTravail.non.get()); - userAction.click(ui.next.get()); - userAction.click(ui.agreement.unknownAgreement.get()); - userAction.setInput(ui.agreement.agreementCompanyInput.get(), "carrefour"); - userAction.click(ui.agreement.agreementCompanySearchButton.get()); - await waitFor(() => { - userAction.click(ui.agreement.searchItem.carrefour.get()); - }); - expect(push).toHaveBeenCalledWith([ - "trackEvent", - "enterprise_search", - "Indemnité de licenciement", - JSON.stringify({ query: "carrefour" }), - ]); - }); - - test("vérifier le tracking sur la recherche CC", async () => { - userAction - .click(ui.introduction.startButton.get()) - .click(ui.contract.type.cdi.get()) - .click(ui.contract.fauteGrave.non.get()) - .click(ui.contract.inaptitude.non.get()) - .click(ui.contract.arretTravail.non.get()) - .click(ui.next.get()) - .click(ui.agreement.noAgreement.get()) - .click(ui.agreement.agreement.get()) - .setInput(ui.agreement.agreementInput.get(), "16") - .click(await waitFor(() => ui.agreement.ccChoice.transport.get())); - - expect(push).toHaveBeenCalledWith([ - "trackEvent", - "cc_search", - "Indemnité de licenciement", - JSON.stringify({ query: "16" }), - ]); - }); - - test("vérifier le tracking sur la selection CC", async () => { - userAction - .click(ui.introduction.startButton.get()) - .click(ui.contract.type.cdi.get()) - .click(ui.contract.fauteGrave.non.get()) - .click(ui.contract.inaptitude.non.get()) - .click(ui.contract.arretTravail.non.get()) - .click(ui.next.get()) - .click(ui.agreement.noAgreement.get()) - .click(ui.agreement.agreement.get()) - .setInput(ui.agreement.agreementInput.get(), "16") - .click(await waitFor(() => ui.agreement.ccChoice.transport.get())) - .click(ui.next.get()); - - expect(push).toHaveBeenCalledWith([ - "trackEvent", - "cc_search_type_of_users", - "click_p1", - "Indemnité de licenciement", - ]); - expect(push).toHaveBeenCalledWith([ - "trackEvent", - "cc_select_p1", - "Indemnité de licenciement", - "idcc16", - ]); - userAction.click(ui.previous.get()); - userAction.click(ui.agreement.unknownAgreement.get()); - userAction.setInput(ui.agreement.agreementCompanyInput.get(), "carrefour"); - userAction.click(ui.agreement.agreementCompanySearchButton.get()); - await waitFor(() => { - userAction.click(ui.agreement.searchItem.carrefour.get()); - }); - userAction.click(ui.agreement.ccChoice.commerce.get()); - userAction.click(ui.next.get()); - expect(push).toHaveBeenCalledWith([ - "trackEvent", - "cc_search_type_of_users", - "click_p2", - "Indemnité de licenciement", - ]); - expect(push).toHaveBeenCalledWith([ - "trackEvent", - "cc_select_p2", - "Indemnité de licenciement", - "idcc2216", - ]); - userAction.click(ui.previous.get()); - userAction.click(ui.agreement.noAgreement.get()); - userAction.click(ui.next.get()); - expect(push).toHaveBeenCalledWith([ - "trackEvent", - "cc_search_type_of_users", - "click_p3", - "Indemnité de licenciement", - ]); - }); - - test("vérifier le tracking CC traités", () => { - jest.spyOn(Storage.prototype, "setItem"); - Storage.prototype.getItem = jest.fn( - () => - `{"num":16,"shortTitle":"Transports routiers et activités auxiliaires du transport"}` - ); - userAction.click(ui.introduction.startButton.get()); - userAction.click(ui.contract.type.cdi.get()); - userAction.click(ui.contract.fauteGrave.non.get()); - userAction.click(ui.contract.inaptitude.non.get()); - userAction.click(ui.contract.arretTravail.non.get()); - userAction.click(ui.next.get()); - userAction.click(ui.next.get()); - expect(push).toHaveBeenCalledWith([ - "trackEvent", - "outil", - "cc_select_traitée", - 16, - ]); - }); - - test("vérifier le tracking CC non traités", () => { - jest.spyOn(Storage.prototype, "setItem"); - Storage.prototype.getItem = jest.fn( - () => - `{"num":1261,"shortTitle":"Acteurs du lien social et familial (centres sociaux et socioculturels, associations d'accueil de jeunes enfants, associations de développement social local)"}` - ); - userAction.click(ui.introduction.startButton.get()); - userAction.click(ui.contract.type.cdi.get()); - userAction.click(ui.contract.fauteGrave.non.get()); - userAction.click(ui.contract.inaptitude.non.get()); - userAction.click(ui.contract.arretTravail.non.get()); - userAction.click(ui.next.get()); - userAction.click(ui.next.get()); - expect(push).toHaveBeenCalledWith([ - "trackEvent", - "outil", - "cc_select_non_traitée", - 1261, - ]); - }); - - test("vérifier qu'on a un event ineligible sur la recherche entreprise", async () => { - userAction.click(ui.introduction.startButton.get()); - userAction.click(ui.contract.type.cdd.get()); - userAction.click(ui.next.get()); - expect(push).toHaveBeenCalledWith([ - "trackEvent", - "outil", - `view_step_Indemnité de licenciement`, - "results_ineligible", - ]); - }); -}); diff --git "a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/validation-anciennet\303\251-absence.test.tsx" "b/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/validation-anciennet\303\251-absence.test.tsx" deleted file mode 100644 index 193e4745be..0000000000 --- "a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/__tests__/validation-anciennet\303\251-absence.test.tsx" +++ /dev/null @@ -1,39 +0,0 @@ -import { render, screen } from "@testing-library/react"; -import React from "react"; -import { CalculateurIndemniteLicenciement } from "../../../../src/outils"; -import { ui } from "../../CommonIndemniteDepart/__tests__/ui"; -import { UserAction } from "../../../common"; - -jest.mock("../../../conventions/Search/api/agreements.service"); -jest.mock("../../../conventions/Search/api/enterprises.service"); - -describe("Page ancienneté: vérification validation lorsque absence > ancienneté", () => { - test("should show 12 month", async () => { - const { getByText } = render( - - ); - const userAction = new UserAction(); - userAction.click(ui.introduction.startButton.get()); - userAction.click(ui.contract.type.cdi.get()); - userAction.click(ui.contract.fauteGrave.non.get()); - userAction.click(ui.contract.inaptitude.oui.get()); - userAction.click(ui.next.get()); - userAction.click(ui.agreement.noAgreement.get()); - userAction.click(ui.next.get()); - userAction.setInput(ui.seniority.startDate.get(), "01/01/2024"); - userAction.setInput(ui.seniority.notificationDate.get(), "31/01/2024"); - userAction.setInput(ui.seniority.endDate.get(), "31/01/2024"); - userAction.click(ui.seniority.hasAbsence.oui.get()); - userAction.setInput(ui.seniority.absences.duration(0).get(), "1"); - userAction.click(ui.next.get()); - expect( - getByText( - /La durée totale des absences doit être inférieure ou égale à l'ancienneté/ - ) - ).toBeInTheDocument(); - }); -}); diff --git a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/agreements/ui-customizations/index.ts b/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/agreements/ui-customizations/index.ts deleted file mode 100644 index c2e7ea9a13..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/agreements/ui-customizations/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./messages"; diff --git a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/agreements/ui-customizations/messages.ts b/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/agreements/ui-customizations/messages.ts deleted file mode 100644 index d2b43dd945..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/agreements/ui-customizations/messages.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { CatPro3239 } from "@socialgouv/modeles-social"; - -export const getForMoreInfoMessage = ( - isAgreementBetter: boolean, - agreementNumber?: number -): string | undefined => { - if (isAgreementBetter && agreementNumber === 44) { - return "Le montant donné n’est qu’une estimation, il est donné à titre indicatif. Pour simplifier l’utilisation de ce simulateur, certains paramètres complexes n’ont pas été pris en compte dans le calcul de l’indemnité et peuvent donner lieu à un montant différent. Par exemple, les absences de moins d’un mois ou les contrats antérieurs au CDI ne sont pas pris en compte dans le calcul de l’ancienneté du salarié. Des règles particulières peuvent également s’appliquer en cas de licenciement pour raisons économiques. L'outil n'a pas intégré ces règles car elles ne s’appliquent pas de façon uniforme à toutes les entreprises."; - } - return "Le montant donné n’est qu’une estimation, il est donné à titre indicatif. Pour simplifier l’utilisation de ce simulateur, certains paramètres complexes n’ont pas été pris en compte dans le calcul de l’indemnité et peuvent donner lieu à un montant différent. Par exemple, les absences de moins d’un mois ou les contrats antérieurs au CDI ne sont pas pris en compte dans le calcul de l’ancienneté du salarié."; -}; - -export const getResultMessage = ( - informations?: Record -): string => { - let isAssMat = false; - if (informations) { - const categoryPro3239 = - informations[ - "contrat salarié . convention collective . particuliers employeurs et emploi à domicile . indemnité de licenciement . catégorie professionnelle" - ]; - isAssMat = categoryPro3239 === CatPro3239.assistantMaternel; - } - if (isAssMat) - return "À partir des éléments que vous avez saisis, l’indemnité de licenciement (appelée « indemnité de rupture » pour les assistants maternels) est estimée à :"; - return "À partir des éléments que vous avez saisis, l’indemnité de licenciement est estimée à :"; -}; diff --git a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/events/useIndemniteLicenciementEventEmitter.tsx b/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/events/useIndemniteLicenciementEventEmitter.tsx deleted file mode 100644 index f991bda60c..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/events/useIndemniteLicenciementEventEmitter.tsx +++ /dev/null @@ -1,33 +0,0 @@ -import { useEffect } from "react"; -import { - MatomoActionEvent, - MatomoBaseEvent, - MatomoSimulatorEvent, - trackQuestion, -} from "src/lib"; -import { push as matopush } from "@socialgouv/matomo-next"; -import { eventEmitter, EventType } from "../../common/indemnite-depart/events"; -import { IndemniteDepartStepName } from "../../common/indemnite-depart"; - -export const useIndemniteLicenciementEventEmitter = () => { - useEffect(() => { - eventEmitter.subscribe(EventType.SEND_RESULT_EVENT, (isEligible) => { - matopush([ - MatomoBaseEvent.TRACK_EVENT, - MatomoBaseEvent.OUTIL, - MatomoActionEvent.INDEMNITE_LICENCIEMENT, - isEligible - ? IndemniteDepartStepName.Resultat - : MatomoSimulatorEvent.STEP_RESULT_INELIGIBLE, - ]); - }); - - eventEmitter.subscribe(EventType.TRACK_QUESTION, (titre) => { - trackQuestion(titre, MatomoActionEvent.INDEMNITE_LICENCIEMENT); - }); - - return () => { - eventEmitter.unsubscribeAll(); - }; - }, []); -}; diff --git a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/index.tsx b/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/index.tsx deleted file mode 100644 index dc5ef0b424..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/index.tsx +++ /dev/null @@ -1,82 +0,0 @@ -import React from "react"; -import { - CalculateurIndemnite, - IndemniteDepartStepName, -} from "../CommonIndemniteDepart"; -import { IndemniteDepartType } from "../types"; -import { Step } from "../Simulator"; -import { - StepAgreement, - StepInformations, - StepSalaires, -} from "../CommonIndemniteDepart/steps"; -import { - StepAnciennete, - StepContratTravail, - StepIntro, - StepResultat, -} from "./steps"; -import { useIndemniteLicenciementEventEmitter } from "./events/useIndemniteLicenciementEventEmitter"; -import { EVENT_CATEGORY } from "../common/Feedback/tracking"; - -type Props = { - icon: string; - title: string; - displayTitle: string; -}; - -const steps: Step[] = [ - { - label: "Introduction", - name: IndemniteDepartStepName.Introduction, - Component: StepIntro, - }, - { - label: "Contrat de travail", - name: IndemniteDepartStepName.ContratTravail, - Component: StepContratTravail, - }, - { - label: "Convention collective", - name: IndemniteDepartStepName.Agreement, - Component: StepAgreement, - }, - { - label: "Informations", - name: IndemniteDepartStepName.Informations, - Component: StepInformations, - }, - { - label: "Ancienneté", - name: IndemniteDepartStepName.Anciennete, - Component: StepAnciennete, - }, - { - label: "Salaires", - name: IndemniteDepartStepName.Salaires, - Component: () => , - }, - { - label: "Indemnité", - name: IndemniteDepartStepName.Resultat, - Component: StepResultat, - }, -]; - -export const CalculateurIndemniteLicenciement = ({ - icon, - title, - displayTitle, -}: Props): JSX.Element => { - useIndemniteLicenciementEventEmitter(); - return ( - - ); -}; diff --git "a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/steps/Anciennet\303\251/index.tsx" "b/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/steps/Anciennet\303\251/index.tsx" deleted file mode 100644 index c3c89986a8..0000000000 --- "a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/steps/Anciennet\303\251/index.tsx" +++ /dev/null @@ -1,168 +0,0 @@ -import React, { useContext, useEffect } from "react"; - -import { SectionTitle } from "../../../common/stepStyles"; -import { RadioQuestion, TextQuestion } from "../../../Components"; -import { informationToSituation } from "../../../Components/Informations/utils"; -// Do not optimize the following import -import { getMessageMotifExample } from "../../../CommonIndemniteDepart/agreements/ui-customizations"; -import { - IndemniteDepartContext, - useIndemniteDepartStore, -} from "../../../CommonIndemniteDepart/store"; -import { - AbsencePeriods, - SectionTitleWithTooltip, -} from "../../../CommonIndemniteDepart/steps"; - -const StepAnciennete = () => { - const store = useContext(IndemniteDepartContext); - const { - init, - onChangeAbsencePeriods, - motifs, - absencePeriods, - onChangeHasAbsenceProlonge, - hasAbsenceProlonge, - dateEntree, - onChangeDateEntree, - dateSortie, - onChangeDateSortie, - dateNotification, - onChangeDateNotification, - errorDateNotification, - errorDateSortie, - errorAbsenceProlonge, - errorDateEntree, - errorAbsencePeriods, - informationData, - } = useIndemniteDepartStore(store, (state) => ({ - init: state.ancienneteFunction.init, - onChangeAbsencePeriods: state.ancienneteFunction.onChangeAbsencePeriods, - motifs: state.ancienneteData.input.motifs, - absencePeriods: state.ancienneteData.input.absencePeriods, - onChangeHasAbsenceProlonge: - state.ancienneteFunction.onChangeHasAbsenceProlonge, - hasAbsenceProlonge: state.ancienneteData.input.hasAbsenceProlonge, - dateEntree: state.ancienneteData.input.dateEntree, - onChangeDateEntree: state.ancienneteFunction.onChangeDateEntree, - dateSortie: state.ancienneteData.input.dateSortie, - onChangeDateSortie: state.ancienneteFunction.onChangeDateSortie, - dateNotification: state.ancienneteData.input.dateNotification, - onChangeDateNotification: state.ancienneteFunction.onChangeDateNotification, - errorDateNotification: state.ancienneteData.error.errorDateNotification, - errorDateSortie: state.ancienneteData.error.errorDateSortie, - errorAbsenceProlonge: state.ancienneteData.error.errorAbsenceProlonge, - errorDateEntree: state.ancienneteData.error.errorDateEntree, - errorAbsencePeriods: state.ancienneteData.error.errorAbsencePeriods, - agreement: state.agreementData.input.agreement, - informationData: informationToSituation( - state.informationsData.input.publicodesInformations - ), - })); - - useEffect(() => { - init(); - }, [init]); - - const messageMotifsExample = React.useMemo( - () => getMessageMotifExample(informationData), - [informationData] - ); - - return ( - <> - - Dates de début et de fin de contrat - - - - - En cas de dispense de préavis à l'initiative de - l'employeur, ou si le licenciement intervient à la suite d’un - avis d’inaptitude non professionnelle, indiquer la date de fin du - préavis « théorique » non effectué. -

      - ), - }} - /> - - Pour rendre la saisie de l'outil plus simple, les absences de - moins d'un mois ne sont pas comptabilisées. Or, ces absences - peuvent impacter l'ancienneté et donner ainsi lieu à un - montant d'indemnité inférieur à celui calculé par notre - simulateur. -

      - ), - }} - /> - - {hasAbsenceProlonge === "oui" && ( - - )} - - ); -}; - -export default StepAnciennete; diff --git a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/steps/ContratTravail/index.tsx b/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/steps/ContratTravail/index.tsx deleted file mode 100644 index 6aa8e35dc7..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/steps/ContratTravail/index.tsx +++ /dev/null @@ -1,164 +0,0 @@ -import React, { useContext } from "react"; -import { RadioQuestion, TextQuestion } from "../../../Components"; -import { - IndemniteDepartContext, - useIndemniteDepartStore, -} from "../../../CommonIndemniteDepart/store"; - -const StepContratTravail = (): JSX.Element => { - const store = useContext(IndemniteDepartContext); - const { - licenciementFauteGrave, - onChangeLicenciementFauteGrave, - licenciementInaptitude, - onChangeLicenciementInaptitude, - typeContratTravail, - onChangeTypeContratTravail, - errorLicenciementFauteGrave, - errorLicenciementInaptitude, - errorTypeContratTravail, - arretTravail, - onChangeArretTravail, - errorArretTravail, - dateArretTravail, - onChangeDateArretTravail, - errorDateArretTravail, - } = useIndemniteDepartStore(store, (state) => ({ - licenciementFauteGrave: - state.contratTravailData.input.licenciementFauteGrave, - onChangeLicenciementFauteGrave: - state.contratTravailFunction.onChangeLicenciementFauteGrave, - licenciementInaptitude: - state.contratTravailData.input.licenciementInaptitude, - onChangeLicenciementInaptitude: - state.contratTravailFunction.onChangeLicenciementInaptitude, - typeContratTravail: state.contratTravailData.input.typeContratTravail, - onChangeTypeContratTravail: - state.contratTravailFunction.onChangeTypeContratTravail, - errorLicenciementFauteGrave: - state.contratTravailData.error.errorLicenciementFauteGrave, - errorLicenciementInaptitude: - state.contratTravailData.error.errorLicenciementInaptitude, - errorTypeContratTravail: - state.contratTravailData.error.errorTypeContratTravail, - arretTravail: state.contratTravailData.input.arretTravail, - dateArretTravail: state.contratTravailData.input.dateArretTravail, - onChangeArretTravail: state.contratTravailFunction.onChangeArretTravail, - onChangeDateArretTravail: - state.contratTravailFunction.onChangeDateArretTravail, - errorArretTravail: state.contratTravailData.error.errorArretTravail, - errorDateArretTravail: state.contratTravailData.error.errorDateArretTravail, - })); - - return ( - <> - - {typeContratTravail === "cdi" && ( - - )} - {typeContratTravail === "cdi" && licenciementFauteGrave === "non" && ( - - )} - {typeContratTravail === "cdi" && - licenciementFauteGrave === "non" && - licenciementInaptitude === "non" && ( - - )} - {typeContratTravail === "cdi" && - licenciementFauteGrave === "non" && - licenciementInaptitude === "non" && - arretTravail === "oui" && ( - - )} - - ); -}; - -export default StepContratTravail; diff --git a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/steps/Introduction/components/Intro.tsx b/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/steps/Introduction/components/Intro.tsx deleted file mode 100644 index 7cd78dc911..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/steps/Introduction/components/Intro.tsx +++ /dev/null @@ -1,19 +0,0 @@ -import React from "react"; - -const Intro = (): JSX.Element => { - return ( - <> -

      - Ce simulateur permet d’estimer le montant de l’indemnité de licenciement - d’un salarié. -

      -

      - Vous aurez besoin d’informations telles que les dates d’entrée et de - sortie de l’entreprise, la date de notification du licenciement et le - montant des derniers salaires. -

      - - ); -}; - -export default Intro; diff --git a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/steps/Introduction/components/__tests__/Intro.test.tsx b/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/steps/Introduction/components/__tests__/Intro.test.tsx deleted file mode 100644 index 2e8774900f..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/steps/Introduction/components/__tests__/Intro.test.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import { render } from "@testing-library/react"; -import React from "react"; -import Intro from "../Intro"; - -describe("", () => { - it("should render", () => { - expect(render()).toBeTruthy(); - }); -}); diff --git a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/steps/Introduction/components/index.ts b/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/steps/Introduction/components/index.ts deleted file mode 100644 index d5cc454148..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/steps/Introduction/components/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default as Intro } from "./Intro"; diff --git a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/steps/Introduction/index.tsx b/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/steps/Introduction/index.tsx deleted file mode 100644 index 04c8e8db92..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/steps/Introduction/index.tsx +++ /dev/null @@ -1,6 +0,0 @@ -import React from "react"; -import { Intro } from "./components"; - -const StepIntro = (): JSX.Element => ; - -export default StepIntro; diff --git a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/steps/Resultat/Eligible.tsx b/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/steps/Resultat/Eligible.tsx deleted file mode 100644 index 31791891df..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/steps/Resultat/Eligible.tsx +++ /dev/null @@ -1,247 +0,0 @@ -import { - Notification, - getSupportedAgreement, -} from "@socialgouv/modeles-social"; -import React, { useContext } from "react"; -import PubliReferences from "../../../common/PubliReferences"; -import Disclaimer from "../../../common/Disclaimer"; -import ShowDetails from "../../../common/ShowDetails"; -import { - DecryptResult, - FilledElements, - FormulaInterpreter, - Result, -} from "../../../CommonIndemniteDepart/steps/Resultat/components"; -import { informationToSituation } from "../../../Components/Informations/utils"; -import { - IndemniteDepartContext, - useIndemniteDepartStore, -} from "../../../CommonIndemniteDepart/store"; -// Do not optimize the following import -import { IndemniteDepartStepName } from "../../../CommonIndemniteDepart"; -import { IndemniteDepartType } from "../../../types"; -import Link from "next/link"; -import { AgreementsInjector } from "../../../CommonIndemniteDepart/agreements"; -import { Paragraph } from "@socialgouv/cdtn-ui"; -import { - getForMoreInfoMessage, - getResultMessage, -} from "../../agreements/ui-customizations"; -import { StyledLink } from "../../../CommonIndemniteDepart/steps/Resultat/components/Result"; - -export default function Eligible() { - const store = useContext(IndemniteDepartContext); - const { - result, - publicodesLegalResult, - publicodesAgreementResult, - agreementExplanation, - resultExplanation, - typeContratTravail, - licenciementInaptitude, - licenciementFauteGrave, - agreement, - route, - dateEntree, - dateSortie, - dateNotification, - absencePeriods, - salaryPeriods, - formula, - legalReferences, - agreementReferences, - hasTempsPartiel, - isAgreementBetter, - agreementInformations, - salary, - hasSameSalary, - notifications, - agreementHasNoLegalIndemnity, - agreementHasNoBetterAllowance, - isStepSalaryHidden, - infoWarning, - dateArretTravail, - arretTravail, - showHasTempsPartiel, - informationData, - isAgreementSupported, - isParentalNoticeHidden, - } = useIndemniteDepartStore(store, (state) => ({ - result: state.resultData.input.result, - publicodesLegalResult: state.resultData.input.publicodesLegalResult, - publicodesAgreementResult: state.resultData.input.publicodesAgreementResult, - typeContratTravail: state.contratTravailData.input.typeContratTravail, - licenciementInaptitude: - state.contratTravailData.input.licenciementInaptitude, - licenciementFauteGrave: - state.contratTravailData.input.licenciementFauteGrave, - agreement: state.agreementData.input.agreement, - route: state.agreementData.input.route, - dateEntree: state.ancienneteData.input.dateEntree, - dateSortie: state.ancienneteData.input.dateSortie, - dateNotification: state.ancienneteData.input.dateNotification, - absencePeriods: state.ancienneteData.input.absencePeriods, - salaryPeriods: state.salairesData.input.salaryPeriods, - formula: state.resultData.input.formula, - legalReferences: state.resultData.input.legalReferences, - agreementReferences: state.resultData.input.agreementReferences, - hasTempsPartiel: state.salairesData.input.hasTempsPartiel, - isAgreementBetter: state.resultData.input.isAgreementBetter, - agreementInformations: state.resultData.input.agreementInformations, - salary: state.salairesData.input.salary, - hasSameSalary: state.salairesData.input.hasSameSalary, - notifications: state.resultData.input.notifications, - agreementHasNoLegalIndemnity: - state.resultData.input.agreementHasNoLegalIndemnity, - agreementHasNoBetterAllowance: - state.resultData.input.agreementHasNoBetterAllowance, - isStepSalaryHidden: state.informationsData.input.isStepSalaryHidden, - infoWarning: state.resultData.input.infoWarning, - dateArretTravail: state.contratTravailData.input.dateArretTravail, - arretTravail: state.contratTravailData.input.arretTravail, - showHasTempsPartiel: state.salairesData.input.showHasTempsPartiel, - informationData: informationToSituation( - state.informationsData.input.publicodesInformations - ), - isAgreementSupported: - state.agreementData.input.isAgreementSupportedIndemniteLicenciement, - isParentalNoticeHidden: state.resultData.input.isParentalNoticeHidden, - agreementExplanation: state.resultData.input.agreementExplanation, - resultExplanation: state.resultData.input.resultExplanation, - })); - - const defaultNotification = [ - { - dottedName: "default notification 1", - description: ( - - Ce montant est exonéré d’impôt sur le revenu et de cotisations - sociales sous certaines conditions,{" "} - - en savoir plus - - - ), - } as Notification, - ]; - - return ( - <> - - - - ) - } - isStepSalaryHidden={isStepSalaryHidden} - disableParentalNotice={isParentalNoticeHidden} - /> - - {!agreementHasNoLegalIndemnity && ( - - )} - - - {!agreementHasNoBetterAllowance && infoWarning && ( - -

      {infoWarning.message}

      -
      - )} -

      - Pour en savoir plus sur l’indemnité de licenciement et son mode de - calcul, consultez{" "} - - cet article - - . -

      - - {getForMoreInfoMessage(isAgreementBetter, agreement?.num)} - - - ); -} diff --git a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/steps/Resultat/Ineligible.tsx b/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/steps/Resultat/Ineligible.tsx deleted file mode 100644 index 233433fd10..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/steps/Resultat/Ineligible.tsx +++ /dev/null @@ -1,39 +0,0 @@ -import React, { useContext } from "react"; -import { HighlightResult, SectionTitle } from "../../../common/stepStyles"; -import Disclaimer from "../../../common/Disclaimer"; -import { - IndemniteDepartContext, - useIndemniteDepartStore, -} from "../../../CommonIndemniteDepart/store"; -import Html from "../../../../common/Html"; - -export default function Ineligible() { - const store = useContext(IndemniteDepartContext); - const { agreementHasNoLegalIndemnity, getEligibilityError, infoWarning } = - useIndemniteDepartStore(store, (state) => ({ - agreementHasNoLegalIndemnity: - state.resultData.input.agreementHasNoLegalIndemnity, - getEligibilityError: state.resultFunction.getEligibilityError, - infoWarning: state.resultData.input.infoWarning, - })); - return ( - <> - Indemnité de licenciement -

      - - Il n'y a pas d'indemnité de licenciement dans cette - situation - -

      - {getEligibilityError() ?? ""} - {!agreementHasNoLegalIndemnity && infoWarning && ( - -

      {infoWarning.message}

      -
      - )} - - ); -} diff --git a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/steps/Resultat/index.tsx b/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/steps/Resultat/index.tsx deleted file mode 100644 index 5057858561..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/steps/Resultat/index.tsx +++ /dev/null @@ -1,15 +0,0 @@ -import React from "react"; -import { StepResultat } from "../../../CommonIndemniteDepart/steps"; -import Eligible from "./Eligible"; -import Ineligible from "./Ineligible"; - -const StepResult = () => { - return ( - } - ineligibleComponent={} - /> - ); -}; - -export default StepResult; diff --git a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/steps/index.ts b/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/steps/index.ts deleted file mode 100644 index cb44c9b077..0000000000 --- a/packages/code-du-travail-frontend/src/modules/outils/indemnite-licenciement/steps/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export { default as StepIntro } from "./Introduction"; -export { default as StepContratTravail } from "./ContratTravail"; -export { default as StepAnciennete } from "./Ancienneté"; -export { default as StepResultat } from "./Resultat"; diff --git a/packages/code-du-travail-frontend/src/modules/outils/indemnite-rupture-conventionnelle/IndemniteRuptureCoSimulator.tsx b/packages/code-du-travail-frontend/src/modules/outils/indemnite-rupture-conventionnelle/IndemniteRuptureCoSimulator.tsx index 0d3fe4470a..87296ef7b5 100644 --- a/packages/code-du-travail-frontend/src/modules/outils/indemnite-rupture-conventionnelle/IndemniteRuptureCoSimulator.tsx +++ b/packages/code-du-travail-frontend/src/modules/outils/indemnite-rupture-conventionnelle/IndemniteRuptureCoSimulator.tsx @@ -1,7 +1,7 @@ "use client"; import { ContainerSimulator } from "../../layout/ContainerSimulator"; import { RelatedItem } from "../../documents"; -import React, { useContext } from "react"; +import React from "react"; import { StepAgreement, StepInformations, @@ -13,15 +13,14 @@ import { StepResultat, } from "./steps"; import { useRuptureCoEventEmitter } from "./events/useRuptureCoEventEmitter"; -import { EVENT_CATEGORY } from "../common/components/Feedback/tracking"; import { CalculateurIndemnite, IndemniteDepartStepName, } from "../common/indemnite-depart"; -import { SimulatorLayout } from "../common/components/SimulatorLayout"; -import { IndemniteDepartContext } from "../common/indemnite-depart/store"; import { Step } from "../common/components/SimulatorLayout/types"; import { IndemniteDepartType } from "../common/indemnite-depart/types"; +import { EVENT_CATEGORY } from "src/outils/common/Feedback/tracking"; +import StepSalaires from "../common/indemnite-depart/steps/Salaires"; const steps: Step[] = [ { @@ -29,38 +28,38 @@ const steps: Step[] = [ name: IndemniteDepartStepName.Introduction, Component: StepIntro, }, - // { - // label: "Contrat de travail", - // name: IndemniteDepartStepName.ContratTravail, - // Component: StepContratTravail, - // }, - // { - // label: "Convention collective", - // name: IndemniteDepartStepName.Agreement, - // Component: StepAgreement, - // }, - // { - // label: "Informations", - // name: IndemniteDepartStepName.Informations, - // Component: StepInformations, - // }, - // { - // label: "Ancienneté", - // name: IndemniteDepartStepName.Anciennete, - // Component: StepAnciennete, - // }, - // { - // label: "Salaires", - // name: IndemniteDepartStepName.Salaires, - // Component: () => ( - // - // ), - // }, - // { - // label: "Indemnité", - // name: IndemniteDepartStepName.Resultat, - // Component: StepResultat, - // }, + { + label: "Contrat de travail", + name: IndemniteDepartStepName.ContratTravail, + Component: StepContratTravail, + }, + { + label: "Convention collective", + name: IndemniteDepartStepName.Agreement, + Component: StepAgreement, + }, + { + label: "Informations", + name: IndemniteDepartStepName.Informations, + Component: StepInformations, + }, + { + label: "Ancienneté", + name: IndemniteDepartStepName.Anciennete, + Component: StepAnciennete, + }, + { + label: "Salaires", + name: IndemniteDepartStepName.Salaires, + Component: () => ( + + ), + }, + { + label: "Indemnité", + name: IndemniteDepartStepName.Resultat, + Component: StepResultat, + }, ]; type Props = { diff --git a/packages/code-du-travail-frontend/src/modules/outils/indemnite-rupture-conventionnelle/steps/Anciennete/index.tsx b/packages/code-du-travail-frontend/src/modules/outils/indemnite-rupture-conventionnelle/steps/Anciennete/index.tsx index 201510190c..71622ef0e1 100644 --- a/packages/code-du-travail-frontend/src/modules/outils/indemnite-rupture-conventionnelle/steps/Anciennete/index.tsx +++ b/packages/code-du-travail-frontend/src/modules/outils/indemnite-rupture-conventionnelle/steps/Anciennete/index.tsx @@ -1,12 +1,11 @@ import React, { useContext, useEffect } from "react"; -import { informationToSituation } from "src/modules/outils/common/components/Informations/utils"; -import RadioQuestion from "src/modules/outils/common/components/RadioQuestion"; -import TextQuestion from "src/modules/outils/common/components/TextQuestion"; -import { getMessageMotifExample } from "src/modules/outils/common/indemnite-depart/agreements"; import { - AbsencePeriods, - SectionTitleWithTooltip, -} from "src/modules/outils/common/indemnite-depart/steps/Anciennete"; + RadioQuestion, + TextQuestion, +} from "src/modules/outils/common/components"; +import { informationToSituation } from "src/modules/outils/common/indemnite-depart/steps/Informations/utils"; +import { getMessageMotifExample } from "src/modules/outils/common/indemnite-depart/agreements"; +import { AbsencePeriods } from "src/modules/outils/common/indemnite-depart/steps/Anciennete"; import { IndemniteDepartContext, useIndemniteDepartStore, @@ -65,22 +64,18 @@ const StepAnciennete = () => { return ( <> -

      Dates de début et de fin de contrat

      { onChangeDateNotification(value); @@ -88,32 +83,8 @@ const StepAnciennete = () => { }} error={errorDateSortie} id="dateSortie" - showRequired dataTestId={"date-sortie"} - tooltip={{ - content: ( -

      - La date de rupture du contrat est indiquée dans la convention de - rupture. Dans tous les cas, elle ne peut intervenir avant la fin - du délai laissé à l’administration pour valider la rupture - conventionnelle. -

      - ), - }} - /> - - Pour rendre la saisie de l'outil plus simple, les absences de - moins d'un mois ne sont pas comptabilisées. Or, ces absences - peuvent impacter l'ancienneté et donner ainsi lieu à un - montant d'indemnité inférieur à celui calculé par notre - simulateur. -

      - ), - }} + subLabel="La date de rupture du contrat est indiquée dans la convention de rupture. Dans tous les cas, elle ne peut intervenir avant la fin du délai laissé à l’administration pour valider la rupture conventionnelle." /> { selectedOption={hasAbsenceProlonge} onChangeSelectedOption={onChangeHasAbsenceProlonge} error={errorAbsenceProlonge} - showRequired /> {hasAbsenceProlonge === "oui" && ( { } }} error={errorTypeContratTravail} - showRequired autoFocus /> {typeContratTravail === "cdi" && ( @@ -94,19 +95,16 @@ const StepContratTravail = (): JSX.Element => { selectedOption={arretTravail} onChangeSelectedOption={onChangeArretTravail} error={errorArretTravail} - showRequired /> )} {typeContratTravail === "cdi" && arretTravail === "oui" && ( )} diff --git a/packages/code-du-travail-frontend/src/modules/outils/indemnite-rupture-conventionnelle/steps/Resultat/Eligible.tsx b/packages/code-du-travail-frontend/src/modules/outils/indemnite-rupture-conventionnelle/steps/Resultat/Eligible.tsx index f32a189c5f..f73553853d 100644 --- a/packages/code-du-travail-frontend/src/modules/outils/indemnite-rupture-conventionnelle/steps/Resultat/Eligible.tsx +++ b/packages/code-du-travail-frontend/src/modules/outils/indemnite-rupture-conventionnelle/steps/Resultat/Eligible.tsx @@ -9,7 +9,7 @@ import { IndemniteDepartContext, useIndemniteDepartStore, } from "src/modules/outils/common/indemnite-depart/store"; -import { informationToSituation } from "src/modules/outils/common/components/Informations/utils"; +import { informationToSituation } from "src/modules/outils/common/indemnite-depart/steps/Informations/utils"; import { DecryptResult, FilledElements,
      + {header.label} +