Skip to content

Commit

Permalink
feat(mon-pix): handle errors service in PasswordResetDemandForm
Browse files Browse the repository at this point in the history
component
  • Loading branch information
er-lim authored Nov 6, 2024
1 parent 2964768 commit 5537ca8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import PixInput from '@1024pix/pix-ui/components/pix-input';
import PixMessage from '@1024pix/pix-ui/components/pix-message';
import { on } from '@ember/modifier';
import { action } from '@ember/object';
import { service } from '@ember/service';
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
import { t } from 'ember-intl';
Expand All @@ -14,8 +15,10 @@ import isEmailValid from '../../../utils/email-validator.js';
import PasswordResetDemandReceivedInfo from './password-reset-demand-received-info';

export default class PasswordResetDemandForm extends Component {
@service errors;

@tracked globalError = this.errors.hasErrors && this.errors.shift();
@tracked isLoading = false;
@tracked globalError;
@tracked isPasswordResetDemandReceived = false;

validation = new FormValidation({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,21 @@ module('Integration | Component | Authentication | PasswordResetDemand | passwor
assert.dom(screen.queryByText(t('common.api-error-messages.internal-server-error'))).exists();
});
});

module('when there is an error in errors service', function () {
test('it displays the error on the corresponding banner', async function (assert) {
// given
const errorKeyMessageToBeDisplayed = 'pages.reset-password.error.expired-demand';
const errorsService = this.owner.lookup('service:errors');

// when
errorsService.push(errorKeyMessageToBeDisplayed);
const screen = await render(<template><PasswordResetDemandForm /></template>);

// then
assert.dom(screen.getByRole('alert', { value: t(errorKeyMessageToBeDisplayed) })).exists();
});
});
});
});

Expand Down

0 comments on commit 5537ca8

Please sign in to comment.