From 804a3f30bcaf8e2882cdafb24189ddfda8ec4e08 Mon Sep 17 00:00:00 2001 From: Ornella <68587983+Ornella452@users.noreply.github.com> Date: Wed, 2 Oct 2024 14:50:27 +0200 Subject: [PATCH] Fix + refactor formulaire (#225) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 1er refactor (codeCommune en paramètre + rectif de récuperation du cdde postal au lieux de code commune * import alert dsfr * renommage composant candidature-validee => candidature-validee-conseiller + rectif wording * copy candidature validee conseiller en version pour structure * resolve warning Error: Not implemented: window.scrollTo * test pour récupérer la valeur après le build (version avant refacto api geo) * ajout de 2 tests pour le téléphone dans le cas où c'est rempli par l'utilisateur * refacto codeCommune + api adresse * correction test * fix correction required champs * refactor window scrollTo * retour commentaire * refactor code commune + ajout du '*' pur l'input required à true * fix get info commune --- src/App.js | 6 +- src/components/commun/Input.jsx | 6 +- .../candidature-conseiller/AddressChooser.jsx | 21 +- .../CandidatureConseiller.jsx | 2 +- .../CandidatureConseiller.test.jsx | 230 ++++++++++++++++-- .../candidature-conseiller/useApiAdmin.js | 32 +-- src/views/candidature-conseiller/useGeoApi.js | 30 ++- .../CandidatureCoordinateur.jsx | 7 +- .../CandidatureCoordinateur.test.jsx | 115 ++++++++- .../CandidatureStructure.jsx | 7 +- .../CandidatureStructure.test.jsx | 116 ++++++++- .../InformationsDeStructure.jsx | 8 +- .../useEntrepriseFinder.js | 11 +- .../CandidatureValideeConseiller.css} | 0 .../CandidatureValideeConseiller.jsx | 24 ++ .../CandidatureValideeConseiller.test.jsx | 28 +++ .../PageCandidatureValideeConseiller.jsx | 12 + .../CandidatureValideeStructure.css | 7 + .../CandidatureValideeStructure.jsx} | 4 +- .../CandidatureValideeStructure.test.jsx} | 4 +- .../PageCandidatureValideeStructure.jsx | 12 + .../PageCandidatureValidee.jsx | 12 - ...ConfirmationEmailCandidatureConseiller.jsx | 1 + .../ConfirmationEmailCandidatureStructure.jsx | 2 + vitest.setup.js | 1 + 25 files changed, 610 insertions(+), 88 deletions(-) rename src/views/{candidature-validee/CandidatureValidee.css => candidature-validee-conseiller/CandidatureValideeConseiller.css} (100%) create mode 100644 src/views/candidature-validee-conseiller/CandidatureValideeConseiller.jsx create mode 100644 src/views/candidature-validee-conseiller/CandidatureValideeConseiller.test.jsx create mode 100644 src/views/candidature-validee-conseiller/PageCandidatureValideeConseiller.jsx create mode 100644 src/views/candidature-validee-structure/CandidatureValideeStructure.css rename src/views/{candidature-validee/CandidatureValidee.jsx => candidature-validee-structure/CandidatureValideeStructure.jsx} (89%) rename src/views/{candidature-validee/CandidatureValidee.test.jsx => candidature-validee-structure/CandidatureValideeStructure.test.jsx} (90%) create mode 100644 src/views/candidature-validee-structure/PageCandidatureValideeStructure.jsx delete mode 100644 src/views/candidature-validee/PageCandidatureValidee.jsx diff --git a/src/App.js b/src/App.js index 2a179d6d..f9cfd2fd 100644 --- a/src/App.js +++ b/src/App.js @@ -39,7 +39,8 @@ function App() { const PageCandidatureConseiller = lazy(() => import('./views/candidature-conseiller/PageCandidatureConseiller')); const PageCandidatureStructure = lazy(() => import('./views/candidature-structure/PageCandidatureStructure')); const PageCandidatureCoordinateur = lazy(() => import('./views/candidature-coordinateur/PageCandidatureCoordinateur')); - const PageCandidatureValidee = lazy(() => import('./views/candidature-validee/PageCandidatureValidee')); + const PageCandidatureValideeConseiller = lazy(() => import('./views/candidature-validee-conseiller/PageCandidatureValideeConseiller')); + const PageCandidatureValideeStructure = lazy(() => import('./views/candidature-validee-structure/PageCandidatureValideeStructure')); const PageConfirmationEmailCandidatureConseiller = lazy(() => import('./views/confirmation-email-candidature-conseiller/PageConfirmationEmailCandidatureConseiller')); const PageConfirmationEmailCandidatureStructure = @@ -54,7 +55,8 @@ function App() { }/> }/> }/> - }/> + }/> + }/> }/> }/> }/> diff --git a/src/components/commun/Input.jsx b/src/components/commun/Input.jsx index dd3e053b..2db9e1c4 100644 --- a/src/components/commun/Input.jsx +++ b/src/components/commun/Input.jsx @@ -1,7 +1,7 @@ import React from 'react'; import PropTypes from 'prop-types'; -export default function Input({ children, id, isRequired = true, type = 'text', pattern, onChange, list, min, readOnly, isLoading, ariaBusy, value }) { +export default function Input({ children, id, isRequired = true, type = 'text', pattern, onChange, list, min, readOnly, isLoading, ariaBusy, value, testId = '' }) { return (
@@ -19,6 +19,7 @@ export default function Input({ children, id, isRequired = true, type = 'text', name={id} value={value} aria-busy={ariaBusy} + data-testid={testId} /> {isLoading && ( }
- + diff --git a/src/views/candidature-coordinateur/CandidatureCoordinateur.test.jsx b/src/views/candidature-coordinateur/CandidatureCoordinateur.test.jsx index c22c1b1e..358db4a7 100644 --- a/src/views/candidature-coordinateur/CandidatureCoordinateur.test.jsx +++ b/src/views/candidature-coordinateur/CandidatureCoordinateur.test.jsx @@ -1,8 +1,10 @@ -import { render, screen, within, fireEvent, act } from '@testing-library/react'; +import { render, screen, within, fireEvent, act, renderHook } from '@testing-library/react'; import { describe, expect, it, vi } from 'vitest'; import CandidatureCoordinateur from './CandidatureCoordinateur'; import { textMatcher, dateDujour } from '../../../test/test-utils'; import * as ReactRouterDom from 'react-router-dom'; +import { useApiAdmin } from '../candidature-conseiller/useApiAdmin'; +import { useEntrepriseFinder } from '../candidature-structure/useEntrepriseFinder'; vi.mock('react-router-dom', () => ({ useLocation: () => ({ hash: '' }), @@ -260,7 +262,7 @@ describe('candidature coordinateur', () => { const denomination = screen.getByLabelText('Dénomination *'); fireEvent.change(denomination, { target: { value: 'Entreprise' } }); const adresse = screen.getByLabelText('Adresse *'); - fireEvent.change(adresse, { target: { value: '75056 Paris' } }); + fireEvent.change(adresse, { target: { value: '75007 Paris' } }); const typeStructure = screen.getByRole('radio', { name: 'Une commune' }); fireEvent.click(typeStructure); const prenom = screen.getByLabelText('Prénom *'); @@ -318,7 +320,7 @@ describe('candidature coordinateur', () => { const denomination = screen.getByLabelText('Dénomination *'); fireEvent.change(denomination, { target: { value: 'Entreprise' } }); const adresse = screen.getByLabelText('Adresse *'); - fireEvent.change(adresse, { target: { value: '75056 Paris' } }); + fireEvent.change(adresse, { target: { value: '75007 Paris' } }); const typeStructure = screen.getByRole('radio', { name: 'Une commune' }); fireEvent.click(typeStructure); const prenom = screen.getByLabelText('Prénom *'); @@ -351,7 +353,112 @@ describe('candidature coordinateur', () => { }); // THEN - expect(mockNavigate).toHaveBeenCalledWith('/candidature-validee'); + expect(mockNavigate).toHaveBeenCalledWith('/candidature-validee-structure'); + + vi.useRealTimers(); + }); + + it('quand je valide le formulaire alors j’envoie toute les données nescessaires', async () => { + // GIVEN + const formData = [ + [ + 'siret', + '13002603200016' + ], + [ + 'denomination', + 'AGENCE NATIONALE DE LA COHESION DES TERRITOIRES' + ], + [ + 'adresse', + '20 AVENUE DE SEGUR, 75007 PARIS' + ], + [ + 'type', + 'COMMUNE' + ], + [ + 'prenom', + 'Jean' + ], + [ + 'nom', + 'Dupont' + ], + [ + 'fonction', + 'Test' + ], + [ + 'email', + 'jean.dupont@example.com' + ], + [ + 'telephone', + '+33123456789' + ], + [ + 'aIdentifieCoordinateur', + 'non' + ], + [ + 'coordinateurTypeContrat', + 'FT' + ], + [ + 'dateDebutMission', + '2023-12-12' + ], + [ + 'motivation', + 'je suis motivé !' + ], + [ + 'confirmationEngagement', + 'on' + ], + [ + 'g-recaptcha-response', + '1' + ], + [ + 'h-captcha-response', + '1' + ] + ]; + + const { buildCoordinateurData } = renderHook(() => useApiAdmin()).result.current; + const { getGeoLocationFromAddress } = renderHook(() => useEntrepriseFinder()).result.current; + + // //WHEN + const geoLocation = await getGeoLocationFromAddress('20 AVENUE DE SEGUR, 75007 PARIS'); + const result = await buildCoordinateurData(formData, geoLocation, '75107'); + + // THEN + expect(result).toBe(JSON.stringify({ + 'siret': '13002603200016', + 'type': 'COMMUNE', + 'aIdentifieCoordinateur': false, + 'coordinateurTypeContrat': 'FT', + 'dateDebutMission': '2023-12-12', + 'motivation': 'je suis motivé !', + 'confirmationEngagement': true, + 'h-captcha-response': '1', + 'contact': { + 'prenom': 'Jean', 'nom': 'Dupont', + 'fonction': 'Test', 'email': + 'jean.dupont@example.com', + 'telephone': '+33123456789' + }, + 'nom': 'AGENCE NATIONALE DE LA COHESION DES TERRITOIRES', + 'nomCommune': 'Paris 7e Arrondissement', + 'codePostal': '75007', + 'codeCommune': '75107', + 'location': { 'type': 'Point', 'coordinates': [2.3115, 48.8548] }, + 'codeDepartement': '75', + 'codeRegion': '11', + 'codeCom': null, + })); vi.useRealTimers(); }); diff --git a/src/views/candidature-structure/CandidatureStructure.jsx b/src/views/candidature-structure/CandidatureStructure.jsx index 72d9f497..3695c26a 100644 --- a/src/views/candidature-structure/CandidatureStructure.jsx +++ b/src/views/candidature-structure/CandidatureStructure.jsx @@ -23,6 +23,7 @@ import '../candidature-conseiller/CandidatureConseiller.css'; export default function CandidatureStructure() { const [geoLocation, setGeoLocation] = useState(null); + const [codeCommune, setCodeCommune] = useState(''); const [validationError, setValidationError] = useState(''); const navigate = useNavigate(); const { buildStructureData, creerCandidatureStructure } = useApiAdmin(); @@ -37,14 +38,14 @@ export default function CandidatureStructure() { event.preventDefault(); const formData = new FormData(event.currentTarget); - const structureData = await buildStructureData(formData, geoLocation); + const structureData = await buildStructureData(formData, geoLocation, codeCommune); const resultatCreation = await creerCandidatureStructure(structureData); if (resultatCreation.status >= 400) { const error = await resultatCreation.json(); setValidationError(error.message); window.scrollTo({ top: 0, behavior: 'smooth' }); } else { - navigate('/candidature-validee'); + navigate('/candidature-validee-structure'); } }; @@ -65,7 +66,7 @@ export default function CandidatureStructure() {
} - + diff --git a/src/views/candidature-structure/CandidatureStructure.test.jsx b/src/views/candidature-structure/CandidatureStructure.test.jsx index 589c5acb..c890545e 100644 --- a/src/views/candidature-structure/CandidatureStructure.test.jsx +++ b/src/views/candidature-structure/CandidatureStructure.test.jsx @@ -1,8 +1,10 @@ -import { render, screen, within, waitFor, fireEvent, act } from '@testing-library/react'; +import { render, screen, within, waitFor, fireEvent, act, renderHook } from '@testing-library/react'; import { describe, expect, it, vi } from 'vitest'; import CandidatureStructure from './CandidatureStructure'; import { textMatcher, dateDujour } from '../../../test/test-utils'; import * as ReactRouterDom from 'react-router-dom'; +import { useApiAdmin } from '../candidature-conseiller/useApiAdmin'; +import { useEntrepriseFinder } from './useEntrepriseFinder'; vi.mock('react-router-dom', () => ({ useLocation: () => ({ hash: '' }), @@ -352,7 +354,7 @@ describe('candidature structure', () => { const denomination = screen.getByLabelText('Dénomination *'); fireEvent.change(denomination, { target: { value: 'Entreprise' } }); const adresse = screen.getByLabelText('Adresse *'); - fireEvent.change(adresse, { target: { value: '75056 Paris' } }); + fireEvent.change(adresse, { target: { value: '75007 Paris' } }); const typeStructure = screen.getByRole('radio', { name: 'Une commune' }); fireEvent.click(typeStructure); const prenom = screen.getByLabelText('Prénom *'); @@ -410,7 +412,7 @@ describe('candidature structure', () => { const denomination = screen.getByLabelText('Dénomination *'); fireEvent.change(denomination, { target: { value: 'Entreprise' } }); const adresse = screen.getByLabelText('Adresse *'); - fireEvent.change(adresse, { target: { value: '75056 Paris' } }); + fireEvent.change(adresse, { target: { value: '75007 Paris' } }); const typeStructure = screen.getByRole('radio', { name: 'Une commune' }); fireEvent.click(typeStructure); const prenom = screen.getByLabelText('Prénom *'); @@ -443,7 +445,113 @@ describe('candidature structure', () => { }); // THEN - expect(mockNavigate).toHaveBeenCalledWith('/candidature-validee'); + expect(mockNavigate).toHaveBeenCalledWith('/candidature-validee-structure'); + + vi.useRealTimers(); + }); + + it('quand je valide le formulaire alors j’envoie toute les données nescessaires', async () => { + // GIVEN + const formData = [ + [ + 'siret', + '13002603200016' + ], + [ + 'denomination', + 'AGENCE NATIONALE DE LA COHESION DES TERRITOIRES' + ], + [ + 'adresse', + '20 AVENUE DE SEGUR, 75007 PARIS' + ], + [ + 'type', + 'COMMUNE' + ], + [ + 'prenom', + 'Jean' + ], + [ + 'nom', + 'Dupont' + ], + [ + 'fonction', + 'Test' + ], + [ + 'email', + 'jean.dupont@example.com' + ], + [ + 'telephone', + '+33123456789' + ], + [ + 'nombreConseillersSouhaites', + '1' + ], + [ + 'aIdentifieCandidat', + 'oui' + ], + [ + 'dateDebutMission', + '2024-12-12' + ], + [ + 'motivation', + 'je suis motivé !' + ], + [ + 'confirmationEngagement', + 'on' + ], + [ + 'g-recaptcha-response', + '1' + ], + [ + 'h-captcha-response', + '1' + ] + ]; + + const { buildStructureData } = renderHook(() => useApiAdmin()).result.current; + const { getGeoLocationFromAddress } = renderHook(() => useEntrepriseFinder()).result.current; + + // //WHEN + const geoLocation = await getGeoLocationFromAddress('20 AVENUE DE SEGUR, 75007 PARIS'); + const result = await buildStructureData(formData, geoLocation, '75107'); + + // THEN + expect(result).toBe(JSON.stringify({ + 'siret': '13002603200016', + 'type': 'COMMUNE', + 'nombreConseillersSouhaites': '1', + 'aIdentifieCandidat': true, + 'dateDebutMission': '2024-12-12', + 'motivation': 'je suis motivé !', + 'confirmationEngagement': true, + 'h-captcha-response': '1', + 'location': { 'type': 'Point', 'coordinates': [2.3115, 48.8548] }, + 'contact': { + 'prenom': 'Jean', + 'nom': 'Dupont', + 'fonction': 'Test', + 'email': 'jean.dupont@example.com', + 'telephone': '+33123456789' + }, + 'nom': 'AGENCE NATIONALE DE LA COHESION DES TERRITOIRES', + 'nomCommune': 'Paris 7e Arrondissement', + 'codePostal': '75007', + 'codeCommune': '75107', + 'codeDepartement': '75', + 'codeRegion': '11', + 'codeCom': null, + })); vi.useRealTimers(); }); diff --git a/src/views/candidature-structure/InformationsDeStructure.jsx b/src/views/candidature-structure/InformationsDeStructure.jsx index fb8c21d2..3ace056e 100644 --- a/src/views/candidature-structure/InformationsDeStructure.jsx +++ b/src/views/candidature-structure/InformationsDeStructure.jsx @@ -10,7 +10,7 @@ const TAILLE_SIRET = 14; const TAILLE_RIDET = [6, 7]; const TAILLES_POSSIBLES = [...TAILLE_RIDET, TAILLE_SIRET]; -export default function InformationsDeStructure({ setGeoLocation }) { +export default function InformationsDeStructure({ setGeoLocation, setCodeCommune }) { const { entreprise, search, @@ -22,8 +22,8 @@ export default function InformationsDeStructure({ setGeoLocation }) { denomination, setDenomination, adresse, - setAdresse - } = useEntrepriseFinder(setGeoLocation); + setAdresse, + } = useEntrepriseFinder(setGeoLocation, setCodeCommune); const handleSearch = value => { const numericValue = value.replace(/\D/g, ''); @@ -43,6 +43,7 @@ export default function InformationsDeStructure({ setGeoLocation }) { const handleSuggestionClick = suggestion => { setAdresse(suggestion.label); + setCodeCommune(suggestion.codeCommune); setGeoLocation(suggestion.geometry); getAddressSuggestions(''); }; @@ -118,5 +119,6 @@ export default function InformationsDeStructure({ setGeoLocation }) { InformationsDeStructure.propTypes = { setGeoLocation: PropTypes.func.isRequired, + setCodeCommune: PropTypes.func.isRequired, geoLocation: PropTypes.object, }; diff --git a/src/views/candidature-structure/useEntrepriseFinder.js b/src/views/candidature-structure/useEntrepriseFinder.js index 7996f3c6..e605153d 100644 --- a/src/views/candidature-structure/useEntrepriseFinder.js +++ b/src/views/candidature-structure/useEntrepriseFinder.js @@ -4,7 +4,7 @@ const TAILLE_SIRET = 14; const TAILLE_RIDET = [6, 7]; const TAILLES_POSSIBLES = [...TAILLE_RIDET, TAILLE_SIRET]; -export const useEntrepriseFinder = setGeoLocation => { +export const useEntrepriseFinder = (setGeoLocation, setCodeCommune) => { const [entreprise, setEntreprise] = useState(null); const [error, setError] = useState(null); const [addressSuggestions, setAddressSuggestions] = useState([]); @@ -22,6 +22,7 @@ export const useEntrepriseFinder = setGeoLocation => { setEntreprise(null); setError(null); setGeoLocation(null); + setCodeCommune(''); setDenomination(''); setAdresse(''); }; @@ -32,6 +33,7 @@ export const useEntrepriseFinder = setGeoLocation => { const response = await fetch(urlAPI); const result = await response.json(); if (result.features && result.features.length > 0) { + setCodeCommune(result.features[0].properties.citycode); return result.features[0].geometry; } } catch (error) { @@ -86,7 +88,8 @@ export const useEntrepriseFinder = setGeoLocation => { const response = await fetch(urlAPI); const result = await response.json(); const suggestions = result.features.map(feature => ({ - label: `${feature.properties.citycode} ${feature.properties.city}`, + label: `${feature.properties.postcode} ${feature.properties.city}`, + codeCommune: feature.properties.citycode, geometry: feature.geometry, })); setAddressSuggestions(suggestions); @@ -98,6 +101,7 @@ export const useEntrepriseFinder = setGeoLocation => { }; return { + getGeoLocationFromAddress, search, entreprise, error, @@ -109,6 +113,7 @@ export const useEntrepriseFinder = setGeoLocation => { setDenomination, setAdresse, denomination, - adresse + adresse, + setCodeCommune, }; }; diff --git a/src/views/candidature-validee/CandidatureValidee.css b/src/views/candidature-validee-conseiller/CandidatureValideeConseiller.css similarity index 100% rename from src/views/candidature-validee/CandidatureValidee.css rename to src/views/candidature-validee-conseiller/CandidatureValideeConseiller.css diff --git a/src/views/candidature-validee-conseiller/CandidatureValideeConseiller.jsx b/src/views/candidature-validee-conseiller/CandidatureValideeConseiller.jsx new file mode 100644 index 00000000..f3de3a31 --- /dev/null +++ b/src/views/candidature-validee-conseiller/CandidatureValideeConseiller.jsx @@ -0,0 +1,24 @@ +import React, { useEffect } from 'react'; + +import './CandidatureValideeConseiller.css'; + +export default function CandidatureValideeConseiller() { + useEffect(() => { + window.scrollTo({ top: 0, behavior: 'smooth' }); + document.title = 'Conseiller numérique - Candidature validée'; + }, []); + + return ( +
+
👏
+

Merci, votre demande a été envoyée.

+

+ Pour confirmer votre inscription et pouvoir recevoir des propositions de structure consultez le mail qui vient de vous être envoyé.
+ Si toutefois vous ne receviez pas dans les prochaines minutes un mail de confirmation de votre inscription, pensez à vérifier vos spams. +

+ + Retour à la page d’accueil + +
+ ); +} diff --git a/src/views/candidature-validee-conseiller/CandidatureValideeConseiller.test.jsx b/src/views/candidature-validee-conseiller/CandidatureValideeConseiller.test.jsx new file mode 100644 index 00000000..a677c80e --- /dev/null +++ b/src/views/candidature-validee-conseiller/CandidatureValideeConseiller.test.jsx @@ -0,0 +1,28 @@ +import { render, screen } from '@testing-library/react'; +import { describe, expect, it } from 'vitest'; +import CandidatureValideeConseiller from './CandidatureValideeConseiller'; +import { textMatcher } from '../../../test/test-utils'; + +describe('candidature validée', () => { + it('quand j’affiche la page candidature validée alors le titre et les informations de la page s’affichent', () => { + // WHEN + render(); + + // THEN + const emoji = screen.getByText('👏'); + expect(emoji).toBeInTheDocument(); + + const titre = screen.getByRole('heading', { level: 1, name: 'Merci, votre demande a été envoyée.' }); + expect(titre).toBeInTheDocument(); + + const confirmation = screen.getByText( + textMatcher('Pour confirmer votre inscription et pouvoir recevoir des propositions de structure consultez le mail qui vient de vous être envoyé.' + + 'Si toutefois vous ne receviez pas dans les prochaines minutes un mail de confirmation de votre inscription, pensez à vérifier vos spams.'), + { selector: 'p' } + ); + expect(confirmation).toBeInTheDocument(); + + const retourAccueil = screen.getByRole('link', { name: 'Retour à la page d’accueil' }); + expect(retourAccueil).toBeInTheDocument(); + }); +}); diff --git a/src/views/candidature-validee-conseiller/PageCandidatureValideeConseiller.jsx b/src/views/candidature-validee-conseiller/PageCandidatureValideeConseiller.jsx new file mode 100644 index 00000000..6638853a --- /dev/null +++ b/src/views/candidature-validee-conseiller/PageCandidatureValideeConseiller.jsx @@ -0,0 +1,12 @@ +import React from 'react'; +import Header from '../../components/Header'; +import CandidatureValideeConseiller from './CandidatureValideeConseiller'; + +export default function PageCandidatureValideeConseiller() { + return ( + <> +
+ + + ); +} diff --git a/src/views/candidature-validee-structure/CandidatureValideeStructure.css b/src/views/candidature-validee-structure/CandidatureValideeStructure.css new file mode 100644 index 00000000..cec63313 --- /dev/null +++ b/src/views/candidature-validee-structure/CandidatureValideeStructure.css @@ -0,0 +1,7 @@ +.cv-contenu { + text-align: center; +} + +.cv-titre { + color: var(--blue-france-sun-113-625); +} diff --git a/src/views/candidature-validee/CandidatureValidee.jsx b/src/views/candidature-validee-structure/CandidatureValideeStructure.jsx similarity index 89% rename from src/views/candidature-validee/CandidatureValidee.jsx rename to src/views/candidature-validee-structure/CandidatureValideeStructure.jsx index 5baf5bee..6a11c27f 100644 --- a/src/views/candidature-validee/CandidatureValidee.jsx +++ b/src/views/candidature-validee-structure/CandidatureValideeStructure.jsx @@ -1,8 +1,8 @@ import React, { useEffect } from 'react'; -import './CandidatureValidee.css'; +import './CandidatureValideeStructure.css'; -export default function CandidatureValidee() { +export default function CandidatureValideeStructure() { useEffect(() => { window.scrollTo({ top: 0, behavior: 'smooth' }); document.title = 'Conseiller numérique - Candidature validée'; diff --git a/src/views/candidature-validee/CandidatureValidee.test.jsx b/src/views/candidature-validee-structure/CandidatureValideeStructure.test.jsx similarity index 90% rename from src/views/candidature-validee/CandidatureValidee.test.jsx rename to src/views/candidature-validee-structure/CandidatureValideeStructure.test.jsx index 3e1cd2ec..0310581a 100644 --- a/src/views/candidature-validee/CandidatureValidee.test.jsx +++ b/src/views/candidature-validee-structure/CandidatureValideeStructure.test.jsx @@ -1,12 +1,12 @@ import { render, screen } from '@testing-library/react'; import { describe, expect, it } from 'vitest'; -import CandidatureValidee from './CandidatureValidee'; +import CandidatureValideeStructure from './CandidatureValideeStructure'; import { textMatcher } from '../../../test/test-utils'; describe('candidature validée', () => { it('quand j’affiche la page candidature validée alors le titre et les informations de la page s’affichent', () => { // WHEN - render(); + render(); // THEN const emoji = screen.getByText('👏'); diff --git a/src/views/candidature-validee-structure/PageCandidatureValideeStructure.jsx b/src/views/candidature-validee-structure/PageCandidatureValideeStructure.jsx new file mode 100644 index 00000000..cc586609 --- /dev/null +++ b/src/views/candidature-validee-structure/PageCandidatureValideeStructure.jsx @@ -0,0 +1,12 @@ +import React from 'react'; +import Header from '../../components/Header'; +import CandidatureValideeStructure from './CandidatureValideeStructure'; + +export default function PageCandidatureValideeStructure() { + return ( + <> +
+ + + ); +} diff --git a/src/views/candidature-validee/PageCandidatureValidee.jsx b/src/views/candidature-validee/PageCandidatureValidee.jsx deleted file mode 100644 index 9ce714e3..00000000 --- a/src/views/candidature-validee/PageCandidatureValidee.jsx +++ /dev/null @@ -1,12 +0,0 @@ -import React from 'react'; -import Header from '../../components/Header'; -import CandidatureValidee from './CandidatureValidee'; - -export default function PageCandidatureValidee() { - return ( - <> -
- - - ); -} diff --git a/src/views/confirmation-email-candidature-conseiller/ConfirmationEmailCandidatureConseiller.jsx b/src/views/confirmation-email-candidature-conseiller/ConfirmationEmailCandidatureConseiller.jsx index 21a812da..05f55299 100644 --- a/src/views/confirmation-email-candidature-conseiller/ConfirmationEmailCandidatureConseiller.jsx +++ b/src/views/confirmation-email-candidature-conseiller/ConfirmationEmailCandidatureConseiller.jsx @@ -2,6 +2,7 @@ import React, { useEffect, useState } from 'react'; import { useParams } from 'react-router-dom'; import { useApiConfirmationEmailCandidatureConseiller } from './useApiConfirmationEmailCandidatureConseiller'; +import '@gouvfr/dsfr/dist/component/alert/alert.min.css'; export default function ConfirmationEmailCandidatureConseiller() { const [reponseStatusConfirmation, setReponseStatusConfirmation] = useState(null); diff --git a/src/views/confirmation-email-candidature-structure/ConfirmationEmailCandidatureStructure.jsx b/src/views/confirmation-email-candidature-structure/ConfirmationEmailCandidatureStructure.jsx index da2ab48e..7c63bb97 100644 --- a/src/views/confirmation-email-candidature-structure/ConfirmationEmailCandidatureStructure.jsx +++ b/src/views/confirmation-email-candidature-structure/ConfirmationEmailCandidatureStructure.jsx @@ -2,6 +2,8 @@ import React, { useEffect, useState } from 'react'; import { useParams } from 'react-router-dom'; import { useApiConfirmationEmailCandidatureStructure } from './useApiConfirmationEmailCandidatureStructure'; +import '@gouvfr/dsfr/dist/component/alert/alert.min.css'; + export default function ConfirmationEmailCandidatureStructure() { const [reponseStatusConfirmation, setReponseStatusConfirmation] = useState(null); const { actionConfirmationEmailCandidatureStructure } = useApiConfirmationEmailCandidatureStructure(); diff --git a/vitest.setup.js b/vitest.setup.js index 730c7d2c..a2915ef3 100644 --- a/vitest.setup.js +++ b/vitest.setup.js @@ -3,3 +3,4 @@ import 'vitest-dom/extend-expect'; // scrollIntoView is not implemented in jsdom window.HTMLElement.prototype.scrollIntoView = vi.fn(); +window.scrollTo = vi.fn();