From bc301fbe33cd216f182ded89fc2fa2736705e384 Mon Sep 17 00:00:00 2001 From: P-Jeremy Date: Tue, 1 Oct 2024 11:49:22 +0200 Subject: [PATCH 01/12] :recycle: mon-pix: turn candidate elligible subscriptions in array Co-authored-by: Andreia Pena Ferreira Co-authored-by: Guillaume LAGORCE --- .../app/components/certification-starter.hbs | 5 +++-- .../certification-candidate-subscription.js | 4 ++-- .../certifications/information-test.js | 6 +++--- .../acceptance/certification-course-test.js | 18 +++++++++--------- .../components/certification-starter-test.js | 12 ++++++------ 5 files changed, 23 insertions(+), 22 deletions(-) diff --git a/mon-pix/app/components/certification-starter.hbs b/mon-pix/app/components/certification-starter.hbs index dea4d8e7267..0340d1221be 100644 --- a/mon-pix/app/components/certification-starter.hbs +++ b/mon-pix/app/components/certification-starter.hbs @@ -8,10 +8,11 @@ {{t "pages.certification-start.subscription"}}

- {{#if @certificationCandidateSubscription.eligibleSubscription}} + + {{#if (gt @certificationCandidateSubscription.eligibleSubscriptions.length 0)}} - {{@certificationCandidateSubscription.eligibleSubscription.label}} + {{get @certificationCandidateSubscription.eligibleSubscriptions "0.label"}} {{else}} diff --git a/mon-pix/app/models/certification-candidate-subscription.js b/mon-pix/app/models/certification-candidate-subscription.js index 0646ff03df5..b8c36e034de 100644 --- a/mon-pix/app/models/certification-candidate-subscription.js +++ b/mon-pix/app/models/certification-candidate-subscription.js @@ -2,12 +2,12 @@ import Model, { attr } from '@ember-data/model'; export default class CertificationCandidateSubscription extends Model { @attr sessionId; - @attr eligibleSubscription; + @attr eligibleSubscriptions; @attr nonEligibleSubscription; @attr sessionVersion; get hasSubscription() { - return this.eligibleSubscription || this.nonEligibleSubscription; + return this.eligibleSubscriptions?.length || this.nonEligibleSubscription; } get isSessionVersion3() { diff --git a/mon-pix/tests/acceptance/authenticated/certifications/information-test.js b/mon-pix/tests/acceptance/authenticated/certifications/information-test.js index a8c92a20d43..90d845a9a20 100644 --- a/mon-pix/tests/acceptance/authenticated/certifications/information-test.js +++ b/mon-pix/tests/acceptance/authenticated/certifications/information-test.js @@ -26,7 +26,7 @@ module('Acceptance | Certifications | Information', function (hooks) { server.create('certification-candidate-subscription', { id: 2, sessionId: 123, - eligibleSubscription: null, + eligibleSubscriptions: null, nonEligibleSubscription: null, sessionVersion: 3, }); @@ -61,7 +61,7 @@ module('Acceptance | Certifications | Information', function (hooks) { server.create('certification-candidate-subscription', { id: 2, sessionId: 123, - eligibleSubscription: null, + eligibleSubscriptions: null, nonEligibleSubscription: null, sessionVersion: 3, }); @@ -102,7 +102,7 @@ module('Acceptance | Certifications | Information', function (hooks) { server.create('certification-candidate-subscription', { id: 2, sessionId: 123, - eligibleSubscription: null, + eligibleSubscriptions: null, nonEligibleSubscription: null, sessionVersion: 3, }); diff --git a/mon-pix/tests/acceptance/certification-course-test.js b/mon-pix/tests/acceptance/certification-course-test.js index 20bb82ef3b5..f7cad42e4ed 100644 --- a/mon-pix/tests/acceptance/certification-course-test.js +++ b/mon-pix/tests/acceptance/certification-course-test.js @@ -211,7 +211,7 @@ module('Acceptance | Certification | Certification Course', function (hooks) { this.server.create('certification-candidate-subscription', { id: 1, sessionId: 1, - eligibleSubscription: null, + eligibleSubscriptions: null, nonEligibleSubscription: null, }); @@ -238,7 +238,7 @@ module('Acceptance | Certification | Certification Course', function (hooks) { this.server.create('certification-candidate-subscription', { id: 2, sessionId: 1, - eligibleSubscription: null, + eligibleSubscriptions: null, nonEligibleSubscription: null, }); @@ -279,7 +279,7 @@ module('Acceptance | Certification | Certification Course', function (hooks) { this.server.create('certification-candidate-subscription', { id: 2, sessionId: 1, - eligibleSubscription: null, + eligibleSubscriptions: null, nonEligibleSubscription: null, }); }); @@ -402,7 +402,7 @@ module('Acceptance | Certification | Certification Course', function (hooks) { this.server.create('certification-candidate-subscription', { id: 2, sessionId: 1, - eligibleSubscription: null, + eligibleSubscriptions: null, nonEligibleSubscription: null, }); @@ -477,7 +477,7 @@ module('Acceptance | Certification | Certification Course', function (hooks) { server.create('certification-candidate-subscription', { id: 2, sessionId: 1, - eligibleSubscription: null, + eligibleSubscriptions: null, nonEligibleSubscription: null, }); @@ -556,7 +556,7 @@ module('Acceptance | Certification | Certification Course', function (hooks) { this.server.create('certification-candidate-subscription', { id: 2, sessionId: 1, - eligibleSubscription: null, + eligibleSubscriptions: null, nonEligibleSubscription: null, }); @@ -607,7 +607,7 @@ module('Acceptance | Certification | Certification Course', function (hooks) { this.server.create('certification-candidate-subscription', { id: 2, sessionId: 1, - eligibleSubscription: null, + eligibleSubscriptions: null, nonEligibleSubscription: null, }); @@ -653,7 +653,7 @@ module('Acceptance | Certification | Certification Course', function (hooks) { this.server.create('certification-candidate-subscription', { id: 2, sessionId: 1, - eligibleSubscription: null, + eligibleSubscriptions: null, nonEligibleSubscription: null, }); @@ -709,7 +709,7 @@ module('Acceptance | Certification | Certification Course', function (hooks) { this.server.create('certification-candidate-subscription', { id: 2, sessionId: 1, - eligibleSubscription: null, + eligibleSubscriptions: null, nonEligibleSubscription: null, }); diff --git a/mon-pix/tests/integration/components/certification-starter-test.js b/mon-pix/tests/integration/components/certification-starter-test.js index ee2a26c2d93..fbb44919ed9 100644 --- a/mon-pix/tests/integration/components/certification-starter-test.js +++ b/mon-pix/tests/integration/components/certification-starter-test.js @@ -19,11 +19,11 @@ module('Integration | Component | certification-starter', function (hooks) { this.set( 'certificationCandidateSubscription', store.createRecord('certification-candidate-subscription', { - eligibleSubscription: null, + eligibleSubscriptions: null, nonEligibleSubscription: null, }), ); - this.set('certificationCandidateSubscription', { eligibleSubscription: null, nonEligibleSubscription: null }); + this.set('certificationCandidateSubscription', { eligibleSubscriptions: null, nonEligibleSubscription: null }); // when const screen = await render( @@ -48,7 +48,7 @@ module('Integration | Component | certification-starter', function (hooks) { this.set( 'certificationCandidateSubscription', store.createRecord('certification-candidate-subscription', { - eligibleSubscription: { label: 'Certif complémentaire 1' }, + eligibleSubscriptions: [{ label: 'Certif complémentaire 1' }], nonEligibleSubscription: null, }), ); @@ -73,7 +73,7 @@ module('Integration | Component | certification-starter', function (hooks) { this.set( 'certificationCandidateSubscription', store.createRecord('certification-candidate-subscription', { - eligibleSubscription: { label: 'Certif complémentaire 1' }, + eligibleSubscriptions: [{ label: 'Certif complémentaire 1' }], nonEligibleSubscription: null, }), ); @@ -95,7 +95,7 @@ module('Integration | Component | certification-starter', function (hooks) { this.set( 'certificationCandidateSubscription', store.createRecord('certification-candidate-subscription', { - eligibleSubscription: null, + eligibleSubscriptions: null, nonEligibleSubscription: { label: 'Certif complémentaire 1' }, }), ); @@ -119,7 +119,7 @@ module('Integration | Component | certification-starter', function (hooks) { this.set( 'certificationCandidateSubscription', store.createRecord('certification-candidate-subscription', { - eligibleSubscription: null, + eligibleSubscriptions: null, nonEligibleSubscription: { label: 'Certif complémentaire 1' }, }), ); From b6bf739074c174db1f0707b746a02b893e8156e4 Mon Sep 17 00:00:00 2001 From: P-Jeremy Date: Wed, 2 Oct 2024 16:22:37 +0200 Subject: [PATCH 02/12] :sparkles: mon-pix: hide banner if v3 only core subscription --- .../app/components/certification-starter.hbs | 69 ++++++++++--------- .../certification-candidate-subscription.js | 10 +++ .../components/certification-starter-test.js | 29 ++++++++ 3 files changed, 76 insertions(+), 32 deletions(-) diff --git a/mon-pix/app/components/certification-starter.hbs b/mon-pix/app/components/certification-starter.hbs index 0340d1221be..f3016ad81cd 100644 --- a/mon-pix/app/components/certification-starter.hbs +++ b/mon-pix/app/components/certification-starter.hbs @@ -2,41 +2,46 @@

{{t "pages.certification-start.first-title"}}

{{#if @certificationCandidateSubscription.hasSubscription}} -
-
-

- {{t "pages.certification-start.subscription"}} -

-
+ {{#unless @certificationCandidateSubscription.isV3CoreOnly}} +
+
+

+ {{t "pages.certification-start.subscription"}} +

+
- {{#if (gt @certificationCandidateSubscription.eligibleSubscriptions.length 0)}} - - - {{get @certificationCandidateSubscription.eligibleSubscriptions "0.label"}} - - {{else}} - - - {{@certificationCandidateSubscription.nonEligibleSubscription.label}} - - {{/if}} + {{#if (gt @certificationCandidateSubscription.eligibleSubscriptions.length 0)}} + + + {{get @certificationCandidateSubscription.eligibleSubscriptions "0.label"}} + + {{else}} + + + {{@certificationCandidateSubscription.nonEligibleSubscription.label}} + + {{/if}} +
+ {{#if @certificationCandidateSubscription.nonEligibleSubscription}} +
+ + + {{t + "pages.certification-start.non-eligible-subscription" + nonEligibleSubscriptionLabel=@certificationCandidateSubscription.nonEligibleSubscription.label + }} + +
+ {{/if}}
- {{#if @certificationCandidateSubscription.nonEligibleSubscription}} -
- - - {{t - "pages.certification-start.non-eligible-subscription" - nonEligibleSubscriptionLabel=@certificationCandidateSubscription.nonEligibleSubscription.label - }} - -
- {{/if}} -
+ {{/unless}} {{/if}}