Skip to content

Commit

Permalink
[FEATURE] Affiche les participations anonymisées (Pix-15517)
Browse files Browse the repository at this point in the history
  • Loading branch information
pix-service-auto-merge authored Dec 12, 2024
2 parents a5c72de + 78aa892 commit 79e7b29
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 5 deletions.
8 changes: 6 additions & 2 deletions admin/app/components/campaigns/participation-row.gjs
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,13 @@ export default class ParticipationRow extends Component {
<template>
<td>{{@participation.firstName}} {{@participation.lastName}}</td>
<td>
<LinkTo @route="authenticated.users.get" @model={{@participation.userId}}>
{{#if @participation.userId}}
<LinkTo @route="authenticated.users.get" @model={{@participation.userId}}>
{{@participation.userFullName}}
</LinkTo>
{{else}}
{{@participation.userFullName}}
</LinkTo>
{{/if}}
</td>
{{#if @idPixLabel}}
<td class="table__column table__column--break-word">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ module('Integration | Component | Campaigns | participation-row', function (hook
const participation = EmberObject.create({
firstName: 'Jean',
lastName: 'Claude',
userId: 123,
userFullName: 'Jean-Claude Gangan',
createdAt: new Date('2020-01-01'),
});
Expand All @@ -36,6 +37,22 @@ module('Integration | Component | Campaigns | participation-row', function (hook
assert.dom(screen.getByRole('link', { name: 'Jean-Claude Gangan' })).exists();
assert.dom(screen.getByText('01/01/2020')).exists();
});
test('it should display name without link when there is no userId', async function (assert) {
// given
const participation = EmberObject.create({
firstName: '',
lastName: '',
userFullName: '(Anonymised)',
createdAt: new Date('2020-01-01'),
});

// when
const screen = await render(<template><ParticipationRow @participation={{participation}} /></template>);

// then
assert.ok(screen.getByText('(Anonymised)'));
assert.notOk(screen.queryByRole('link', { name: '(Anonymised)' }));
});

test('it should not display participantExternalId if idPixLabel is null', async function (assert) {
// given
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ class ParticipationForCampaignManagement {
this.lastName = lastName;
this.firstName = firstName;
this.userId = userId;
this.userFullName = userFirstName + ' ' + userLastName;
if (userFirstName && userLastName) {
this.userFullName = `${userFirstName} ${userLastName}`;
} else {
this.userFullName = '(Anonymised)';
}
this.participantExternalId = participantExternalId;
this.status = status;
this.createdAt = createdAt;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ const findPaginatedParticipationsForCampaignManagement = async function ({ campa
deletedByFirstName: 'deletedByUsers.firstName',
deletedByLastName: 'deletedByUsers.lastName',
})
.join(
.leftJoin(
'view-active-organization-learners',
'view-active-organization-learners.id',
'campaign-participations.organizationLearnerId',
)
.leftJoin('users as deletedByUsers', 'deletedByUsers.id', 'campaign-participations.deletedBy')
.innerJoin('users', 'users.id', 'campaign-participations.userId')
.leftJoin('users', 'users.id', 'campaign-participations.userId')
.where('campaignId', campaignId)
.orderBy(['lastName', 'firstName'], ['asc', 'asc']);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,5 +268,43 @@ describe('Integration | Repository | Participations-For-Campaign-Management', fu
expect(pagination).to.include(expectedPagination);
});
});

context('whern participations have been anonymised', function () {
it('should return participation with no userId', async function () {
// given
const user = databaseBuilder.factory.buildUser();
const organizationLearner = databaseBuilder.factory.prescription.organizationLearners.buildOrganizationLearner({
userId: user.id,
deletedAt: new Date('2024-12-24'),
updatedAt: new Date('2024-12-24'),
firstName: '',
lastName: '',
});
const campaignParticipation = databaseBuilder.factory.buildCampaignParticipation({
campaignId,
organizationLearnerId: organizationLearner.id,
userId: null,
participantExternalId: null,
deletedAt: new Date('2024-12-24'),
});
const otherCampaignId = databaseBuilder.factory.buildCampaign().id;
databaseBuilder.factory.buildCampaignParticipation({
campaignId: otherCampaignId,
organizationLearnerId: organizationLearner.id,
});
await databaseBuilder.commit();

// when
const { models: participationsForCampaignManagement } =
await participationsForCampaignManagementRepository.findPaginatedParticipationsForCampaignManagement({
campaignId,
page,
});

// then
expect(participationsForCampaignManagement).to.have.lengthOf(1);
expect(participationsForCampaignManagement[0].id).to.equal(campaignParticipation.id);
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@ describe('Unit | Domain | Models | ParticipationForCampaignManagement', function
// then
expect(participationForCampaignManagement.userFullName).to.equal('Jacques Ouche');
});
it('is empty if no userFirstName or userLastname', function () {
// when
const participationForCampaignManagement = new ParticipationForCampaignManagement({
userFirstName: '',
userLastName: '',
});

// then
expect(participationForCampaignManagement.userFullName).to.equal('(Anonymised)');
});
});

context('#deletedByFullName', function () {
Expand Down

0 comments on commit 79e7b29

Please sign in to comment.