@@ -2,6 +2,7 @@ import { Membership } from '../../../../../src/shared/domain/models/Membership.j
2
2
import {
3
3
createServer ,
4
4
databaseBuilder ,
5
+ domainBuilder ,
5
6
expect ,
6
7
generateValidRequestAuthorizationHeader ,
7
8
learningContentBuilder ,
@@ -350,4 +351,96 @@ describe('Acceptance | API | Campaign Route', function () {
350
351
} ) ;
351
352
} ) ;
352
353
} ) ;
354
+
355
+ describe ( 'GET /api/campaigns/{campaignId}/presentation-steps' , function ( ) {
356
+ it ( 'should return the presentation steps informations' , async function ( ) {
357
+ // given
358
+ const userId = databaseBuilder . factory . buildUser ( ) . id ;
359
+ const organization = databaseBuilder . factory . buildOrganization ( ) ;
360
+
361
+ databaseBuilder . factory . buildMembership ( {
362
+ userId,
363
+ organizationId : organization . id ,
364
+ organizationRole : Membership . roles . MEMBER ,
365
+ } ) ;
366
+
367
+ const targetProfile = databaseBuilder . factory . buildTargetProfile ( { organizationId : organization . id } ) ;
368
+ const badge = databaseBuilder . factory . buildBadge ( { targetProfileId : targetProfile . id } ) ;
369
+ const campaign = databaseBuilder . factory . buildCampaign ( {
370
+ code : 'CAMPAIGN1' ,
371
+ customLandingPageText : 'landing page text' ,
372
+ targetProfileId : targetProfile . id ,
373
+ organizationId : organization . id ,
374
+ } ) ;
375
+
376
+ const learningContent = domainBuilder . buildLearningContent . withSimpleContent ( ) ;
377
+ const learningContentObjects = learningContentBuilder . fromAreas ( learningContent . frameworks [ 0 ] . areas ) ;
378
+ mockLearningContent ( learningContentObjects ) ;
379
+
380
+ databaseBuilder . factory . buildCampaignSkill ( {
381
+ campaignId : campaign . id ,
382
+ skillId : learningContentObjects . competences [ 0 ] . skillIds [ 0 ] ,
383
+ } ) ;
384
+ await databaseBuilder . commit ( ) ;
385
+
386
+ // when
387
+ const options = {
388
+ method : 'GET' ,
389
+ url : `/api/campaigns/${ campaign . code } /presentation-steps` ,
390
+ headers : { authorization : generateValidRequestAuthorizationHeader ( userId ) } ,
391
+ } ;
392
+
393
+ const response = await server . inject ( options ) ;
394
+
395
+ // then
396
+ expect ( response . statusCode ) . to . equal ( 200 ) ;
397
+ expect ( response . result ) . to . deep . equal ( {
398
+ data : {
399
+ type : 'campaign-presentation-steps' ,
400
+ attributes : { 'custom-landing-page-text' : campaign . customLandingPageText } ,
401
+ relationships : {
402
+ badges : {
403
+ data : [
404
+ {
405
+ id : String ( badge . id ) ,
406
+ type : 'badges' ,
407
+ } ,
408
+ ] ,
409
+ } ,
410
+ competences : {
411
+ data : [
412
+ {
413
+ id : learningContentObjects . competences [ 0 ] . id ,
414
+ type : 'competences' ,
415
+ } ,
416
+ ] ,
417
+ } ,
418
+ } ,
419
+ } ,
420
+ included : [
421
+ {
422
+ type : 'badges' ,
423
+ id : String ( badge . id ) ,
424
+ attributes : {
425
+ 'alt-message' : badge . altMessage ,
426
+ 'image-url' : badge . imageUrl ,
427
+ 'is-always-visible' : badge . isAlwaysVisible ,
428
+ 'is-certifiable' : badge . isCertifiable ,
429
+ key : badge . key ,
430
+ message : badge . message ,
431
+ title : badge . title ,
432
+ } ,
433
+ } ,
434
+ {
435
+ type : 'competences' ,
436
+ id : learningContentObjects . competences [ 0 ] . id ,
437
+ attributes : {
438
+ index : learningContentObjects . competences [ 0 ] . index ,
439
+ name : learningContentObjects . competences [ 0 ] . name ,
440
+ } ,
441
+ } ,
442
+ ] ,
443
+ } ) ;
444
+ } ) ;
445
+ } ) ;
353
446
} ) ;
0 commit comments