Skip to content

Commit

Permalink
[FEATURE] Mise à jour du CTA de fin de parcours à accès simplifié (PI…
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeyffrey authored Nov 19, 2024
1 parent 301e3e7 commit 2439879
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ export default class EvaluationResultsHero extends Component {
{{else}}
{{#unless @campaign.hasCustomResultPageButton}}
<PixButtonLink @route="authentication.login" @size="large">
{{t "navigation.back-to-homepage"}}
{{if this.currentUser.user.isAnonymous (t "common.actions.login") (t "navigation.back-to-homepage")}}
</PixButtonLink>
{{/unless}}
{{/if}}
Expand Down
5 changes: 4 additions & 1 deletion mon-pix/app/routes/authentication/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@ import Route from '@ember/routing/route';
import { service } from '@ember/service';

export default class LoginRoute extends Route {
@service currentUser;
@service session;
@service store;
@service router;

beforeModel() {
this.session.prohibitAuthentication('authenticated.user-dashboard');
if (!this.currentUser?.user?.isAnonymous) {
this.session.prohibitAuthentication('authenticated.user-dashboard');
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -237,28 +237,68 @@ module('Integration | Components | Campaigns | Assessment | Results | Evaluation

module('when campaign is simplified access', function () {
module('when there is no custom link', function () {
test('it should display only a homepage link', async function (assert) {
// given
this.set('campaign', {
isSimplifiedAccess: true,
hasCustomResultPageButton: false,
module('when user is anonymous', function () {
test('it should display only a connection link', async function (assert) {
// given
class currentUserService extends Service {
user = { isAnonymous: true };
}
this.owner.register('service:current-user', currentUserService);

this.set('campaign', {
isSimplifiedAccess: 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('common.actions.login') })).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();
});
this.set('campaignParticipationResult', { masteryRate: 0.75 });
});

// when
const screen = await render(
hbs`<Campaigns::Assessment::Results::EvaluationResultsHero
module('when user is connected', function () {
test('it should display only a connection link', async function (assert) {
// given
class currentUserService extends Service {
user = {
firstName: 'Hermione',
};
}
this.owner.register('service:currentUser', currentUserService);

this.set('campaign', {
isSimplifiedAccess: 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();
// 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();
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();
});
});
});

Expand Down

0 comments on commit 2439879

Please sign in to comment.