Skip to content

Commit

Permalink
fix(orga): add condition in order not to display evolution, and count…
Browse files Browse the repository at this point in the history
… colums if campaign is not multiple sendings
  • Loading branch information
ThomasBazin authored Nov 20, 2024
1 parent f3b2b40 commit 37890b2
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 8 deletions.
18 changes: 12 additions & 6 deletions orga/app/components/campaign/results/profile-list.gjs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ import ParticipationEvolutionIcon from './participation-evolution-icon';
{{/if}}
<col class="hide-on-mobile" />
<col class="hide-on-mobile" />
<col />
{{#if @campaign.multipleSendings}}
<col />
{{/if}}
</colgroup>
<thead>
<tr>
Expand Down Expand Up @@ -113,8 +115,10 @@ import ParticipationEvolutionIcon from './participation-evolution-icon';
</PixTag>
{{/if}}
</td>
<td class="table__column--center">
<ParticipationEvolutionIcon @evolution={{profile.evolution}} /></td>
{{#if @campaign.multipleSendings}}
<td class="table__column--center">
<ParticipationEvolutionIcon @evolution={{profile.evolution}} /></td>
{{/if}}
<td class="table__column--center hide-on-mobile">
{{#if profile.certifiable}}
<PixTag @color="green-light">{{t "pages.profiles-list.table.column.certifiable"}}</PixTag>
Expand All @@ -123,9 +127,11 @@ import ParticipationEvolutionIcon from './participation-evolution-icon';
<td class="table__column--center hide-on-mobile">
{{profile.certifiableCompetencesCount}}
</td>
<td class="table__column--center">
{{profile.sharedProfileCount}}
</td>
{{#if @campaign.multipleSendings}}
<td class="table__column--center">
{{profile.sharedProfileCount}}
</td>
{{/if}}
</tr>
{{/each}}
</tbody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,42 @@ module('Integration | Component | Campaign::Results::ProfileList', function (hoo
assert.ok(screen.getByRole('cell', { name: '01/02/2020' }));
});

test('it should display correct evolution', async function (assert) {
test('it should not display evolution if campaign is not multiple sendings', async function (assert) {
// given
this.campaign = store.createRecord('campaign', {
id: '1',
name: 'campagne 1',
participationsCount: 1,
multipleSendings: false,
});
this.profiles = [
{
firstName: 'Alice',
lastName: 'Red',
participantExternalId: '789',
evolution: null,
sharedAt: new Date(2020, 1, 1),
},
];
this.profiles.meta = { rowCount: 1 };

// when
const screen = await render(
hbs`<Campaign::Results::ProfileList
@campaign={{this.campaign}}
@profiles={{this.profiles}}
@onClickParticipant={{this.noop}}
@onFilter={{this.noop}}
@selectedDivisions={{this.divisions}}
@selectedGroups={{this.groups}}
/>`,
);

// then
assert.notOk(screen.queryByRole('cell', { name: t('pages.profiles-list.table.evolution.unavailable') }));
});

test('it should display correct evolution if campaign is multiple sendings', async function (assert) {
// given
this.campaign = store.createRecord('campaign', {
id: '1',
Expand Down Expand Up @@ -215,7 +250,7 @@ module('Integration | Component | Campaign::Results::ProfileList', function (hoo
assert.ok(screen.getByRole('cell', { name: t('pages.profiles-list.table.evolution.unavailable') }));
});

test('it should display number of profiles shares', async function (assert) {
test('it should display number of profiles shares if campaign is multiple sendings', async function (assert) {
// given
this.campaign = store.createRecord('campaign', {
id: '1',
Expand Down Expand Up @@ -251,6 +286,42 @@ module('Integration | Component | Campaign::Results::ProfileList', function (hoo
assert.ok(screen.getByRole('cell', { name: '3' }));
});

test('it should not display number of profiles shares if campaign is not multiple sendings', async function (assert) {
// given
this.campaign = store.createRecord('campaign', {
id: '1',
name: 'campagne 1',
participationsCount: 1,
multipleSendings: false,
});
this.profiles = [
{
firstName: 'John',
lastName: 'Doe',
participantExternalId: '123',
sharedProfileCount: 1,
evolution: 'decrease',
sharedAt: new Date(2020, 1, 1),
},
];
this.profiles.meta = { rowCount: 1 };

// when
const screen = await render(
hbs`<Campaign::Results::ProfileList
@campaign={{this.campaign}}
@profiles={{this.profiles}}
@onClickParticipant={{this.noop}}
@onFilter={{this.noop}}
@selectedDivisions={{this.divisions}}
@selectedGroups={{this.groups}}
/>`,
);

// then
assert.notOk(screen.queryByRole('cell', { name: '1' }));
});

test('it should display the profile list with external id', async function (assert) {
// given
this.campaign = store.createRecord('campaign', {
Expand Down

0 comments on commit 37890b2

Please sign in to comment.