From fc503cc48e584ae5ca132cd6a9070fe1391006fd Mon Sep 17 00:00:00 2001 From: Eric Lim Date: Tue, 29 Oct 2024 15:24:55 +0100 Subject: [PATCH 1/5] refactor(mon-pix): move PasswordResetDemandForm in its own directory to app/components/authentication/password-reset-demand --- .../password-reset-demand-form.gjs | 2 +- .../{ => password-reset-demand}/password-reset-demand.scss | 0 mon-pix/app/styles/app.scss | 2 +- mon-pix/app/templates/password-reset-demand.hbs | 2 +- .../password-reset-demand-form-test.gjs | 6 +++--- 5 files changed, 6 insertions(+), 6 deletions(-) rename mon-pix/app/components/authentication/{ => password-reset-demand}/password-reset-demand-form.gjs (98%) rename mon-pix/app/components/authentication/{ => password-reset-demand}/password-reset-demand.scss (100%) rename mon-pix/tests/integration/components/authentication/{ => password-reset-demand}/password-reset-demand-form-test.gjs (96%) 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 98% 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..745cb581d71 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,7 @@ 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'; export default class PasswordResetDemandForm extends Component { @service intl; 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 96% 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..3fa357a032f 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,13 @@ 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 PasswordResetDemandForm from 'mon-pix/components/authentication/password-reset-demand/password-reset-demand-form'; 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) { From 8428ace37410a63aea0d688880e16befb4273f46 Mon Sep 17 00:00:00 2001 From: Eric Lim Date: Tue, 29 Oct 2024 15:50:55 +0100 Subject: [PATCH 2/5] refactor(mon-pix): extract PasswordResetDemandReceivedInfo component in its own file --- .../password-reset-demand-form.gjs | 24 +--------------- .../password-reset-demand-received-info.gjs | 28 +++++++++++++++++++ 2 files changed, 29 insertions(+), 23 deletions(-) create mode 100644 mon-pix/app/components/authentication/password-reset-demand/password-reset-demand-received-info.gjs diff --git a/mon-pix/app/components/authentication/password-reset-demand/password-reset-demand-form.gjs b/mon-pix/app/components/authentication/password-reset-demand/password-reset-demand-form.gjs index 745cb581d71..624af6b5d20 100644 --- a/mon-pix/app/components/authentication/password-reset-demand/password-reset-demand-form.gjs +++ b/mon-pix/app/components/authentication/password-reset-demand/password-reset-demand-form.gjs @@ -11,6 +11,7 @@ import { t } from 'ember-intl'; import ENV from 'mon-pix/config/environment'; 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..a0db22f3108 --- /dev/null +++ b/mon-pix/app/components/authentication/password-reset-demand/password-reset-demand-received-info.gjs @@ -0,0 +1,28 @@ +import PixButtonLink from '@1024pix/pix-ui/components/pix-button-link'; +import Component from '@glimmer/component'; +import { t } from 'ember-intl'; + +export default class PasswordResetDemandReceivedInfo extends Component { + +} From e627abd1d6447a7d4beb4771cc4b256dfee20087 Mon Sep 17 00:00:00 2001 From: Eric Lim Date: Tue, 29 Oct 2024 15:51:22 +0100 Subject: [PATCH 3/5] refactor(mon-pix): add test for PasswordResetDemandReceivedInfo component --- ...ssword-reset-demand-received-info-test.gjs | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 mon-pix/tests/integration/components/authentication/password-reset-demand/password-reset-demand-received-info-test.gjs 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..dea50480e06 --- /dev/null +++ b/mon-pix/tests/integration/components/authentication/password-reset-demand/password-reset-demand-received-info-test.gjs @@ -0,0 +1,37 @@ +import { render } from '@1024pix/ember-testing-library'; +import { t } from 'ember-intl/test-support'; +import PasswordResetDemandReceivedInfo from 'mon-pix/components/authentication/password-reset-demand/password-reset-demand-received-info'; +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(); + assert.strictEqual(tryAgainLink.getAttribute('href'), '/mot-de-passe-oublie'); + }); + }, +); From e481175cb61d1e0590c112907b29efe91ac7cf0f Mon Sep 17 00:00:00 2001 From: Eric Lim Date: Tue, 29 Oct 2024 16:19:08 +0100 Subject: [PATCH 4/5] feat(mon-pix): update try again link text used in password reset demand received info component --- mon-pix/translations/fr.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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": { From 8e5a4a1597cabeb8bb11a2087b7d6c2d8ca77af9 Mon Sep 17 00:00:00 2001 From: Eric Lim Date: Tue, 29 Oct 2024 16:09:25 +0100 Subject: [PATCH 5/5] feat(mon-pix): add lang query param in try again link on PasswordResetDemandReceivedInfo component --- .../password-reset-demand-received-info.gjs | 14 +++++++++++--- .../password-reset-demand-form-test.gjs | 10 +++++++--- ...ssword-reset-demand-received-info-test.gjs | 19 +++++++++++++++++-- 3 files changed, 35 insertions(+), 8 deletions(-) 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 index a0db22f3108..944098a3caa 100644 --- 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 @@ -1,8 +1,15 @@ 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; + }