-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEATURE] Déplacer les CGU vers un onglet dédié
- Loading branch information
Showing
13 changed files
with
208 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { service } from '@ember/service'; | ||
import Component from '@glimmer/component'; | ||
import dayjs from 'dayjs'; | ||
import { t } from 'ember-intl'; | ||
|
||
export default class Cgu extends Component { | ||
@service accessControl; | ||
@service intl; | ||
|
||
get userHasValidatePixAppTermsOfService() { | ||
return this._formatValidatedTermsOfServiceText(this.args.lastTermsOfServiceValidatedAt, this.args.cgu); | ||
} | ||
|
||
get userHasValidatePixOrgaTermsOfService() { | ||
return this._formatValidatedTermsOfServiceText( | ||
this.args.lastPixOrgaTermsOfServiceValidatedAt, | ||
this.args.pixOrgaTermsOfServiceAccepted, | ||
); | ||
} | ||
|
||
get userHasValidatePixCertifTermsOfService() { | ||
return this._formatValidatedTermsOfServiceText( | ||
this.args.lastPixCertifTermsOfServiceValidatedAt, | ||
this.args.pixCertifTermsOfServiceAccepted, | ||
); | ||
} | ||
_formatValidatedTermsOfServiceText(date, hasValidatedTermsOfService) { | ||
if (!hasValidatedTermsOfService) { | ||
return this.intl.t('components.users.user-detail-personal-information.cgu.validation.status.non-validated'); | ||
} | ||
|
||
return date | ||
? this.intl.t('components.users.user-detail-personal-information.cgu.validation.status.validated-with-date', { | ||
formattedDate: dayjs(date).format('DD/MM/YYYY'), | ||
}) | ||
: this.intl.t('components.users.user-detail-personal-information.cgu.validation.status.validated'); | ||
} | ||
|
||
<template> | ||
<header class="page-section__header"> | ||
<h2 class="page-section__title">{{t "components.users.user-detail-personal-information.cgu.title"}}</h2> | ||
</header> | ||
|
||
<ul class="cgu__cgu-list"> | ||
<li class="cgu__cgu-information"> | ||
{{t "components.users.user-detail-personal-information.cgu.validation.domain.pix-app"}} | ||
{{this.userHasValidatePixAppTermsOfService}}</li> | ||
|
||
<li class="cgu__cgu-information"> | ||
{{t "components.users.user-detail-personal-information.cgu.validation.domain.pix-orga"}} | ||
{{this.userHasValidatePixOrgaTermsOfService}}</li> | ||
|
||
<li class="cgu__cgu-information"> | ||
{{t "components.users.user-detail-personal-information.cgu.validation.domain.pix-certif"}} | ||
{{this.userHasValidatePixCertifTermsOfService}}</li> | ||
</ul> | ||
</template> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.cgu { | ||
&__cgu-list { | ||
margin-top: var(--pix-spacing-6x); | ||
} | ||
|
||
&__cgu-information { | ||
margin-bottom: var(--pix-spacing-3x); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<section class="page-section"> | ||
<Users::Cgu | ||
@cgu={{@model.cgu}} | ||
@pixOrgaTermsOfServiceAccepted={{@model.pixOrgaTermsOfServiceAccepted}} | ||
@pixCertifTermsOfServiceAccepted={{@model.pixCertifTermsOfServiceAccepted}} | ||
@lastTermsOfServiceValidatedAt={{@model.lastTermsOfServiceValidatedAt}} | ||
@lastPixOrgaTermsOfServiceValidatedAt={{@model.lastPixOrgaTermsOfServiceValidatedAt}} | ||
@lastPixCertifTermsOfServiceValidatedAt={{@model.lastPixCertifTermsOfServiceValidatedAt}} | ||
/> | ||
</section> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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,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(); | ||
|
@@ -43,6 +46,9 @@ 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) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { render } from '@1024pix/ember-testing-library'; | ||
import { setupRenderingTest } from 'ember-qunit'; | ||
import Cgu from 'pix-admin/components/users/cgu'; | ||
import { module, test } from 'qunit'; | ||
|
||
import setupIntl from '../../../helpers/setup-intl'; | ||
|
||
module('Integration | Component | cgu', function (hooks) { | ||
setupRenderingTest(hooks); | ||
setupIntl(hooks); | ||
|
||
hooks.beforeEach(function () { | ||
this.intl = this.owner.lookup('service:intl'); | ||
}); | ||
|
||
test('displays correct Terms of Service status for Pix App, Pix Orga and Pix Certif', async function (assert) { | ||
//Given | ||
|
||
const cgu = true; | ||
const lastTermsOfServiceValidatedAt = new Date('2021-12-10'); | ||
const pixOrgaTermsOfServiceAccepted = true; | ||
const lastPixOrgaTermsOfServiceValidatedAt = null; | ||
const pixCertifTermsOfServiceAccepted = false; | ||
const lastPixCertifTermsOfServiceValidatedAt = null; | ||
|
||
const appDomain = this.intl.t('components.users.user-detail-personal-information.cgu.validation.domain.pix-app'); | ||
const validatedWithDate = this.intl.t( | ||
'components.users.user-detail-personal-information.cgu.validation.status.validated-with-date', | ||
{ formattedDate: '10/12/2021' }, | ||
); | ||
|
||
const orgaDomain = this.intl.t('components.users.user-detail-personal-information.cgu.validation.domain.pix-orga'); | ||
const validated = this.intl.t('components.users.user-detail-personal-information.cgu.validation.status.validated'); | ||
|
||
const certifDomain = this.intl.t( | ||
'components.users.user-detail-personal-information.cgu.validation.domain.pix-certif', | ||
); | ||
const nonValidated = this.intl.t( | ||
'components.users.user-detail-personal-information.cgu.validation.status.non-validated', | ||
); | ||
|
||
//When | ||
const screen = await render( | ||
<template> | ||
<Cgu | ||
@lastTermsOfServiceValidatedAt={{lastTermsOfServiceValidatedAt}} | ||
@cgu={{cgu}} | ||
@lastPixOrgaTermsOfServiceValidatedAt={{lastPixOrgaTermsOfServiceValidatedAt}} | ||
@pixOrgaTermsOfServiceAccepted={{pixOrgaTermsOfServiceAccepted}} | ||
@lastPixCertifTermsOfServiceValidatedAt={{lastPixCertifTermsOfServiceValidatedAt}} | ||
@pixCertifTermsOfServiceAccepted={{pixCertifTermsOfServiceAccepted}} | ||
/> | ||
</template>, | ||
); | ||
|
||
//Then | ||
assert.dom(screen.queryByText(`${appDomain} ${validatedWithDate}`)).exists(); | ||
assert.dom(screen.queryByText(`${orgaDomain} ${validated}`)).exists(); | ||
assert.dom(screen.queryByText(`${certifDomain} ${nonValidated}`)).exists(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.