diff --git a/mon-aide-cyber-ui/src/composants/utilisateur/ComposantMenuUtilisateur.tsx b/mon-aide-cyber-ui/src/composants/utilisateur/ComposantMenuUtilisateur.tsx
index bc54ea0fc..188c0bd7e 100644
--- a/mon-aide-cyber-ui/src/composants/utilisateur/ComposantMenuUtilisateur.tsx
+++ b/mon-aide-cyber-ui/src/composants/utilisateur/ComposantMenuUtilisateur.tsx
@@ -30,6 +30,12 @@ export const ComposantMenuUtilisateur = ({
navigationMAC.etat
);
}
+ if (new MoteurDeLiens(navigationMAC.etat).existe('valider-signature-cgu')) {
+ navigationMAC.navigue(
+ `${ROUTE_AIDANT}/valide-signature-cgu`,
+ navigationMAC.etat
+ );
+ }
}, [navigationMAC, resetBoundary]);
const deconnecter = useCallback(() => {
diff --git a/mon-aide-cyber-ui/src/domaine/Lien.ts b/mon-aide-cyber-ui/src/domaine/Lien.ts
index 8eefeb5fa..675f4c05b 100644
--- a/mon-aide-cyber-ui/src/domaine/Lien.ts
+++ b/mon-aide-cyber-ui/src/domaine/Lien.ts
@@ -17,7 +17,7 @@ export type Action =
| 'afficher-profil'
| 'afficher-tableau-de-bord'
| 'afficher-annuaire-aidants'
- | 'creer-espace-aidant'
+ | 'valider-signature-cgu'
| 'demander-aide'
| 'solliciter-aide'
| 'demande-devenir-aidant'
diff --git a/mon-aide-cyber-ui/src/domaine/MoteurDeLiens.ts b/mon-aide-cyber-ui/src/domaine/MoteurDeLiens.ts
index 618fc747e..b315b174b 100644
--- a/mon-aide-cyber-ui/src/domaine/MoteurDeLiens.ts
+++ b/mon-aide-cyber-ui/src/domaine/MoteurDeLiens.ts
@@ -16,9 +16,8 @@ const actionsStatiques: ActionsStatiques = {
'lancer-diagnostic': {
applique: (lien) => (lien.route = `${ROUTE_AIDANT}/tableau-de-bord`),
},
- 'creer-espace-aidant': {
- applique: (lien) =>
- (lien.route = `${ROUTE_AIDANT}/finalise-creation-espace-aidant`),
+ 'valider-signature-cgu': {
+ applique: (lien) => (lien.route = `${ROUTE_AIDANT}/valide-signature-cgu`),
},
'se-connecter': { applique: (lien) => (lien.route = '/connexion') },
};
diff --git a/mon-aide-cyber-ui/src/domaine/authentification/FormulaireAuthentification.tsx b/mon-aide-cyber-ui/src/domaine/authentification/FormulaireAuthentification.tsx
index 040ccb753..6396a032b 100644
--- a/mon-aide-cyber-ui/src/domaine/authentification/FormulaireAuthentification.tsx
+++ b/mon-aide-cyber-ui/src/domaine/authentification/FormulaireAuthentification.tsx
@@ -89,9 +89,9 @@ export const ComposantAuthentification = ({
...reponse.liens,
}),
() =>
- moteurDeLiens.trouve('creer-espace-aidant', () =>
+ moteurDeLiens.trouve('valider-signature-cgu', () =>
navigationMAC.navigue(
- `${ROUTE_AIDANT}/finalise-creation-espace-aidant`,
+ `${ROUTE_AIDANT}/valide-signature-cgu`,
{ ...reponse.liens }
)
)
diff --git a/mon-aide-cyber-ui/src/domaine/connexion/composants/FormulaireConnexion.tsx b/mon-aide-cyber-ui/src/domaine/connexion/composants/FormulaireConnexion.tsx
index f7503efb3..c111f839d 100644
--- a/mon-aide-cyber-ui/src/domaine/connexion/composants/FormulaireConnexion.tsx
+++ b/mon-aide-cyber-ui/src/domaine/connexion/composants/FormulaireConnexion.tsx
@@ -16,9 +16,9 @@ export const FormulaireConnexion = () => {
useEffect(() => {
const moteurDeLiens = new MoteurDeLiens(navigationMAC.etat);
- moteurDeLiens.trouve('creer-espace-aidant', () =>
+ moteurDeLiens.trouve('valider-signature-cgu', () =>
navigationMAC.navigue(
- `${ROUTE_AIDANT}/finalise-creation-espace-aidant`,
+ `${ROUTE_AIDANT}/valide-signature-cgu`,
navigationMAC.etat
)
);
diff --git a/mon-aide-cyber-ui/src/domaine/espace-aidant/EspaceAidant.ts b/mon-aide-cyber-ui/src/domaine/espace-aidant/EspaceAidant.ts
index 7cece6dec..36101811c 100644
--- a/mon-aide-cyber-ui/src/domaine/espace-aidant/EspaceAidant.ts
+++ b/mon-aide-cyber-ui/src/domaine/espace-aidant/EspaceAidant.ts
@@ -1,5 +1,3 @@
-export type CreationEspaceAidant = {
- cguSignees: boolean;
- motDePasse: string;
- motDePasseTemporaire: string;
+export type ValidationSignatureCGU = {
+ cguValidees: boolean;
};
diff --git a/mon-aide-cyber-ui/src/domaine/espace-aidant/creation-espace-aidant/EcranCreationEspaceAidant.tsx b/mon-aide-cyber-ui/src/domaine/espace-aidant/creation-espace-aidant/EcranCreationEspaceAidant.tsx
deleted file mode 100644
index 42e27c287..000000000
--- a/mon-aide-cyber-ui/src/domaine/espace-aidant/creation-espace-aidant/EcranCreationEspaceAidant.tsx
+++ /dev/null
@@ -1,34 +0,0 @@
-import { FormulaireCreationEspaceAidant } from './FormulaireCreationEspaceAidant.tsx';
-import { Header } from '../../../composants/layout/Header.tsx';
-import { LienMAC } from '../../../composants/LienMAC.tsx';
-import { Footer } from '../../../composants/layout/Footer.tsx';
-
-export const EcranCreationEspaceAidant = () => {
- return (
- <>
-
} />
-
-
-
-
-
-
Création de votre espace Aidant MonAideCyber
-
Bienvenue dans la communauté !
-
-
-
-
-
-
-
- >
- );
-};
diff --git a/mon-aide-cyber-ui/src/domaine/espace-aidant/creation-espace-aidant/FormulaireCreationEspaceAidant.tsx b/mon-aide-cyber-ui/src/domaine/espace-aidant/creation-espace-aidant/FormulaireCreationEspaceAidant.tsx
deleted file mode 100644
index 03eecaeff..000000000
--- a/mon-aide-cyber-ui/src/domaine/espace-aidant/creation-espace-aidant/FormulaireCreationEspaceAidant.tsx
+++ /dev/null
@@ -1,156 +0,0 @@
-import { FormEvent, useCallback, useEffect, useReducer, useState } from 'react';
-import {
- cguCliquees,
- creationEspaceAidantInvalidee,
- creationEspaceAidantTransmise,
- creationEspaceAidantValidee,
- initialiseReducteur,
- reducteurCreationEspaceAidant,
-} from './reducteurCreationEspaceAidant.tsx';
-import { useNavigationMAC } from '../../../fournisseurs/hooks.ts';
-import { MoteurDeLiens, ROUTE_AIDANT } from '../../MoteurDeLiens.ts';
-import { Lien, ReponseHATEOAS } from '../../Lien.ts';
-import { constructeurParametresAPI } from '../../../fournisseurs/api/ConstructeurParametresAPI.ts';
-import { CreationEspaceAidant } from '../EspaceAidant.ts';
-import { ComposantModificationMotDePasse } from '../../../composants/mot-de-passe/ComposantModificationMotDePasse.tsx';
-import { MACAPIType, useMACAPI } from '../../../fournisseurs/api/useMACAPI.ts';
-
-type ProprietesComposantCreationEspaceAidant = {
- macAPI: MACAPIType;
-};
-
-export const ComposantCreationEspaceAidant = ({
- macAPI,
-}: ProprietesComposantCreationEspaceAidant) => {
- const [etatCreationEspaceAidant, envoie] = useReducer(
- reducteurCreationEspaceAidant,
- initialiseReducteur()
- );
- const [boutonValiderClique, setBoutonValiderClique] = useState(false);
- const navigationMAC = useNavigationMAC();
-
- const creeEspaceAidant = useCallback(async (e: FormEvent) => {
- e.preventDefault();
- setBoutonValiderClique(true);
- }, []);
-
- useEffect(() => {
- new MoteurDeLiens(navigationMAC.etat).trouve(
- 'creer-espace-aidant',
- (lien: Lien) => {
- if (
- etatCreationEspaceAidant.saisieValide() &&
- etatCreationEspaceAidant.creationEspaceAidantATransmettre
- ) {
- const parametresAPI =
- constructeurParametresAPI
()
- .url(lien.url)
- .methode(lien.methode!)
- .corps({
- cguSignees: etatCreationEspaceAidant.cguSignees,
- motDePasse:
- etatCreationEspaceAidant.motDePasse!.nouveauMotDePasse,
- motDePasseTemporaire:
- etatCreationEspaceAidant.motDePasse!.ancienMotDePasse,
- })
- .construis();
- macAPI
- .execute(
- parametresAPI,
- async (json) => await json
- )
- .then((reponse) => {
- envoie(creationEspaceAidantTransmise());
- navigationMAC.navigue(
- `${ROUTE_AIDANT}/tableau-de-bord`,
- reponse.liens,
- ['creer-espace-aidant']
- );
- })
- .catch((erreur) => envoie(creationEspaceAidantInvalidee(erreur)));
- }
- },
- () =>
- navigationMAC.navigue(
- `${ROUTE_AIDANT}/tableau-de-bord`,
- navigationMAC.etat
- )
- );
- }, [navigationMAC, etatCreationEspaceAidant]);
-
- const surCGUSignees = useCallback(() => {
- envoie(cguCliquees());
- }, []);
-
- return (
-
- );
-};
-
-export const FormulaireCreationEspaceAidant = () => {
- return ;
-};
diff --git a/mon-aide-cyber-ui/src/domaine/espace-aidant/creation-espace-aidant/reducteurCreationEspaceAidant.tsx b/mon-aide-cyber-ui/src/domaine/espace-aidant/creation-espace-aidant/reducteurCreationEspaceAidant.tsx
deleted file mode 100644
index 3ad0e7010..000000000
--- a/mon-aide-cyber-ui/src/domaine/espace-aidant/creation-espace-aidant/reducteurCreationEspaceAidant.tsx
+++ /dev/null
@@ -1,144 +0,0 @@
-import { ReactElement } from 'react';
-import {
- ChampsErreur,
- construisErreur,
- PresentationErreur,
-} from '../../../composants/alertes/Erreurs.tsx';
-import { ModificationMotDePasse } from '../../../composants/mot-de-passe/ComposantModificationMotDePasse.tsx';
-
-type ErreurCreationEspaceAidant = {
- cguSignees?: PresentationErreur;
-};
-
-export type EtatCreationEspaceAidant = {
- cguSignees: boolean;
- motDePasse?: ModificationMotDePasse;
- champsErreur?: ReactElement;
- erreur?: ErreurCreationEspaceAidant;
- creationEspaceAidantATransmettre?: boolean;
- saisieValide: () => boolean;
-};
-
-enum TypeActionCreationEspaceAidant {
- CREATION_ESPACE_AIDANT_VALIDEE = 'CREATION_ESPACE_AIDANT_VALIDEE',
- CGU_CLIQUEES = 'CGU_CLIQUEES',
- CREATION_ESPACE_AIDANT_TRANSMISE = 'CREATION_ESPACE_AIDANT_TRANSMISE',
- CREATION_ESPACE_AIDANT_INVALIDEE = 'CREATION_ESPACE_AIDANT_INVALIDEE',
-}
-
-type ActionCreationEspaceAidant =
- | {
- motDePasse: ModificationMotDePasse;
- type: TypeActionCreationEspaceAidant.CREATION_ESPACE_AIDANT_VALIDEE;
- }
- | {
- type: TypeActionCreationEspaceAidant.CGU_CLIQUEES;
- }
- | {
- type: TypeActionCreationEspaceAidant.CREATION_ESPACE_AIDANT_TRANSMISE;
- }
- | {
- erreur: Error;
- type: TypeActionCreationEspaceAidant.CREATION_ESPACE_AIDANT_INVALIDEE;
- };
-
-export const reducteurCreationEspaceAidant = (
- etat: EtatCreationEspaceAidant,
- action: ActionCreationEspaceAidant
-): EtatCreationEspaceAidant => {
- const construisErreurCGU = () =>
- construisErreur('cguSignees', {
- texte: 'Veuillez accepter les CGU.',
- identifiantTexteExplicatif: 'cguSignees',
- });
-
- switch (action.type) {
- case TypeActionCreationEspaceAidant.CREATION_ESPACE_AIDANT_INVALIDEE: {
- const etatCourant = { ...etat };
- delete etatCourant['creationEspaceAidantATransmettre'];
- delete etatCourant['motDePasse'];
- return {
- ...etatCourant,
- cguSignees: false,
- champsErreur: ,
- saisieValide: () => false,
- };
- }
- case TypeActionCreationEspaceAidant.CREATION_ESPACE_AIDANT_TRANSMISE: {
- const etatCourant = { ...etat };
- delete etatCourant['creationEspaceAidantATransmettre'];
- delete etatCourant['motDePasse'];
- return {
- ...etatCourant,
- };
- }
- case TypeActionCreationEspaceAidant.CGU_CLIQUEES: {
- const cguSignees = !etat.cguSignees;
- const erreur = { ...etat.erreur };
- delete erreur['cguSignees'];
- return {
- ...etat,
- cguSignees: cguSignees,
- erreur: {
- ...erreur,
- ...(!cguSignees && construisErreurCGU()),
- },
- saisieValide: () =>
- cguSignees && !!etat.motDePasse && etat.motDePasse.valide,
- };
- }
- case TypeActionCreationEspaceAidant.CREATION_ESPACE_AIDANT_VALIDEE: {
- const motDePasse = action.motDePasse;
- const motDePasseValide = motDePasse.valide;
- return {
- ...etat,
- erreur: {
- ...(!etat.cguSignees && {
- ...construisErreurCGU(),
- }),
- },
- motDePasse: {
- ancienMotDePasse: motDePasse.ancienMotDePasse,
- nouveauMotDePasse: motDePasse.nouveauMotDePasse,
- confirmationNouveauMotDePasse:
- motDePasse.confirmationNouveauMotDePasse,
- valide: motDePasse.valide,
- },
- saisieValide: () => etat.cguSignees && motDePasseValide,
- ...(etat.cguSignees &&
- motDePasseValide && {
- creationEspaceAidantATransmettre:
- etat.cguSignees && motDePasseValide,
- }),
- };
- }
- }
-};
-
-export const creationEspaceAidantValidee = (
- motDePasse: ModificationMotDePasse
-): ActionCreationEspaceAidant => ({
- motDePasse,
- type: TypeActionCreationEspaceAidant.CREATION_ESPACE_AIDANT_VALIDEE,
-});
-
-export const cguCliquees = (): ActionCreationEspaceAidant => ({
- type: TypeActionCreationEspaceAidant.CGU_CLIQUEES,
-});
-
-export const creationEspaceAidantTransmise =
- (): ActionCreationEspaceAidant => ({
- type: TypeActionCreationEspaceAidant.CREATION_ESPACE_AIDANT_TRANSMISE,
- });
-
-export const creationEspaceAidantInvalidee = (
- erreur: Error
-): ActionCreationEspaceAidant => ({
- erreur,
- type: TypeActionCreationEspaceAidant.CREATION_ESPACE_AIDANT_INVALIDEE,
-});
-export const initialiseReducteur = (): EtatCreationEspaceAidant => ({
- cguSignees: false,
- saisieValide: () => false,
- erreur: {},
-});
diff --git a/mon-aide-cyber-ui/src/domaine/espace-aidant/ecran-diagnostics/EcranDiagnostics.tsx b/mon-aide-cyber-ui/src/domaine/espace-aidant/ecran-diagnostics/EcranDiagnostics.tsx
index e76608940..8bbda72fb 100644
--- a/mon-aide-cyber-ui/src/domaine/espace-aidant/ecran-diagnostics/EcranDiagnostics.tsx
+++ b/mon-aide-cyber-ui/src/domaine/espace-aidant/ecran-diagnostics/EcranDiagnostics.tsx
@@ -11,6 +11,7 @@ import {
} from '../../../composants/diagnostic/ComposantLancerDiagnostic.tsx';
import { TypographieH2 } from '../../../composants/communs/typographie/TypographieH2/TypographieH2.tsx';
import { useMACAPI } from '../../../fournisseurs/api/useMACAPI.ts';
+import { useErrorBoundary } from 'react-error-boundary';
export type Diagnostic = {
dateCreation: string;
@@ -25,6 +26,7 @@ export const EcranDiagnostics = () => {
const [enCoursDeChargement, setEnCoursDeChargement] = useState(true);
const [diagnostics, setDiagnostics] = useState([]);
const navigationMAC = useNavigationMAC();
+ const { showBoundary } = useErrorBoundary();
const macAPI = useMACAPI();
useEffect(() => {
@@ -46,7 +48,7 @@ export const EcranDiagnostics = () => {
setDiagnostics(tableauDeBord.diagnostics);
})
.catch((erreur: ReponseHATEOAS) => {
- console.log(erreur);
+ showBoundary(erreur);
});
}
}
diff --git a/mon-aide-cyber-ui/src/domaine/validation-cgu/EcranValidationSignatureCGU.tsx b/mon-aide-cyber-ui/src/domaine/validation-cgu/EcranValidationSignatureCGU.tsx
new file mode 100644
index 000000000..056f79bf1
--- /dev/null
+++ b/mon-aide-cyber-ui/src/domaine/validation-cgu/EcranValidationSignatureCGU.tsx
@@ -0,0 +1,28 @@
+import { FormulaireValidationSignatureCGU } from './FormulaireValidationSignatureCGU.tsx';
+import illustrationValidationCGU from '../../../public/images/illustration-mesures.svg';
+import './ecran-validation-cgu.scss';
+import { Header } from '../../composants/layout/Header.tsx';
+import { LienMAC } from '../../composants/LienMAC.tsx';
+import { Footer } from '../../composants/layout/Footer.tsx';
+
+export const EcranValidationSignatureCGU = () => {
+ return (
+ <>
+ } />
+
+
+
+

+
+
+
+ >
+ );
+};
diff --git a/mon-aide-cyber-ui/src/domaine/validation-cgu/FormulaireValidationSignatureCGU.tsx b/mon-aide-cyber-ui/src/domaine/validation-cgu/FormulaireValidationSignatureCGU.tsx
new file mode 100644
index 000000000..e52e49451
--- /dev/null
+++ b/mon-aide-cyber-ui/src/domaine/validation-cgu/FormulaireValidationSignatureCGU.tsx
@@ -0,0 +1,127 @@
+import { FormEvent, useCallback, useReducer } from 'react';
+import {
+ cguCliquees,
+ initialiseReducteur,
+ reducteurValidationCGU,
+ validationCGUInvalidee,
+} from './reducteurValidationCGU.tsx';
+import { MACAPIType, useMACAPI } from '../../fournisseurs/api/useMACAPI.ts';
+import { useNavigationMAC } from '../../fournisseurs/hooks.ts';
+import { MoteurDeLiens, ROUTE_AIDANT } from '../MoteurDeLiens.ts';
+import { Lien, ReponseHATEOAS } from '../Lien.ts';
+import { constructeurParametresAPI } from '../../fournisseurs/api/ConstructeurParametresAPI.ts';
+import { ValidationSignatureCGU } from '../espace-aidant/EspaceAidant.ts';
+import { TypographieH2 } from '../../composants/communs/typographie/TypographieH2/TypographieH2.tsx';
+
+type ProprietesComposantCreationEspaceAidant = {
+ macAPI: MACAPIType;
+};
+
+export const ComposantValidationSignatureCGU = ({
+ macAPI,
+}: ProprietesComposantCreationEspaceAidant) => {
+ const [etatCreationEspaceAidant, envoie] = useReducer(
+ reducteurValidationCGU,
+ initialiseReducteur()
+ );
+ const navigationMAC = useNavigationMAC();
+
+ const valideLesCGU = useCallback(
+ async (e: FormEvent) => {
+ e.preventDefault();
+ new MoteurDeLiens(navigationMAC.etat).trouve(
+ 'valider-signature-cgu',
+ (lien: Lien) => {
+ if (etatCreationEspaceAidant.saisieValide()) {
+ const parametresAPI =
+ constructeurParametresAPI()
+ .url(lien.url)
+ .methode(lien.methode!)
+ .corps({
+ cguValidees: etatCreationEspaceAidant.cguSignees,
+ })
+ .construis();
+ macAPI
+ .execute(
+ parametresAPI,
+ async (json) => await json
+ )
+ .then((reponse) => {
+ navigationMAC.navigue(
+ `${ROUTE_AIDANT}/tableau-de-bord`,
+ reponse.liens,
+ ['valider-signature-cgu']
+ );
+ })
+ .catch((erreur) => envoie(validationCGUInvalidee(erreur)));
+ }
+ },
+ () =>
+ navigationMAC.navigue(
+ `${ROUTE_AIDANT}/tableau-de-bord`,
+ navigationMAC.etat
+ )
+ );
+ },
+ [navigationMAC, etatCreationEspaceAidant]
+ );
+
+ const surCGUSignees = useCallback(() => {
+ envoie(cguCliquees());
+ }, []);
+
+ return (
+ <>
+
+
+ Les Conditions Générales d’Utilisation MonAideCyber évoluent !
+
+
+
+ >
+ );
+};
+
+export const FormulaireValidationSignatureCGU = () => {
+ return ;
+};
diff --git a/mon-aide-cyber-ui/src/domaine/validation-cgu/ecran-validation-cgu.scss b/mon-aide-cyber-ui/src/domaine/validation-cgu/ecran-validation-cgu.scss
new file mode 100644
index 000000000..ae799263b
--- /dev/null
+++ b/mon-aide-cyber-ui/src/domaine/validation-cgu/ecran-validation-cgu.scss
@@ -0,0 +1,66 @@
+@import '../../assets/styles/points-de-rupture';
+
+.ecran-validation-cgu {
+ display: grid;
+ grid-template-columns: 1fr;
+ grid-template-areas: 'formulaire';
+
+ @include a-partir-de(md) {
+ grid-template-columns: 55% auto;
+ grid-template-areas: 'formulaire icone';
+ }
+
+ @include a-partir-de(xl) {
+ grid-template-columns: 20% 30% 30% 20%;
+ grid-template-areas: 'gauche formulaire icone droite';
+ }
+
+ height: 800px;
+
+ .formulaire-colonne-gauche {
+ grid-area: formulaire;
+ padding: 3rem 2.5rem;
+
+ @include a-partir-de(md) {
+ padding: 5rem 4rem;
+ }
+
+ @include a-partir-de(lg) {
+ padding: 5rem 6rem;
+ }
+
+ @include a-partir-de(xl) {
+ padding: 5rem 13rem;
+ }
+
+ form {
+ padding-top: 2.5rem;
+ }
+
+ .mac-radio-group {
+ padding-top: 1.5rem;
+ padding-bottom: 1.5rem;
+ }
+
+ button {
+ width: 100%;
+ justify-content: center;
+ }
+ }
+
+ .icone-colonne-droite {
+ display: none;
+ //grid-area: icone / icone / icone / droite;
+ grid-area: icone;
+
+ @include a-partir-de(md) {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ }
+ }
+
+ img {
+ max-width: 100%;
+ }
+}
diff --git a/mon-aide-cyber-ui/src/domaine/validation-cgu/reducteurValidationCGU.tsx b/mon-aide-cyber-ui/src/domaine/validation-cgu/reducteurValidationCGU.tsx
new file mode 100644
index 000000000..d88cdf681
--- /dev/null
+++ b/mon-aide-cyber-ui/src/domaine/validation-cgu/reducteurValidationCGU.tsx
@@ -0,0 +1,83 @@
+import { ReactElement } from 'react';
+import {
+ ChampsErreur,
+ construisErreur,
+ PresentationErreur,
+} from '../../composants/alertes/Erreurs.tsx';
+
+type ErreurCreationEspaceAidant = {
+ cguSignees?: PresentationErreur;
+};
+
+export type EtatValidationCGU = {
+ cguSignees: boolean;
+ champsErreur?: ReactElement;
+ erreur?: ErreurCreationEspaceAidant;
+ saisieValide: () => boolean;
+};
+
+enum TypeActionValidationCGU {
+ CGU_CLIQUEES = 'CGU_CLIQUEES',
+ CREATION_ESPACE_AIDANT_INVALIDEE = 'CREATION_ESPACE_AIDANT_INVALIDEE',
+}
+
+type ActionCreationEspaceAidant =
+ | {
+ type: TypeActionValidationCGU.CGU_CLIQUEES;
+ }
+ | {
+ erreur: Error;
+ type: TypeActionValidationCGU.CREATION_ESPACE_AIDANT_INVALIDEE;
+ };
+
+export const reducteurValidationCGU = (
+ etat: EtatValidationCGU,
+ action: ActionCreationEspaceAidant
+): EtatValidationCGU => {
+ const construisErreurCGU = () =>
+ construisErreur('cguSignees', {
+ texte: 'Veuillez accepter les CGU.',
+ identifiantTexteExplicatif: 'cguSignees',
+ });
+
+ switch (action.type) {
+ case TypeActionValidationCGU.CREATION_ESPACE_AIDANT_INVALIDEE: {
+ const etatCourant = { ...etat };
+ return {
+ ...etatCourant,
+ cguSignees: false,
+ champsErreur: ,
+ saisieValide: () => false,
+ };
+ }
+ case TypeActionValidationCGU.CGU_CLIQUEES: {
+ const cguSignees = !etat.cguSignees;
+ const erreur = { ...etat.erreur };
+ delete erreur['cguSignees'];
+ return {
+ ...etat,
+ cguSignees: cguSignees,
+ erreur: {
+ ...erreur,
+ ...(!cguSignees && construisErreurCGU()),
+ },
+ saisieValide: () => cguSignees,
+ };
+ }
+ }
+};
+
+export const cguCliquees = (): ActionCreationEspaceAidant => ({
+ type: TypeActionValidationCGU.CGU_CLIQUEES,
+});
+export const validationCGUInvalidee = (
+ erreur: Error
+): ActionCreationEspaceAidant => ({
+ erreur,
+ type: TypeActionValidationCGU.CREATION_ESPACE_AIDANT_INVALIDEE,
+});
+export const initialiseReducteur = (): EtatValidationCGU => ({
+ cguSignees: false,
+ saisieValide: () => false,
+ erreur: {},
+});
diff --git a/mon-aide-cyber-ui/src/fournisseurs/RequiertAidantSansEspace.tsx b/mon-aide-cyber-ui/src/fournisseurs/NecessiteValidationCGU.tsx
similarity index 90%
rename from mon-aide-cyber-ui/src/fournisseurs/RequiertAidantSansEspace.tsx
rename to mon-aide-cyber-ui/src/fournisseurs/NecessiteValidationCGU.tsx
index ee6e2ff8c..da4b67a64 100644
--- a/mon-aide-cyber-ui/src/fournisseurs/RequiertAidantSansEspace.tsx
+++ b/mon-aide-cyber-ui/src/fournisseurs/NecessiteValidationCGU.tsx
@@ -3,14 +3,14 @@ import { ReactElement, useEffect, useState } from 'react';
import { MoteurDeLiens, ROUTE_AIDANT } from '../domaine/MoteurDeLiens.ts';
import { Outlet } from 'react-router-dom';
-export const RequiertAidantSansEspace = () => {
+export const NecessiteValidationCGU = () => {
const navigationMAC = useNavigationMAC();
const [redirection, setRedirection] = useState(<>>);
useEffect(() => {
const moteurDeLiens = new MoteurDeLiens(navigationMAC.etat);
moteurDeLiens.trouve(
- 'creer-espace-aidant',
+ 'valider-signature-cgu',
() => setRedirection(),
() =>
moteurDeLiens.trouve('lancer-diagnostic', () =>
diff --git a/mon-aide-cyber-ui/src/fournisseurs/RequiertEspaceAidant.tsx b/mon-aide-cyber-ui/src/fournisseurs/RequiertValidationCGU.tsx
similarity index 81%
rename from mon-aide-cyber-ui/src/fournisseurs/RequiertEspaceAidant.tsx
rename to mon-aide-cyber-ui/src/fournisseurs/RequiertValidationCGU.tsx
index b7eba888a..4b98ee8ef 100644
--- a/mon-aide-cyber-ui/src/fournisseurs/RequiertEspaceAidant.tsx
+++ b/mon-aide-cyber-ui/src/fournisseurs/RequiertValidationCGU.tsx
@@ -3,16 +3,16 @@ import { ReactElement, useEffect, useState } from 'react';
import { MoteurDeLiens, ROUTE_AIDANT } from '../domaine/MoteurDeLiens.ts';
import { Outlet } from 'react-router-dom';
-export const RequiertEspaceAidant = () => {
+export const RequiertValidationCGU = () => {
const navigationMAC = useNavigationMAC();
const [redirection, setRedirection] = useState(<>>);
useEffect(() => {
new MoteurDeLiens(navigationMAC.etat).trouve(
- 'creer-espace-aidant',
+ 'valider-signature-cgu',
() =>
navigationMAC.navigue(
- `${ROUTE_AIDANT}/finalise-creation-espace-aidant`,
+ `${ROUTE_AIDANT}/valide-signature-cgu`,
navigationMAC.etat
),
() => setRedirection()
diff --git a/mon-aide-cyber-ui/src/stories/CreationEspaceAidant.stories.tsx b/mon-aide-cyber-ui/src/stories/CreationEspaceAidant.stories.tsx
deleted file mode 100644
index fea8bd8d2..000000000
--- a/mon-aide-cyber-ui/src/stories/CreationEspaceAidant.stories.tsx
+++ /dev/null
@@ -1,229 +0,0 @@
-import { Meta, StoryObj } from '@storybook/react';
-import { ParametresAPI } from '../fournisseurs/api/ConstructeurParametresAPI.ts';
-import { ContexteNavigationMAC } from '../fournisseurs/ContexteNavigationMAC.tsx';
-import { expect, userEvent, within } from '@storybook/test';
-import { ComposantCreationEspaceAidant } from '../domaine/espace-aidant/creation-espace-aidant/FormulaireCreationEspaceAidant.tsx';
-
-const meta = {
- title: "Création de l'espace Aidant",
- component: ComposantCreationEspaceAidant,
- parameters: {
- layout: 'fullscreen',
- },
-} satisfies Meta;
-
-let valeursSaisies = {};
-const macAPIMemoire = {
- execute: (
- parametresAPI: ParametresAPI,
- _transcris: (contenu: Promise) => Promise
- ) => {
- valeursSaisies = parametresAPI.corps!;
- return Promise.resolve({ liens: { url: '' } }) as Promise;
- },
-};
-
-export default meta;
-type Story = StoryObj;
-
-export const CreationEspaceAidant: Story = {
- args: { macAPI: macAPIMemoire },
- decorators: [
- (story) => (
- {
- return;
- },
- // eslint-disable-next-line @typescript-eslint/no-empty-function
- ajouteEtat: () => {},
- // eslint-disable-next-line @typescript-eslint/no-empty-function
- navigue: (_moteurDeLiens, _action, _exclusion) => {},
- // eslint-disable-next-line @typescript-eslint/no-empty-function
- retourAccueil: () => {},
- }}
- >
- {story()}
-
- ),
- ],
- name: "Crée l'espace de l'aidant",
- play: async ({ canvasElement, step }) => {
- const canvas = within(canvasElement);
-
- await step(
- "Lorsque l'on arrive sur la page de création de l'aidant",
- async () => {
- expect(
- canvas.getByRole('textbox', {
- name: /saisissez votre mot de passe temporaire/i,
- })
- ).toBeInTheDocument();
- expect(
- canvas.getByRole('textbox', {
- name: /choisissez un nouveau mot de passe/i,
- })
- ).toBeInTheDocument();
- expect(
- canvas.getByRole('textbox', {
- name: /confirmez votre nouveau mot de passe/i,
- })
- ).toBeInTheDocument();
- expect(
- canvas.getByRole('checkbox', {
- name: /j'accepte les conditions générales d'utilisation/i,
- })
- ).toBeInTheDocument();
- }
- );
-
- await step(
- "L'utilisateur clique sur Valider sans rien remplir",
- async () => {
- await userEvent.click(canvas.getByRole('button', { name: /valider/i }));
-
- await expect(
- canvas.getByText(/vous devez saisir vos mots de passe./i)
- ).toBeInTheDocument();
- await expect(
- canvas.getByText(/veuillez accepter les cgu./i)
- ).toBeInTheDocument();
- }
- );
-
- await step("L'utilisateur se trompe dans la confirmation", async () => {
- const champMotDePasseTemporaire = canvas.getByRole('textbox', {
- name: /saisissez votre mot de passe temporaire/i,
- });
- const champNouveauMotDePasse = canvas.getByRole('textbox', {
- name: /choisissez un nouveau mot de passe/i,
- });
- const champConfirmationMotDePasse = canvas.getByRole('textbox', {
- name: /confirmez votre nouveau mot de passe/i,
- });
- await userEvent.type(champMotDePasseTemporaire, 'a');
- await userEvent.type(champNouveauMotDePasse, 'b');
- await userEvent.type(champConfirmationMotDePasse, 'c');
-
- await userEvent.click(canvas.getByRole('button', { name: /valider/i }));
-
- await expect(
- canvas.getByText(
- /la confirmation de votre mot de passe ne correspond pas au mot de passe saisi./i
- )
- ).toBeInTheDocument();
-
- await expect(
- canvas.getByText(/veuillez accepter les cgu./i)
- ).toBeInTheDocument();
- });
-
- await step(
- "L'utilisateur saisit le même mot de passe que le temporaire",
- async () => {
- const champMotDePasseTemporaire = canvas.getByRole('textbox', {
- name: /saisissez votre mot de passe temporaire/i,
- });
- const champNouveauMotDePasse = canvas.getByRole('textbox', {
- name: /choisissez un nouveau mot de passe/i,
- });
- const champConfirmationMotDePasse = canvas.getByRole('textbox', {
- name: /confirmez votre nouveau mot de passe/i,
- });
- await userEvent.clear(champMotDePasseTemporaire);
- await userEvent.clear(champNouveauMotDePasse);
- await userEvent.clear(champConfirmationMotDePasse);
- await userEvent.type(champMotDePasseTemporaire, 'a');
- await userEvent.type(champNouveauMotDePasse, 'a');
- await userEvent.type(champConfirmationMotDePasse, 'a');
-
- await userEvent.click(canvas.getByRole('button', { name: /valider/i }));
-
- await expect(
- canvas.getByText(
- /votre nouveau mot de passe doit être différent du mot de passe temporaire./i
- )
- ).toBeInTheDocument();
- await expect(
- canvas.getByText(/veuillez accepter les cgu./i)
- ).toBeInTheDocument();
- }
- );
-
- await step("L'utilisateur signe les CGU", async () => {
- const champMotDePasseTemporaire = canvas.getByRole('textbox', {
- name: /saisissez votre mot de passe temporaire/i,
- });
- const champNouveauMotDePasse = canvas.getByRole('textbox', {
- name: /choisissez un nouveau mot de passe/i,
- });
- const champConfirmationMotDePasse = canvas.getByRole('textbox', {
- name: /confirmez votre nouveau mot de passe/i,
- });
- await userEvent.clear(champMotDePasseTemporaire);
- await userEvent.clear(champNouveauMotDePasse);
- await userEvent.clear(champConfirmationMotDePasse);
- await userEvent.type(champMotDePasseTemporaire, 'a');
- await userEvent.type(champNouveauMotDePasse, 'a');
- await userEvent.type(champConfirmationMotDePasse, 'a');
-
- await userEvent.click(
- canvas.getByRole('checkbox', {
- name: /j'accepte les conditions générales d'utilisation/i,
- })
- );
- await userEvent.click(canvas.getByRole('button', { name: /valider/i }));
-
- await expect(
- canvas.getByText(
- /votre nouveau mot de passe doit être différent du mot de passe temporaire./i
- )
- ).toBeInTheDocument();
- await expect(
- canvas.queryByText(/veuillez accepter les cgu./i)
- ).not.toBeInTheDocument();
- });
-
- await step("L'utilisateur crée son espace aidant", async () => {
- const champMotDePasseTemporaire = canvas.getByRole('textbox', {
- name: /saisissez votre mot de passe temporaire/i,
- });
- const champNouveauMotDePasse = canvas.getByRole('textbox', {
- name: /choisissez un nouveau mot de passe/i,
- });
- const champConfirmationMotDePasse = canvas.getByRole('textbox', {
- name: /confirmez votre nouveau mot de passe/i,
- });
- const champCGU = canvas.getByRole('checkbox', {
- name: /j'accepte les conditions générales d'utilisation/i,
- });
-
- await userEvent.clear(champMotDePasseTemporaire);
- await userEvent.clear(champNouveauMotDePasse);
- await userEvent.clear(champConfirmationMotDePasse);
- await userEvent.click(champCGU);
- await userEvent.type(champMotDePasseTemporaire, 'a');
- await userEvent.type(champNouveauMotDePasse, 'b');
- await userEvent.type(champConfirmationMotDePasse, 'b');
- await userEvent.click(champCGU);
-
- await userEvent.click(canvas.getByRole('button', { name: /valider/i }));
-
- await expect(
- canvas.queryByText(/veuillez accepter les cgu./i)
- ).not.toBeInTheDocument();
-
- await expect(valeursSaisies).toStrictEqual({
- cguSignees: true,
- motDePasse: 'b',
- motDePasseTemporaire: 'a',
- });
- });
- },
-};
diff --git a/mon-aide-cyber-ui/test/domaine/espace-aidant/creation-espace-aidant/reducteurCreationEspaceAidant.spec.tsx b/mon-aide-cyber-ui/test/domaine/espace-aidant/creation-espace-aidant/reducteurCreationEspaceAidant.spec.tsx
deleted file mode 100644
index f11332eff..000000000
--- a/mon-aide-cyber-ui/test/domaine/espace-aidant/creation-espace-aidant/reducteurCreationEspaceAidant.spec.tsx
+++ /dev/null
@@ -1,293 +0,0 @@
-import { describe, expect, it } from 'vitest';
-import {
- ChampsErreur,
- TexteExplicatif,
-} from '../../../../src/composants/alertes/Erreurs.tsx';
-import {
- cguCliquees,
- creationEspaceAidantInvalidee,
- creationEspaceAidantTransmise,
- creationEspaceAidantValidee,
- EtatCreationEspaceAidant,
- initialiseReducteur,
- reducteurCreationEspaceAidant,
-} from '../../../../src/domaine/espace-aidant/creation-espace-aidant/reducteurCreationEspaceAidant.tsx';
-
-describe("Réducteur de création de l'espace Aidant", () => {
- const etatInitialCreationEspaceAidant: EtatCreationEspaceAidant =
- initialiseReducteur();
- describe("Lors de la création de l'espace", () => {
- it('valide les CGU', () => {
- const etatCreationEspaceAidant = reducteurCreationEspaceAidant(
- {
- ...etatInitialCreationEspaceAidant,
- cguSignees: true,
- },
- creationEspaceAidantValidee({
- ancienMotDePasse: 'mdp-temporaire',
- nouveauMotDePasse: 'mdp',
- confirmationNouveauMotDePasse: 'mdp',
- valide: true,
- })
- );
-
- expect(etatCreationEspaceAidant).toStrictEqual({
- cguSignees: true,
- motDePasse: {
- ancienMotDePasse: 'mdp-temporaire',
- nouveauMotDePasse: 'mdp',
- confirmationNouveauMotDePasse: 'mdp',
- valide: true,
- },
- erreur: {},
- creationEspaceAidantATransmettre: true,
- saisieValide: expect.any(Function),
- });
- expect(etatCreationEspaceAidant.saisieValide()).toBe(true);
- });
-
- it('invalide les CGU si elles ne sont pas signées', () => {
- const etatCreationEspaceAidant = reducteurCreationEspaceAidant(
- {
- ...etatInitialCreationEspaceAidant,
- },
- creationEspaceAidantValidee({
- ancienMotDePasse: 'mdp-temporaire',
- nouveauMotDePasse: 'mdp',
- confirmationNouveauMotDePasse: 'mdp',
- valide: true,
- })
- );
-
- expect(etatCreationEspaceAidant).toStrictEqual({
- cguSignees: false,
- erreur: {
- cguSignees: {
- className: 'fr-input-group--error',
- texteExplicatif: (
-
- ),
- },
- },
- motDePasse: {
- ancienMotDePasse: 'mdp-temporaire',
- nouveauMotDePasse: 'mdp',
- confirmationNouveauMotDePasse: 'mdp',
- valide: true,
- },
- saisieValide: expect.any(Function),
- });
- expect(etatCreationEspaceAidant.saisieValide()).toBe(false);
- });
-
- it("sur la confirmation, la saisie est invalide si le mot de passe n'est pas valide", () => {
- const etatCreationEspaceAidant = reducteurCreationEspaceAidant(
- {
- ...etatInitialCreationEspaceAidant,
- cguSignees: true,
- saisieValide: () => false,
- },
- creationEspaceAidantValidee({
- ancienMotDePasse: 'mot-de-passe',
- nouveauMotDePasse: 'mot-de-passe',
- confirmationNouveauMotDePasse: 'mot-de-passe',
- valide: false,
- })
- );
-
- expect(etatCreationEspaceAidant).toStrictEqual({
- cguSignees: true,
- erreur: {},
- motDePasse: {
- ancienMotDePasse: 'mot-de-passe',
- nouveauMotDePasse: 'mot-de-passe',
- confirmationNouveauMotDePasse: 'mot-de-passe',
- valide: false,
- },
- saisieValide: expect.any(Function),
- });
- expect(etatCreationEspaceAidant.saisieValide()).toBe(false);
- });
- });
-
- describe("Lorsque l'on clique sur la case à cocher des CGU", () => {
- it('Elles sont signées', () => {
- const etatCreationEspaceAidant = reducteurCreationEspaceAidant(
- {
- ...etatInitialCreationEspaceAidant,
- motDePasse: {
- ancienMotDePasse: 'mot-de-passe',
- nouveauMotDePasse: 'mdp',
- confirmationNouveauMotDePasse: 'mdp',
- valide: true,
- },
- erreur: {},
- },
- cguCliquees()
- );
-
- expect(etatCreationEspaceAidant).toStrictEqual({
- cguSignees: true,
- erreur: {},
- motDePasse: {
- ancienMotDePasse: 'mot-de-passe',
- nouveauMotDePasse: 'mdp',
- confirmationNouveauMotDePasse: 'mdp',
- valide: true,
- },
- saisieValide: expect.any(Function),
- });
- expect(etatCreationEspaceAidant.saisieValide()).toBe(true);
- });
-
- it("Elles sont invalidées lorsque l'on reclique dessus", () => {
- const etatCreationEspaceAidant = reducteurCreationEspaceAidant(
- {
- ...etatInitialCreationEspaceAidant,
- cguSignees: true,
- erreur: {},
- },
- cguCliquees()
- );
-
- expect(etatCreationEspaceAidant).toStrictEqual({
- cguSignees: false,
- erreur: {
- cguSignees: {
- className: 'fr-input-group--error',
- texteExplicatif: (
-
- ),
- },
- },
- saisieValide: expect.any(Function),
- });
- expect(etatCreationEspaceAidant.saisieValide()).toBe(false);
- });
-
- it('Les erreurs précédentes sur les CGU sont vidées', () => {
- const etatCreationEspaceAidant = reducteurCreationEspaceAidant(
- {
- ...etatInitialCreationEspaceAidant,
- erreur: {
- cguSignees: {
- className: 'fr-input-group--error',
- texteExplicatif: <>>,
- },
- },
- motDePasse: {
- ancienMotDePasse: 'mot-de-passe',
- nouveauMotDePasse: 'mdp',
- confirmationNouveauMotDePasse: 'mdp',
- valide: true,
- },
- },
- cguCliquees()
- );
-
- expect(etatCreationEspaceAidant).toStrictEqual({
- cguSignees: true,
- erreur: {},
- motDePasse: {
- ancienMotDePasse: 'mot-de-passe',
- nouveauMotDePasse: 'mdp',
- confirmationNouveauMotDePasse: 'mdp',
- valide: true,
- },
- saisieValide: expect.any(Function),
- });
- expect(etatCreationEspaceAidant.saisieValide()).toBe(true);
- });
-
- it('Si les mots de passe sont incorrects, la saisie est invalide', () => {
- const etatCreationEspaceAidant = reducteurCreationEspaceAidant(
- {
- ...etatInitialCreationEspaceAidant,
- cguSignees: false,
- motDePasse: {
- ancienMotDePasse: 'mot-de-passe',
- nouveauMotDePasse: 'mdp',
- confirmationNouveauMotDePasse: 'incorrect',
- valide: false,
- },
- saisieValide: () => false,
- },
- cguCliquees()
- );
-
- expect(etatCreationEspaceAidant).toStrictEqual({
- cguSignees: true,
- erreur: {},
- motDePasse: {
- ancienMotDePasse: 'mot-de-passe',
- nouveauMotDePasse: 'mdp',
- confirmationNouveauMotDePasse: 'incorrect',
- valide: false,
- },
- saisieValide: expect.any(Function),
- });
- expect(etatCreationEspaceAidant.saisieValide()).toBe(false);
- });
- });
-
- describe("Lorsque la création de l'espace Aidant a été transmise", () => {
- it('Supprime la notion creation espace Aidant à transmettre et le mot de passe', () => {
- const etatCreationEspaceAidant = reducteurCreationEspaceAidant(
- {
- ...etatInitialCreationEspaceAidant,
- creationEspaceAidantATransmettre: true,
- cguSignees: true,
- motDePasse: {
- ancienMotDePasse: 'mot-de-passe',
- nouveauMotDePasse: 'mdp',
- confirmationNouveauMotDePasse: 'mdp',
- valide: true,
- },
- },
- creationEspaceAidantTransmise()
- );
-
- expect(etatCreationEspaceAidant).toStrictEqual({
- cguSignees: true,
- erreur: {},
- saisieValide: expect.any(Function),
- });
- });
- });
-
- describe("Lorsque la création de l'espace Aidant a subi une erreur", () => {
- it('Marque la création comme invalide', () => {
- const etatCreationEspaceAidant = reducteurCreationEspaceAidant(
- {
- ...etatInitialCreationEspaceAidant,
- cguSignees: true,
- creationEspaceAidantATransmettre: true,
- motDePasse: {
- ancienMotDePasse: 'mot-de-passe',
- nouveauMotDePasse: 'mdp',
- confirmationNouveauMotDePasse: 'mdp',
- valide: true,
- },
- saisieValide: () => true,
- },
- creationEspaceAidantInvalidee(new Error('Une erreur est survenue'))
- );
-
- expect(etatCreationEspaceAidant).toStrictEqual({
- cguSignees: false,
- erreur: {},
- saisieValide: expect.any(Function),
- champsErreur: (
-
- ),
- });
- expect(etatCreationEspaceAidant.saisieValide()).toBe(false);
- });
- });
-});
diff --git a/mon-aide-cyber-ui/test/domaine/validation-cgu/reducteurValidationCGU.spec.tsx b/mon-aide-cyber-ui/test/domaine/validation-cgu/reducteurValidationCGU.spec.tsx
new file mode 100644
index 000000000..521e42797
--- /dev/null
+++ b/mon-aide-cyber-ui/test/domaine/validation-cgu/reducteurValidationCGU.spec.tsx
@@ -0,0 +1,108 @@
+import { describe, expect, it } from 'vitest';
+import {
+ ChampsErreur,
+ TexteExplicatif,
+} from '../../../src/composants/alertes/Erreurs.tsx';
+import {
+ cguCliquees,
+ EtatValidationCGU,
+ initialiseReducteur,
+ reducteurValidationCGU,
+ validationCGUInvalidee,
+} from '../../../src/domaine/validation-cgu/reducteurValidationCGU.tsx';
+
+describe('Réducteur de validation des CGU', () => {
+ const etatInitialValidationCGU: EtatValidationCGU = initialiseReducteur();
+
+ describe("Lorsque l'on clique sur la case à cocher des CGU", () => {
+ it('Elles sont signées', () => {
+ const etatValidationCGU = reducteurValidationCGU(
+ {
+ ...etatInitialValidationCGU,
+ erreur: {},
+ },
+ cguCliquees()
+ );
+
+ expect(etatValidationCGU).toStrictEqual({
+ cguSignees: true,
+ erreur: {},
+ saisieValide: expect.any(Function),
+ });
+ expect(etatValidationCGU.saisieValide()).toBe(true);
+ });
+
+ it("Elles sont invalidées lorsque l'on reclique dessus", () => {
+ const etatValidationCGU = reducteurValidationCGU(
+ {
+ ...etatInitialValidationCGU,
+ cguSignees: true,
+ erreur: {},
+ },
+ cguCliquees()
+ );
+
+ expect(etatValidationCGU).toStrictEqual({
+ cguSignees: false,
+ erreur: {
+ cguSignees: {
+ className: 'fr-input-group--error',
+ texteExplicatif: (
+
+ ),
+ },
+ },
+ saisieValide: expect.any(Function),
+ });
+ expect(etatValidationCGU.saisieValide()).toBe(false);
+ });
+
+ it('Les erreurs précédentes sur les CGU sont vidées', () => {
+ const etatValidationCGU = reducteurValidationCGU(
+ {
+ ...etatInitialValidationCGU,
+ erreur: {
+ cguSignees: {
+ className: 'fr-input-group--error',
+ texteExplicatif: <>>,
+ },
+ },
+ },
+ cguCliquees()
+ );
+
+ expect(etatValidationCGU).toStrictEqual({
+ cguSignees: true,
+ erreur: {},
+ saisieValide: expect.any(Function),
+ });
+ expect(etatValidationCGU.saisieValide()).toBe(true);
+ });
+ });
+
+ describe('Lorsque la validation des CGU est revenue en erreur', () => {
+ it('Marque la validation comme invalide', () => {
+ const etatValidationCGU = reducteurValidationCGU(
+ {
+ ...etatInitialValidationCGU,
+ cguSignees: true,
+ saisieValide: () => true,
+ },
+ validationCGUInvalidee(new Error('Une erreur est survenue'))
+ );
+
+ expect(etatValidationCGU).toStrictEqual({
+ cguSignees: false,
+ erreur: {},
+ saisieValide: expect.any(Function),
+ champsErreur: (
+
+ ),
+ });
+ expect(etatValidationCGU.saisieValide()).toBe(false);
+ });
+ });
+});