Skip to content

Commit

Permalink
[BUGFIX] Si l'utilisateur a un identifiant renseigné alors le champ "…
Browse files Browse the repository at this point in the history
…e-mail" ne doit pas être obligatoire dans Pix Admin (PIX-15540)

 #11099
  • Loading branch information
pix-service-auto-merge authored Jan 15, 2025
2 parents 5ca196a + 5573e5c commit 80cc393
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
6 changes: 5 additions & 1 deletion admin/app/components/users/user-overview.gjs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ export default class UserOverview extends Component {
return hasBeenAnonymised || isPixAgent;
}

get isEmailRequired() {
return this.args.user.username ? null : 'obligatoire';
}

_initForm() {
this.form.firstName = this.args.user.firstName;
this.form.lastName = this.args.user.lastName;
Expand Down Expand Up @@ -201,7 +205,7 @@ export default class UserOverview extends Component {
{{#if this.canModifyEmail}}
<div class="form-field">
<PixInput
@requiredLabel="obligatoire"
@requiredLabel={{this.isEmailRequired}}
@errorMessage={{this.form.emailError.message}}
@validationStatus={{this.form.emailError.status}}
@value={{this.form.email}}
Expand Down
2 changes: 1 addition & 1 deletion admin/tests/acceptance/authenticated/users/get-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ module('Acceptance | authenticated/users/get', function (hooks) {
// when
await fillIn(screen.getByLabelText('Prénom *', { exact: false }), 'john');
await fillIn(screen.getByLabelText(/Nom */), 'doe');
await fillIn(screen.getByLabelText('Adresse e-mail *', { exact: false }), 'john.doe@example.net');
await fillIn(screen.getByLabelText('Adresse e-mail', { exact: false }), 'john.doe@example.net');
await fillIn(screen.getByLabelText('Identifiant *', { exact: false }), 'john.doe0101');
await click(screen.getByRole('button', { name: 'Langue' }));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ module('Integration | Component | users | user-overview', function (hooks) {
assert.dom(screen.getByRole('textbox', { name: 'Identifiant *' })).hasValue(user.username);
});

test('displays email', async function (assert) {
test('displays not required email', async function (assert) {
// given
const user = EmberObject.create({
lastName: 'Harry',
Expand All @@ -529,7 +529,9 @@ module('Integration | Component | users | user-overview', function (hooks) {
await clickByName('Modifier');

// then
assert.dom(screen.getByRole('textbox', { name: 'Adresse e-mail *' })).exists();
const emailInput = screen.getByRole('textbox', { name: 'Adresse e-mail' });
assert.dom(emailInput).exists();
assert.dom(emailInput).hasNoAttribute('required');
});
});

Expand Down

0 comments on commit 80cc393

Please sign in to comment.