Skip to content

Commit

Permalink
feat(orga): add evolution column and icon to collection profile results
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasBazin committed Nov 5, 2024
1 parent 1480258 commit dee9a46
Show file tree
Hide file tree
Showing 3 changed files with 163 additions and 1 deletion.
15 changes: 15 additions & 0 deletions orga/app/components/campaign/results/profile-list.gjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { gt } from 'ember-truth-helpers';
import TableHeader from '../../table/header';
import TablePaginationControl from '../../table/pagination-control';
import CampaignParticipationFilters from '../filter/participation-filters';
import EvolutionHeader from './evolution-header';
import ParticipationEvolutionIcon from './participation-evolution-icon';

<template>
<section ...attributes>
Expand All @@ -28,6 +30,7 @@ import CampaignParticipationFilters from '../filter/participation-filters';

<div class="panel">
<table class="table content-text content-text--small">
<caption class="screen-reader-only">{{t "pages.profiles-list.table.caption"}}</caption>
<colgroup class="table__column">
<col />
<col />
Expand All @@ -36,6 +39,9 @@ import CampaignParticipationFilters from '../filter/participation-filters';
{{/if}}
<col />
<col />
{{#if @campaign.multipleSendings}}
<col />
{{/if}}
<col class="hide-on-mobile" />
<col class="hide-on-mobile" />
</colgroup>
Expand All @@ -48,6 +54,14 @@ import CampaignParticipationFilters from '../filter/participation-filters';
{{/if}}
<TableHeader @align="center">{{t "pages.profiles-list.table.column.sending-date.label"}}</TableHeader>
<TableHeader @align="center">{{t "pages.profiles-list.table.column.pix-score.label"}}</TableHeader>
{{#if @campaign.multipleSendings}}
<TableHeader @align="center">
<EvolutionHeader
class="table__column--center"
@tooltipContent={{t "pages.profiles-list.table.evolution-tooltip.content"}}
/></TableHeader>

{{/if}}
<TableHeader @align="center" class="hide-on-mobile">{{t
"pages.profiles-list.table.column.certifiable"
}}</TableHeader>
Expand Down Expand Up @@ -93,6 +107,7 @@ import CampaignParticipationFilters from '../filter/participation-filters';
</PixTag>
{{/if}}
</td>
<td class="table__column--center"> <ParticipationEvolutionIcon @evolution={{profile.evolution}} /></td>
<td class="table__column--center hide-on-mobile">
{{#if profile.certifiable}}
<PixTag @color="green-light">{{t "pages.profiles-list.table.column.certifiable"}}</PixTag>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export default class CampaignProfilesCollectionParticipationSummary extends Mode
@attr('string') participantExternalId;
@attr('date') sharedAt;
@attr('number') pixScore;
@attr('nullable-string') evolution;
@attr('boolean') certifiable;
@attr('number') certifiableCompetencesCount;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { render } from '@1024pix/ember-testing-library';
import { render, within } from '@1024pix/ember-testing-library';
import { hbs } from 'ember-cli-htmlbars';
import { t } from 'ember-intl/test-support';
import { module, test } from 'qunit';
import sinon from 'sinon';

Expand All @@ -17,6 +18,92 @@ module('Integration | Component | Campaign::Results::ProfileList', function (hoo
this.set('groups', []);
});

module('table informations', function () {
test('it should display table caption', async function (assert) {
// given
this.campaign = store.createRecord('campaign', {
id: '1',
name: 'campagne 1',
participationsCount: 1,
});
this.profiles = [];
this.profiles.meta = { rowCount: 0 };

// 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.ok(screen.getByRole('table', { name: t('pages.profiles-list.table.caption') }));
});
});
module('table headers for multiple sendings campaign', function () {
test('it should display evolution header and tooltip when campaign is multiple sendings', async function (assert) {
// given
this.campaign = store.createRecord('campaign', {
id: '1',
name: 'campagne 1',
participationsCount: 1,
multipleSendings: true,
});
this.profiles = [];
this.profiles.meta = { rowCount: 0 };

// 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
const evolutionHeader = screen.getByRole('columnheader', {
name: t('pages.profiles-list.table.column.evolution'),
});
assert.ok(within(evolutionHeader).getByText(t('pages.profiles-list.table.evolution-tooltip.content')));
});

test('it should not display evolution header 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 = [];
this.profiles.meta = { rowCount: 0 };

// 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('columnheader', { name: t('pages.profiles-list.table.column.evolution') }));
});
});

module('when there are profiles', function () {
test('it should display the profile list', async function (assert) {
// given
Expand Down Expand Up @@ -63,6 +150,65 @@ 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) {
// given
this.campaign = store.createRecord('campaign', {
id: '1',
name: 'campagne 1',
participationsCount: 4,
multipleSendings: true,
});
this.profiles = [
{
firstName: 'John',
lastName: 'Doe',
participantExternalId: '123',
evolution: 'decrease',
sharedAt: new Date(2020, 1, 1),
},
{
firstName: 'Donald',
lastName: 'Goose',
participantExternalId: '321',
evolution: 'increase',
sharedAt: new Date(2020, 1, 1),
},
{
firstName: 'James',
lastName: 'Green',
participantExternalId: '456',
evolution: 'stable',
sharedAt: new Date(2020, 1, 1),
},
{
firstName: 'Alice',
lastName: 'Red',
participantExternalId: '789',
evolution: null,
sharedAt: new Date(2020, 1, 1),
},
];
this.profiles.meta = { rowCount: 4 };

// 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.ok(screen.getByRole('cell', { name: t('pages.profiles-list.table.evolution.increase') }));
assert.ok(screen.getByRole('cell', { name: t('pages.profiles-list.table.evolution.decrease') }));
assert.ok(screen.getByRole('cell', { name: t('pages.profiles-list.table.evolution.stable') }));
assert.ok(screen.getByRole('cell', { name: t('pages.profiles-list.table.evolution.unavailable') }));
});

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 dee9a46

Please sign in to comment.