Skip to content

Commit

Permalink
feat(mon-pix): prevent results share action for isForAbsoluteNovice c…
Browse files Browse the repository at this point in the history
…ampaigns
  • Loading branch information
Jeyffrey committed Nov 14, 2024
1 parent bd43f7a commit 794baf5
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { service } from '@ember/service';
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
import { t } from 'ember-intl';
import { or } from 'ember-truth-helpers';
import ENV from 'mon-pix/config/environment';

import MarkdownToHtml from '../../../../markdown-to-html';
Expand Down Expand Up @@ -143,7 +144,7 @@ export default class EvaluationResultsHero extends Component {
</p>
{{/if}}
{{else}}
{{#unless this.isAutonomousCourse}}
{{#unless (or this.isAutonomousCourse @campaign.isForAbsoluteNovice)}}
<p class="evaluation-results-hero-details__explanations">
{{t "pages.skill-review.hero.explanations.send-results"}}
</p>
Expand All @@ -168,7 +169,7 @@ export default class EvaluationResultsHero extends Component {
{{/unless}}
{{/if}}
{{else}}
{{#if this.isAutonomousCourse}}
{{#if (or this.isAutonomousCourse @campaign.isForAbsoluteNovice)}}
{{#unless @campaign.hasCustomResultPageButton}}
<PixButtonLink @route="authentication.login" @size="large">
{{t "navigation.back-to-homepage"}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,60 @@ module('Integration | Components | Campaigns | Assessment | Results | Evaluation
});
});

module('when it is an isForAbsoluteNovice campaign', function () {
module('when there is no custom link', function () {
test('it should display only a homepage link', async function (assert) {
// given
this.set('campaign', {
isForAbsoluteNovice: true,
hasCustomResultPageButton: false,
});
this.set('campaignParticipationResult', { masteryRate: 0.75 });

// when
const screen = await render(
hbs`<Campaigns::Assessment::Results::EvaluationResultsHero
@campaign={{this.campaign}}
@campaignParticipationResult={{this.campaignParticipationResult}}
/>`,
);

// then
assert.dom(screen.queryByText(t('pages.skill-review.hero.explanations.send-results'))).doesNotExist();

assert.dom(screen.getByRole('link', { name: t('navigation.back-to-homepage') })).exists();
assert.dom(screen.queryByRole('button', { name: t('pages.skill-review.hero.see-trainings') })).doesNotExist();
assert.dom(screen.queryByRole('button', { name: t('pages.skill-review.actions.send') })).doesNotExist();
});
});

module('when there is a custom link', function () {
test('it should not display a homepage link', async function (assert) {
// given
this.set('campaign', {
isForAbsoluteNovice: true,
hasCustomResultPageButton: true,
});
this.set('campaignParticipationResult', { masteryRate: 0.75 });

// when
const screen = await render(
hbs`<Campaigns::Assessment::Results::EvaluationResultsHero
@campaign={{this.campaign}}
@campaignParticipationResult={{this.campaignParticipationResult}}
/>`,
);

// then
assert.dom(screen.queryByText(t('pages.skill-review.hero.explanations.send-results'))).doesNotExist();

assert.dom(screen.queryByRole('link', { name: t('navigation.back-to-homepage') })).doesNotExist();
assert.dom(screen.queryByRole('button', { name: t('pages.skill-review.hero.see-trainings') })).doesNotExist();
assert.dom(screen.queryByRole('button', { name: t('pages.skill-review.actions.send') })).doesNotExist();
});
});
});

module('improve results', function () {
module('when user can improve results', function () {
test('it should display specific explanation and button', async function (assert) {
Expand Down

0 comments on commit 794baf5

Please sign in to comment.