From 37890b23ad258982afa303bf0b3909a735d4c5cc Mon Sep 17 00:00:00 2001 From: ThomasBazin Date: Mon, 18 Nov 2024 18:53:45 +0100 Subject: [PATCH 1/2] fix(orga): add condition in order not to display evolution, and count colums if campaign is not multiple sendings --- .../campaign/results/profile-list.gjs | 18 +++-- .../campaign/results/profile-list-test.js | 75 ++++++++++++++++++- 2 files changed, 85 insertions(+), 8 deletions(-) diff --git a/orga/app/components/campaign/results/profile-list.gjs b/orga/app/components/campaign/results/profile-list.gjs index 1c90e4902d0..e911b6a58e6 100644 --- a/orga/app/components/campaign/results/profile-list.gjs +++ b/orga/app/components/campaign/results/profile-list.gjs @@ -44,7 +44,9 @@ import ParticipationEvolutionIcon from './participation-evolution-icon'; {{/if}} - + {{#if @campaign.multipleSendings}} + + {{/if}} @@ -113,8 +115,10 @@ import ParticipationEvolutionIcon from './participation-evolution-icon'; {{/if}} - - + {{#if @campaign.multipleSendings}} + + + {{/if}} {{#if profile.certifiable}} {{t "pages.profiles-list.table.column.certifiable"}} @@ -123,9 +127,11 @@ import ParticipationEvolutionIcon from './participation-evolution-icon'; {{profile.certifiableCompetencesCount}} - - {{profile.sharedProfileCount}} - + {{#if @campaign.multipleSendings}} + + {{profile.sharedProfileCount}} + + {{/if}} {{/each}} diff --git a/orga/tests/integration/components/campaign/results/profile-list-test.js b/orga/tests/integration/components/campaign/results/profile-list-test.js index f21bb7364c9..48e6193eabd 100644 --- a/orga/tests/integration/components/campaign/results/profile-list-test.js +++ b/orga/tests/integration/components/campaign/results/profile-list-test.js @@ -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``, + ); + + // 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', @@ -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', @@ -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``, + ); + + // 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', { From 0caf11a8e951b97756fa69bcf945bb04716eac93 Mon Sep 17 00:00:00 2001 From: ThomasBazin Date: Wed, 20 Nov 2024 12:24:24 +0100 Subject: [PATCH 2/2] chore?(api): refacto profile-list test to be more specific on evolution in rows --- .../campaign/results/profile-list-test.js | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/orga/tests/integration/components/campaign/results/profile-list-test.js b/orga/tests/integration/components/campaign/results/profile-list-test.js index 48e6193eabd..b800094b288 100644 --- a/orga/tests/integration/components/campaign/results/profile-list-test.js +++ b/orga/tests/integration/components/campaign/results/profile-list-test.js @@ -45,8 +45,9 @@ module('Integration | Component | Campaign::Results::ProfileList', function (hoo 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 and shared profile count when campaign is multiple sendings', async function (assert) { + + module('table headers', function () { + test('it should display evolution header with tooltip and shared profile count when campaign is multiple sendings', async function (assert) { // given this.campaign = store.createRecord('campaign', { id: '1', @@ -243,11 +244,13 @@ module('Integration | Component | Campaign::Results::ProfileList', function (hoo />`, ); + const rows = screen.getAllByRole('row'); + // 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') })); + assert.ok(within(rows[1]).getByRole('cell', { name: t('pages.profiles-list.table.evolution.decrease') })); + assert.ok(within(rows[2]).getByRole('cell', { name: t('pages.profiles-list.table.evolution.increase') })); + assert.ok(within(rows[3]).getByRole('cell', { name: t('pages.profiles-list.table.evolution.stable') })); + assert.ok(within(rows[4]).getByRole('cell', { name: t('pages.profiles-list.table.evolution.unavailable') })); }); test('it should display number of profiles shares if campaign is multiple sendings', async function (assert) { @@ -263,7 +266,7 @@ module('Integration | Component | Campaign::Results::ProfileList', function (hoo firstName: 'John', lastName: 'Doe', participantExternalId: '123', - sharedProfileCount: 3, + sharedProfileCount: 'My profileCount', evolution: 'decrease', sharedAt: new Date(2020, 1, 1), }, @@ -283,7 +286,7 @@ module('Integration | Component | Campaign::Results::ProfileList', function (hoo ); // then - assert.ok(screen.getByRole('cell', { name: '3' })); + assert.ok(screen.getByRole('cell', { name: 'My profileCount' })); }); test('it should not display number of profiles shares if campaign is not multiple sendings', async function (assert) { @@ -299,8 +302,7 @@ module('Integration | Component | Campaign::Results::ProfileList', function (hoo firstName: 'John', lastName: 'Doe', participantExternalId: '123', - sharedProfileCount: 1, - evolution: 'decrease', + sharedProfileCount: 'My profileCount', sharedAt: new Date(2020, 1, 1), }, ]; @@ -319,7 +321,7 @@ module('Integration | Component | Campaign::Results::ProfileList', function (hoo ); // then - assert.notOk(screen.queryByRole('cell', { name: '1' })); + assert.notOk(screen.queryByRole('cell', { name: 'My profileCount' })); }); test('it should display the profile list with external id', async function (assert) {