Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Afficher dans les détails d'une organisation si la fonctionnalitée Attestations est activée (PIX-15550) #11266

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@ export default class OrganizationInformationSection extends Component {
{{#if @organization.isComputeCertificabilityEnabled}}
<li>Certificabilité automatique activée</li>
{{/if}}
{{#if @organization.isAttestationsEnabled}}
<li>{{t "components.organizations.information-section-view.features.attestations"}}</li>
{{/if}}

</ul>
{{#if this.accessControl.hasAccessToOrganizationActionsScope}}
Expand Down
6 changes: 6 additions & 0 deletions admin/app/models/organization.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
};
}

Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ module('Acceptance | Organizations | Information management', function (hooks) {
LEARNER_IMPORT: { active: false },
MULTIPLE_SENDING_ASSESSMENT: { active: false },
COMPUTE_ORGANIZATION_LEARNER_CERTIFICABILITY: { active: false },
ATTESTATIONS_MANAGEMENT: { active: false },
},
});
this.server.create('organization', { id: '1234' });
Expand Down
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -319,30 +320,65 @@ 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(<template><InformationSectionView @organization={{organization}} /></template>);
// then
assert.ok(screen.getByText('Certificabilité automatique activée'));
});
});

// when
const screen = await render(<template><InformationSectionView @organization={{organization}} /></template>);
// 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,
});

// when
const screen = await render(<template><InformationSectionView @organization={{organization}} /></template>);
// then
assert.notOk(screen.queryByText('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('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(<template><InformationSectionView @organization={{organization}} /></template>);
// then
assert.ok(screen.getByText(t('components.organizations.information-section-view.features.attestations')));
});
});

// when
const screen = await render(<template><InformationSectionView @organization={{organization}} /></template>);
// then
assert.notOk(screen.queryByText('Certificabilité automatique activée'));
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(<template><InformationSectionView @organization={{organization}} /></template>);
// then
assert.notOk(
screen.queryByText(t('components.organizations.information-section-view.features.attestations')),
);
});
});
});
});
Expand Down
44 changes: 44 additions & 0 deletions admin/tests/unit/models/organization-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 3 additions & 0 deletions admin/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,9 @@
},
"information-section-view": {
"child-organization": "Child organization",
"features": {
"attestations": "Attestations enabled"
},
"parent-organization": "Parent organization"
}
},
Expand Down
3 changes: 3 additions & 0 deletions admin/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,9 @@
},
"information-section-view": {
"child-organization": "Organisation fille",
"features": {
"attestations": "Attestations activée"
},
"parent-organization": "Organisation mère"
}
},
Expand Down