@@ -14,6 +14,8 @@ import {
1414 type ExpectSavedNotificationsAndEvents ,
1515 makeExpectSavedNotificationsAndEvents ,
1616} from "../../../../utils/makeExpectSavedNotificationAndEvent.helpers" ;
17+ import type { FtConnectImmersionAdvisorDto } from "../../../core/authentication/ft-connect/dto/FtConnectAdvisor.dto" ;
18+ import type { FtConnectUserDto } from "../../../core/authentication/ft-connect/dto/FtConnectUserDto" ;
1719import {
1820 makeSaveNotificationAndRelatedEvent ,
1921 type SaveNotificationAndRelatedEvent ,
@@ -483,7 +485,52 @@ describe("NotifyEstablishmentUsersAndBeneficiariesThatEstablishmentIsBanned", ()
483485 } ) ;
484486
485487 it ( "sends email only to FT advisor when present" , async ( ) => {
486- uow . conventionRepository . setConventions ( [ validatedConvention ] ) ;
488+ const ftConnectedBeneficiary : FtConnectUserDto = {
489+ firstName : "Jean" ,
490+ lastName : "Bénéficiaire" ,
491+ isJobseeker : true ,
492+ peExternalId : "beneficiary-external-id" ,
493+ email : "jean@beneficiaire.com" ,
494+ birthdate : "2000-02-02" ,
495+ } ;
496+ const ftConnectImmersionAdvisor : FtConnectImmersionAdvisorDto = {
497+ email : "jean@advisor.com" ,
498+ firstName : "Jean" ,
499+ lastName : "Advisor" ,
500+ type : "PLACEMENT" ,
501+ } ;
502+
503+ const conventionWithFtConnectUsers : ConventionDto = {
504+ ...validatedConvention ,
505+ internshipKind : "immersion" ,
506+ signatories : {
507+ ...validatedConvention . signatories ,
508+ beneficiary : {
509+ ...validatedConvention . signatories . beneficiary ,
510+ ...ftConnectedBeneficiary ,
511+ } ,
512+ } ,
513+ validators : {
514+ ...validatedConvention . validators ,
515+ agencyCounsellor : {
516+ firstname : ftConnectImmersionAdvisor . firstName ,
517+ lastname : ftConnectImmersionAdvisor . lastName ,
518+ } ,
519+ } ,
520+ } ;
521+
522+ uow . conventionRepository . setConventions ( [ conventionWithFtConnectUsers ] ) ;
523+ uow . conventionFranceTravailAdvisorRepository . ftConnectedUsers = {
524+ [ ftConnectedBeneficiary . peExternalId ] : {
525+ advisor : ftConnectImmersionAdvisor ,
526+ user : ftConnectedBeneficiary ,
527+ } ,
528+ } ;
529+ uow . conventionFranceTravailAdvisorRepository . conventionFranceTravailUsers =
530+ {
531+ [ conventionWithFtConnectUsers . id ] :
532+ ftConnectedBeneficiary . peExternalId ,
533+ } ;
487534
488535 await notifyEstablishmentUsersAndBeneficiariesThatEstablishmentIsBanned . execute (
489536 { siret } ,
@@ -503,22 +550,19 @@ describe("NotifyEstablishmentUsersAndBeneficiariesThatEstablishmentIsBanned", ()
503550 } ,
504551 {
505552 kind : "ESTABLISHMENT_BANNED_NOTIFICATION_TO_VALIDATOR_AND_PREVALIDATOR" ,
506- recipients : [ agency . contactEmail ] ,
553+ recipients : [ ftConnectImmersionAdvisor . email ] ,
507554 params : {
508555 businessName,
509- conventionId : validatedConvention . id ,
556+ conventionId : conventionWithFtConnectUsers . id ,
510557 beneficiaryFirstName :
511- validatedConvention . signatories . beneficiary . firstName ,
558+ conventionWithFtConnectUsers . signatories . beneficiary . firstName ,
512559 beneficiaryLastName :
513- validatedConvention . signatories . beneficiary . lastName ,
560+ conventionWithFtConnectUsers . signatories . beneficiary . lastName ,
514561 immersionBaseUrl,
515562 } ,
516563 } ,
517564 ] ,
518565 } ) ;
519- throw new Error (
520- "Use repo when conventionFranceTravailAdvisorRepository is updated" ,
521- ) ;
522566 } ) ;
523567
524568 it ( "sends email to agency validators when convention is validated and agency has no refersToAgency" , async ( ) => {
0 commit comments