From 243987913f09e3301555590fae13d1f0483d2a59 Mon Sep 17 00:00:00 2001 From: Geoffroy Begouaussel Date: Tue, 19 Nov 2024 10:26:26 +0100 Subject: [PATCH] =?UTF-8?q?[FEATURE]=20Mise=20=C3=A0=20jour=20du=20CTA=20d?= =?UTF-8?q?e=20fin=20de=20parcours=20=C3=A0=20acc=C3=A8s=20simplifi=C3=A9?= =?UTF-8?q?=20(PIX-15070).=20(#10491)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../results/evaluation-results-hero/index.gjs | 2 +- mon-pix/app/routes/authentication/login.js | 5 +- .../hero/evaluation-results-hero-test.js | 70 +++++++++++++++---- 3 files changed, 60 insertions(+), 17 deletions(-) diff --git a/mon-pix/app/components/campaigns/assessment/results/evaluation-results-hero/index.gjs b/mon-pix/app/components/campaigns/assessment/results/evaluation-results-hero/index.gjs index 19035c0c0a1..95d080802d3 100644 --- a/mon-pix/app/components/campaigns/assessment/results/evaluation-results-hero/index.gjs +++ b/mon-pix/app/components/campaigns/assessment/results/evaluation-results-hero/index.gjs @@ -208,7 +208,7 @@ export default class EvaluationResultsHero extends Component { {{else}} {{#unless @campaign.hasCustomResultPageButton}} - {{t "navigation.back-to-homepage"}} + {{if this.currentUser.user.isAnonymous (t "common.actions.login") (t "navigation.back-to-homepage")}} {{/unless}} {{/if}} diff --git a/mon-pix/app/routes/authentication/login.js b/mon-pix/app/routes/authentication/login.js index 255035b59b5..aafd8bcf1a2 100644 --- a/mon-pix/app/routes/authentication/login.js +++ b/mon-pix/app/routes/authentication/login.js @@ -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'); + } } } diff --git a/mon-pix/tests/integration/components/campaigns/assessment/results/hero/evaluation-results-hero-test.js b/mon-pix/tests/integration/components/campaigns/assessment/results/hero/evaluation-results-hero-test.js index b6ae4bd7e17..a65970b7ef0 100644 --- a/mon-pix/tests/integration/components/campaigns/assessment/results/hero/evaluation-results-hero-test.js +++ b/mon-pix/tests/integration/components/campaigns/assessment/results/hero/evaluation-results-hero-test.js @@ -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``, + ); + + // 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``, - ); + ); - // 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(); + }); }); });