From da8d066c13d9bfb25f1c9a294bc25934b9c66ff9 Mon Sep 17 00:00:00 2001 From: Geoffroy Begouaussel Date: Wed, 30 Oct 2024 11:21:27 +0100 Subject: [PATCH 1/3] test(mon-pix): move evaluation-results tabs tests files --- .../{rewards/rewards-badge-test.js => tabs/badge-test.js} | 0 .../assessment/skill-review/{rewards => tabs}/rewards-test.js | 0 .../assessment/skill-review/{rewards => tabs}/trainings-test.js | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename mon-pix/tests/integration/components/campaigns/assessment/skill-review/{rewards/rewards-badge-test.js => tabs/badge-test.js} (100%) rename mon-pix/tests/integration/components/campaigns/assessment/skill-review/{rewards => tabs}/rewards-test.js (100%) rename mon-pix/tests/integration/components/campaigns/assessment/skill-review/{rewards => tabs}/trainings-test.js (100%) diff --git a/mon-pix/tests/integration/components/campaigns/assessment/skill-review/rewards/rewards-badge-test.js b/mon-pix/tests/integration/components/campaigns/assessment/skill-review/tabs/badge-test.js similarity index 100% rename from mon-pix/tests/integration/components/campaigns/assessment/skill-review/rewards/rewards-badge-test.js rename to mon-pix/tests/integration/components/campaigns/assessment/skill-review/tabs/badge-test.js diff --git a/mon-pix/tests/integration/components/campaigns/assessment/skill-review/rewards/rewards-test.js b/mon-pix/tests/integration/components/campaigns/assessment/skill-review/tabs/rewards-test.js similarity index 100% rename from mon-pix/tests/integration/components/campaigns/assessment/skill-review/rewards/rewards-test.js rename to mon-pix/tests/integration/components/campaigns/assessment/skill-review/tabs/rewards-test.js diff --git a/mon-pix/tests/integration/components/campaigns/assessment/skill-review/rewards/trainings-test.js b/mon-pix/tests/integration/components/campaigns/assessment/skill-review/tabs/trainings-test.js similarity index 100% rename from mon-pix/tests/integration/components/campaigns/assessment/skill-review/rewards/trainings-test.js rename to mon-pix/tests/integration/components/campaigns/assessment/skill-review/tabs/trainings-test.js From 98437c0fe8754f1ea3d689093db993daf29686be Mon Sep 17 00:00:00 2001 From: Geoffroy Begouaussel Date: Wed, 30 Oct 2024 11:33:38 +0100 Subject: [PATCH 2/3] refactor(mon-pix): simplify evaluation-results-tabs props --- .../evaluation-results-tabs/index.gjs | 19 ++++++--- .../assessment/evaluation-results.gjs | 7 +--- .../evaluation-results-tabs-test.js | 39 ++++++++++++------- 3 files changed, 40 insertions(+), 25 deletions(-) diff --git a/mon-pix/app/components/campaigns/assessment/skill-review/evaluation-results-tabs/index.gjs b/mon-pix/app/components/campaigns/assessment/skill-review/evaluation-results-tabs/index.gjs index 7d2c13743b1..afd62cc69db 100644 --- a/mon-pix/app/components/campaigns/assessment/skill-review/evaluation-results-tabs/index.gjs +++ b/mon-pix/app/components/campaigns/assessment/skill-review/evaluation-results-tabs/index.gjs @@ -11,7 +11,7 @@ export default class EvaluationResultsTabs extends Component { @service tabManager; get showRewardsTab() { - return this.args.badges.length > 0; + return this.args.campaignParticipationResult.campaignParticipationBadges.length > 0; } get initialTabIndex() { @@ -46,18 +46,22 @@ export default class EvaluationResultsTabs extends Component { <:panels as |Panel|> {{#if this.showRewardsTab}} - + {{/if}} - + {{#if this.showTrainingsTab}} {{/if}} @@ -65,7 +69,10 @@ export default class EvaluationResultsTabs extends Component { {{else}}
- +
{{/if}} diff --git a/mon-pix/app/components/routes/campaigns/assessment/evaluation-results.gjs b/mon-pix/app/components/routes/campaigns/assessment/evaluation-results.gjs index b74860623e8..94c881b83df 100644 --- a/mon-pix/app/components/routes/campaigns/assessment/evaluation-results.gjs +++ b/mon-pix/app/components/routes/campaigns/assessment/evaluation-results.gjs @@ -43,11 +43,8 @@ export default class EvaluationResults extends Component { @showTrainings={{this.showTrainings}} /> diff --git a/mon-pix/tests/integration/components/campaigns/assessment/skill-review/evaluation-results-tabs-test.js b/mon-pix/tests/integration/components/campaigns/assessment/skill-review/evaluation-results-tabs-test.js index 6f8b342196c..92fee0ad840 100644 --- a/mon-pix/tests/integration/components/campaigns/assessment/skill-review/evaluation-results-tabs-test.js +++ b/mon-pix/tests/integration/components/campaigns/assessment/skill-review/evaluation-results-tabs-test.js @@ -16,14 +16,19 @@ module('Integration | Components | Campaigns | Assessment | Skill Review | Evalu const store = this.owner.lookup('service:store'); const acquiredBadge = store.createRecord('badge', { isAcquired: true }); - this.set('badges', [acquiredBadge]); + this.set('campaignParticipationResult', { + campaignParticipationBadges: [acquiredBadge], + }); const training = store.createRecord('training', { duration: { days: 2 } }); this.set('trainings', [training]); // when screen = await render( - hbs``, + hbs``, ); }); @@ -47,16 +52,19 @@ module('Integration | Components | Campaigns | Assessment | Skill Review | Evalu // given const store = this.owner.lookup('service:store'); const acquiredBadge = store.createRecord('badge', { isAcquired: true }); - this.set('badges', [acquiredBadge]); + + this.set('campaignParticipationResult', { + campaignParticipationBadges: [acquiredBadge], + competenceResults: [], + }); + this.set('trainings', []); - this.set('competenceResults', []); // when const screen = await render( hbs``, ); @@ -76,8 +84,10 @@ module('Integration | Components | Campaigns | Assessment | Skill Review | Evalu // given const store = this.owner.lookup('service:store'); - this.set('badges', []); - this.set('competenceResults', []); + this.set('campaignParticipationResult', { + campaignParticipationBadges: [], + competenceResults: [], + }); const training = store.createRecord('training', { duration: { days: 2 } }); this.set('trainings', [training]); @@ -85,9 +95,8 @@ module('Integration | Components | Campaigns | Assessment | Skill Review | Evalu // when screen = await render( hbs``, ); }); @@ -110,16 +119,18 @@ module('Integration | Components | Campaigns | Assessment | Skill Review | Evalu module('when there are no rewards and no trainings', function () { test('it should not display the tabs component', async function (assert) { // given - this.set('badges', []); this.set('trainings', []); - this.set('competenceResults', []); + + this.set('campaignParticipationResult', { + campaignParticipationBadges: [], + competenceResults: [], + }); // when const screen = await render( hbs``, ); From e6dded0200ad2d1f1fba4d381afd131485a2a43a Mon Sep 17 00:00:00 2001 From: Geoffroy Begouaussel Date: Wed, 30 Oct 2024 11:36:28 +0100 Subject: [PATCH 3/3] fix(mon-pix): share results from evaluation results training tab now reloads model --- .../evaluation-results-tabs/trainings.gjs | 25 +++++------ .../skill-review/tabs/trainings-test.js | 43 +++++++++---------- 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/mon-pix/app/components/campaigns/assessment/skill-review/evaluation-results-tabs/trainings.gjs b/mon-pix/app/components/campaigns/assessment/skill-review/evaluation-results-tabs/trainings.gjs index 440247d0d17..dcb9b706efc 100644 --- a/mon-pix/app/components/campaigns/assessment/skill-review/evaluation-results-tabs/trainings.gjs +++ b/mon-pix/app/components/campaigns/assessment/skill-review/evaluation-results-tabs/trainings.gjs @@ -9,17 +9,11 @@ import { t } from 'ember-intl'; import TrainingCard from '../../../../training/card'; export default class EvaluationResultsTabsTrainings extends Component { + @service currentUser; @service store; @tracked isShareResultsLoading = false; @tracked isShareResultsError = false; - @tracked isParticipationShared = false; - - constructor() { - super(...arguments); - - this.isParticipationShared = this.args.isParticipationShared; - } @action async shareResults() { @@ -31,7 +25,14 @@ export default class EvaluationResultsTabsTrainings extends Component { await adapter.share(this.args.campaignParticipationResultId); - this.isParticipationShared = true; + await this.store.queryRecord( + 'campaign-participation-result', + { + campaignId: this.args.campaignId, + userId: this.currentUser.user.id, + }, + { reload: true }, + ); } catch { this.isShareResultsError = true; } finally { @@ -42,12 +43,12 @@ export default class EvaluationResultsTabsTrainings extends Component {