Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUGFIX] Si l'utilisateur a un identifiant renseigné alors le champ "e-mail" ne doit pas être obligatoire dans Pix Admin (PIX-15540) #11099

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading