Skip to content

Commit 2b99c08

Browse files
yafAlexandre Coin
and
Alexandre Coin
committed
🧹 refactor(admin & api) certif center is always v3
Co-authored-by: Alexandre Coin <alexandre@mbpdealexandre-1.home>
1 parent 5f36561 commit 2b99c08

File tree

10 files changed

+3
-149
lines changed

10 files changed

+3
-149
lines changed

Diff for: admin/app/components/certification-centers/creation-form.gjs

-11
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,6 @@ export default class CertificationCenterForm extends Component {
3131
this.args.certificationCenter.externalId = event.target.value;
3232
}
3333

34-
@action
35-
handleIsV3PilotChange(event) {
36-
this.args.certificationCenter.isV3Pilot = event.target.checked;
37-
}
38-
3934
@action
4035
handleDataProtectionOfficerFirstNameChange(event) {
4136
this.args.certificationCenter.dataProtectionOfficerFirstName = event.target.value;
@@ -122,12 +117,6 @@ export default class CertificationCenterForm extends Component {
122117
<:label>Adresse e-mail du DPO</:label>
123118
</PixInput>
124119

125-
<div class="form-field">
126-
<PixCheckbox @id="isV3Pilot" @size="small" onChange={{this.handleIsV3PilotChange}}>
127-
<:label>{{t "components.certification-centers.is-v3-pilot-label"}}</:label>
128-
</PixCheckbox>
129-
</div>
130-
131120
<section>
132121
<h2 class="habilitations-title">Habilitations aux certifications complémentaires</h2>
133122
<ul class="form-field habilitations-checkbox-list">

Diff for: admin/app/components/certification-centers/information-edit.gjs

-11
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,6 @@ export default class InformationEdit extends Component {
3939
this.form.set('type', value ? value.trim() : value);
4040
}
4141

42-
@action
43-
updateIsV3Pilot(event) {
44-
this.form.set('isV3Pilot', event.target.checked);
45-
}
46-
4742
@action
4843
async updateGrantedHabilitation(habilitation) {
4944
const habilitations = await this.form.habilitations;
@@ -70,7 +65,6 @@ export default class InformationEdit extends Component {
7065
this.args.certificationCenter.set('dataProtectionOfficerFirstName', this.form.dataProtectionOfficerFirstName);
7166
this.args.certificationCenter.set('dataProtectionOfficerLastName', this.form.dataProtectionOfficerLastName);
7267
this.args.certificationCenter.set('dataProtectionOfficerEmail', this.form.dataProtectionOfficerEmail);
73-
this.args.certificationCenter.set('isV3Pilot', this.form.isV3Pilot);
7468

7569
this.args.toggleEditMode();
7670
return this.args.onSubmit();
@@ -85,7 +79,6 @@ export default class InformationEdit extends Component {
8579
'dataProtectionOfficerFirstName',
8680
'dataProtectionOfficerLastName',
8781
'dataProtectionOfficerEmail',
88-
'isV3Pilot',
8982
);
9083
this.form.setProperties({ ...properties, habilitations });
9184
}
@@ -184,10 +177,6 @@ export default class InformationEdit extends Component {
184177
</span>
185178
{{/if}}
186179

187-
<PixCheckbox @id="isV3Pilot" @size="small" onChange={{this.updateIsV3Pilot}} @checked={{this.form.isV3Pilot}}>
188-
<:label>{{t "components.certification-centers.is-v3-pilot-label"}}</:label>
189-
</PixCheckbox>
190-
191180
<span class="field-label">Habilitations aux certifications complémentaires</span>
192181
<ul class="form-field certification-center-information__edit-form__habilitations-checkbox-list">
193182
{{#each this.availableHabilitations as |habilitation|}}

Diff for: admin/tests/acceptance/authenticated/certification-centers/get-test.js

-36
Original file line numberDiff line numberDiff line change
@@ -197,42 +197,6 @@ module('Acceptance | authenticated/certification-centers/get', function (hooks)
197197
.dom(screen.getByText("Une erreur est survenue, le centre de certification n'a pas été mis à jour."))
198198
.exists();
199199
});
200-
201-
module('when the certification is updated with v3Pilot with a feature pilot', function () {
202-
test('should display an error notification', async function (assert) {
203-
// given
204-
await authenticateAdminMemberWithRole({ isSuperAdmin: true })(server);
205-
const certificationCenter = server.create('certification-center', {
206-
name: 'Center 1',
207-
externalId: 'ABCDEF',
208-
type: 'SCO',
209-
});
210-
this.server.patch(
211-
`/admin/certification-centers/${certificationCenter.id}`,
212-
{ errors: [{ code: 'PILOT_FEATURES_CONFLICT' }] },
213-
403,
214-
);
215-
const screen = await visit(`/certification-centers/${certificationCenter.id}`);
216-
await clickByName('Modifier');
217-
await click(
218-
screen.getByRole('checkbox', {
219-
name: 'Pilote Certification V3 (ce centre de certification ne pourra organiser que des sessions V3)',
220-
}),
221-
);
222-
223-
// when
224-
await clickByName('Enregistrer');
225-
226-
// then
227-
assert
228-
.dom(
229-
screen.getByText(
230-
'Il y a une incompatibilité entre les fonctionnalités pilotes auxquelles vous souhaitez habiliter le centre. Merci de rafraîchir la page.',
231-
),
232-
)
233-
.exists();
234-
});
235-
});
236200
});
237201

238202
module('tab navigation', function () {

Diff for: admin/tests/integration/components/certification-centers/creation-form-test.gjs

-39
Original file line numberDiff line numberDiff line change
@@ -27,45 +27,6 @@ module('Integration | Component | certification-centers/creation-form', function
2727
assert.dom(screen.getByText('Identifiant externe')).exists();
2828
assert.dom(screen.getByRole('button', { name: 'Annuler' })).exists();
2929
assert.dom(screen.getByText('Ajouter')).exists();
30-
assert
31-
.dom(
32-
screen.getByRole('checkbox', {
33-
name: 'Pilote Certification V3 (ce centre de certification ne pourra organiser que des sessions V3)',
34-
}),
35-
)
36-
.exists();
37-
});
38-
39-
module('#handleIsV3PilotChange', function () {
40-
test('should add isV3Pilot to certification center on checked checkbox', async function (assert) {
41-
// given
42-
const store = this.owner.lookup('service:store');
43-
const certificationCenter = store.createRecord('certification-center');
44-
const habilitations = [];
45-
const onSubmit = () => {};
46-
const onCancel = () => {};
47-
48-
const screen = await render(
49-
<template>
50-
<CreationForm
51-
@habilitations={{habilitations}}
52-
@certificationCenter={{certificationCenter}}
53-
@onSubmit={{onSubmit}}
54-
@onCancel={{onCancel}}
55-
/>
56-
</template>,
57-
);
58-
59-
// when
60-
await click(
61-
screen.getByRole('checkbox', {
62-
name: 'Pilote Certification V3 (ce centre de certification ne pourra organiser que des sessions V3)',
63-
}),
64-
);
65-
66-
// then
67-
assert.true(certificationCenter.isV3Pilot);
68-
});
6930
});
7031

7132
module('#selectCertificationCenterType', function () {

Diff for: admin/tests/integration/components/certification-centers/information-edit-test.gjs

+1-22
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,6 @@ module('Integration | Component | certification-centers/information-edit', funct
2525
const onSubmit = sinon.stub();
2626

2727
module('certification center edit form validation', function () {
28-
test('it should display a checkbox to edit the isV3Pilot certification center status ', async function (assert) {
29-
// when
30-
const screen = await render(
31-
<template><InformationEdit @certificationCenter={{certificationCenter}} /></template>,
32-
);
33-
34-
// then
35-
assert
36-
.dom(
37-
screen.getByRole('checkbox', {
38-
name: 'Pilote Certification V3 (ce centre de certification ne pourra organiser que des sessions V3)',
39-
}),
40-
)
41-
.exists();
42-
});
43-
4428
test("it should show an error message if certification center's name is empty", async function (assert) {
4529
// given
4630
const screen = await render(
@@ -210,11 +194,6 @@ module('Integration | Component | certification-centers/information-edit', funct
210194
await fillByLabel('Prénom du DPO', 'newFirstname');
211195
await fillByLabel('Nom du DPO', 'newLastname');
212196
await fillByLabel('Adresse e-mail du DPO', 'newMail@example.net');
213-
await click(
214-
screen.getByRole('checkbox', {
215-
name: 'Pilote Certification V3 (ce centre de certification ne pourra organiser que des sessions V3)',
216-
}),
217-
);
218197

219198
await click(screen.getByRole('button', { name: 'Enregistrer' }));
220199

@@ -226,7 +205,7 @@ module('Integration | Component | certification-centers/information-edit', funct
226205
assert.strictEqual(certificationCenter.dataProtectionOfficerFirstName, 'newFirstname');
227206
assert.strictEqual(certificationCenter.dataProtectionOfficerLastName, 'newLastname');
228207
assert.strictEqual(certificationCenter.dataProtectionOfficerEmail, 'newMail@example.net');
229-
assert.false(certificationCenter.isV3Pilot);
208+
assert.true(certificationCenter.isV3Pilot);
230209
});
231210

232211
test('it should add the habilitation to the certification center', async function (assert) {

Diff for: admin/tests/unit/components/certification-centers/information-edit-test.js

-24
Original file line numberDiff line numberDiff line change
@@ -19,30 +19,6 @@ module('Unit | Component | certification-centers/information-edit', function (ho
1919
});
2020
});
2121

22-
module('#updateIsV3Pilot', function () {
23-
test('should add isV3Pilot to certification center on checked checkbox', async function (assert) {
24-
// given
25-
component.form.isV3Pilot = false;
26-
27-
// when
28-
component.updateIsV3Pilot({ target: { checked: true } });
29-
30-
// then
31-
assert.true(component.form.isV3Pilot);
32-
});
33-
34-
test('should remove isV3Pilot to certification center on unchecked checkbox', async function (assert) {
35-
// given
36-
component.form.isV3Pilot = true;
37-
38-
// when
39-
component.updateIsV3Pilot({ target: { checked: false } });
40-
41-
// then
42-
assert.false(component.form.isV3Pilot);
43-
});
44-
});
45-
4622
module('#availableHabilitations', function () {
4723
test('it should return a sorted list of available habilitations', async function (assert) {
4824
// given

Diff for: admin/translations/en.json

-1
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,6 @@
278278
}
279279
},
280280
"certification-centers": {
281-
"is-v3-pilot-label": "V3 Certification Pilot (This center will only be able to organize v3 sessions)",
282281
"membership-item": {
283282
"actions": {
284283
"edit-role": "Edit role"

Diff for: admin/translations/fr.json

-1
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,6 @@
286286
}
287287
},
288288
"certification-centers": {
289-
"is-v3-pilot-label": "Pilote Certification V3 (ce centre de certification ne pourra organiser que des sessions V3)",
290289
"membership-item": {
291290
"actions": {
292291
"edit-role": "Modifier le rôle"

Diff for: api/src/organizational-entities/infrastructure/repositories/certification-center-for-admin.repository.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const save = async function (certificationCenter) {
77
name: certificationCenter.name,
88
type: certificationCenter.type,
99
externalId: certificationCenter.externalId,
10-
isV3Pilot: certificationCenter.isV3Pilot,
10+
isV3Pilot: true,
1111
});
1212
return _toDomain(certificationCenterCreated);
1313
};

Diff for: api/tests/organizational-entities/integration/infrastructure/repositories/certification-center-for-admin-repository_test.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,11 @@ describe('Integration | Organizational Entities | Infrastructure | Repository |
2020
const certificationCenterId = 1;
2121
const certificationCenterName = 'CertificationCenterName';
2222
const certificationCenterType = 'SCO';
23-
const certificationCenterIsV3Pilot = true;
2423

2524
const center = databaseBuilder.factory.buildCertificationCenter({
2625
id: certificationCenterId,
2726
name: certificationCenterName,
2827
type: certificationCenterType,
29-
isV3Pilot: certificationCenterIsV3Pilot,
3028
});
3129

3230
const certificationCenterForAdmin = new CenterForAdmin({
@@ -41,7 +39,7 @@ describe('Integration | Organizational Entities | Infrastructure | Repository |
4139
expect(savedCertificationCenter.id).to.exist;
4240
expect(savedCertificationCenter.name).to.equal(certificationCenterName);
4341
expect(savedCertificationCenter.type).to.equal(certificationCenterType);
44-
expect(savedCertificationCenter.isV3Pilot).to.equal(certificationCenterIsV3Pilot);
42+
expect(savedCertificationCenter.isV3Pilot).to.equal(true);
4543
});
4644
});
4745

0 commit comments

Comments
 (0)