From faa10a423b4d5e779dd718cfda4896a31c2689f9 Mon Sep 17 00:00:00 2001 From: Emmanuelle Bonnemay Date: Thu, 5 Dec 2024 17:38:34 +0100 Subject: [PATCH] feat(admin): add new route, model and and link for CGU --- admin/app/router.js | 1 + admin/app/routes/authenticated/users/get/cgu.js | 15 +++++++++++++++ admin/app/templates/authenticated/users/get.hbs | 9 +++++++++ .../acceptance/authenticated/users/get-test.js | 6 +++++- 4 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 admin/app/routes/authenticated/users/get/cgu.js diff --git a/admin/app/router.js b/admin/app/router.js index 5ee9137d2c8..d14542a48b0 100644 --- a/admin/app/router.js +++ b/admin/app/router.js @@ -55,6 +55,7 @@ Router.map(function () { this.route('campaign-participations', { path: '/participations' }); this.route('organizations'); this.route('certification-center-memberships'); + this.route('cgu'); }); }); diff --git a/admin/app/routes/authenticated/users/get/cgu.js b/admin/app/routes/authenticated/users/get/cgu.js new file mode 100644 index 00000000000..d31aa15ebdb --- /dev/null +++ b/admin/app/routes/authenticated/users/get/cgu.js @@ -0,0 +1,15 @@ +import Route from '@ember/routing/route'; + +export default class UserCguRoute extends Route { + async model() { + const user = this.modelFor('authenticated.users.get'); + return { + cgu: user.cgu, + pixOrgaTermsOfServiceAccepted: user.pixOrgaTermsOfServiceAccepted, + pixCertifTermsOfServiceAccepted: user.pixCertifTermsOfServiceAccepted, + lastTermsOfServiceValidatedAt: user.lastTermsOfServiceValidatedAt, + lastPixOrgaTermsOfServiceValidatedAt: user.lastPixOrgaTermsOfServiceValidatedAt, + lastPixCertifTermsOfServiceValidatedAt: user.lastPixCertifTermsOfServiceValidatedAt, + }; + } +} diff --git a/admin/app/templates/authenticated/users/get.hbs b/admin/app/templates/authenticated/users/get.hbs index dba78e3abe7..e90b74bf0d4 100644 --- a/admin/app/templates/authenticated/users/get.hbs +++ b/admin/app/templates/authenticated/users/get.hbs @@ -49,6 +49,15 @@ {{t "pages.user-details.navbar.certification-centers-list"}} ({{@model.certificationCenterMembershipsCount}}) + + + {{t "pages.user-details.navbar.cgu"}} + {{outlet}} diff --git a/admin/tests/acceptance/authenticated/users/get-test.js b/admin/tests/acceptance/authenticated/users/get-test.js index 9fc61b6e4a4..53fa0896040 100644 --- a/admin/tests/acceptance/authenticated/users/get-test.js +++ b/admin/tests/acceptance/authenticated/users/get-test.js @@ -5,9 +5,12 @@ import { setupApplicationTest } from 'ember-qunit'; import { createAuthenticateSession } from 'pix-admin/tests/helpers/test-init'; import { module, test } from 'qunit'; +import setupIntl from '../../../helpers/setup-intl'; + module('Acceptance | authenticated/users/get', function (hooks) { setupApplicationTest(hooks); setupMirage(hooks); + setupIntl(hooks); test('access to user details page by URL /users/:id', async function (assert) { // when @@ -20,6 +23,7 @@ module('Acceptance | authenticated/users/get', function (hooks) { test('displays user detail information page', async function (assert) { // given + this.intl = this.owner.lookup('service:intl'); const user = await _buildAndAuthenticateUser(this.server, { email: 'john.harry@example.net', username: null }); const expectedOrganizationMembershipsCount = 2; const expectedParticipationCount = 1; @@ -27,7 +31,6 @@ module('Acceptance | authenticated/users/get', function (hooks) { // when const screen = await visit(`/users/${user.id}`); - // then assert.dom(screen.getByRole('heading', { name: "Informations de l'utilisateur" })).exists(); assert.dom(screen.getByRole('heading', { name: 'Informations prescrit' })).exists(); @@ -43,6 +46,7 @@ module('Acceptance | authenticated/users/get', function (hooks) { assert .dom(userNavigation.getByLabelText('Organisations de l’utilisateur')) .hasText(`Pix Orga (${expectedOrganizationMembershipsCount})`); + assert.dom(userNavigation.getByRole('link', { name: this.intl.t('pages.user-details.navbar.cgu-aria-label') })).exists(); }); test('redirects to list users page when click page title', async function (assert) {