Skip to content

Commit

Permalink
feat(admin): add new route, model and and link for CGU
Browse files Browse the repository at this point in the history
  • Loading branch information
EmmanuelleBonnemay committed Dec 5, 2024
1 parent ca76e7b commit faa10a4
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 1 deletion.
1 change: 1 addition & 0 deletions admin/app/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ Router.map(function () {
this.route('campaign-participations', { path: '/participations' });
this.route('organizations');
this.route('certification-center-memberships');
this.route('cgu');
});
});

Expand Down
15 changes: 15 additions & 0 deletions admin/app/routes/authenticated/users/get/cgu.js
Original file line number Diff line number Diff line change
@@ -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,
};
}
}
9 changes: 9 additions & 0 deletions admin/app/templates/authenticated/users/get.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@
{{t "pages.user-details.navbar.certification-centers-list"}}
({{@model.certificationCenterMembershipsCount}})
</LinkTo>

<LinkTo
@route="authenticated.users.get.cgu"
@model={{@model}}
aria-label="Conditions générales d'utilisation"
class="navbar-item"
>
{{t "pages.user-details.navbar.cgu"}}
</LinkTo>
</nav>

{{outlet}}
Expand Down
6 changes: 5 additions & 1 deletion admin/tests/acceptance/authenticated/users/get-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -20,14 +23,14 @@ 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: '[email protected]', username: null });
const expectedOrganizationMembershipsCount = 2;
const expectedParticipationCount = 1;
const expectedCertificationCenterCount = 3;

// 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();
Expand All @@ -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) {
Expand Down

0 comments on commit faa10a4

Please sign in to comment.