Skip to content

Commit

Permalink
fix(mon-pix): test
Browse files Browse the repository at this point in the history
  • Loading branch information
xav-car committed Jan 17, 2025
1 parent 6dde426 commit d7dfc3f
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 65 deletions.
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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') }));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" }));

Expand Down Expand Up @@ -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" }));

Expand All @@ -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 }),
Expand Down Expand Up @@ -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" }));

Expand All @@ -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
Expand Down
57 changes: 20 additions & 37 deletions mon-pix/tests/acceptance/start-campaigns-workflow-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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');
Expand All @@ -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: [email protected])' }),
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)',
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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' }));

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading

0 comments on commit d7dfc3f

Please sign in to comment.