Skip to content

Commit

Permalink
[TECH] Correction de l'affichage des heures des invitations (PIX-10414).
Browse files Browse the repository at this point in the history
  • Loading branch information
pix-service-auto-merge authored Jan 5, 2024
2 parents a75fdba + 83db175 commit 8c7228b
Show file tree
Hide file tree
Showing 10 changed files with 68 additions and 17 deletions.
2 changes: 1 addition & 1 deletion admin/app/components/certification-centers/invitations.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<tr aria-label="Invitation en attente de {{invitation.email}}">
<td>{{invitation.email}}</td>
<td>{{invitation.roleLabel}}</td>
<td>{{dayjs-format invitation.updatedAt "DD/MM/YYYY [-] HH:mm" locale="fr"}}</td>
<td>{{dayjs-format invitation.updatedAt "DD/MM/YYYY [-] HH:mm"}}</td>
<td>
<PixButton
@size="small"
Expand Down
2 changes: 1 addition & 1 deletion admin/app/components/organizations/invitations.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<tr aria-label="Invitation en attente de {{invitation.email}}">
<td>{{invitation.email}}</td>
<td>{{invitation.roleInFrench}}</td>
<td>{{dayjs-format invitation.updatedAt "DD/MM/YYYY [-] HH:mm" locale="fr"}}</td>
<td>{{dayjs-format invitation.updatedAt "DD/MM/YYYY [-] HH:mm"}}</td>
{{#if this.accessControl.hasAccessToOrganizationActionsScope}}
<td>
<PixButton
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<td>{{organizationMembership.organizationName}}</td>
<td>{{organizationMembership.organizationType}}</td>
<td>{{organizationMembership.organizationExternalId}}</td>
<td>{{dayjs-format organizationMembership.updatedAt "DD/MM/YYYY [-] HH:mm" locale="fr"}}</td>
<td>{{dayjs-format organizationMembership.updatedAt "DD/MM/YYYY [-] HH:mm"}}</td>
<ActionsOnUsersRoleInOrganization @organizationMembership={{organizationMembership}} />
</tr>
{{/each}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import { setupApplicationTest } from 'ember-qunit';
import { setupMirage } from 'ember-cli-mirage/test-support';
import { visit } from '@1024pix/ember-testing-library';
import { authenticateAdminMemberWithRole } from 'pix-admin/tests/helpers/test-init';
import setupIntl from '../../../helpers/setup-intl';

module('Acceptance | Organizations | Invitations management', function (hooks) {
setupApplicationTest(hooks);
setupIntl(hooks);
setupMirage(hooks);

test('should allow to invite a member when user has access', async function (assert) {
Expand Down Expand Up @@ -65,7 +67,10 @@ module('Acceptance | Organizations | Invitations management', function (hooks) {
module('and an error occurs', function () {
test('it should display an error notification and the invitation should remain in the list', async function (assert) {
// given
const dayjsService = this.owner.lookup('service:dayjs');
await authenticateAdminMemberWithRole({ isSuperAdmin: true })(server);
const updatedAt = new Date('2023-12-05T09:00:00Z');

const organization = this.server.create('organization', {
id: 5,
name: 'Kabuki',
Expand All @@ -74,6 +79,7 @@ module('Acceptance | Organizations | Invitations management', function (hooks) {
id: 10,
email: '[email protected]',
lang: 'fr',
updatedAt,
organization,
});
this.server.delete(
Expand All @@ -87,8 +93,12 @@ module('Acceptance | Organizations | Invitations management', function (hooks) {
await click(screen.getByRole('button', { name: 'Annuler l’invitation de [email protected]' }));

// then
const formattedDate = dayjsService.self(updatedAt).format('DD/MM/YYYY [-] HH:mm');

assert.dom(screen.getByText('Une erreur s’est produite, veuillez réessayer.')).exists();
assert.dom(screen.getByRole('row', { name: 'Invitation en attente de [email protected]' })).exists();
assert.dom(screen.getByRole('cell', { name: '[email protected]' })).exists();
assert.dom(screen.getByRole('cell', { name: formattedDate })).exists();
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,17 @@ module('Integration | Component | Certification Centers | Invitations', function
test('should show invitations list', async function (assert) {
// given
const store = this.owner.lookup('service:store');
const dayjsService = this.owner.lookup('service:dayjs');

const invitationUpdatedAt1 = new Date('2020-02-02T09:00:00Z');
const invitationUpdatedAt2 = new Date('2022-02-02T15:12:00Z');
const certificationCenterInvitation1 = store.createRecord('certification-center-invitation', {
email: '[email protected]',
updatedAt: new Date('2020-02-02'),
updatedAt: invitationUpdatedAt1,
});
const certificationCenterInvitation2 = store.createRecord('certification-center-invitation', {
email: '[email protected]',
updatedAt: new Date('2022-02-02'),
updatedAt: invitationUpdatedAt2,
});
this.certificationCenterInvitations = [certificationCenterInvitation1, certificationCenterInvitation2];
this.cancelCertificationCenterInvitation = sinon.stub();
Expand All @@ -46,11 +50,16 @@ module('Integration | Component | Certification Centers | Invitations', function
);

// then
const formattedInvitationUpdatedAt1 = dayjsService.self(invitationUpdatedAt1).format('DD/MM/YYYY [-] HH:mm');
const formattedInvitationUpdatedAt2 = dayjsService.self(invitationUpdatedAt2).format('DD/MM/YYYY [-] HH:mm');

assert.dom(screen.getByRole('heading', { name: 'Invitations' })).exists();
assert.dom(screen.getByRole('columnheader', { name: 'Adresse e-mail' })).exists();
assert.dom(screen.getByRole('columnheader', { name: 'Date de dernier envoi' })).exists();
assert.dom(screen.getByRole('cell', { name: '[email protected]' })).exists();
assert.dom(screen.getByRole('cell', { name: formattedInvitationUpdatedAt1 })).exists();
assert.dom(screen.getByRole('cell', { name: '[email protected]' })).exists();
assert.dom(screen.getByRole('cell', { name: formattedInvitationUpdatedAt2 })).exists();
});
});
});
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render } from '@1024pix/ember-testing-library';
import { render, within } from '@1024pix/ember-testing-library';
import { hbs } from 'ember-cli-htmlbars';
import EmberObject from '@ember/object';
import Service from '@ember/service';
Expand Down Expand Up @@ -36,20 +36,27 @@ module('Integration | Component | users | organization-memberships', function (h
hasAccessToOrganizationActionsScope = false;
}
this.owner.register('service:accessControl', SessionStub);
const dayjsService = this.owner.lookup('service:dayjs');

const membershipUpdatedAt1 = new Date('2023-12-05T08:00:00Z');
const membershipUpdatedAt2 = new Date('2023-12-05T09:00:00Z');
const organizationMembership1 = EmberObject.create({
id: 111,
role: 'MEMBER',
organizationId: 100025,
organizationName: 'Dragon & Co',
organizationType: 'PRO',
updatedAt: membershipUpdatedAt1,
});

const organizationMembership2 = EmberObject.create({
id: 222,
role: 'MEMBER',
organizationId: 100095,
organizationName: 'Collège The Night Watch',
organizationType: 'SCO',
organizationExternalId: '1237457A',
updatedAt: membershipUpdatedAt2,
});

const organizationMemberships = [organizationMembership1, organizationMembership2];
Expand All @@ -61,8 +68,24 @@ module('Integration | Component | users | organization-memberships', function (h
);

// then
assert.dom(screen.getByText('Collège The Night Watch')).exists();
assert.dom(screen.getByText('Dragon & Co')).exists();
const formattedUpdatedAt1 = dayjsService.self(membershipUpdatedAt1).format('DD/MM/YYYY [-] HH:mm');
const formattedUpdatedAt2 = dayjsService.self(membershipUpdatedAt2).format('DD/MM/YYYY [-] HH:mm');

const rows = await screen.findAllByRole('row');
assert.dom(within(rows[1]).getByRole('cell', { name: '222' })).exists();
assert.dom(within(rows[1]).getByRole('cell', { name: '100095' })).exists();
assert.dom(within(rows[1]).getByRole('cell', { name: 'Collège The Night Watch' })).exists();
assert.dom(within(rows[1]).getByRole('cell', { name: 'SCO' })).exists();
assert.dom(within(rows[1]).getByRole('cell', { name: '1237457A' })).exists();
assert.dom(within(rows[1]).getByRole('cell', { name: formattedUpdatedAt2 })).exists();

assert.dom(within(rows[2]).getByRole('cell', { name: '111' })).exists();

assert.dom(within(rows[2]).getByRole('cell', { name: '111' })).exists();
assert.dom(within(rows[2]).getByRole('cell', { name: '100025' })).exists();
assert.dom(within(rows[2]).getByRole('cell', { name: 'Dragon & Co' })).exists();
assert.dom(within(rows[2]).getByRole('cell', { name: 'PRO' })).exists();
assert.dom(within(rows[2]).getByRole('cell', { name: formattedUpdatedAt1 })).exists();
});
});
});
2 changes: 1 addition & 1 deletion certif/app/components/team/invitations-list-item.hbs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<tr aria-label="{{t 'pages.team-invitations.table.row.aria-label'}}">
<td>{{@invitation.email}}</td>
<td>
{{dayjs-format @invitation.updatedAt "DD/MM/YYYY [-] HH:mm" locale="fr"}}
{{dayjs-format @invitation.updatedAt "DD/MM/YYYY [-] HH:mm"}}
</td>
<td>
<div class="invitations-list-item__actions">
Expand Down
12 changes: 9 additions & 3 deletions certif/tests/acceptance/team/list/invitations_test.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import { module, test } from 'qunit';
import { currentURL } from '@ember/test-helpers';
import { setupApplicationTest } from 'ember-qunit';
import { clickByName, visit } from '@1024pix/ember-testing-library';

import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
import {
authenticateSession,
createCertificationPointOfContactWithTermsOfServiceAccepted,
} from '../../../helpers/test-init';
import setupIntl from '../../../helpers/setup-intl';
import { clickByName, visit } from '@1024pix/ember-testing-library';

module('Acceptance | Team | Invitations', function (hooks) {
setupApplicationTest(hooks);
Expand Down Expand Up @@ -112,10 +111,13 @@ module('Acceptance | Team | Invitations', function (hooks) {
module('when user clicks on resend invitation button', function () {
test('resends the invitation and displays a success notification', async function (assert) {
// given
const dayjsService = this.owner.lookup('service:dayjs');
const previousUpdatedAt = new Date('2023-12-05T09:00:00Z');

this.server.create('certification-center-invitation', {
certificationCenterId: 1,
email: '[email protected]',
updatedAt: new Date('2023-12-05T11:30:00Z'),
updatedAt: previousUpdatedAt,
});

const screen = await visit('/equipe/invitations');
Expand All @@ -124,6 +126,10 @@ module('Acceptance | Team | Invitations', function (hooks) {
await clickByName(this.intl.t('pages.team-invitations.actions.resend-invitation'));

// then
const formattedDate = dayjsService.self(new Date('2023-12-05T11:35:00Z')).format('DD/MM/YYYY [-] HH:mm');

assert.dom(screen.getByRole('cell', { name: '[email protected]' })).exists();
assert.dom(screen.getByRole('cell', { name: formattedDate })).exists();
assert.dom(screen.getByText("L'invitation a bien été renvoyée.")).exists();
});

Expand Down
2 changes: 1 addition & 1 deletion orga/app/components/team/invitations-list-item.hbs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<tr aria-label="{{t 'pages.team-invitations.table.row.aria-label'}}">
<td>{{@invitation.email}}</td>
<td class="hide-on-mobile">
{{dayjs-format @invitation.updatedAt "DD/MM/YYYY [-] HH:mm" locale="fr"}}
{{dayjs-format @invitation.updatedAt "DD/MM/YYYY [-] HH:mm"}}
</td>
<td>
<div class="invitations-list__action">
Expand Down
11 changes: 7 additions & 4 deletions orga/tests/integration/components/team/invitations-list_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,19 @@ module('Integration | Component | Team::InvitationsList', function (hooks) {

test('it should display email and creation date of invitation', async function (assert) {
// given
const pendingInvitationDate = '2019-10-08T10:50:00Z';
const dayjsService = this.owner.lookup('service:dayjs');
const pendingInvitationDate = '2023-12-05T09:00:00Z';

this.set('invitations', [{ email: '[email protected]', isPending: true, updatedAt: pendingInvitationDate }]);

// when
await render(hbs`<Team::InvitationsList @invitations={{this.invitations}} />`);
const component = await render(hbs`<Team::InvitationsList @invitations={{this.invitations}} />`);

// then
assert.contains('[email protected]');
assert.contains(this.dayjs.self(pendingInvitationDate).format('DD/MM/YYYY - HH:mm'));
const formattedPendingInvitationDate = dayjsService.self(pendingInvitationDate).format('DD/MM/YYYY [-] HH:mm');

assert.dom(component.getByRole('cell', { name: '[email protected]' })).exists();
assert.dom(component.getByRole('cell', { name: formattedPendingInvitationDate })).exists();
});

test('it should show success notification when cancelling an invitation succeeds', async function (assert) {
Expand Down

0 comments on commit 8c7228b

Please sign in to comment.