Skip to content

Commit

Permalink
fix(admin): test after update package
Browse files Browse the repository at this point in the history
  • Loading branch information
xav-car committed Nov 26, 2024
1 parent 08efa64 commit 97d8f77
Show file tree
Hide file tree
Showing 16 changed files with 72 additions and 71 deletions.
14 changes: 7 additions & 7 deletions admin/app/components/badges/badge.gjs
Original file line number Diff line number Diff line change
Expand Up @@ -150,39 +150,39 @@ export default class Badge extends Component {
@value={{this.form.title}}
@requiredLabel={{true}}
{{on "input" (pick "target.value" (set this "form.title"))}}
><:label>Titre : </:label></PixInput>
><:label>Titre</:label></PixInput>
</div>
<div class="badge-edit-form__field">
<PixInput
class="form-control"
@value={{this.form.key}}
@requiredLabel={{true}}
{{on "input" (pick "target.value" (set this "form.key"))}}
><:label>Clé : </:label></PixInput>
><:label>Clé</:label></PixInput>
</div>
<div class="badge-edit-form__field">
<PixTextarea
class="form-control"
@value={{this.form.message}}
rows="4"
{{on "input" (pick "target.value" (set this "form.message"))}}
><:label>Message : </:label></PixTextarea>
><:label>Message</:label></PixTextarea>
</div>
<div class="badge-edit-form__field">
<PixInput
class="form-control"
@value={{this.form.imageName}}
@requiredLabel={{true}}
@requiredLabel={{t "common.forms.mandatory"}}
{{on "input" (pick "target.value" (set this "form.imageName"))}}
><:label>Nom de l'image (svg) : </:label></PixInput>
><:label>Nom de l'image (svg)</:label></PixInput>
</div>
<div class="badge-edit-form__field">
<PixInput
class="form-control"
@value={{this.form.altMessage}}
@requiredLabel={{true}}
@requiredLabel={{t "common.forms.mandatory"}}
{{on "input" (pick "target.value" (set this "form.altMessage"))}}
><:label>Message Alternatif : </:label></PixInput>
><:label>Message Alternatif</:label></PixInput>
</div>
<div class="badge-edit-form__field">
<PixCheckbox
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,12 @@ export default class OrganizationInformationSectionEditionMode extends Component
<div class="form-field">
<PixInput
required={{true}}
@requiredLabel="obligatoire"
@errorMessage={{this.form.nameError.message}}
@validationStatus={{this.form.nameError.status}}
@value={{this.form.name}}
{{on "input" (fn this.updateFormValue "name")}}
><:label>
<abbr title="obligatoire" class="mandatory-mark" aria-hidden="true">*</abbr>
Nom
</:label></PixInput>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export default class PlacesLotCreationForm extends Component {
@value={{this.activationDate}}
@requiredLabel={{true}}
{{on "input" (pick "target.value" (set this "activationDate"))}}
><:label>Date d'activation : </:label></PixInput>
><:label>Date d'activation</:label></PixInput>

{{#if @errors.activationDate}}
<div class="form-field__error">
Expand All @@ -108,7 +108,7 @@ export default class PlacesLotCreationForm extends Component {
type="date"
@value={{this.expirationDate}}
{{on "input" (pick "target.value" (set this "expirationDate"))}}
><:label>Date d'expiration : </:label></PixInput>
><:label>Date d'expiration</:label></PixInput>

{{#if @errors.expirationDate}}
<div class="form-field__error">
Expand All @@ -125,7 +125,7 @@ export default class PlacesLotCreationForm extends Component {
@errorMessage={{get @errors.category "0.message"}}
@requiredLabel="Champs obligatoire"
>
<:label>Catégorie :</:label>
<:label>Catégorie</:label>
</PixSelect>
</div>
<div class="form-field">
Expand All @@ -135,7 +135,7 @@ export default class PlacesLotCreationForm extends Component {
maxlength="255"
@requiredLabel={{true}}
{{on "input" (pick "target.value" (set this "reference"))}}
><:label>Référence :</:label></PixInput>
><:label>Référence</:label></PixInput>

{{#if @errors.reference}}
<div class="form-field__error">
Expand Down
2 changes: 1 addition & 1 deletion admin/app/components/target-profiles/badge-form.gjs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export default class BadgeForm extends Component {
placeholder="exemple: clea_num.svg"
{{on "change" (fn this.updateFormValue "imageName")}}
>
<:label>Nom de l'image (svg) :</:label>
<:label>Nom de l'image (svg)</:label>
</PixInput>
</div>
<div class="badge-form__text-field">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { t } from 'ember-intl';
@requiredLabel={{t "common.forms.mandatory"}}
{{on "change" @onThresholdChange}}
>
<:label>Taux de réussite requis :</:label>
<:label>Taux de réussite requis</:label>
</PixInput>
</section>
</template>
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export default class CappedTubesCriterion extends Component {
@requiredLabel={{t "common.forms.mandatory"}}
{{on "change" @onThresholdChange}}
>
<:label>Taux de réussite requis :</:label>
<:label>Taux de réussite requis</:label>
</PixInput>
<Areas
@areas={{this.areas}}
Expand Down
20 changes: 10 additions & 10 deletions admin/app/components/users/user-overview.gjs
Original file line number Diff line number Diff line change
Expand Up @@ -195,51 +195,51 @@ export default class UserOverview extends Component {
</span>
<div class="form-field">
<PixInput
@requiredLabel="obligatoire"
@errorMessage={{this.form.firstNameError.message}}
@validationStatus={{this.form.firstNameError.status}}
@value={{this.form.firstName}}
{{on "input" (fn this.updateFormValue "firstName")}}
><:label>
<abbr title="obligatoire" class="mandatory-mark" aria-hidden="true">*</abbr>
Prénom :
Prénom
</:label></PixInput>
</div>
<div class="form-field">
<PixInput
@requiredLabel="obligatoire"
@errorMessage={{this.form.lastNameError.message}}
@validationStatus={{this.form.lastNameError.status}}
@value={{this.form.lastName}}
{{on "input" (fn this.updateFormValue "lastName")}}
>
<:label>
<abbr title="obligatoire" class="mandatory-mark" aria-hidden="true">*</abbr>
Nom :
Nom
</:label></PixInput>
</div>
{{#if this.canModifyEmail}}
<div class="form-field">
<PixInput
@requiredLabel="obligatoire"
@errorMessage={{this.form.emailError.message}}
@validationStatus={{this.form.emailError.status}}
@value={{this.form.email}}
{{on "input" (fn this.updateFormValue "email")}}
>
<:label>
<abbr title="obligatoire" class="mandatory-mark" aria-hidden="true">*</abbr>
Adresse e-mail :
Adresse e-mail
</:label></PixInput>
</div>
{{/if}}
{{#if @user.username}}
<div class="form-field">
<PixInput
@requiredLabel="obligatoire"
@errorMessage={{this.form.usernameError.message}}
@validationStatus={{this.form.usernameError.status}}
@value={{this.form.username}}
{{on "input" (fn this.updateFormValue "username")}}
><:label>
<abbr title="obligatoire" class="mandatory-mark" aria-hidden="true">*</abbr>
Identifiant :
Identifiant
</:label></PixInput>
</div>
{{/if}}
Expand All @@ -251,7 +251,7 @@ export default class UserOverview extends Component {
@onChange={{this.onChangeLanguage}}
@hideDefaultOption={{true}}
>
<:label>Langue :</:label>
<:label>Langue</:label>
</PixSelect>
</div>
<div class="form-field">
Expand All @@ -262,7 +262,7 @@ export default class UserOverview extends Component {
@onChange={{this.onLocaleChange}}
@hideDefaultOption={{true}}
>
<:label>Locale :</:label>
<:label>Locale</:label>
</PixSelect>
</div>
<div class="form-actions">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { clickByName, fillByLabel, visit } from '@1024pix/ember-testing-library';
import { click, currentURL } from '@ember/test-helpers';
import { click, currentURL, fillIn } from '@ember/test-helpers';
import { setupMirage } from 'ember-cli-mirage/test-support';
import { setupApplicationTest } from 'ember-qunit';
import { authenticateAdminMemberWithRole } from 'pix-admin/tests/helpers/test-init';
Expand Down Expand Up @@ -32,7 +32,7 @@ module('Acceptance | Organizations | Information management', function (hooks) {
await clickByName('Modifier');

// when
await fillByLabel('* Nom', 'newOrganizationName');
await fillIn(screen.getByLabelText(/Nom \*/), 'newOrganizationName');
await fillByLabel('Prénom du DPO', 'Bru');
await fillByLabel('Nom du DPO', 'No');
await fillByLabel('Adresse e-mail du DPO', '[email protected]');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,6 @@ module('Acceptance | Target Profile Insights', function (hooks) {
await click(secondStageLevelButton);
await screen.findByRole('listbox');
await click(screen.getByRole('option', { name: '3' }));
await waitForElementToBeRemoved(() => screen.queryByRole('listbox'));

await fillIn(firstStageLevelMessage, 'mon message un');
await fillIn(secondStageLevelMessage, 'mon message deux');
Expand Down Expand Up @@ -496,11 +495,11 @@ module('Acceptance | Target Profile Insights', function (hooks) {
await clickByName('Clés de lecture');
await clickByName('Voir le détail du résultat thématique ancien titre');
await clickByName('Modifier');
await fillByLabel('* Titre :', 'nouveau titre');
await fillByLabel('* Clé :', 'NEW_KEY');
await fillByLabel('Message :', 'nouveau message');
await fillByLabel("* Nom de l'image (svg) :", 'new_image.svg');
await fillByLabel('* Message Alternatif :', 'nouveau alt');
await fillIn(screen.getByLabelText('Titre *', { exact: false }), 'nouveau titre');
await fillIn(screen.getByLabelText('Clé *', { exact: false }), 'NEW_KEY');
await fillByLabel('Message', 'nouveau message');
await fillIn(screen.getByLabelText("Nom de l'image (svg) *", { exact: false }), 'new_image.svg');
await fillIn(screen.getByLabelText('Message Alternatif *', { exact: false }), 'nouveau alt');
await clickByName('Certifiable');
await clickByName('Lacunes');
await clickByName('Enregistrer');
Expand Down Expand Up @@ -528,7 +527,7 @@ module('Acceptance | Target Profile Insights', function (hooks) {
await clickByName('Clés de lecture');
await clickByName('Voir le détail du résultat thématique tagada');
await clickByName('Modifier');
await fillByLabel('* Titre :', 'tsouintsouin');
await fillIn(screen.getByLabelText('Titre *', { exact: false }), 'tsouintsouin');
await clickByName('Annuler');

// then
Expand Down Expand Up @@ -589,7 +588,7 @@ module('Acceptance | Target Profile Insights', function (hooks) {
await clickByName('Clés de lecture');
await clickByName('Nouveau résultat thématique');
await fillByLabel(/Nom du résultat thématique :/, 'Mon nouveau RT');
await fillByLabel("* Nom de l'image (svg) :", 'troll.png');
await fillIn(screen.getByLabelText("Nom de l'image (svg) *", { exact: false }), 'troll.png');
await fillByLabel(/Texte alternatif pour l'image :/, 'Je mets du png je fais ce que je veux');
await fillByLabel('Message :', 'message de mon RT');
await fillByLabel(/Clé/, 'MY_BADGE');
Expand All @@ -602,7 +601,7 @@ module('Acceptance | Target Profile Insights', function (hooks) {
const [tubeGroupNameInput] = screen.getAllByLabelText('Nom du critère :');
await fillIn(tubeGroupNameInput, "Le tube de l'année");

const thresholdInputs = screen.getAllByLabelText('* Taux de réussite requis :');
const thresholdInputs = screen.getAllByLabelText('Taux de réussite requis *', { exact: false });
await fillIn(thresholdInputs[0], 50);
await fillIn(thresholdInputs[1], 60);
await fillIn(thresholdInputs[2], 70);
Expand Down
14 changes: 7 additions & 7 deletions admin/tests/acceptance/authenticated/users/get-test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { clickByName, fillByLabel, visit, within } from '@1024pix/ember-testing-library';
import { click, currentURL } from '@ember/test-helpers';
import { clickByName, visit, within } from '@1024pix/ember-testing-library';
import { click, currentURL, fillIn } from '@ember/test-helpers';
import { setupMirage } from 'ember-cli-mirage/test-support';
import { setupApplicationTest } from 'ember-qunit';
import { createAuthenticateSession } from 'pix-admin/tests/helpers/test-init';
Expand Down Expand Up @@ -69,11 +69,11 @@ module('Acceptance | authenticated/users/get', function (hooks) {
await clickByName('Modifier');

// when
await fillByLabel('* Prénom :', 'john');
await fillByLabel('* Nom :', 'doe');
await fillByLabel('* Adresse e-mail :', '[email protected]');
await fillByLabel('* Identifiant :', 'john.doe0101');
await click(screen.getByRole('button', { name: 'Langue :' }));
await fillIn(screen.getByLabelText('Prénom *', { exact: false }), 'john');
await fillIn(screen.getByLabelText(/Nom */), 'doe');
await fillIn(screen.getByLabelText('Adresse e-mail *', { exact: false }), '[email protected]');
await fillIn(screen.getByLabelText('Identifiant *', { exact: false }), 'john.doe0101');
await click(screen.getByRole('button', { name: 'Langue' }));

await screen.findByRole('listbox');
await click(screen.getByRole('option', { name: 'Anglais' }));
Expand Down
9 changes: 5 additions & 4 deletions admin/tests/integration/components/campaigns/update-test.gjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { clickByName, fillByLabel, render } from '@1024pix/ember-testing-library';
import EmberObject from '@ember/object';
import Service from '@ember/service';
import { fillIn } from '@ember/test-helpers';
import Update from 'pix-admin/components/campaigns/update';
import { module, test } from 'qunit';
import sinon from 'sinon';
Expand Down Expand Up @@ -111,7 +112,7 @@ module('Integration | Component | Campaigns | Update', function (hooks) {
test('it should display an error text when the name is empty', async function (assert) {
// when
const screen = await render(<template><Update @campaign={{campaign}} @onExit={{onExit}} /></template>);
await fillByLabel('* Nom de la campagne', '');
await fillIn(screen.getByLabelText('Nom de la campagne *', { exact: false }), '');

// then
assert.dom(screen.getByText('Le nom ne peut pas être vide')).exists();
Expand All @@ -120,16 +121,16 @@ module('Integration | Component | Campaigns | Update', function (hooks) {
test('it should display an error text when the name has more than 255 characters', async function (assert) {
// when
const screen = await render(<template><Update @campaign={{campaign}} @onExit={{onExit}} /></template>);
await fillByLabel('* Nom de la campagne', 'a'.repeat(256));
await fillIn(screen.getByLabelText('Nom de la campagne *', { exact: false }), 'a'.repeat(256));

// then
assert.dom(screen.getByText('La longueur du nom ne doit pas excéder 255 caractères')).exists();
});

test('it should call Update when form is valid', async function (assert) {
//when
await render(<template><Update @campaign={{campaign}} @onExit={{onExit}} /></template>);
await fillByLabel('* Nom de la campagne', 'Nouveau nom');
const screen = await render(<template><Update @campaign={{campaign}} @onExit={{onExit}} /></template>);
await fillIn(screen.getByLabelText('Nom de la campagne *', { exact: false }), 'Nouveau nom');
await clickByName('Enregistrer');

//then
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { fillByLabel, render } from '@1024pix/ember-testing-library';
import EmberObject from '@ember/object';
import Service from '@ember/service';
import { fillIn } from '@ember/test-helpers';
import InformationSectionEdit from 'pix-admin/components/organizations/information-section-edit';
import { module, test } from 'qunit';

Expand Down Expand Up @@ -35,7 +36,7 @@ module('Integration | Component | organizations/information-section-edit', funct
const screen = await render(<template><InformationSectionEdit @organization={{organization}} /></template>);

// when
await fillByLabel('* Nom', '');
await fillIn(screen.getByLabelText('Nom *', { exact: false }), '');

// then
assert.dom(screen.getByText('Le nom ne peut pas être vide')).exists();
Expand All @@ -46,7 +47,7 @@ module('Integration | Component | organizations/information-section-edit', funct
const screen = await render(<template><InformationSectionEdit @organization={{organization}} /></template>);

// when
await fillByLabel('* Nom', 'a'.repeat(256));
await fillIn(screen.getByLabelText('Nom *', { exact: false }), 'a'.repeat(256));

// then
assert.dom(screen.getByText('La longueur du nom ne doit pas excéder 255 caractères')).exists();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { clickByName, fillByLabel, render } from '@1024pix/ember-testing-library';
import EmberObject from '@ember/object';
import Service from '@ember/service';
import { click } from '@ember/test-helpers';
import { click, fillIn } from '@ember/test-helpers';
import InformationSection from 'pix-admin/components/organizations/information-section';
import { module, test } from 'qunit';

Expand Down Expand Up @@ -39,7 +39,7 @@ module('Integration | Component | organizations/information-section', function (
await clickByName('Modifier');

// then
assert.dom(screen.getByRole('textbox', { name: 'Nom' })).exists();
assert.dom(screen.getByRole('textbox', { name: 'Nom *' })).exists();
assert.dom(screen.getByRole('textbox', { name: 'Identifiant externe' })).exists();
assert.dom(screen.getByRole('button', { name: 'Annuler' })).exists();
assert.dom(screen.getByRole('button', { name: 'Enregistrer' })).exists();
Expand All @@ -65,7 +65,7 @@ module('Integration | Component | organizations/information-section', function (

await clickByName('Modifier');

await fillByLabel('* Nom', 'new name');
await fillIn(screen.getByLabelText('Nom *', { exact: false }), 'new name');
await fillByLabel('Identifiant externe', 'new externalId');
await fillByLabel('Département (en 3 chiffres)', 'new provinceCode');
await clickByName('Gestion d’élèves/étudiants');
Expand Down Expand Up @@ -112,7 +112,7 @@ module('Integration | Component | organizations/information-section', function (
);
await clickByName('Modifier');

await fillByLabel('* Nom', 'new name');
await fillIn(screen.getByLabelText('Nom *', { exact: false }), 'new name');
await fillByLabel('Identifiant externe', 'new externalId');
await fillByLabel('Département (en 3 chiffres)', ' ');
await fillByLabel('Crédits', 50);
Expand Down
Loading

0 comments on commit 97d8f77

Please sign in to comment.