diff --git a/mon-pix/tests/acceptance/account-recovery/update-sco-record-test.js b/mon-pix/tests/acceptance/account-recovery/update-sco-record-test.js index 78e645615bd..0fa5a3a0841 100644 --- a/mon-pix/tests/acceptance/account-recovery/update-sco-record-test.js +++ b/mon-pix/tests/acceptance/account-recovery/update-sco-record-test.js @@ -1,5 +1,5 @@ -import { fillByLabel, visit } from '@1024pix/ember-testing-library'; -import { click, currentURL, settled } from '@ember/test-helpers'; +import { visit } from '@1024pix/ember-testing-library'; +import { click, currentURL, fillIn, settled } from '@ember/test-helpers'; import { setupMirage } from 'ember-cli-mirage/test-support'; import { t } from 'ember-intl/test-support'; import { setupApplicationTest } from 'ember-qunit'; @@ -169,7 +169,10 @@ module('Acceptance | account-recovery | UpdateScoRecordRoute', function (hooks) const screen = await visit(`/recuperer-mon-compte/${temporaryKey}`); - await fillByLabel(t('pages.account-recovery.update-sco-record.form.password-label'), password); + const passwordInput = screen.getByLabelText(t('pages.account-recovery.update-sco-record.form.password-label'), { + exact: false, + }); + await fillIn(passwordInput, password); await click(screen.getByRole('checkbox', { name: t('common.cgu.label') })); // when @@ -201,7 +204,12 @@ module('Acceptance | account-recovery | UpdateScoRecordRoute', function (hooks) server.patch('/account-recovery', () => errorsApi); const screen = await visit(`/recuperer-mon-compte/${temporaryKey}`); - await fillByLabel(t('pages.account-recovery.update-sco-record.form.password-label'), newPassword); + + const passwordInput = screen.getByLabelText(t('pages.account-recovery.update-sco-record.form.password-label'), { + exact: false, + }); + await fillIn(passwordInput, newPassword); + await click(screen.getByRole('checkbox', { name: t('common.cgu.label') })); // when @@ -238,7 +246,11 @@ module('Acceptance | account-recovery | UpdateScoRecordRoute', function (hooks) server.patch('/account-recovery', () => errorsApi); const screen = await visit(`/recuperer-mon-compte/${temporaryKey}`); - await fillByLabel(t('pages.account-recovery.update-sco-record.form.password-label'), newPassword); + + const passwordInput = screen.getByLabelText(t('pages.account-recovery.update-sco-record.form.password-label'), { + exact: false, + }); + await fillIn(passwordInput, newPassword); await click(screen.getByRole('checkbox', { name: t('common.cgu.label') })); // when @@ -274,7 +286,10 @@ module('Acceptance | account-recovery | UpdateScoRecordRoute', function (hooks) server.patch('/account-recovery', () => errorsApi); const screen = await visit(`/recuperer-mon-compte/${temporaryKey}`); - await fillByLabel(t('pages.account-recovery.update-sco-record.form.password-label'), newPassword); + const passwordInput = screen.getByLabelText(t('pages.account-recovery.update-sco-record.form.password-label'), { + exact: false, + }); + await fillIn(passwordInput, newPassword); await click(screen.getByRole('checkbox', { name: t('common.cgu.label') })); // when @@ -311,7 +326,10 @@ module('Acceptance | account-recovery | UpdateScoRecordRoute', function (hooks) server.patch('/account-recovery', () => errorsApi); const screen = await visit(`/recuperer-mon-compte/${temporaryKey}`); - await fillByLabel(t('pages.account-recovery.update-sco-record.form.password-label'), newPassword); + const passwordInput = screen.getByLabelText(t('pages.account-recovery.update-sco-record.form.password-label'), { + exact: false, + }); + await fillIn(passwordInput, newPassword); await click(screen.getByRole('checkbox', { name: t('common.cgu.label') })); // when @@ -347,7 +365,10 @@ module('Acceptance | account-recovery | UpdateScoRecordRoute', function (hooks) server.patch('/account-recovery', () => errorsApi); const screen = await visit(`/recuperer-mon-compte/${temporaryKey}`); - await fillByLabel(t('pages.account-recovery.update-sco-record.form.password-label'), newPassword); + const passwordInput = screen.getByLabelText(t('pages.account-recovery.update-sco-record.form.password-label'), { + exact: false, + }); + await fillIn(passwordInput, newPassword); await click(screen.getByRole('checkbox', { name: t('common.cgu.label') })); // when diff --git a/mon-pix/tests/acceptance/start-campaigns-with-type-assessment-test.js b/mon-pix/tests/acceptance/start-campaigns-with-type-assessment-test.js index 0d507851993..995fe7fa244 100644 --- a/mon-pix/tests/acceptance/start-campaigns-with-type-assessment-test.js +++ b/mon-pix/tests/acceptance/start-campaigns-with-type-assessment-test.js @@ -93,15 +93,19 @@ module('Acceptance | Campaigns | Start Campaigns with type Assessment', function // when await click(screen.getByRole('button', { name: 'Se connecter' })); - await fillIn(screen.getByRole('textbox', { name: 'Adresse e-mail ou identifiant' }), prescritUser.email); - await fillIn(screen.getByLabelText('Mot de passe'), prescritUser.password); + await fillIn( + screen.getByLabelText('Adresse e-mail ou identifiant', { exact: false }), + prescritUser.email, + ); + await fillIn(screen.getByLabelText('Mot de passe', { exact: false }), prescritUser.password); await click(screen.getByRole('button', { name: 'Se connecter' })); - await fillIn(screen.getByRole('textbox', { name: 'Prénom' }), prescritUser.firstName); - await fillIn(screen.getByRole('textbox', { name: 'Nom' }), prescritUser.lastName); - await fillIn(screen.getByRole('textbox', { name: 'jour de naissance' }), '10'); - await fillIn(screen.getByRole('textbox', { name: 'mois de naissance' }), '12'); - await fillIn(screen.getByRole('textbox', { name: 'année de naissance' }), '2000'); + await fillIn(screen.getByLabelText('Prénom'), prescritUser.firstName); + await fillIn(screen.getByLabelText('Nom'), prescritUser.lastName); + await fillIn(screen.getByLabelText('jour de naissance'), '10'); + await fillIn(screen.getByLabelText('mois de naissance'), '12'); + await fillIn(screen.getByLabelText('année de naissance'), '2000'); + await click(screen.getByRole('button', { name: t('pages.join.button') })); await click(screen.getByRole('button', { name: t('pages.join.sco.associate') })); diff --git a/mon-pix/tests/acceptance/start-campaigns-with-type-profiles-collection-test.js b/mon-pix/tests/acceptance/start-campaigns-with-type-profiles-collection-test.js index bbcfc1d869c..1276f0a0bc3 100644 --- a/mon-pix/tests/acceptance/start-campaigns-with-type-profiles-collection-test.js +++ b/mon-pix/tests/acceptance/start-campaigns-with-type-profiles-collection-test.js @@ -46,7 +46,7 @@ module('Acceptance | Campaigns | Start Campaigns with type Profiles Collection', await fillIn(screen.getByRole('textbox', { name: FIRST_NAME_INPUT_LABEL }), campaignParticipant.firstName); await fillIn(screen.getByRole('textbox', { name: LAST_NAME_INPUT_LABEL }), campaignParticipant.lastName); await fillIn(screen.getByRole('textbox', { name: EMAIL_INPUT_LABEL }), campaignParticipant.email); - await fillIn(screen.getByLabelText(PASSWORD_INPUT_LABEL), campaignParticipant.password); + await fillIn(screen.getByLabelText(PASSWORD_INPUT_LABEL, { exact: false }), campaignParticipant.password); await click(screen.getByRole('checkbox', { name: t('common.cgu.label') })); await click(screen.getByRole('button', { name: "Je m'inscris" })); @@ -75,7 +75,7 @@ module('Acceptance | Campaigns | Start Campaigns with type Profiles Collection', ); await fillIn(screen.getByRole('textbox', { name: LAST_NAME_INPUT_LABEL }), campaignParticipant.lastName); await fillIn(screen.getByRole('textbox', { name: EMAIL_INPUT_LABEL }), campaignParticipant.email); - await fillIn(screen.getByLabelText(PASSWORD_INPUT_LABEL), campaignParticipant.password); + await fillIn(screen.getByLabelText(PASSWORD_INPUT_LABEL, { exact: false }), campaignParticipant.password); await click(screen.getByRole('checkbox', { name: t('common.cgu.label') })); await click(screen.getByRole('button', { name: "Je m'inscris" })); @@ -100,10 +100,11 @@ module('Acceptance | Campaigns | Start Campaigns with type Profiles Collection', // when await click(screen.getByRole('button', { name: 'Se connecter' })); await fillIn( - screen.getByRole('textbox', { name: 'Adresse e-mail ou identifiant' }), + screen.getByLabelText('Adresse e-mail ou identifiant', { exact: false }), campaignParticipant.email, ); - await fillIn(screen.getByLabelText('Mot de passe'), campaignParticipant.password); + await fillIn(screen.getByLabelText(PASSWORD_INPUT_LABEL, { exact: false }), campaignParticipant.password); + await click(screen.getByRole('button', { name: 'Se connecter' })); await fillIn( screen.getByRole('textbox', { name: FIRST_NAME_INPUT_LABEL }), @@ -131,7 +132,7 @@ module('Acceptance | Campaigns | Start Campaigns with type Profiles Collection', await fillIn(screen.getByRole('textbox', { name: FIRST_NAME_INPUT_LABEL }), campaignParticipant.firstName); await fillIn(screen.getByRole('textbox', { name: LAST_NAME_INPUT_LABEL }), campaignParticipant.lastName); await fillIn(screen.getByRole('textbox', { name: EMAIL_INPUT_LABEL }), campaignParticipant.email); - await fillIn(screen.getByLabelText(PASSWORD_INPUT_LABEL), campaignParticipant.password); + await fillIn(screen.getByLabelText(PASSWORD_INPUT_LABEL, { exact: false }), campaignParticipant.password); await click(screen.getByRole('checkbox', { name: t('common.cgu.label') })); await click(screen.getByRole('button', { name: "Je m'inscris" })); @@ -148,7 +149,7 @@ module('Acceptance | Campaigns | Start Campaigns with type Profiles Collection', await fillIn(screen.getByRole('textbox', { name: FIRST_NAME_INPUT_LABEL }), campaignParticipant.firstName); await fillIn(screen.getByRole('textbox', { name: LAST_NAME_INPUT_LABEL }), campaignParticipant.lastName); await fillIn(screen.getByRole('textbox', { name: EMAIL_INPUT_LABEL }), campaignParticipant.email); - await fillIn(screen.getByLabelText(PASSWORD_INPUT_LABEL), campaignParticipant.password); + await fillIn(screen.getByLabelText(PASSWORD_INPUT_LABEL, { exact: false }), campaignParticipant.password); await click(screen.getByRole('checkbox', { name: t('common.cgu.label') })); // when diff --git a/mon-pix/tests/acceptance/start-campaigns-workflow-test.js b/mon-pix/tests/acceptance/start-campaigns-workflow-test.js index 677c3825e82..f3abce69b26 100644 --- a/mon-pix/tests/acceptance/start-campaigns-workflow-test.js +++ b/mon-pix/tests/acceptance/start-campaigns-workflow-test.js @@ -21,6 +21,11 @@ module('Acceptance | Campaigns | Start Campaigns workflow', function (hooks) { let campaign; + async function _loginUser(screen, prescritUser) { + await fillIn(screen.getByLabelText('Adresse e-mail ou identifiant', { exact: false }), prescritUser.email); + await fillIn(screen.getByLabelText('Mot de passe', { exact: false }), prescritUser.password); + } + hooks.beforeEach(function () { this.server.schema.users.create({ mustValidateTermsOfService: true, @@ -104,8 +109,7 @@ module('Acceptance | Campaigns | Start Campaigns workflow', function (hooks) { // when await fillIn(screen.getByRole('textbox', { name: 'Prénom' }), prescritUser.firstName); await fillIn(screen.getByRole('textbox', { name: 'Nom' }), prescritUser.lastName); - await fillIn(screen.getByRole('textbox', { name: 'Adresse e-mail' }), prescritUser.email); - await fillIn(screen.getByLabelText('Mot de passe'), prescritUser.password); + await _loginUser(screen, prescritUser); await click(screen.getByRole('checkbox', { name: t('common.cgu.label') })); // when @@ -135,8 +139,7 @@ module('Acceptance | Campaigns | Start Campaigns workflow', function (hooks) { await click(screen.getByRole('button', { name: 'Accéder au parcours' })); await click(screen.getByRole('button', { name: 'Je commence' })); await click(screen.getByRole('button', { name: 'Se connecter' })); - await fillIn(screen.getByRole('textbox', { name: 'Adresse e-mail ou identifiant' }), prescritUser.email); - await fillIn(screen.getByLabelText('Mot de passe'), prescritUser.password); + await _loginUser(screen, prescritUser); await click(screen.getByRole('button', { name: 'Se connecter' })); // then @@ -162,11 +165,7 @@ module('Acceptance | Campaigns | Start Campaigns workflow', function (hooks) { await click(screen.getByRole('button', { name: 'Accéder au parcours' })); await click(screen.getByRole('button', { name: 'Je commence' })); await click(screen.getByRole('button', { name: 'Se connecter' })); - await fillIn( - screen.getByRole('textbox', { name: 'Adresse e-mail ou identifiant' }), - prescritUser.email, - ); - await fillIn(screen.getByLabelText('Mot de passe'), prescritUser.password); + await _loginUser(screen, prescritUser); await click(screen.getByRole('button', { name: 'Se connecter' })); // then @@ -187,8 +186,7 @@ module('Acceptance | Campaigns | Start Campaigns workflow', function (hooks) { await click(screen.getByRole('button', { name: 'Accéder au parcours' })); await click(screen.getByRole('button', { name: 'Je commence' })); await click(screen.getByRole('button', { name: 'Se connecter' })); - await fillIn(screen.getByRole('textbox', { name: 'Adresse e-mail ou identifiant' }), prescritUser.email); - await fillIn(screen.getByLabelText('Mot de passe'), prescritUser.password); + await _loginUser(screen, prescritUser); await click(screen.getByRole('button', { name: 'Se connecter' })); // when @@ -257,8 +255,8 @@ module('Acceptance | Campaigns | Start Campaigns workflow', function (hooks) { await click(screen.getByRole('button', { name: 'Je commence' })); // when - await fillIn(screen.getByRole('textbox', { name: '* Prénom' }), prescritUser.firstName); - await fillIn(screen.getByRole('textbox', { name: '* Nom' }), prescritUser.lastName); + await fillIn(screen.getByLabelText('Prénom'), prescritUser.firstName); + await fillIn(screen.getByLabelText('Nom'), prescritUser.lastName); await fillIn(screen.getByRole('spinbutton', { name: 'Jour de naissance' }), '10'); await fillIn(screen.getByRole('spinbutton', { name: 'Mois de naissance' }), '12'); await fillIn(screen.getByRole('spinbutton', { name: 'Année de naissance' }), '2000'); @@ -267,10 +265,7 @@ module('Acceptance | Campaigns | Start Campaigns workflow', function (hooks) { //go to email-based authentication window await click(screen.getByText('Mon adresse e-mail')); - await fillIn( - screen.getByRole('textbox', { name: '* Adresse e-mail (ex: nom@exemple.fr)' }), - prescritUser.email, - ); + await fillIn(screen.getByLabelText('Adresse e-mail', { exact: false }), prescritUser.email); await fillIn( screen.getByLabelText( 'Mot de passe (8 caractères minimum, dont une majuscule, une minuscule et un chiffre)', @@ -317,8 +312,7 @@ module('Acceptance | Campaigns | Start Campaigns workflow', function (hooks) { // when await click(screen.getByRole('button', { name: 'Se connecter' })); - await fillIn(screen.getByRole('textbox', { name: 'Adresse e-mail ou identifiant' }), prescritUser.email); - await fillIn(screen.getByLabelText('Mot de passe'), prescritUser.password); + await _loginUser(screen, prescritUser); await click(screen.getByRole('button', { name: 'Se connecter' })); // then @@ -335,8 +329,7 @@ module('Acceptance | Campaigns | Start Campaigns workflow', function (hooks) { // when await click(screen.getByRole('button', { name: 'Se connecter' })); - await fillIn(screen.getByRole('textbox', { name: 'Adresse e-mail ou identifiant' }), prescritUser.email); - await fillIn(screen.getByLabelText('Mot de passe'), prescritUser.password); + await _loginUser(screen, prescritUser); await click(screen.getByRole('button', { name: 'Se connecter' })); // then @@ -391,8 +384,7 @@ module('Acceptance | Campaigns | Start Campaigns workflow', function (hooks) { // when await click(screen.getByRole('link', { name: 'Se connecter' })); - await fillIn(screen.getByRole('textbox', { name: 'Adresse e-mail ou identifiant' }), prescritUser.email); - await fillIn(screen.getByLabelText('Mot de passe'), prescritUser.password); + await _loginUser(screen, prescritUser); await click(screen.getByRole('button', { name: 'Je me connecte' })); @@ -972,8 +964,7 @@ module('Acceptance | Campaigns | Start Campaigns workflow', function (hooks) { await click(screen.getByRole('button', { name: 'Continuer avec mon compte Pix' })); // when - await fillIn(screen.getByRole('textbox', { name: 'Adresse e-mail ou identifiant' }), prescritUser.email); - await fillIn(screen.getByLabelText('Mot de passe'), prescritUser.password); + await _loginUser(screen, prescritUser); await click(screen.getByRole('button', { name: 'Se connecter' })); const session = currentSession(); @@ -1006,8 +997,7 @@ module('Acceptance | Campaigns | Start Campaigns workflow', function (hooks) { await click(screen.getByRole('button', { name: 'Continuer avec mon compte Pix' })); // when - await fillIn(screen.getByRole('textbox', { name: 'Adresse e-mail ou identifiant' }), prescritUser.email); - await fillIn(screen.getByLabelText('Mot de passe'), prescritUser.password); + await _loginUser(screen, prescritUser); await click(screen.getByRole('button', { name: 'Se connecter' })); // then @@ -1045,8 +1035,7 @@ module('Acceptance | Campaigns | Start Campaigns workflow', function (hooks) { await click(screen.getByRole('button', { name: 'Continuer avec mon compte Pix' })); // when - await fillIn(screen.getByRole('textbox', { name: 'Adresse e-mail ou identifiant' }), prescritUser.email); - await fillIn(screen.getByLabelText('Mot de passe'), prescritUser.password); + await _loginUser(screen, prescritUser); await click(screen.getByRole('button', { name: 'Se connecter' })); // then @@ -1076,8 +1065,7 @@ module('Acceptance | Campaigns | Start Campaigns workflow', function (hooks) { await click(screen.getByRole('button', { name: 'Continuer avec mon compte Pix' })); // when - await fillIn(screen.getByRole('textbox', { name: 'Adresse e-mail ou identifiant' }), prescritUser.email); - await fillIn(screen.getByLabelText('Mot de passe'), prescritUser.password); + await _loginUser(screen, prescritUser); await click(screen.getByRole('button', { name: 'Se connecter' })); // then @@ -1136,12 +1124,7 @@ module('Acceptance | Campaigns | Start Campaigns workflow', function (hooks) { await fillIn(screen.getByRole('textbox', { name: 'année de naissance' }), '2000'); await click(screen.getByRole('button', { name: "C'est parti !" })); await click(screen.getByRole('button', { name: 'Continuer avec mon compte Pix' })); - await fillIn( - screen.getByRole('textbox', { name: 'Adresse e-mail ou identifiant' }), - userShouldChangePassword.username, - ); - - await fillIn(screen.getByLabelText('Mot de passe'), userShouldChangePassword.password); + await _loginUser(screen, prescritUser); await click(screen.getByRole('button', { name: 'Se connecter' })); // then diff --git a/mon-pix/tests/integration/components/update-expired-password-form-test.js b/mon-pix/tests/integration/components/update-expired-password-form-test.js index 61ff86b12f2..9621ce3e3cb 100644 --- a/mon-pix/tests/integration/components/update-expired-password-form-test.js +++ b/mon-pix/tests/integration/components/update-expired-password-form-test.js @@ -11,7 +11,7 @@ import setupIntlRenderingTest from '../../helpers/setup-intl-rendering'; const ApiErrorMessages = ENV.APP.API_ERROR_MESSAGES; -const PASSWORD_INPUT_LABEL = '* Mot de passe (8 caractères minimum, dont une majuscule, une minuscule et un chiffre)'; +const PASSWORD_INPUT_LABEL = 'Mot de passe'; module('Integration | Component | update-expired-password-form', function (hooks) { setupIntlRenderingTest(hooks); @@ -23,7 +23,7 @@ module('Integration | Component | update-expired-password-form', function (hooks //then assert.dom(screen.getByRole('heading', { name: 'Réinitialiser le mot de passe' })).exists(); assert.dom(screen.getByRole('button', { name: 'Réinitialiser' })).exists(); - assert.dom(screen.getByLabelText(PASSWORD_INPUT_LABEL)).exists(); + assert.dom(screen.getByLabelText(PASSWORD_INPUT_LABEL, { exist: false })).exists(); }); module('successful cases', function () { @@ -43,13 +43,13 @@ module('Integration | Component | update-expired-password-form', function (hooks ); // when - await fillIn(screen.getByLabelText(PASSWORD_INPUT_LABEL), newPassword); - await triggerEvent(screen.getByLabelText(PASSWORD_INPUT_LABEL), 'change'); + await fillIn(screen.getByLabelText(PASSWORD_INPUT_LABEL, { exist: false }), newPassword); + await triggerEvent(screen.getByLabelText(PASSWORD_INPUT_LABEL, { exist: false }), 'change'); await click(screen.getByRole('button', { name: 'Réinitialiser' })); // then - assert.dom(screen.queryByLabelText(PASSWORD_INPUT_LABEL)).doesNotExist(); + assert.dom(screen.queryByLabelText(PASSWORD_INPUT_LABEL, { exist: false })).doesNotExist(); assert.dom(screen.getByText('Votre mot de passe a été mis à jour.')).exists(); }); }); @@ -71,8 +71,8 @@ module('Integration | Component | update-expired-password-form', function (hooks ); // when - await fillIn(screen.getByLabelText(PASSWORD_INPUT_LABEL), newPassword); - await triggerEvent(screen.getByLabelText(PASSWORD_INPUT_LABEL), 'change'); + await fillIn(screen.getByLabelText(PASSWORD_INPUT_LABEL, { exist: false }), newPassword); + await triggerEvent(screen.getByLabelText(PASSWORD_INPUT_LABEL, { exist: false }), 'change'); await click(screen.getByRole('button', { name: 'Réinitialiser' }));