@@ -2,9 +2,11 @@ import { render as renderScreen } from '@1024pix/ember-testing-library';
2
2
import Service from '@ember/service' ;
3
3
import { click } from '@ember/test-helpers' ;
4
4
import { hbs } from 'ember-cli-htmlbars' ;
5
+ import { t } from 'ember-intl/test-support' ;
5
6
import { module , test } from 'qunit' ;
6
7
import sinon from 'sinon' ;
7
8
9
+ import { stubCurrentUserService } from '../../helpers/service-stubs' ;
8
10
import setupIntlRenderingTest from '../../helpers/setup-intl-rendering' ;
9
11
10
12
module ( 'Integration | Component | user certifications detail header' , function ( hooks ) {
@@ -16,6 +18,7 @@ module('Integration | Component | user certifications detail header', function (
16
18
17
19
hooks . beforeEach ( async function ( ) {
18
20
// given
21
+ stubCurrentUserService ( this . owner ) ;
19
22
store = this . owner . lookup ( 'service:store' ) ;
20
23
certification = store . createRecord ( 'certification' , {
21
24
id : '1' ,
@@ -92,6 +95,7 @@ module('Integration | Component | user certifications detail header', function (
92
95
93
96
module ( 'when domain is french' , function ( hooks ) {
94
97
hooks . beforeEach ( function ( ) {
98
+ stubCurrentUserService ( this . owner , { lang : 'fr' } ) ;
95
99
class CurrentDomainServiceStub extends Service {
96
100
get isFranceDomain ( ) {
97
101
return true ;
@@ -136,7 +140,7 @@ module('Integration | Component | user certifications detail header', function (
136
140
} ) ;
137
141
} ) ;
138
142
139
- module ( 'when certification is delivered before 2022-01-01' , function ( ) {
143
+ module ( 'when certification is v2 and delivered before 2022-01-01' , function ( ) {
140
144
test ( 'should not display the professionalizing warning' , async function ( assert ) {
141
145
// given
142
146
const store = this . owner . lookup ( 'service:store' ) ;
@@ -246,9 +250,35 @@ module('Integration | Component | user certifications detail header', function (
246
250
} ) ;
247
251
assert . ok ( true ) ;
248
252
} ) ;
253
+
254
+ test ( 'should display a link to the results explanation' , async function ( assert ) {
255
+ // given
256
+ stubCurrentUserService ( this . owner , { lang : 'en' } ) ;
257
+ const store = this . owner . lookup ( 'service:store' ) ;
258
+ const certification = store . createRecord ( 'certification' , {
259
+ birthdate : '2000-01-22' ,
260
+ date : new Date ( '2018-02-15T15:15:52Z' ) ,
261
+ isPublished : true ,
262
+ status : 'validated' ,
263
+ version : 3 ,
264
+ } ) ;
265
+ this . set ( 'certification' , certification ) ;
266
+
267
+ // when
268
+ const screen = await renderScreen ( hbs `<UserCertificationsDetailHeader @certification={{this.certification}} />` ) ;
269
+
270
+ // then
271
+ assert
272
+ . dom ( screen . getByRole ( 'link' , { name : t ( 'pages.certificate.learn-about-certification-results' ) } ) )
273
+ . hasAttribute ( 'href' , 'https://pix.fr/certification-comprendre-score-niveau' ) ;
274
+ } ) ;
249
275
} ) ;
250
276
251
- module ( 'when domain is not french' , function ( ) {
277
+ module ( 'when domain is not french' , function ( hooks ) {
278
+ hooks . beforeEach ( function ( ) {
279
+ stubCurrentUserService ( this . owner , { lang : 'en' } ) ;
280
+ } ) ;
281
+
252
282
test ( 'should not display the professionalizing warning' , async function ( assert ) {
253
283
// given
254
284
class CurrentDomainServiceStub extends Service {
@@ -327,11 +357,64 @@ module('Integration | Component | user certifications detail header', function (
327
357
} ) ;
328
358
assert . ok ( true ) ;
329
359
} ) ;
360
+
361
+ module ( 'when user is a French reader' , function ( ) {
362
+ test ( 'should display a link to the results explanation' , async function ( assert ) {
363
+ // given
364
+ stubCurrentUserService ( this . owner , { lang : 'fr' } ) ;
365
+
366
+ const store = this . owner . lookup ( 'service:store' ) ;
367
+ const certification = store . createRecord ( 'certification' , {
368
+ birthdate : '2000-01-22' ,
369
+ date : new Date ( '2018-02-15T15:15:52Z' ) ,
370
+ isPublished : true ,
371
+ status : 'validated' ,
372
+ version : 3 ,
373
+ } ) ;
374
+ this . set ( 'certification' , certification ) ;
375
+
376
+ // when
377
+ const screen = await renderScreen (
378
+ hbs `<UserCertificationsDetailHeader @certification={{this.certification}} />` ,
379
+ ) ;
380
+
381
+ // then
382
+ assert
383
+ . dom ( screen . getByRole ( 'link' , { name : t ( 'pages.certificate.learn-about-certification-results' ) } ) )
384
+ . hasAttribute ( 'href' , 'https://pix.org/fr/certification-comprendre-score-niveau' ) ;
385
+ } ) ;
386
+ } ) ;
387
+
388
+ module ( 'when user is not a French reader' , function ( ) {
389
+ test ( 'should not display a link to the results explanation' , async function ( assert ) {
390
+ // given
391
+ stubCurrentUserService ( this . owner , { lang : 'en' } ) ;
392
+ const store = this . owner . lookup ( 'service:store' ) ;
393
+ const certification = store . createRecord ( 'certification' , {
394
+ birthdate : '2000-01-22' ,
395
+ date : new Date ( '2018-02-15T15:15:52Z' ) ,
396
+ isPublished : true ,
397
+ status : 'validated' ,
398
+ } ) ;
399
+ this . set ( 'certification' , certification ) ;
400
+
401
+ // when
402
+ const screen = await renderScreen (
403
+ hbs `<UserCertificationsDetailHeader @certification={{this.certification}} />` ,
404
+ ) ;
405
+
406
+ // then
407
+ assert
408
+ . dom ( screen . queryByRole ( 'link' , { name : t ( 'pages.certificate.learn-about-certification-results' ) } ) )
409
+ . doesNotExist ( ) ;
410
+ } ) ;
411
+ } ) ;
330
412
} ) ;
331
413
332
414
module ( 'when there is an error during the download of the attestation' , function ( ) {
333
415
test ( 'should show the common error message' , async function ( assert ) {
334
416
// given
417
+ stubCurrentUserService ( this . owner ) ;
335
418
const fileSaverSaveStub = sinon . stub ( ) ;
336
419
337
420
class FileSaverStub extends Service {
0 commit comments