Skip to content

Commit

Permalink
feat(orga): display expected settings page for exam
Browse files Browse the repository at this point in the history
Co-authored-by: Xavier Carron <[email protected]>
  • Loading branch information
laura-bergoens and xav-car committed Mar 5, 2025
1 parent b746cff commit 3fe006f
Show file tree
Hide file tree
Showing 4 changed files with 384 additions and 7 deletions.
2 changes: 1 addition & 1 deletion orga/app/components/campaign/header/title.gjs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
9 changes: 5 additions & 4 deletions orga/app/components/campaign/settings/view.gjs
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -153,7 +154,7 @@ export default class CampaignView extends Component {
{{/if}}
</div>
<div class="campaign-settings-row">
{{#if @campaign.isTypeAssessment}}
{{#if (or @campaign.isTypeAssessment @campaign.isTypeExam)}}
<div class="campaign-settings-content">
<dt class="label-text campaign-settings-content__label">
{{t "pages.campaign-settings.target-profile.title"}}
Expand Down Expand Up @@ -195,7 +196,7 @@ export default class CampaignView extends Component {
</div>
{{/if}}
</div>
{{#if @campaign.isTypeAssessment}}
{{#if (or @campaign.isTypeAssessment @campaign.isTypeExam)}}
<div class="campaign-settings-row">
<div class="campaign-settings-content campaign-settings-content--single">
<dt class="label-text campaign-settings-content__label">{{t
Expand Down
81 changes: 79 additions & 2 deletions orga/tests/integration/components/campaign/header/title-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});

Expand All @@ -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`<Campaign::Header::Title @campaign={{this.campaign}} />`);

// 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`<Campaign::Header::Title @campaign={{this.campaign}} />`);

// 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`<Campaign::Header::Title @campaign={{this.campaign}} />`);
// 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`<Campaign::Header::Title @campaign={{this.campaign}} />`);

// 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,
});

Expand Down
Loading

0 comments on commit 3fe006f

Please sign in to comment.