@@ -8,11 +8,12 @@ import { OrganizationInvitation } from '../../../../../src/team/domain/models/Or
8
8
import { catchErr , databaseBuilder , domainBuilder , expect , knex , sinon } from '../../../../test-helper.js' ;
9
9
10
10
describe ( 'Integration | Organizational Entities | Infrastructure | Repository | organization-for-admin' , function ( ) {
11
- let clock ;
11
+ let clock , isMultipleSendingFeature ;
12
12
const now = new Date ( '2022-02-02' ) ;
13
13
14
14
beforeEach ( function ( ) {
15
15
clock = sinon . useFakeTimers ( { now, toFake : [ 'Date' ] } ) ;
16
+ isMultipleSendingFeature = databaseBuilder . factory . buildFeature ( ORGANIZATION_FEATURE . MULTIPLE_SENDING_ASSESSMENT ) ;
16
17
} ) ;
17
18
18
19
afterEach ( function ( ) {
@@ -296,6 +297,11 @@ describe('Integration | Organizational Entities | Infrastructure | Repository |
296
297
featureId,
297
298
params : { organizationLearnerImportFormatId } ,
298
299
} ) ;
300
+ databaseBuilder . factory . buildOrganizationFeature ( {
301
+ organizationId : organization . id ,
302
+ featureId : isMultipleSendingFeature . id ,
303
+ params : null ,
304
+ } ) ;
299
305
300
306
await databaseBuilder . commit ( ) ;
301
307
@@ -335,6 +341,7 @@ describe('Integration | Organizational Entities | Infrastructure | Repository |
335
341
features : {
336
342
[ ORGANIZATION_FEATURE . COMPUTE_ORGANIZATION_LEARNER_CERTIFICABILITY . key ] : { active : false } ,
337
343
[ ORGANIZATION_FEATURE . LEARNER_IMPORT . key ] : { active : true , params : { name : 'BIDON' } } ,
344
+ [ ORGANIZATION_FEATURE . MULTIPLE_SENDING_ASSESSMENT . key ] : { active : true , params : null } ,
338
345
} ,
339
346
parentOrganizationId : parentOrganization . id ,
340
347
parentOrganizationName : 'Mother Of Dark Side' ,
@@ -387,7 +394,11 @@ describe('Integration | Organizational Entities | Infrastructure | Repository |
387
394
databaseBuilder . factory . buildOrganizationLearnerImportFormat ( {
388
395
name : 'BIDON' ,
389
396
} ) . id ;
390
-
397
+ databaseBuilder . factory . buildOrganizationFeature ( {
398
+ organizationId : organization . id ,
399
+ featureId : isMultipleSendingFeature . id ,
400
+ params : null ,
401
+ } ) ;
391
402
await databaseBuilder . commit ( ) ;
392
403
393
404
// when
@@ -425,6 +436,7 @@ describe('Integration | Organizational Entities | Infrastructure | Repository |
425
436
identityProviderForCampaigns : 'genericOidcProviderCode' ,
426
437
features : {
427
438
[ ORGANIZATION_FEATURE . LEARNER_IMPORT . key ] : { active : false , params : null } ,
439
+ [ ORGANIZATION_FEATURE . MULTIPLE_SENDING_ASSESSMENT . key ] : { active : true , params : null } ,
428
440
} ,
429
441
parentOrganizationId : null ,
430
442
parentOrganizationName : null ,
@@ -485,7 +497,6 @@ describe('Integration | Organizational Entities | Infrastructure | Repository |
485
497
archivedBy : archivist . id ,
486
498
archivedAt,
487
499
} ) ;
488
- databaseBuilder . factory . buildFeature ( ORGANIZATION_FEATURE . MULTIPLE_SENDING_ASSESSMENT ) ;
489
500
490
501
await databaseBuilder . commit ( ) ;
491
502
@@ -556,7 +567,7 @@ describe('Integration | Organizational Entities | Infrastructure | Repository |
556
567
} ) ;
557
568
558
569
context ( 'when the organization type is SCO-1D' , function ( ) {
559
- it ( 'adds mission_management, oralization and learner_import features to the organization' , async function ( ) {
570
+ it ( 'adds mission_management, oralization, learner_import and multiple sending assessment features to the organization' , async function ( ) {
560
571
const superAdminUserId = databaseBuilder . factory . buildUser ( ) . id ;
561
572
const missionManagementFeatureId = databaseBuilder . factory . buildFeature (
562
573
ORGANIZATION_FEATURE . MISSIONS_MANAGEMENT ,
@@ -583,7 +594,7 @@ describe('Integration | Organizational Entities | Infrastructure | Repository |
583
594
organizationId : savedOrganization . id ,
584
595
} ) ;
585
596
586
- expect ( savedOrganizationFeatures ) . to . have . lengthOf ( 3 ) ;
597
+ expect ( savedOrganizationFeatures ) . to . have . lengthOf ( 4 ) ;
587
598
const savedOrganizationFeatureIds = savedOrganizationFeatures . map (
588
599
( organizationFeature ) => organizationFeature . featureId ,
589
600
) ;
@@ -628,7 +639,7 @@ describe('Integration | Organizational Entities | Infrastructure | Repository |
628
639
createdBy : userId ,
629
640
} ) ;
630
641
631
- const featureId = databaseBuilder . factory . buildFeature ( ORGANIZATION_FEATURE . MULTIPLE_SENDING_ASSESSMENT ) . id ;
642
+ const featureId = databaseBuilder . factory . buildFeature ( ORGANIZATION_FEATURE . PLACES_MANAGEMENT ) . id ;
632
643
await databaseBuilder . commit ( ) ;
633
644
634
645
// when
@@ -637,14 +648,14 @@ describe('Integration | Organizational Entities | Infrastructure | Repository |
637
648
documentationUrl : 'https://pix.fr/' ,
638
649
features : {
639
650
[ ORGANIZATION_FEATURE . LEARNER_IMPORT . key ] : { active : false } ,
640
- [ ORGANIZATION_FEATURE . MULTIPLE_SENDING_ASSESSMENT . key ] : { active : true } ,
651
+ [ ORGANIZATION_FEATURE . PLACES_MANAGEMENT . key ] : { active : true } ,
641
652
} ,
642
653
} ) ;
643
654
await organizationForAdminRepository . update ( organizationToUpdate ) ;
644
655
645
656
// then
646
657
const enabledFeatures = await knex ( 'organization-features' ) . where ( { organizationId : organization . id } ) ;
647
- expect ( enabledFeatures ) . to . have . lengthOf ( 1 ) ;
658
+ expect ( enabledFeatures ) . to . have . lengthOf ( 2 ) ;
648
659
expect ( enabledFeatures [ 0 ] . featureId ) . to . equal ( featureId ) ;
649
660
} ) ;
650
661
@@ -656,7 +667,7 @@ describe('Integration | Organizational Entities | Infrastructure | Repository |
656
667
createdBy : userId ,
657
668
} ) ;
658
669
659
- const featureId = databaseBuilder . factory . buildFeature ( ORGANIZATION_FEATURE . MULTIPLE_SENDING_ASSESSMENT ) . id ;
670
+ const featureId = databaseBuilder . factory . buildFeature ( ORGANIZATION_FEATURE . PLACES_MANAGEMENT ) . id ;
660
671
databaseBuilder . factory . buildOrganizationFeature ( { organizationId : organization . id , featureId } ) ;
661
672
await databaseBuilder . commit ( ) ;
662
673
@@ -665,15 +676,16 @@ describe('Integration | Organizational Entities | Infrastructure | Repository |
665
676
id : organization . id ,
666
677
documentationUrl : 'https://pix.fr/' ,
667
678
features : {
668
- [ ORGANIZATION_FEATURE . MULTIPLE_SENDING_ASSESSMENT . key ] : { active : true } ,
679
+ [ ORGANIZATION_FEATURE . PLACES_MANAGEMENT . key ] : { active : true } ,
680
+ [ ORGANIZATION_FEATURE . PLACES_MANAGEMENT . key ] : { active : true } ,
669
681
} ,
670
682
} ) ;
671
683
672
684
await organizationForAdminRepository . update ( organizationToUpdate ) ;
673
685
674
686
// then
675
687
const enabledFeatures = await knex ( 'organization-features' ) . where ( { organizationId : organization . id } ) ;
676
- expect ( enabledFeatures ) . to . have . lengthOf ( 1 ) ;
688
+ expect ( enabledFeatures ) . to . have . lengthOf ( 2 ) ;
677
689
expect ( enabledFeatures [ 0 ] . featureId ) . to . equal ( featureId ) ;
678
690
} ) ;
679
691
@@ -690,9 +702,14 @@ describe('Integration | Organizational Entities | Infrastructure | Repository |
690
702
createdBy : userId ,
691
703
} ) ;
692
704
693
- const featureId = databaseBuilder . factory . buildFeature ( ORGANIZATION_FEATURE . MULTIPLE_SENDING_ASSESSMENT ) . id ;
694
- databaseBuilder . factory . buildOrganizationFeature ( { organizationId : organization . id , featureId } ) ;
695
- databaseBuilder . factory . buildOrganizationFeature ( { organizationId : otherOrganization . id , featureId } ) ;
705
+ databaseBuilder . factory . buildOrganizationFeature ( {
706
+ organizationId : organization . id ,
707
+ featureId : isMultipleSendingFeature . id ,
708
+ } ) ;
709
+ databaseBuilder . factory . buildOrganizationFeature ( {
710
+ organizationId : otherOrganization . id ,
711
+ featureId : isMultipleSendingFeature . id ,
712
+ } ) ;
696
713
697
714
await databaseBuilder . commit ( ) ;
698
715
0 commit comments