Skip to content

Commit

Permalink
feat(mon-pix): add lang query param in try again link
Browse files Browse the repository at this point in the history
on PasswordResetDemandReceivedInfo component
  • Loading branch information
er-lim committed Oct 30, 2024
1 parent e481175 commit 8e5a4a1
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -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;
}
<template>
<div class="authentication-password-reset-demand-received-info">
<img src="/images/mail.svg" alt="" />
Expand All @@ -15,10 +22,11 @@ export default class PasswordResetDemandReceivedInfo extends Component {
<p class="authentication-password-reset-demand-received-info__help">
{{t "components.authentication.password-reset-demand-received-info.no-email-received-question"}}
<PixButtonLink
@variant="tertiary"
@route="password-reset-demand"
target="_blank"
class="authentication-password-reset-demand-form__help-contact-us-link"
target="_blank"
@query={{hash lang=this.locale}}
@route="password-reset-demand"
@variant="tertiary"
>
{{t "components.authentication.password-reset-demand-received-info.try-again"}}
</PixButtonLink>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { fillByLabel, render } from '@1024pix/ember-testing-library';
import { click } from '@ember/test-helpers';
import { t } from 'ember-intl/test-support';
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';

Expand Down Expand Up @@ -91,9 +92,12 @@ module('Integration | Component | Authentication | PasswordResetDemand | passwor
);

const email = '[email protected]';
const screen = await render(<template><PasswordResetDemandForm /></template>);
const locale = ENGLISH_INTERNATIONAL_LOCALE;

// when
await setLocale(locale);
const screen = await render(<template><PasswordResetDemandForm /></template>);

await fillByLabel(t('components.authentication.password-reset-demand-form.fields.email.label'), email);
await click(
screen.getByRole('button', {
Expand All @@ -116,7 +120,7 @@ module('Integration | Component | Authentication | PasswordResetDemand | passwor
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}`);
});
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { render } from '@1024pix/ember-testing-library';
import { t } from 'ember-intl/test-support';
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';
Expand Down Expand Up @@ -31,7 +32,21 @@ module(
name: t('components.authentication.password-reset-demand-received-info.try-again'),
});
assert.dom(tryAgainLink).exists();
assert.strictEqual(tryAgainLink.getAttribute('href'), '/mot-de-passe-oublie');
});

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(<template><PasswordResetDemandReceivedInfo /></template>);

// 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}`);
});
},
);

0 comments on commit 8e5a4a1

Please sign in to comment.