diff --git a/orga/app/components/campaign/header/title.gjs b/orga/app/components/campaign/header/title.gjs
index 1939dd04b52..d6a6e2db955 100644
--- a/orga/app/components/campaign/header/title.gjs
+++ b/orga/app/components/campaign/header/title.gjs
@@ -31,7 +31,7 @@ export default class Header extends Component {
}
get isMultipleSendingsForAssessmentEnabled() {
- return this.args.campaign.isTypeAssessment && this.currentUser.prescriber.enableMultipleSendingAssessment;
+ return (this.args.campaign.isTypeAssessment || this.args.campaign.isTypeExam) && this.currentUser.prescriber.enableMultipleSendingAssessment;
}
get multipleSendingText() {
diff --git a/orga/app/components/campaign/settings/view.gjs b/orga/app/components/campaign/settings/view.gjs
index 37b23999882..40667601863 100644
--- a/orga/app/components/campaign/settings/view.gjs
+++ b/orga/app/components/campaign/settings/view.gjs
@@ -3,6 +3,7 @@ import PixButtonLink from '@1024pix/pix-ui/components/pix-button-link';
import PixIcon from '@1024pix/pix-ui/components/pix-icon';
import PixTooltip from '@1024pix/pix-ui/components/pix-tooltip';
import { fn } from '@ember/helper';
+import { or } from 'ember-truth-helpers';
import { action } from '@ember/object';
import { service } from '@ember/service';
import Component from '@glimmer/component';
@@ -59,11 +60,11 @@ export default class CampaignView extends Component {
}
get isMultipleSendingsEnable() {
- return !this.args.campaign.isTypeAssessment || this.isMultipleSendingsForAssessmentEnabled;
+ return this.args.campaign.isProfilesCollection || this.isMultipleSendingsForAssessmentEnabled;
}
get isMultipleSendingsForAssessmentEnabled() {
- return this.args.campaign.isTypeAssessment && this.currentUser.prescriber.enableMultipleSendingAssessment;
+ return (this.args.campaign.isTypeAssessment || this.args.campaign.isTypeExam) && this.currentUser.prescriber.enableMultipleSendingAssessment;
}
get displayResetToZero() {
@@ -153,7 +154,7 @@ export default class CampaignView extends Component {
{{/if}}
{{t
diff --git a/orga/tests/integration/components/campaign/header/title-test.js b/orga/tests/integration/components/campaign/header/title-test.js
index 68e2152b23a..61488bb9949 100644
--- a/orga/tests/integration/components/campaign/header/title-test.js
+++ b/orga/tests/integration/components/campaign/header/title-test.js
@@ -131,7 +131,7 @@ module('Integration | Component | Campaign::Header::Title', function (hooks) {
test("it should display 'oui'", async function (assert) {
// given
this.campaign = store.createRecord('campaign', {
- type: 'PROFILES_COLLECTION',
+ type: 'ASSESSMENT',
multipleSendings: true,
});
@@ -147,7 +147,84 @@ module('Integration | Component | Campaign::Header::Title', function (hooks) {
test("it should display 'non'", async function (assert) {
// given
this.campaign = store.createRecord('campaign', {
- type: 'PROFILES_COLLECTION',
+ type: 'ASSESSMENT',
+ multipleSendings: false,
+ });
+
+ // when
+ const screen = await render(hbs``);
+
+ // then
+ assert.ok(screen.getByText(t('pages.campaign.multiple-sendings.status.disabled')));
+ });
+ });
+ });
+ });
+
+ module('when type is EXAM', function () {
+ module('when organization feature enableMultipleSending is false', function () {
+ test('it should not display multiple sendings label', async function (assert) {
+ // given
+ const currentUser = this.owner.lookup('service:currentUser');
+ currentUser.prescriber = {
+ enableMultipleSendingAssessment: false,
+ };
+ this.campaign = store.createRecord('campaign', {
+ type: 'EXAM',
+ });
+
+ // when
+ const screen = await render(hbs``);
+
+ // then
+ assert.notOk(screen.queryByText(t('pages.campaign.multiple-sendings.title')));
+ });
+ });
+
+ module('when organization feature enableMultipleSending is true', function (hooks) {
+ hooks.beforeEach(function () {
+ const currentUser = this.owner.lookup('service:currentUser');
+ currentUser.prescriber = {
+ enableMultipleSendingAssessment: true,
+ };
+ });
+
+ test('it should display multiple sendings label', async function (assert) {
+ // given
+ const currentUser = this.owner.lookup('service:currentUser');
+ currentUser.prescriber = {
+ enableMultipleSendingAssessment: true,
+ };
+ this.campaign = store.createRecord('campaign', {
+ type: 'EXAM',
+ });
+ // when
+ const screen = await render(hbs``);
+ // then
+ assert.ok(screen.getByText(t('pages.campaign.multiple-sendings.title')));
+ });
+
+ module('when the campaign multiple sending is true', function () {
+ test("it should display 'oui'", async function (assert) {
+ // given
+ this.campaign = store.createRecord('campaign', {
+ type: 'EXAM',
+ multipleSendings: true,
+ });
+
+ // when
+ const screen = await render(hbs``);
+
+ // then
+ assert.ok(screen.getByText(t('pages.campaign.multiple-sendings.status.enabled')));
+ });
+ });
+
+ module('when the campaign multiple sending is false', function () {
+ test("it should display 'non'", async function (assert) {
+ // given
+ this.campaign = store.createRecord('campaign', {
+ type: 'EXAM',
multipleSendings: false,
});
diff --git a/orga/tests/integration/components/campaign/settings/view-test.js b/orga/tests/integration/components/campaign/settings/view-test.js
index 43397ba89da..ea123f292c0 100644
--- a/orga/tests/integration/components/campaign/settings/view-test.js
+++ b/orga/tests/integration/components/campaign/settings/view-test.js
@@ -196,6 +196,132 @@ module('Integration | Component | Campaign::Settings::View', function (hooks) {
});
});
+ module('when type is EXAM', function () {
+ test('it should display target profile related to campaign', async function (assert) {
+ // given
+ this.campaign = store.createRecord('campaign', {
+ type: 'EXAM',
+ targetProfileName: 'profil cible de la campagne 1',
+ });
+
+ // when
+ const screen = await render(hbs``);
+
+ // then
+ assert.dom(screen.getByText('profil cible de la campagne 1')).exists();
+ });
+
+ test('it should display target profile description related to campaign', async function (assert) {
+ // given
+ this.campaign = store.createRecord('campaign', {
+ type: 'EXAM',
+ targetProfileDescription: 'Description du profile cible',
+ });
+
+ // when
+ const screen = await render(hbs``);
+
+ // then
+ assert.dom(screen.getByText('Description du profile cible')).exists();
+ });
+
+ test('it should display target profile tubes count related to campaign', async function (assert) {
+ // given
+ this.campaign = store.createRecord('campaign', {
+ type: 'EXAM',
+ targetProfileTubesCount: 3,
+ });
+
+ // when
+ const screen = await render(hbs``);
+
+ // then
+ assert
+ .dom(
+ screen.getByText(
+ t('common.target-profile-details.subjects', { value: this.campaign.targetProfileTubesCount }),
+ ),
+ )
+ .exists();
+ });
+
+ module('Badge context', function () {
+ test('it should not display target profile thematic result when empty related to campaign', async function (assert) {
+ // given
+ this.campaign = store.createRecord('campaign', {
+ type: 'EXAM',
+ targetProfileThematicResultCount: 0,
+ });
+
+ // when
+ const screen = await render(hbs``);
+
+ // then
+ assert
+ .dom(
+ screen.queryByText(
+ t('common.target-profile-details.thematic-results', {
+ value: this.campaign.targetProfileThematicResultCount,
+ }),
+ ),
+ )
+ .doesNotExist();
+ });
+
+ test('it should display target profile thematic result related to campaign', async function (assert) {
+ // given
+ this.campaign = store.createRecord('campaign', {
+ type: 'EXAM',
+ targetProfileThematicResultCount: 1,
+ });
+
+ // when
+ const screen = await render(hbs``);
+
+ // then
+ assert
+ .dom(
+ screen.getByText(
+ t('common.target-profile-details.thematic-results', {
+ value: this.campaign.targetProfileThematicResultCount,
+ }),
+ ),
+ )
+ .exists();
+ });
+ });
+
+ module('Display Result', function () {
+ test('it should display target profile result with stars when stages related to campaign', async function (assert) {
+ // given
+ this.campaign = store.createRecord('campaign', {
+ type: 'EXAM',
+ targetProfileHasStage: true,
+ });
+
+ // when
+ const screen = await render(hbs``);
+
+ // then
+ assert.dom(screen.getByLabelText(t('common.target-profile-details.results.star'))).exists();
+ });
+
+ test('it should display target profile result with percentage when no stages related to campaign', async function (assert) {
+ // given
+ this.campaign = store.createRecord('campaign', {
+ type: 'EXAM',
+ targetProfileHasStage: false,
+ });
+
+ // when
+ const screen = await render(hbs``);
+
+ // then
+ assert.dom(screen.getByLabelText(t('common.target-profile-details.results.percent'))).exists();
+ });
+ });
+ });
+
module('when type is PROFILES_COLLECTION', function () {
test('it should not display target profile', async function (assert) {
this.campaign = store.createRecord('campaign', {
@@ -315,6 +441,22 @@ module('Integration | Component | Campaign::Settings::View', function (hooks) {
});
});
+ module('when type is EXAM', function () {
+ test('it should display the campaign title', async function (assert) {
+ // given
+ this.campaign = store.createRecord('campaign', {
+ type: 'EXAM',
+ title: 'Mon titre de Campagne',
+ });
+
+ // when
+ const screen = await render(hbs``);
+
+ // then
+ assert.dom(screen.getByText('Mon titre de Campagne')).exists();
+ });
+ });
+
module('when type is PROFILES_COLLECTION', function () {
test('it should not display the campaign title', async function (assert) {
// given
@@ -611,5 +753,162 @@ module('Integration | Component | Campaign::Settings::View', function (hooks) {
});
});
});
+
+ module('when type is EXAM', function () {
+ module('when organization feature enableMultipleSending is false', function () {
+ test('it should not display multiple sendings label or tooltip', async function (assert) {
+ // given
+ this.campaign = store.createRecord('campaign', {
+ type: 'EXAM',
+ });
+
+ // when
+ const screen = await render(hbs``);
+
+ // then
+ assert.dom(screen.queryByText(t('pages.campaign-settings.multiple-sendings.title'))).doesNotExist();
+ assert
+ .dom(screen.queryByLabelText(t('pages.campaign-settings.multiple-sendings.tooltip.aria-label')))
+ .doesNotExist();
+ });
+
+ test('it should not display reset to zero label or tooltip', async function (assert) {
+ // given
+ this.campaign = store.createRecord('campaign', {
+ type: 'EXAM',
+ targetProfileAreKnowledgeElementsResettable: true,
+ });
+
+ // when
+ const screen = await render(hbs``);
+
+ // then
+ assert.dom(screen.queryByText(t('pages.campaign-settings.reset-to-zero.title'))).doesNotExist();
+ assert
+ .dom(screen.queryByLabelText(t('pages.campaign-settings.reset-to-zero.tooltip.aria-label')))
+ .doesNotExist();
+ });
+ });
+ module('when organization feature enableMultipleSending is true', function (hooks) {
+ hooks.beforeEach(function () {
+ class CurrentUserStub extends Service {
+ prescriber = { isAdminOfTheCurrentOrganization: true, enableMultipleSendingAssessment: true };
+ }
+ this.owner.register('service:currentUser', CurrentUserStub);
+ });
+
+ test('it should display multiple sendings label', async function (assert) {
+ // given
+ this.campaign = store.createRecord('campaign', {
+ type: 'EXAM',
+ });
+ // when
+ const screen = await render(hbs``);
+ // then
+ assert.dom(screen.getByText(t('pages.campaign-settings.multiple-sendings.title'))).exists();
+ });
+
+ test('it should display tooltip with multiple sendings explanatory text', async function (assert) {
+ // given
+ this.campaign = store.createRecord('campaign', {
+ type: 'EXAM',
+ });
+ // when
+ const screen = await render(hbs``);
+
+ // then
+ assert.dom(screen.getByText(t('pages.campaign-settings.multiple-sendings.tooltip.text'))).exists();
+ });
+ });
+
+ module('when the campaign has multiple sending enabled', function (hooks) {
+ hooks.beforeEach(function () {
+ class CurrentUserStub extends Service {
+ prescriber = { isAdminOfTheCurrentOrganization: true, enableMultipleSendingAssessment: true };
+ }
+ this.owner.register('service:currentUser', CurrentUserStub);
+ });
+ test('it should display reset to zero label as enabled when targetProfileAreKnowledgeElementsResettable is true', async function (assert) {
+ // given
+ this.campaign = store.createRecord('campaign', {
+ type: 'EXAM',
+ multipleSendings: true,
+ targetProfileAreKnowledgeElementsResettable: true,
+ });
+ // when
+ const screen = await render(hbs``);
+ // then
+ const resetToZeroNode = screen.getByText(t('pages.campaign-settings.reset-to-zero.title')).parentNode
+ .parentNode;
+ assert
+ .dom(within(resetToZeroNode).getByText(t('pages.campaign-settings.reset-to-zero.status.enabled')))
+ .exists();
+ });
+
+ test('it should display the reset to zero label as disabled when targetProfileAreKnowledgeElementsResettable is false', async function (assert) {
+ // given
+ this.campaign = store.createRecord('campaign', {
+ type: 'EXAM',
+ multipleSendings: true,
+ targetProfileAreKnowledgeElementsResettable: false,
+ });
+ // when
+ const screen = await render(hbs``);
+ // then
+ const resetToZeroNode = screen.getByText(t('pages.campaign-settings.reset-to-zero.title')).parentNode
+ .parentNode;
+ assert
+ .dom(within(resetToZeroNode).getByText(t('pages.campaign-settings.reset-to-zero.status.disabled')))
+ .exists();
+ });
+
+ test('it should display tooltip with reset to zero explanatory text', async function (assert) {
+ // given
+ this.campaign = store.createRecord('campaign', {
+ type: 'EXAM',
+ multipleSendings: true,
+ });
+ // when
+ const screen = await render(hbs``);
+
+ // then
+ assert.dom(screen.getByText(t('pages.campaign-settings.reset-to-zero.tooltip.text'))).exists();
+ });
+ });
+
+ module('when the campaign has multiple sending disabled', function (hooks) {
+ hooks.beforeEach(function () {
+ class CurrentUserStub extends Service {
+ prescriber = { isAdminOfTheCurrentOrganization: true, enableMultipleSendingAssessment: true };
+ }
+ this.owner.register('service:currentUser', CurrentUserStub);
+ });
+ test('it should not display reset to zero label when targetProfileAreKnowledgeElementsResettable is true', async function (assert) {
+ // given
+ this.campaign = store.createRecord('campaign', {
+ type: 'EXAM',
+ multipleSendings: false,
+ targetProfileAreKnowledgeElementsResettable: true,
+ });
+ // when
+ const screen = await render(hbs``);
+ // then
+ assert.dom(screen.queryByText(t('pages.campaign-settings.reset-to-zero.title'))).doesNotExist();
+ });
+
+ test('it should not display the reset to zero label when targetProfileAreKnowledgeElementsResettable is false', async function (assert) {
+ // given
+ this.campaign = store.createRecord('campaign', {
+ type: 'EXAM',
+ multipleSendings: false,
+ targetProfileAreKnowledgeElementsResettable: false,
+ });
+ // when
+ const screen = await render(hbs``);
+ // then
+ assert.dom(screen.queryByText(t('pages.campaign-settings.reset-to-zero.title'))).doesNotExist();
+ });
+ });
+ });
});
});