Skip to content

Commit

Permalink
MEP (#243)
Browse files Browse the repository at this point in the history
* Feat: gestion reset captcha (#230)

* reset captcha en cas d'erreur

* resolve warning : Warning: An update to TestComponent inside a test was not wrapped in act(...).

* retour commentaire

* prise en cmpte retour formulaire (#238)

* build(deps): bump the minor-and-patch group across 1 directory with 10 updates (#239)

Bumps the minor-and-patch group with 9 updates in the / directory:

| Package | From | To |
| --- | --- | --- |
| [@reduxjs/toolkit](https://github.com/reduxjs/redux-toolkit) | `2.2.7` | `2.3.0` |
| [dayjs](https://github.com/iamkun/dayjs) | `1.11.12` | `1.11.13` |
| [react-router-dom](https://github.com/remix-run/react-router/tree/HEAD/packages/react-router-dom) | `6.25.1` | `6.27.0` |
| [react-tooltip](https://github.com/ReactTooltip/react-tooltip) | `5.27.1` | `5.28.0` |
| [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) | `5.3.5` | `5.4.10` |
| [web-vitals](https://github.com/GoogleChrome/web-vitals) | `4.2.2` | `4.2.4` |
| [@testing-library/react](https://github.com/testing-library/react-testing-library) | `16.0.0` | `16.0.1` |
| [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/tree/HEAD/packages/plugin-react) | `4.3.1` | `4.3.3` |
| [@vitest/coverage-istanbul](https://github.com/vitest-dev/vitest/tree/HEAD/packages/coverage-istanbul) | `2.0.4` | `2.1.4` |



Updates `@reduxjs/toolkit` from 2.2.7 to 2.3.0
- [Release notes](https://github.com/reduxjs/redux-toolkit/releases)
- [Commits](reduxjs/redux-toolkit@v2.2.7...v2.3.0)

Updates `dayjs` from 1.11.12 to 1.11.13
- [Release notes](https://github.com/iamkun/dayjs/releases)
- [Changelog](https://github.com/iamkun/dayjs/blob/v1.11.13/CHANGELOG.md)
- [Commits](iamkun/dayjs@v1.11.12...v1.11.13)

Updates `react-router-dom` from 6.25.1 to 6.27.0
- [Release notes](https://github.com/remix-run/react-router/releases)
- [Changelog](https://github.com/remix-run/react-router/blob/[email protected]/packages/react-router-dom/CHANGELOG.md)
- [Commits](https://github.com/remix-run/react-router/commits/[email protected]/packages/react-router-dom)

Updates `react-tooltip` from 5.27.1 to 5.28.0
- [Release notes](https://github.com/ReactTooltip/react-tooltip/releases)
- [Changelog](https://github.com/ReactTooltip/react-tooltip/blob/master/CHANGELOG.md)
- [Commits](ReactTooltip/react-tooltip@v5.27.1...v5.28.0)

Updates `vite` from 5.3.5 to 5.4.10
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/v5.4.10/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v5.4.10/packages/vite)

Updates `web-vitals` from 4.2.2 to 4.2.4
- [Changelog](https://github.com/GoogleChrome/web-vitals/blob/main/CHANGELOG.md)
- [Commits](GoogleChrome/web-vitals@v4.2.2...v4.2.4)

Updates `@testing-library/react` from 16.0.0 to 16.0.1
- [Release notes](https://github.com/testing-library/react-testing-library/releases)
- [Changelog](https://github.com/testing-library/react-testing-library/blob/main/CHANGELOG.md)
- [Commits](testing-library/react-testing-library@v16.0.0...v16.0.1)

Updates `@vitejs/plugin-react` from 4.3.1 to 4.3.3
- [Release notes](https://github.com/vitejs/vite-plugin-react/releases)
- [Changelog](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite-plugin-react/commits/v4.3.3/packages/plugin-react)

Updates `@vitest/coverage-istanbul` from 2.0.4 to 2.1.4
- [Release notes](https://github.com/vitest-dev/vitest/releases)
- [Commits](https://github.com/vitest-dev/vitest/commits/v2.1.4/packages/coverage-istanbul)

Updates `vitest` from 2.0.4 to 2.1.4
- [Release notes](https://github.com/vitest-dev/vitest/releases)
- [Commits](https://github.com/vitest-dev/vitest/commits/v2.1.4/packages/vitest)

---
updated-dependencies:
- dependency-name: "@reduxjs/toolkit"
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: minor-and-patch
- dependency-name: dayjs
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: minor-and-patch
- dependency-name: react-router-dom
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: minor-and-patch
- dependency-name: react-tooltip
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: minor-and-patch
- dependency-name: vite
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: minor-and-patch
- dependency-name: web-vitals
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: minor-and-patch
- dependency-name: "@testing-library/react"
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: minor-and-patch
- dependency-name: "@vitejs/plugin-react"
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: minor-and-patch
- dependency-name: "@vitest/coverage-istanbul"
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: minor-and-patch
- dependency-name: vitest
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: minor-and-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* maj url menu + maj wording (#242)

* maj menu partie 2 (#244)

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Loading branch information
Ornella452 and dependabot[bot] authored Nov 15, 2024
1 parent 5dcf8aa commit d8cdedb
Show file tree
Hide file tree
Showing 20 changed files with 537 additions and 714 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
VITE_APP_BLOG_URL=https://media.conseiller-numerique.gouv.fr
VITE_APP_DASHBOARD_URL=https://pilotage.conseiller-numerique.gouv.fr
VITE_APP_COOP_URL=https://coop.conseiller-numerique.gouv.fr/login
VITE_APP_COOP_URL=https://coop-numerique.anct.gouv.fr
VITE_APP_CANDIDAT_URL=https://candidat.conseiller-numerique.gouv.fr/login
VITE_APP_FORMS_URL=https://app.conseiller-numerique.gouv.fr/candidature
VITE_APP_AIDE_URL=https://aide.conseiller-numerique.gouv.fr/fr
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy-production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
with:
envkey_VITE_APP_BLOG_URL: https://media.conseiller-numerique.gouv.fr
envkey_VITE_APP_DASHBOARD_URL: https://pilotage.conseiller-numerique.gouv.fr
envkey_VITE_APP_COOP_URL: https://coop.conseiller-numerique.gouv.fr/login
envkey_VITE_APP_COOP_URL: https://coop-numerique.anct.gouv.fr
envkey_VITE_APP_CANDIDAT_URL: https://candidat.conseiller-numerique.gouv.fr/login
envkey_VITE_APP_FORMS_URL: https://app.conseiller-numerique.gouv.fr/candidature
envkey_VITE_APP_AIDE_URL: https://aide.conseiller-numerique.gouv.fr/fr
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy-recette.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
with:
envkey_VITE_APP_BLOG_URL: https://beta.media.conseiller-numerique.gouv.fr
envkey_VITE_APP_DASHBOARD_URL: https://beta.pilotage.conseiller-numerique.gouv.fr
envkey_VITE_APP_COOP_URL: https://beta.coop.conseiller-numerique.gouv.fr/login
envkey_VITE_APP_COOP_URL: https://coop-numerique.anct.gouv.fr
envkey_VITE_APP_CANDIDAT_URL: https://beta.candidat.conseiller-numerique.gouv.fr/login
envkey_VITE_APP_FORMS_URL: https://uat-cnum-front.osc-fr1.scalingo.io/candidature
envkey_VITE_APP_AIDE_URL: https://aide.conseiller-numerique.gouv.fr/fr
Expand Down
1,035 changes: 408 additions & 627 deletions package-lock.json

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@
"dependencies": {
"@gouvfr-anct/cartographie-nationale": "^5.22.0",
"@gouvfr/dsfr": "1.12.1",
"@reduxjs/toolkit": "^2.2.7",
"dayjs": "^1.11.12",
"@reduxjs/toolkit": "^2.3.0",
"dayjs": "^1.11.13",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-redux": "^9.1.2",
"react-router-dom": "^6.25.1",
"react-tooltip": "^5.27.1",
"react-router-dom": "^6.27.0",
"react-tooltip": "^5.28.0",
"redux": "^5.0.1",
"vite": "^5.4.8",
"web-vitals": "^4.2.2"
"vite": "^5.4.10",
"web-vitals": "^4.2.4"
},
"devDependencies": {
"@testing-library/react": "^16.0.0",
"@vitejs/plugin-react": "^4.3.1",
"@vitest/coverage-istanbul": "^2.0.4",
"@testing-library/react": "^16.0.1",
"@vitejs/plugin-react": "^4.3.3",
"@vitest/coverage-istanbul": "^2.1.4",
"eslint": "^8.57.0",
"eslint-plugin-react": "^7.34.3",
"eslint-plugin-testing-library": "^6.2.2",
Expand Down
6 changes: 1 addition & 5 deletions src/components/Menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ function Menu() {
<div className={`fr-collapse fr-menu ${activeMenu === 'pfs' ? 'fr-collapse--expanded' : ''}`} id="menu-pfs">
<ul className="fr-menu__list">
<li>
<a className="fr-nav__link" href={urlCoop} target="_blank" rel="noopener noreferrer">Espace coop</a>
<a className="fr-nav__link" href={urlCoop} target="_blank" rel="noopener noreferrer">La Coop de la médiation numérique</a>
</li>
<li>
<a className="fr-nav__link" href={urlCandidat} target="_blank" rel="noopener noreferrer">Espace candidat</a>
Expand All @@ -145,10 +145,6 @@ function Menu() {
<a className="fr-nav__link" href={urlDashboard}
target="_blank" rel="noopener noreferrer">Tableau de pilotage - pr&eacute;fecture</a>
</li>
<li>
<a className="fr-nav__link" href={urlDashboard}
target="_blank" rel="noopener noreferrer">Tableau de pilotage - coordinateur</a>
</li>
</ul>
</div>
</li>
Expand Down
6 changes: 3 additions & 3 deletions src/components/commun/Input.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import PropTypes from 'prop-types';

export default function Input({ children, id, isRequired = true, autoComplete = 'on', testId = '', type = 'text',
pattern, onChange, list, min, readOnly, isLoading, ariaBusy, value }) {
pattern, onChange, list, min, disabled, isLoading, ariaBusy, value }) {
return (
<div className="fr-fieldset__element">
<div className="fr-input-group">
Expand All @@ -17,7 +17,7 @@ export default function Input({ children, id, isRequired = true, autoComplete =
onChange={onChange}
list={list}
min={min}
readOnly={readOnly}
disabled={disabled}
name={id}
value={value?.trim()}
aria-busy={ariaBusy}
Expand All @@ -43,7 +43,7 @@ Input.propTypes = {
onChange: PropTypes.func,
list: PropTypes.string,
min: PropTypes.string,
readOnly: PropTypes.bool,
disabled: PropTypes.bool,
isLoading: PropTypes.bool,
ariaBusy: PropTypes.bool,
value: PropTypes.string,
Expand Down
2 changes: 2 additions & 0 deletions src/views/candidature-conseiller/CandidatureConseiller.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,11 @@ export default function CandidatureConseiller() {
if (resultatCreation?.status >= 400) {
const error = await resultatCreation.json();
setValidationError(error.message);
window.hcaptcha.reset();
window.scrollTo({ top: 0, behavior: 'smooth' });
} else if (!resultatCreation.status) {
setValidationError(resultatCreation.message);
window.hcaptcha.reset();
window.scrollTo({ top: 0, behavior: 'smooth' });
} else {
navigate('/candidature-validee-conseiller');
Expand Down
31 changes: 21 additions & 10 deletions src/views/candidature-conseiller/CandidatureConseiller.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ describe('candidature conseiller', () => {
expect(nom).toHaveAttribute('type', 'text');
expect(nom).toBeRequired();

const email = within(etapeInformationsDeContact).getByLabelText('Adresse e-mail * Format attendu : [email protected]');
const email = within(etapeInformationsDeContact).getByLabelText('Adresse électronique * Format attendu : [email protected]');
expect(email).toHaveAttribute('type', 'email');
expect(email).toBeRequired();

Expand Down Expand Up @@ -343,7 +343,7 @@ describe('candidature conseiller', () => {

// WHEN
const adresse = screen.getByLabelText('Votre lieu d’habitation * Saississez le nom ou le code postal de votre commune.');
fireEvent.change(adresse, { target: { value: 'par' } });
fireEvent.change(adresse, { target: { value: 'paris' } });

// THEN
const paris = await screen.findByRole('option', { name: '75001 Paris', hidden: true });
Expand All @@ -369,7 +369,7 @@ describe('candidature conseiller', () => {
fireEvent.change(prenom, { target: { value: 'Jean' } });
const nom = screen.getByLabelText('Nom *');
fireEvent.change(nom, { target: { value: 'Dupont' } });
const email = screen.getByLabelText('Adresse e-mail * Format attendu : [email protected]');
const email = screen.getByLabelText('Adresse électronique * Format attendu : [email protected]');
fireEvent.change(email, { target: { value: '[email protected]' } });
const adresse = screen.getByLabelText('Votre lieu d’habitation * Saississez le nom ou le code postal de votre commune.');
fireEvent.change(adresse, { target: { value: '93100 Montreuil' } });
Expand Down Expand Up @@ -408,7 +408,7 @@ describe('candidature conseiller', () => {
fireEvent.change(prenom, { target: { value: 'Jean' } });
const nom = screen.getByLabelText('Nom *');
fireEvent.change(nom, { target: { value: 'Dupont' } });
const email = screen.getByLabelText('Adresse e-mail * Format attendu : [email protected]');
const email = screen.getByLabelText('Adresse électronique * Format attendu : [email protected]');
fireEvent.change(email, { target: { value: '[email protected]' } });
const adresse = screen.getByLabelText('Votre lieu d’habitation * Saississez le nom ou le code postal de votre commune.');
fireEvent.change(adresse, { target: { value: '93100 Montreuil' } });
Expand All @@ -431,21 +431,26 @@ describe('candidature conseiller', () => {
vi.useRealTimers();
});

it('quand je remplis le formulaire, que je l’envoie et que le serveur me renvoie une erreur, alors elle s’affiche sur la page', async () => {
// eslint-disable-next-line max-len
it('quand je remplis le formulaire, que je l’envoie et que le serveur me renvoie une erreur, alors elle s’affiche sur la page et le captcha est rénitialisé', async () => {
// GIVEN
vi.useFakeTimers();
vi.setSystemTime(new Date(2023, 11, 12, 13));

vi.stubGlobal('fetch', vi.fn(
() => ({ status: 400, json: async () => Promise.resolve({ message: 'Cette adresse mail est déjà utilisée' }) }))
);
vi.stubGlobal('hcaptcha', {
reset: vi.fn(),
render: vi.fn()
});

render(<CandidatureConseiller />);
const prenom = screen.getByLabelText('Prénom *');
fireEvent.change(prenom, { target: { value: 'Jean' } });
const nom = screen.getByLabelText('Nom *');
fireEvent.change(nom, { target: { value: 'Dupont' } });
const email = screen.getByLabelText('Adresse e-mail * Format attendu : [email protected]');
const email = screen.getByLabelText('Adresse électronique * Format attendu : [email protected]');
fireEvent.change(email, { target: { value: '[email protected]' } });
const adresse = screen.getByLabelText('Votre lieu d’habitation * Saississez le nom ou le code postal de votre commune.');
fireEvent.change(adresse, { target: { value: '93100 Montreuil' } });
Expand All @@ -469,6 +474,7 @@ describe('candidature conseiller', () => {
});

// THEN
expect(window.hcaptcha.reset).toHaveBeenCalledTimes(1);
const titreErreurValidation = screen.getByRole('heading', { level: 3, name: 'Erreur de validation' });
expect(titreErreurValidation).toBeInTheDocument();
const contenuErreurValidation = screen.getByText('Cette adresse mail est déjà utilisée', { selector: 'p' });
Expand All @@ -493,7 +499,7 @@ describe('candidature conseiller', () => {
fireEvent.change(prenom, { target: { value: 'Jean' } });
const nom = screen.getByLabelText('Nom *');
fireEvent.change(nom, { target: { value: 'Dupont' } });
const email = screen.getByLabelText('Adresse e-mail * Format attendu : [email protected]');
const email = screen.getByLabelText('Adresse électronique * Format attendu : [email protected]');
const adresse = screen.getByLabelText('Votre lieu d’habitation * Saississez le nom ou le code postal de votre commune.');
fireEvent.change(adresse, { target: { value: '93100 Montreuil' } });
fireEvent.change(email, { target: { value: '[email protected]' } });
Expand Down Expand Up @@ -539,7 +545,7 @@ describe('candidature conseiller', () => {
fireEvent.change(prenom, { target: { value: 'Jean' } });
const nom = screen.getByLabelText('Nom *');
fireEvent.change(nom, { target: { value: 'Dupont' } });
const email = screen.getByLabelText('Adresse e-mail * Format attendu : [email protected]');
const email = screen.getByLabelText('Adresse électronique * Format attendu : [email protected]');
fireEvent.change(email, { target: { value: '[email protected]' } });
const adresse = screen.getByLabelText('Votre lieu d’habitation * Saississez le nom ou le code postal de votre commune.');
fireEvent.change(adresse, { target: { value: '93100 Montreuil' } });
Expand Down Expand Up @@ -662,7 +668,7 @@ describe('candidature conseiller', () => {
vi.useRealTimers();
});

it('quand je remplis le formulaire et qu’une erreur se produit alors un message d’erreur s’affiche', async () => {
it('quand je remplis le formulaire et qu’une erreur se produit alors un message d’erreur s’affiche et le captcha est rénitialisé', async () => {
// GIVEN
vi.useFakeTimers();
vi.setSystemTime(new Date(2023, 11, 12, 13));
Expand All @@ -671,13 +677,17 @@ describe('candidature conseiller', () => {
creerCandidatureConseiller: vi.fn().mockReturnValue({ message: 'Failed to fetch' }),
buildConseillerData: vi.fn(),
}));
vi.stubGlobal('hcaptcha', {
reset: vi.fn(),
render: vi.fn()
});

render(<CandidatureConseiller />);
const prenom = screen.getByLabelText('Prénom *');
fireEvent.change(prenom, { target: { value: 'Jean' } });
const nom = screen.getByLabelText('Nom *');
fireEvent.change(nom, { target: { value: 'Dupont' } });
const email = screen.getByLabelText('Adresse e-mail * Format attendu : [email protected]');
const email = screen.getByLabelText('Adresse électronique * Format attendu : [email protected]');
fireEvent.change(email, { target: { value: '[email protected]' } });
const adresse = screen.getByLabelText('Votre lieu d’habitation * Saississez le nom ou le code postal de votre commune.');
fireEvent.change(adresse, { target: { value: '93100 Montreuil' } });
Expand All @@ -703,6 +713,7 @@ describe('candidature conseiller', () => {
});

// THEN
expect(window.hcaptcha.reset).toHaveBeenCalledTimes(1);
const contenuErreurValidation = screen.getByText('Failed to fetch', { selector: 'p' });
expect(contenuErreurValidation).toBeInTheDocument();

Expand Down
2 changes: 1 addition & 1 deletion src/views/candidature-conseiller/InformationsDeContact.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default function InformationsDeContact() {
id="email"
type="email"
>
Adresse e-mail <span className="cc-obligatoire">*</span> <span className="fr-hint-text">Format attendu : [email protected]</span>
Adresse électronique <span className="cc-obligatoire">*</span> <span className="fr-hint-text">Format attendu : [email protected]</span>
</Input>
<Input
id="telephone"
Expand Down
4 changes: 2 additions & 2 deletions src/views/candidature-coordinateur/BesoinEnCoordinateur.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default function BesoinEnCoordinateur() {
<legend className="fr-h5">Votre besoin en coordinateur</legend>
<hr />
<p className="fr-mb-3w cc-bold">
Avez-vous déjà identifié un candidat pour le poste de coordinateur de conseiller numérique ?<span className="cc-obligatoire">*</span>
Avez-vous déjà identifié un candidat pour le poste de coordinateur de conseiller numérique ? <span className="cc-obligatoire">*</span>
</p>
<p className="fr-text--sm fr-hint-text">Si oui, merci d’inviter ce candidat à s’inscrire sur la plateforme Conseiller numérique</p>
<BoutonRadio id="oui" nomGroupe="aIdentifieCoordinateur">
Expand All @@ -27,7 +27,7 @@ export default function BesoinEnCoordinateur() {
Accompagnera également des publics
</BoutonRadio>
<hr />
<p className="fr-mb-3w cc-bold">À partir de quand êtes vous prêt à accueillir votre coordinateur ?<span className="cc-obligatoire">*</span></p>
<p className="fr-mb-3w cc-bold">À partir de quand êtes vous prêt à accueillir votre coordinateur ? <span className="cc-obligatoire">*</span></p>
<Datepicker id="dateDebutMission" min={dateDuJour}>
Choisir une date
</Datepicker>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,11 @@ export default function CandidatureCoordinateur() {
if (resultatCreation?.status >= 400) {
const error = await resultatCreation.json();
setValidationError(error.message);
window.hcaptcha.reset();
window.scrollTo({ top: 0, behavior: 'smooth' });
} else if (!resultatCreation.status) {
setValidationError(resultatCreation.message);
window.hcaptcha.reset();
window.scrollTo({ top: 0, behavior: 'smooth' });
} else {
navigate('/candidature-validee-structure');
Expand Down
Loading

0 comments on commit d8cdedb

Please sign in to comment.