diff --git a/admin/app/components/organizations/information-section-view.gjs b/admin/app/components/organizations/information-section-view.gjs index 2f293fa2d8c..9854bd11ca7 100644 --- a/admin/app/components/organizations/information-section-view.gjs +++ b/admin/app/components/organizations/information-section-view.gjs @@ -187,6 +187,9 @@ export default class OrganizationInformationSection extends Component { {{#if @organization.isComputeCertificabilityEnabled}}
  • Certificabilité automatique activée
  • {{/if}} + {{#if @organization.isAttestationsEnabled}} +
  • {{t "components.organizations.information-section-view.features.attestations"}}
  • + {{/if}} {{#if this.accessControl.hasAccessToOrganizationActionsScope}} diff --git a/admin/app/models/organization.js b/admin/app/models/organization.js index 1293e3f5a20..0a71e9b3e33 100644 --- a/admin/app/models/organization.js +++ b/admin/app/models/organization.js @@ -43,6 +43,7 @@ export default class Organization extends Model { PLACES_MANAGEMENT: 'PLACES_MANAGEMENT', COMPUTE_ORGANIZATION_LEARNER_CERTIFICABILITY: 'COMPUTE_ORGANIZATION_LEARNER_CERTIFICABILITY', LEARNER_IMPORT: 'LEARNER_IMPORT', + ATTESTATIONS_MANAGEMENT: 'ATTESTATIONS_MANAGEMENT', }; } @@ -51,6 +52,11 @@ export default class Organization extends Model { return this.features[Organization.featureList.COMPUTE_ORGANIZATION_LEARNER_CERTIFICABILITY].active; } + get isAttestationsEnabled() { + if (!this.features) return false; + return this.features[Organization.featureList.ATTESTATIONS_MANAGEMENT].active; + } + get isLearnerImportEnabled() { if (!this.features) return false; return this.features[Organization.featureList.LEARNER_IMPORT].active; diff --git a/admin/tests/integration/components/organizations/information-section-view-test.gjs b/admin/tests/integration/components/organizations/information-section-view-test.gjs index dd45e5fc580..4aa25a1d3e1 100644 --- a/admin/tests/integration/components/organizations/information-section-view-test.gjs +++ b/admin/tests/integration/components/organizations/information-section-view-test.gjs @@ -1,6 +1,7 @@ import { render } from '@1024pix/ember-testing-library'; import EmberObject from '@ember/object'; import Service from '@ember/service'; +import { t } from 'ember-intl/test-support'; import InformationSectionView from 'pix-admin/components/organizations/information-section-view'; import { module, test } from 'qunit'; @@ -319,30 +320,63 @@ module('Integration | Component | organizations/information-section-view', funct }); module('Features', function () { - module('when compute certificability is true', function () { - test('should display this information', async function (assert) { - // given - const organization = EmberObject.create({ - isComputeCertificabilityEnabled: true, + module('Compute certificability', function () { + module('when compute certificability is true', function () { + test('should display this information', async function (assert) { + // given + const organization = EmberObject.create({ + isComputeCertificabilityEnabled: true, + }); + + // when + const screen = await render(); + // then + assert.ok(screen.getByText('Certificabilité automatique activée')); }); - - // when - const screen = await render(); - // then - assert.ok(screen.getByText('Certificabilité automatique activée')); }); - }); - module('when compute certificability is false', function () { - test('should not display this information', async function (assert) { - // given - const organization = EmberObject.create({ - isComputeCertificabilityEnabled: false, + module('when compute certificability is false', function () { + test('should not display this information', async function (assert) { + // given + const organization = EmberObject.create({ + isComputeCertificabilityEnabled: false, + }); + + // when + const screen = await render(); + // then + assert.notOk(screen.queryByText('Certificabilité automatique activée')); }); + }); + }); - // when - const screen = await render(); - // then - assert.notOk(screen.queryByText('Certificabilité automatique activée')); + module('Attestations', function () { + module('when attestations is enabled', function () { + test('should display this information', async function (assert) { + // given + const organization = EmberObject.create({ + isAttestationsEnabled: true, + }); + + // when + const screen = await render(); + // then + assert.ok(screen.getByText(t('components.organizations.information-section-view.features.attestations'))); + }); + }); + module('when attestations is not enabled', function () { + test('should not display this information', async function (assert) { + // given + const organization = EmberObject.create({ + isAttestationsEnabled: false, + }); + + // when + const screen = await render(); + // then + assert.notOk( + screen.queryByText(t('components.organizations.information-section-view.features.attestations')), + ); + }); }); }); }); diff --git a/admin/tests/unit/models/organization-test.js b/admin/tests/unit/models/organization-test.js index 192bcbcabda..0707c5c064d 100644 --- a/admin/tests/unit/models/organization-test.js +++ b/admin/tests/unit/models/organization-test.js @@ -48,6 +48,50 @@ module('Unit | Model | organization', function (hooks) { }); }); + module('#isAttestationsEnabled', function () { + module('#get', function () { + test('it returns true when feature is enabled', function (assert) { + // given + const store = this.owner.lookup('service:store'); + const model = store.createRecord('organization', { + features: { ['ATTESTATIONS_MANAGEMENT']: { active: true } }, + }); + + // when + const isAttestationsEnabled = model.isAttestationsEnabled; + + // then + assert.true(isAttestationsEnabled); + }); + + test('it returns false when feature is disabled', function (assert) { + // given + const store = this.owner.lookup('service:store'); + const model = store.createRecord('organization', { + features: { ['ATTESTATIONS_MANAGEMENT']: { active: false } }, + }); + + // when + const isAttestationsEnabled = model.isAttestationsEnabled; + + // then + assert.false(isAttestationsEnabled); + }); + + test('it returns false when no features are provided', function (assert) { + // given + const store = this.owner.lookup('service:store'); + const model = store.createRecord('organization', {}); + + // when + const isAttestationsEnabled = model.isAttestationsEnabled; + + // then + assert.false(isAttestationsEnabled); + }); + }); + }); + module('#isLearnerImportEnabled', function () { module('#get', function () { test('it returns true when feature is enabled', function (assert) { diff --git a/admin/translations/en.json b/admin/translations/en.json index 0ef9e7921f2..dcfca753d26 100644 --- a/admin/translations/en.json +++ b/admin/translations/en.json @@ -342,7 +342,10 @@ }, "information-section-view": { "child-organization": "Child organization", - "parent-organization": "Parent organization" + "parent-organization": "Parent organization", + "features": { + "attestations": "Attestation enabled" + } } }, "users": { diff --git a/admin/translations/fr.json b/admin/translations/fr.json index 45d7fc901c2..96c5467435b 100644 --- a/admin/translations/fr.json +++ b/admin/translations/fr.json @@ -350,7 +350,10 @@ }, "information-section-view": { "child-organization": "Organisation fille", - "parent-organization": "Organisation mère" + "parent-organization": "Organisation mère", + "features": { + "attestations": "Attestation activée" + } } }, "users": {