Skip to content

Commit

Permalink
feat(mon-pix): display custom result page for campaign isForAbsoluteN…
Browse files Browse the repository at this point in the history
…ovice
  • Loading branch information
Alexandre-Monney authored and lionelB committed Nov 23, 2023
1 parent 9bf38d1 commit dee5711
Show file tree
Hide file tree
Showing 2 changed files with 154 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,10 @@ export default class SkillReview extends Component {
}

get displayOrganizationCustomMessage() {
return Boolean((this.showOrganizationMessage || this.showOrganizationButton) && this.isShared);
const hasCustomBlock = this.showOrganizationMessage || this.showOrganizationButton;
const showCustomBlock = this.isShared || this.args.model.campaign.isForAbsoluteNovice;

return hasCustomBlock && showCustomBlock;
}

get showOrganizationMessage() {
Expand Down
150 changes: 150 additions & 0 deletions mon-pix/tests/integration/components/campaign/skill-review_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,156 @@ module('Integration | Component | Campaign | skill-review', function (hooks) {
assert.dom(screen.queryByRole('button', { name: 'Remettre à zéro et tout retenter' })).doesNotExist();
});

module('#displayOrganizationCustomMessage', function () {
test('display Organization Custom Message when participation is shared', async function (assert) {
const customResultPageText = 'Je suis Iron Man';
model.campaignParticipationResult.set('isShared', true);
model.campaign.set('customResultPageText', customResultPageText);

this.set('model', model);

// when
const screen = await render(hbs`<Routes::Campaigns::Assessment::SkillReview @model={{this.model}} />`);

assert.ok(screen.getByText(customResultPageText));
});

test('display Organization Custom Message when campaign isForAbsoluteNovice', async function (assert) {
const customResultPageText = "je s'appelle groot";
model.campaignParticipationResult.set('isShared', false);
model.campaign.set('customResultPageText', customResultPageText);
model.campaign.set('isForAbsoluteNovice', true);

this.set('model', model);

// when
const screen = await render(hbs`<Routes::Campaigns::Assessment::SkillReview @model={{this.model}} />`);

assert.ok(screen.getByText(customResultPageText));
});

test('display Organization Custom button when participation is shared', async function (assert) {
const customResultPageButtonText = 'Je suis Iron Man';
const customResultPageButtonUrl = 'http://jesuisunbouton.fr/';
model.campaignParticipationResult.set('isShared', true);
model.campaign.set('customResultPageButtonUrl', customResultPageButtonUrl);
model.campaign.set('customResultPageButtonText', customResultPageButtonText);

this.set('model', model);

// when
const screen = await render(hbs`<Routes::Campaigns::Assessment::SkillReview @model={{this.model}} />`);

assert
.dom(screen.getByRole('link', { name: customResultPageButtonText }))
.hasAttribute('href', customResultPageButtonUrl);
});

test('display Organization Custom button when campaign isForAbsoluteNovice', async function (assert) {
const customResultPageButtonText = 'je suis un bouton';
const customResultPageButtonUrl = 'http://jesuisunbouton.fr/';
model.campaignParticipationResult.set('isShared', false);
model.campaign.set('customResultPageButtonUrl', customResultPageButtonUrl);
model.campaign.set('customResultPageButtonText', customResultPageButtonText);
model.campaign.set('isForAbsoluteNovice', true);

this.set('model', model);

// when
const screen = await render(hbs`<Routes::Campaigns::Assessment::SkillReview @model={{this.model}} />`);

assert
.dom(screen.getByRole('link', { name: customResultPageButtonText }))
.hasAttribute('href', customResultPageButtonUrl);
});

test('display Organization Custom button and Text when campaign isForAbsoluteNovice', async function (assert) {
const customResultPageText = "je s'appelle groot";
const customResultPageButtonText = 'je suis un bouton';
const customResultPageButtonUrl = 'http://jesuisunbouton.fr/';
model.campaign.set('customResultPageText', customResultPageText);
model.campaign.set('customResultPageButtonUrl', customResultPageButtonUrl);
model.campaign.set('customResultPageButtonText', customResultPageButtonText);
model.campaignParticipationResult.set('isShared', false);
model.campaign.set('isForAbsoluteNovice', true);

this.set('model', model);

// when
const screen = await render(hbs`<Routes::Campaigns::Assessment::SkillReview @model={{this.model}} />`);

assert
.dom(screen.getByRole('link', { name: customResultPageButtonText }))
.hasAttribute('href', customResultPageButtonUrl);
assert.ok(screen.getByText(customResultPageText));
});

test('display Organization Custom button and Text when campaign participation isShared', async function (assert) {
const customResultPageText = "je s'appelle groot";
const customResultPageButtonText = 'je suis un bouton';
const customResultPageButtonUrl = 'http://jesuisunbouton.fr/';
model.campaign.set('customResultPageText', customResultPageText);
model.campaign.set('customResultPageButtonUrl', customResultPageButtonUrl);
model.campaign.set('customResultPageButtonText', customResultPageButtonText);
model.campaignParticipationResult.set('isShared', true);
model.campaign.set('isForAbsoluteNovice', false);

this.set('model', model);

// when
const screen = await render(hbs`<Routes::Campaigns::Assessment::SkillReview @model={{this.model}} />`);

assert
.dom(screen.getByRole('link', { name: customResultPageButtonText }))
.hasAttribute('href', customResultPageButtonUrl);
assert.ok(screen.getByText(customResultPageText));
});

test('not display Organization Custom Message when campaign isForAbsoluteForNovice and isShared are false', async function (assert) {
const customResultPageText = "je s'appelle groot";
model.campaignParticipationResult.set('isShared', false);
model.campaign.set('customResultPageText', customResultPageText);
model.campaign.set('isForAbsoluteNovice', false);

this.set('model', model);

// when
const screen = await render(hbs`<Routes::Campaigns::Assessment::SkillReview @model={{this.model}} />`);

assert.notOk(screen.queryByText(customResultPageText));
});

test('not display Organization Custom Message or Url when not set and campaign participation isShared', async function (assert) {
model.campaignParticipationResult.set('isShared', true);
model.campaign.set('isForAbsoluteNovice', false);
model.campaign.set('customResultPageText', null);
model.campaign.set('customResultPageButtonUrl', null);
model.campaign.set('customResultPageButtonText', null);

this.set('model', model);

// when
const screen = await render(hbs`<Routes::Campaigns::Assessment::SkillReview @model={{this.model}} />`);

assert.notOk(screen.queryByText(this.intl.t('pages.skill-review.organization-message')));
});

test('not display Organization Custom Message or Url when not set and campaign isForAbsoluteNovice', async function (assert) {
model.campaignParticipationResult.set('isShared', false);
model.campaign.set('isForAbsoluteNovice', true);
model.campaign.set('customResultPageText', null);
model.campaign.set('customResultPageButtonUrl', null);
model.campaign.set('customResultPageButtonText', null);

this.set('model', model);

// when
const screen = await render(hbs`<Routes::Campaigns::Assessment::SkillReview @model={{this.model}} />`);

assert.notOk(screen.queryByText(this.intl.t('pages.skill-review.organization-message')));
});
});

module('Reset button', function (hooks) {
hooks.beforeEach(function () {
model.campaignParticipationResult.set('canReset', true);
Expand Down

0 comments on commit dee5711

Please sign in to comment.