Skip to content

Commit

Permalink
[BUGFIX] N'afficher que les RT non-acquis qui sont en lacune (PIX-14969
Browse files Browse the repository at this point in the history
…).

 #10387
  • Loading branch information
pix-service-auto-merge authored Oct 23, 2024
2 parents 0aba064 + 4880436 commit f029da4
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default class Rewards extends Component {
}

get notAcquiredBadges() {
return this.getFilteredAndSortedBadges(false);
return this.getFilteredAndSortedBadges(false).filter(({ isAlwaysVisible }) => isAlwaysVisible);
}

<template>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
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';
Expand All @@ -22,11 +22,13 @@ module('Integration | Components | Campaigns | Assessment | Evaluation Results T

const badgeNotAcquired1 = store.createRecord('campaign-participation-badge', {
isAcquired: false,
isAlwaysVisible: true,
acquisitionPercentage: 30,
});

const badgeNotAcquired2 = store.createRecord('campaign-participation-badge', {
isAcquired: false,
isAlwaysVisible: true,
acquisitionPercentage: 70,
});

Expand Down Expand Up @@ -94,24 +96,64 @@ module('Integration | Components | Campaigns | Assessment | Evaluation Results T
});

module('in not acquired badges list', function () {
test('it should only display isAlwaysVisible badges', async function (assert) {
// given
const store = this.owner.lookup('service:store');

const notVisibleBadge1 = store.createRecord('campaign-participation-badge', {
isAcquired: false,
isAlwaysVisible: false,
acquisitionPercentage: 66,
});
const notVisibleBadge2 = store.createRecord('campaign-participation-badge', {
isAcquired: false,
isAlwaysVisible: false,
acquisitionPercentage: 66,
});

const alwaysVisibleBadge = store.createRecord('campaign-participation-badge', {
isAcquired: false,
isAlwaysVisible: true,
acquisitionPercentage: 33,
});

this.set('badges', [notVisibleBadge1, notVisibleBadge2, alwaysVisibleBadge]);

// when
const screen = await render(
hbs`<Campaigns::Assessment::SkillReview::EvaluationResultsTabs::Rewards @badges={{this.badges}} />`,
);

// then
const notAcquiredBadges = screen.getAllByRole('listitem', {
name: t('pages.skill-review.badge-card.not-acquired-full'),
});

assert.strictEqual(notAcquiredBadges.length, 1);
assert.ok(within(notAcquiredBadges[0]).getAllByText(/33/).length);
});

test('it should display certifiable badge first', async function (assert) {
// given
const store = this.owner.lookup('service:store');

const certifiableBadge = store.createRecord('campaign-participation-badge', {
isAcquired: false,
isCertifiable: true,
isAlwaysVisible: true,
acquisitionPercentage: 60,
});

const notCertifiableBadge1 = store.createRecord('campaign-participation-badge', {
isAcquired: false,
isCertifiable: false,
isAlwaysVisible: true,
acquisitionPercentage: 60,
});
const notCertifiableBadge2 = store.createRecord('campaign-participation-badge', {
isAcquired: false,
isCertifiable: false,
isAlwaysVisible: true,
acquisitionPercentage: 60,
});

Expand Down

0 comments on commit f029da4

Please sign in to comment.