diff --git a/mon-pix/app/components/authentication/password-reset-demand-form.gjs b/mon-pix/app/components/authentication/password-reset-demand/password-reset-demand-form.gjs similarity index 80% rename from mon-pix/app/components/authentication/password-reset-demand-form.gjs rename to mon-pix/app/components/authentication/password-reset-demand/password-reset-demand-form.gjs index d3f6dcfe17d..624af6b5d20 100644 --- a/mon-pix/app/components/authentication/password-reset-demand-form.gjs +++ b/mon-pix/app/components/authentication/password-reset-demand/password-reset-demand-form.gjs @@ -10,7 +10,8 @@ import { tracked } from '@glimmer/tracking'; import { t } from 'ember-intl'; import ENV from 'mon-pix/config/environment'; -import isEmailValid from '../../utils/email-validator.js'; +import isEmailValid from '../../../utils/email-validator.js'; +import PasswordResetDemandReceivedInfo from './password-reset-demand-received-info'; export default class PasswordResetDemandForm extends Component { @service intl; @@ -124,26 +125,3 @@ export default class PasswordResetDemandForm extends Component { {{/if}} } - -const PasswordResetDemandReceivedInfo = ; diff --git a/mon-pix/app/components/authentication/password-reset-demand/password-reset-demand-received-info.gjs b/mon-pix/app/components/authentication/password-reset-demand/password-reset-demand-received-info.gjs new file mode 100644 index 00000000000..944098a3caa --- /dev/null +++ b/mon-pix/app/components/authentication/password-reset-demand/password-reset-demand-received-info.gjs @@ -0,0 +1,36 @@ +import PixButtonLink from '@1024pix/pix-ui/components/pix-button-link'; +import { hash } from '@ember/helper'; +import { service } from '@ember/service'; +import Component from '@glimmer/component'; +import { t } from 'ember-intl'; + +export default class PasswordResetDemandReceivedInfo extends Component { + @service intl; + + get locale() { + return this.intl.primaryLocale; + } + +} diff --git a/mon-pix/app/components/authentication/password-reset-demand.scss b/mon-pix/app/components/authentication/password-reset-demand/password-reset-demand.scss similarity index 100% rename from mon-pix/app/components/authentication/password-reset-demand.scss rename to mon-pix/app/components/authentication/password-reset-demand/password-reset-demand.scss diff --git a/mon-pix/app/styles/app.scss b/mon-pix/app/styles/app.scss index 92b78943c55..c19c4802fbd 100644 --- a/mon-pix/app/styles/app.scss +++ b/mon-pix/app/styles/app.scss @@ -141,7 +141,7 @@ of an adaptative/mobile-first approach — refactoring is welcome here */ @import 'authentication/new-password-input/password-rule'; @import 'authentication/oidc-provider-selector'; @import 'authentication/other-authentication-providers'; -@import 'authentication/password-reset-demand'; +@import 'authentication/password-reset-demand/password-reset-demand'; @import 'authentication/password-reset-form/password-reset-form'; @import 'authentication/signin-form'; @import 'authentication/signup-form'; diff --git a/mon-pix/app/templates/password-reset-demand.hbs b/mon-pix/app/templates/password-reset-demand.hbs index cb609c44000..33b5be32245 100644 --- a/mon-pix/app/templates/password-reset-demand.hbs +++ b/mon-pix/app/templates/password-reset-demand.hbs @@ -10,7 +10,7 @@ <:content>

{{t "pages.password-reset-demand.title"}}

- + diff --git a/mon-pix/tests/integration/components/authentication/password-reset-demand-form-test.gjs b/mon-pix/tests/integration/components/authentication/password-reset-demand/password-reset-demand-form-test.gjs similarity index 91% rename from mon-pix/tests/integration/components/authentication/password-reset-demand-form-test.gjs rename to mon-pix/tests/integration/components/authentication/password-reset-demand/password-reset-demand-form-test.gjs index fd515da7017..ba254591ed4 100644 --- a/mon-pix/tests/integration/components/authentication/password-reset-demand-form-test.gjs +++ b/mon-pix/tests/integration/components/authentication/password-reset-demand/password-reset-demand-form-test.gjs @@ -1,13 +1,14 @@ import { fillByLabel, render } from '@1024pix/ember-testing-library'; import { click } from '@ember/test-helpers'; -import { t } from 'ember-intl/test-support'; -import PasswordResetDemandForm from 'mon-pix/components/authentication/password-reset-demand-form'; +import { setLocale, t } from 'ember-intl/test-support'; +import PasswordResetDemandForm from 'mon-pix/components/authentication/password-reset-demand/password-reset-demand-form'; +import { ENGLISH_INTERNATIONAL_LOCALE } from 'mon-pix/services/locale'; import { module, test } from 'qunit'; import sinon from 'sinon'; -import setupIntlRenderingTest from '../../../helpers/setup-intl-rendering'; +import setupIntlRenderingTest from '../../../../helpers/setup-intl-rendering'; -module('Integration | Component | Authentication | password-reset-demand-form', function (hooks) { +module('Integration | Component | Authentication | PasswordResetDemand | password-reset-demand-form', function (hooks) { setupIntlRenderingTest(hooks); test('it displays a contact us link', async function (assert) { @@ -91,9 +92,12 @@ module('Integration | Component | Authentication | password-reset-demand-form', ); const email = 'someone@example.net'; - const screen = await render(); + const locale = ENGLISH_INTERNATIONAL_LOCALE; // when + await setLocale(locale); + const screen = await render(); + await fillByLabel(t('components.authentication.password-reset-demand-form.fields.email.label'), email); await click( screen.getByRole('button', { @@ -116,7 +120,7 @@ module('Integration | Component | Authentication | password-reset-demand-form', name: t('components.authentication.password-reset-demand-received-info.try-again'), }); assert.dom(tryAgainLink).exists(); - assert.strictEqual(tryAgainLink.getAttribute('href'), '/mot-de-passe-oublie'); + assert.strictEqual(tryAgainLink.getAttribute('href'), `/mot-de-passe-oublie?lang=${locale}`); }); }); diff --git a/mon-pix/tests/integration/components/authentication/password-reset-demand/password-reset-demand-received-info-test.gjs b/mon-pix/tests/integration/components/authentication/password-reset-demand/password-reset-demand-received-info-test.gjs new file mode 100644 index 00000000000..7ea91ec49ca --- /dev/null +++ b/mon-pix/tests/integration/components/authentication/password-reset-demand/password-reset-demand-received-info-test.gjs @@ -0,0 +1,52 @@ +import { render } from '@1024pix/ember-testing-library'; +import { setLocale, t } from 'ember-intl/test-support'; +import PasswordResetDemandReceivedInfo from 'mon-pix/components/authentication/password-reset-demand/password-reset-demand-received-info'; +import { ENGLISH_INTERNATIONAL_LOCALE } from 'mon-pix/services/locale'; +import { module, test } from 'qunit'; + +import setupIntlRenderingTest from '../../../../helpers/setup-intl-rendering'; + +module( + 'Integration | Component | Authentication | PasswordResetDemand | password-reset-demand-received-info', + function (hooks) { + setupIntlRenderingTest(hooks); + + test('it displays a heading, an info message and a "try again" link', async function (assert) { + // when + const screen = await render(); + + // then + assert + .dom( + screen.queryByRole('heading', { + name: t('components.authentication.password-reset-demand-received-info.heading'), + }), + ) + .exists(); + + assert + .dom(screen.queryByText(t('components.authentication.password-reset-demand-received-info.message'))) + .exists(); + + const tryAgainLink = await screen.queryByRole('link', { + name: t('components.authentication.password-reset-demand-received-info.try-again'), + }); + assert.dom(tryAgainLink).exists(); + }); + + test('it displays a link with a lang query param equal to the app locale', async function (assert) { + // given + const locale = ENGLISH_INTERNATIONAL_LOCALE; + + // when + await setLocale(locale); + const screen = await render(); + + // then + const tryAgainLink = await screen.queryByRole('link', { + name: t('components.authentication.password-reset-demand-received-info.try-again'), + }); + assert.strictEqual(tryAgainLink.getAttribute('href'), `/mot-de-passe-oublie?lang=${locale}`); + }); + }, +); diff --git a/mon-pix/translations/fr.json b/mon-pix/translations/fr.json index 023a687876a..21fbd990d17 100644 --- a/mon-pix/translations/fr.json +++ b/mon-pix/translations/fr.json @@ -175,7 +175,7 @@ "heading": "Vérifiez votre messagerie électronique", "message": "Si votre adresse est bien associée à un compte Pix, les instructions pour réinitialiser votre mot de passe vous ont été envoyées par e-mail.", "no-email-received-question": "Vous n’avez pas reçu d’e-mail ?", - "try-again": "Renvoyer l’e-mail de réinitialisation" + "try-again": "Faire une autre demande" }, "password-reset-form": { "actions": {