diff --git a/back/src/adapters/primary/config/createUseCases.ts b/back/src/adapters/primary/config/createUseCases.ts index f382684bb2..b0e455a139 100644 --- a/back/src/adapters/primary/config/createUseCases.ts +++ b/back/src/adapters/primary/config/createUseCases.ts @@ -105,9 +105,9 @@ export const createUseCases = ( quarantinedTopics: config.quarantinedTopics, }); const saveNotificationAndRelatedEvent = makeSaveNotificationAndRelatedEvent( - createNewEvent, uuidGenerator, gateways.timeGateway, + createNewEvent, ); const addFormEstablishment = new AddFormEstablishment( uowPerformer, @@ -134,7 +134,7 @@ export const createUseCases = ( ), notifyIcUserAgencyRightChanged: new NotifyIcUserAgencyRightChanged( uowPerformer, - gateways.notification, + saveNotificationAndRelatedEvent, ), getIcUsers: new GetInclusionConnectedUsers(uowPerformer), getUserAgencyDashboardUrl: new GetInclusionConnectedUser( @@ -282,7 +282,7 @@ export const createUseCases = ( ), requestEditFormEstablishment: new RequestEditFormEstablishment( uowPerformer, - gateways.notification, + saveNotificationAndRelatedEvent, gateways.timeGateway, makeGenerateEditFormEstablishmentUrl( config, @@ -315,7 +315,8 @@ export const createUseCases = ( privateListAgencies: new PrivateListAgencies(uowPerformer), getAgencyPublicInfoById: new GetAgencyPublicInfoById(uowPerformer), sendEmailWhenAgencyIsActivated: new SendEmailWhenAgencyIsActivated( - gateways.notification, + uowPerformer, + saveNotificationAndRelatedEvent, ), // METABASE ...dashboardUseCases(gateways.dashboardGateway, gateways.timeGateway), @@ -381,7 +382,8 @@ export const createUseCases = ( config, ), deliverRenewedMagicLink: new DeliverRenewedMagicLink( - gateways.notification, + uowPerformer, + saveNotificationAndRelatedEvent, ), notifyConfirmationEstablishmentCreated: new NotifyConfirmationEstablishmentCreated( @@ -406,7 +408,8 @@ export const createUseCases = ( gateways.timeGateway, ), shareConventionByEmail: new ShareApplicationLinkByEmail( - gateways.notification, + uowPerformer, + saveNotificationAndRelatedEvent, ), addAgency: new AddAgency(uowPerformer, createNewEvent), updateAgencyStatus: new UpdateAgencyStatus(uowPerformer, createNewEvent), diff --git a/back/src/adapters/primary/routers/agencies/agencies.e2e.test.ts b/back/src/adapters/primary/routers/agencies/agencies.e2e.test.ts index 75144fa2e1..144bb1a72f 100644 --- a/back/src/adapters/primary/routers/agencies/agencies.e2e.test.ts +++ b/back/src/adapters/primary/routers/agencies/agencies.e2e.test.ts @@ -11,6 +11,7 @@ import { buildTestApp, InMemoryGateways, } from "../../../../_testBuilders/buildTestApp"; +import { processEventsForEmailToBeSent } from "../../../../_testBuilders/processEventsForEmailToBeSent"; import { BasicEventCrawler } from "../../../secondary/core/EventCrawlerImplementations"; import { AppConfig } from "../../config/appConfig"; import { InMemoryUnitOfWork } from "../../config/uowConfig"; @@ -138,7 +139,7 @@ describe(`/${agenciesRoute} route`, () => { ).toBe("active"); expect(inMemoryUow.outboxRepository.events).toHaveLength(1); - await eventCrawler.processNewEvents(); + await processEventsForEmailToBeSent(eventCrawler); expect(gateways.notification.getSentEmails()).toHaveLength(1); }); }); diff --git a/back/src/adapters/primary/routers/technical/renewMagicLink.e2e.test.ts b/back/src/adapters/primary/routers/technical/renewMagicLink.e2e.test.ts index bc3b21ae10..43bfc8ceab 100644 --- a/back/src/adapters/primary/routers/technical/renewMagicLink.e2e.test.ts +++ b/back/src/adapters/primary/routers/technical/renewMagicLink.e2e.test.ts @@ -13,6 +13,7 @@ import { buildTestApp, InMemoryGateways, } from "../../../../_testBuilders/buildTestApp"; +import { processEventsForEmailToBeSent } from "../../../../_testBuilders/processEventsForEmailToBeSent"; import { GenerateConventionJwt, makeGenerateJwtES256, @@ -85,7 +86,7 @@ describe("Magic link renewal flow", () => { expect(response.status).toBe(200); - await eventCrawler.processNewEvents(); + await processEventsForEmailToBeSent(eventCrawler); const sentEmails = gateways.notification.getSentEmails(); diff --git a/back/src/domain/convention/useCases/RenewConventionMagicLink.ts b/back/src/domain/convention/useCases/RenewConventionMagicLink.ts index 2a9731ff55..830de10869 100644 --- a/back/src/domain/convention/useCases/RenewConventionMagicLink.ts +++ b/back/src/domain/convention/useCases/RenewConventionMagicLink.ts @@ -114,6 +114,7 @@ export class RenewConventionMagicLink extends TransactionalUseCase< conventionStatusLink: await makeMagicShortLink( frontRoutes.conventionStatusDashboard, ), + conventionId: applicationId, }, }), ); diff --git a/back/src/domain/convention/useCases/SendEmailWhenAgencyIsActivated.ts b/back/src/domain/convention/useCases/SendEmailWhenAgencyIsActivated.ts index c257ca84f3..fcc9fa2172 100644 --- a/back/src/domain/convention/useCases/SendEmailWhenAgencyIsActivated.ts +++ b/back/src/domain/convention/useCases/SendEmailWhenAgencyIsActivated.ts @@ -1,24 +1,37 @@ import { z } from "zod"; import { AgencyDto, agencySchema } from "shared"; -import { UseCase } from "../../core/UseCase"; -import { NotificationGateway } from "../../generic/notifications/ports/NotificationGateway"; +import { UnitOfWork, UnitOfWorkPerformer } from "../../core/ports/UnitOfWork"; +import { TransactionalUseCase } from "../../core/UseCase"; +import { SaveNotificationAndRelatedEvent } from "../../generic/notifications/entities/Notification"; type WithAgency = { agency: AgencyDto }; -export class SendEmailWhenAgencyIsActivated extends UseCase { +export class SendEmailWhenAgencyIsActivated extends TransactionalUseCase { inputSchema = z.object({ agency: agencySchema }); - constructor(private readonly notificationGateway: NotificationGateway) { - super(); + constructor( + uowPerformer: UnitOfWorkPerformer, + private readonly saveNotificationAndRelatedEvent: SaveNotificationAndRelatedEvent, + ) { + super(uowPerformer); } - public async _execute({ agency }: WithAgency): Promise { - await this.notificationGateway.sendEmail({ - type: "AGENCY_WAS_ACTIVATED", - recipients: agency.validatorEmails, - params: { - agencyName: agency.name, - agencyLogoUrl: agency.logoUrl, + public async _execute( + { agency }: WithAgency, + uow: UnitOfWork, + ): Promise { + await this.saveNotificationAndRelatedEvent(uow, { + kind: "email", + templatedContent: { + type: "AGENCY_WAS_ACTIVATED", + recipients: agency.validatorEmails, + params: { + agencyName: agency.name, + agencyLogoUrl: agency.logoUrl, + }, + }, + followedIds: { + agencyId: agency.id, }, }); } diff --git a/back/src/domain/convention/useCases/SendEmailWhenAgencyIsActivated.unit.test.ts b/back/src/domain/convention/useCases/SendEmailWhenAgencyIsActivated.unit.test.ts index bd6a5c2d6c..df554a938c 100644 --- a/back/src/domain/convention/useCases/SendEmailWhenAgencyIsActivated.unit.test.ts +++ b/back/src/domain/convention/useCases/SendEmailWhenAgencyIsActivated.unit.test.ts @@ -1,28 +1,53 @@ import { AgencyDtoBuilder } from "shared"; -import { InMemoryNotificationGateway } from "../../../adapters/secondary/notificationGateway/InMemoryNotificationGateway"; -import { SendEmailWhenAgencyIsActivated } from "../../../domain/convention/useCases/SendEmailWhenAgencyIsActivated"; +import { makeExpectSavedNotificationsAndEvents } from "../../../_testBuilders/makeExpectSavedNotificationsAndEvents"; +import { createInMemoryUow } from "../../../adapters/primary/config/uowConfig"; +import { CustomTimeGateway } from "../../../adapters/secondary/core/TimeGateway/CustomTimeGateway"; +import { UuidV4Generator } from "../../../adapters/secondary/core/UuidGeneratorImplementations"; +import { InMemoryUowPerformer } from "../../../adapters/secondary/InMemoryUowPerformer"; +import { makeSaveNotificationAndRelatedEvent } from "../../generic/notifications/entities/Notification"; +import { SendEmailWhenAgencyIsActivated } from "./SendEmailWhenAgencyIsActivated"; describe("SendEmailWhenAgencyIsActivated", () => { it("Sends an email to validators with agency name", async () => { // Prepare - const notificationGateway = new InMemoryNotificationGateway(); - const useCase = new SendEmailWhenAgencyIsActivated(notificationGateway); + const uow = createInMemoryUow(); + const uowPerformer = new InMemoryUowPerformer(uow); + const expectSavedNotificationsAndEvents = + makeExpectSavedNotificationsAndEvents( + uow.notificationRepository, + uow.outboxRepository, + ); + const timeGateway = new CustomTimeGateway(); + const uuidGenerator = new UuidV4Generator(); + const saveNotificationAndRelatedEvent = makeSaveNotificationAndRelatedEvent( + uuidGenerator, + timeGateway, + ); + const useCase = new SendEmailWhenAgencyIsActivated( + uowPerformer, + saveNotificationAndRelatedEvent, + ); const updatedAgency = AgencyDtoBuilder.create() .withValidatorEmails(["toto@email.com"]) .withName("just-activated-agency") + .withLogoUrl("https://logo.com") .build(); // Act await useCase.execute({ agency: updatedAgency }); // Assert - const sentEmails = notificationGateway.getSentEmails(); - expect(sentEmails).toHaveLength(1); - - expect(sentEmails[0].type).toBe("AGENCY_WAS_ACTIVATED"); - expect(sentEmails[0].params).toEqual({ - agencyName: "just-activated-agency", + expectSavedNotificationsAndEvents({ + emails: [ + { + type: "AGENCY_WAS_ACTIVATED", + recipients: ["toto@email.com"], + params: { + agencyName: "just-activated-agency", + agencyLogoUrl: "https://logo.com", + }, + }, + ], }); - expect(sentEmails[0].recipients).toEqual(["toto@email.com"]); }); }); diff --git a/back/src/domain/convention/useCases/ShareApplicationLinkByEmail.ts b/back/src/domain/convention/useCases/ShareApplicationLinkByEmail.ts index 999b630754..33d3d9f4fc 100644 --- a/back/src/domain/convention/useCases/ShareApplicationLinkByEmail.ts +++ b/back/src/domain/convention/useCases/ShareApplicationLinkByEmail.ts @@ -1,22 +1,33 @@ import { ShareLinkByEmailDto, shareLinkByEmailSchema } from "shared"; -import { UseCase } from "../../core/UseCase"; -import { NotificationGateway } from "../../generic/notifications/ports/NotificationGateway"; +import { UnitOfWork, UnitOfWorkPerformer } from "../../core/ports/UnitOfWork"; +import { TransactionalUseCase } from "../../core/UseCase"; +import { SaveNotificationAndRelatedEvent } from "../../generic/notifications/entities/Notification"; -export class ShareApplicationLinkByEmail extends UseCase { - constructor(private readonly notificationGateway: NotificationGateway) { - super(); +export class ShareApplicationLinkByEmail extends TransactionalUseCase { + constructor( + uowPerformer: UnitOfWorkPerformer, + private readonly saveNotificationAndRelatedEvent: SaveNotificationAndRelatedEvent, + ) { + super(uowPerformer); } inputSchema = shareLinkByEmailSchema; - public async _execute(params: ShareLinkByEmailDto): Promise { - await this.notificationGateway.sendEmail({ - type: "SHARE_DRAFT_CONVENTION_BY_LINK", - recipients: [params.email], - params: { - internshipKind: params.internshipKind, - additionalDetails: params.details, - conventionFormUrl: params.conventionLink, + public async _execute( + params: ShareLinkByEmailDto, + uow: UnitOfWork, + ): Promise { + await this.saveNotificationAndRelatedEvent(uow, { + kind: "email", + templatedContent: { + type: "SHARE_DRAFT_CONVENTION_BY_LINK", + recipients: [params.email], + params: { + internshipKind: params.internshipKind, + additionalDetails: params.details, + conventionFormUrl: params.conventionLink, + }, }, + followedIds: {}, }); } } diff --git a/back/src/domain/convention/useCases/notifications/ConfirmToSignatoriesThatApplicationCorrectlySubmittedRequestSignature.unit.test.ts b/back/src/domain/convention/useCases/notifications/ConfirmToSignatoriesThatApplicationCorrectlySubmittedRequestSignature.unit.test.ts index 70d34722cd..7ff9de34a6 100644 --- a/back/src/domain/convention/useCases/notifications/ConfirmToSignatoriesThatApplicationCorrectlySubmittedRequestSignature.unit.test.ts +++ b/back/src/domain/convention/useCases/notifications/ConfirmToSignatoriesThatApplicationCorrectlySubmittedRequestSignature.unit.test.ts @@ -17,7 +17,6 @@ import { InMemoryNotificationRepository } from "../../../../adapters/secondary/I import { InMemoryShortLinkQuery } from "../../../../adapters/secondary/InMemoryShortLinkQuery"; import { InMemoryUowPerformer } from "../../../../adapters/secondary/InMemoryUowPerformer"; import { DeterministShortLinkIdGeneratorGateway } from "../../../../adapters/secondary/shortLinkIdGeneratorGateway/DeterministShortLinkIdGeneratorGateway"; -import { makeCreateNewEvent } from "../../../core/eventBus/EventBus"; import { ShortLinkId } from "../../../core/ports/ShortLinkQuery"; import { EmailNotification, @@ -57,12 +56,7 @@ describe("Add Convention Notifications", () => { .build(); shortLinkGenerator = new DeterministShortLinkIdGeneratorGateway(); const uuidGenerator = new UuidV4Generator(); - const createNewEvent = makeCreateNewEvent({ - timeGateway, - uuidGenerator, - }); const saveNotificationAndRelatedEvent = makeSaveNotificationAndRelatedEvent( - createNewEvent, uuidGenerator, timeGateway, ); diff --git a/back/src/domain/convention/useCases/notifications/DeliverRenewedMagicLink.ts b/back/src/domain/convention/useCases/notifications/DeliverRenewedMagicLink.ts index 9f68a32f64..f9f07f202c 100644 --- a/back/src/domain/convention/useCases/notifications/DeliverRenewedMagicLink.ts +++ b/back/src/domain/convention/useCases/notifications/DeliverRenewedMagicLink.ts @@ -1,14 +1,23 @@ import { z } from "zod"; -import { InternshipKind, internshipKindSchema } from "shared"; -import { UseCase } from "../../../core/UseCase"; -import { NotificationGateway } from "../../../generic/notifications/ports/NotificationGateway"; +import { + conventionIdSchema, + InternshipKind, + internshipKindSchema, +} from "shared"; +import { + UnitOfWork, + UnitOfWorkPerformer, +} from "../../../core/ports/UnitOfWork"; +import { TransactionalUseCase } from "../../../core/UseCase"; +import { SaveNotificationAndRelatedEvent } from "../../../generic/notifications/entities/Notification"; // prettier-ignore export type RenewMagicLinkPayload = { internshipKind:InternshipKind emails:string[] magicLink:string, - conventionStatusLink:string + conventionStatusLink: string, + conventionId?: string, } export const renewMagicLinkPayloadSchema: z.Schema = z.object({ @@ -16,25 +25,39 @@ export const renewMagicLinkPayloadSchema: z.Schema = emails: z.array(z.string()), magicLink: z.string(), conventionStatusLink: z.string(), + conventionId: conventionIdSchema.optional(), }); -export class DeliverRenewedMagicLink extends UseCase { - constructor(private readonly notificationGateway: NotificationGateway) { - super(); +export class DeliverRenewedMagicLink extends TransactionalUseCase { + constructor( + uowPerformer: UnitOfWorkPerformer, + private readonly saveNotificationAndRelatedEvent: SaveNotificationAndRelatedEvent, + ) { + super(uowPerformer); } inputSchema = renewMagicLinkPayloadSchema; - public async _execute({ - emails, - magicLink, - conventionStatusLink, - internshipKind, - }: RenewMagicLinkPayload): Promise { - await this.notificationGateway.sendEmail({ - type: "MAGIC_LINK_RENEWAL", - recipients: emails, - params: { internshipKind, magicLink, conventionStatusLink }, + public async _execute( + { + emails, + magicLink, + conventionStatusLink, + internshipKind, + conventionId, + }: RenewMagicLinkPayload, + uow: UnitOfWork, + ): Promise { + await this.saveNotificationAndRelatedEvent(uow, { + kind: "email", + templatedContent: { + type: "MAGIC_LINK_RENEWAL", + recipients: emails, + params: { internshipKind, magicLink, conventionStatusLink }, + }, + followedIds: { + conventionId, + }, }); } } diff --git a/back/src/domain/convention/useCases/notifications/NotifyAllActorsOfFinalConventionValidation.unit.test.ts b/back/src/domain/convention/useCases/notifications/NotifyAllActorsOfFinalConventionValidation.unit.test.ts index 5b150a1f74..6e61218099 100644 --- a/back/src/domain/convention/useCases/notifications/NotifyAllActorsOfFinalConventionValidation.unit.test.ts +++ b/back/src/domain/convention/useCases/notifications/NotifyAllActorsOfFinalConventionValidation.unit.test.ts @@ -23,7 +23,6 @@ import { CustomTimeGateway } from "../../../../adapters/secondary/core/TimeGatew import { UuidV4Generator } from "../../../../adapters/secondary/core/UuidGeneratorImplementations"; import { InMemoryUowPerformer } from "../../../../adapters/secondary/InMemoryUowPerformer"; import { DeterministShortLinkIdGeneratorGateway } from "../../../../adapters/secondary/shortLinkIdGeneratorGateway/DeterministShortLinkIdGeneratorGateway"; -import { makeCreateNewEvent } from "../../../core/eventBus/EventBus"; import { makeShortLinkUrl } from "../../../core/ShortLink"; import { EmailNotification, @@ -60,9 +59,7 @@ describe("NotifyAllActorsOfFinalApplicationValidation", () => { shortLinkIdGeneratorGateway.addMoreShortLinkIds([shortLinkId]); const uuidGenerator = new UuidV4Generator(); - const createNewEvent = makeCreateNewEvent({ uuidGenerator, timeGateway }); const saveNotificationAndRelatedEvent = makeSaveNotificationAndRelatedEvent( - createNewEvent, uuidGenerator, timeGateway, ); diff --git a/back/src/domain/convention/useCases/notifications/NotifyAllActorsThatConventionIsDeprecated.unit.test.ts b/back/src/domain/convention/useCases/notifications/NotifyAllActorsThatConventionIsDeprecated.unit.test.ts index 9ae6eb6906..8389ab55a9 100644 --- a/back/src/domain/convention/useCases/notifications/NotifyAllActorsThatConventionIsDeprecated.unit.test.ts +++ b/back/src/domain/convention/useCases/notifications/NotifyAllActorsThatConventionIsDeprecated.unit.test.ts @@ -13,7 +13,6 @@ import { import { CustomTimeGateway } from "../../../../adapters/secondary/core/TimeGateway/CustomTimeGateway"; import { UuidV4Generator } from "../../../../adapters/secondary/core/UuidGeneratorImplementations"; import { InMemoryUowPerformer } from "../../../../adapters/secondary/InMemoryUowPerformer"; -import { makeCreateNewEvent } from "../../../core/eventBus/EventBus"; import { EmailNotification, makeSaveNotificationAndRelatedEvent, @@ -70,9 +69,7 @@ describe("NotifyAllActorsThatApplicationIsDeprecated", () => { const timeGateway = new CustomTimeGateway(); const uuidGenerator = new UuidV4Generator(); - const createNewEvent = makeCreateNewEvent({ uuidGenerator, timeGateway }); const saveNotificationAndRelatedEvent = makeSaveNotificationAndRelatedEvent( - createNewEvent, uuidGenerator, timeGateway, ); diff --git a/back/src/domain/convention/useCases/notifications/NotifyBeneficiaryAndEnterpriseThatApplicationIsRejected.unit.test.ts b/back/src/domain/convention/useCases/notifications/NotifyBeneficiaryAndEnterpriseThatApplicationIsRejected.unit.test.ts index 510b700d1f..d2dbb0fb60 100644 --- a/back/src/domain/convention/useCases/notifications/NotifyBeneficiaryAndEnterpriseThatApplicationIsRejected.unit.test.ts +++ b/back/src/domain/convention/useCases/notifications/NotifyBeneficiaryAndEnterpriseThatApplicationIsRejected.unit.test.ts @@ -7,7 +7,6 @@ import { import { CustomTimeGateway } from "../../../../adapters/secondary/core/TimeGateway/CustomTimeGateway"; import { UuidV4Generator } from "../../../../adapters/secondary/core/UuidGeneratorImplementations"; import { InMemoryUowPerformer } from "../../../../adapters/secondary/InMemoryUowPerformer"; -import { makeCreateNewEvent } from "../../../core/eventBus/EventBus"; import { EmailNotification, makeSaveNotificationAndRelatedEvent, @@ -39,9 +38,7 @@ describe("NotifyBeneficiaryAndEnterpriseThatApplicationIsRejected", () => { const timeGateway = new CustomTimeGateway(); const uuidGenerator = new UuidV4Generator(); - const createNewEvent = makeCreateNewEvent({ uuidGenerator, timeGateway }); const saveNotificationAndRelatedEvent = makeSaveNotificationAndRelatedEvent( - createNewEvent, uuidGenerator, timeGateway, ); diff --git a/back/src/domain/convention/useCases/notifications/NotifyBeneficiaryAndEnterpriseThatApplicationNeedsModification.unit.test.ts b/back/src/domain/convention/useCases/notifications/NotifyBeneficiaryAndEnterpriseThatApplicationNeedsModification.unit.test.ts index 9aa18f558b..5cec57a939 100644 --- a/back/src/domain/convention/useCases/notifications/NotifyBeneficiaryAndEnterpriseThatApplicationNeedsModification.unit.test.ts +++ b/back/src/domain/convention/useCases/notifications/NotifyBeneficiaryAndEnterpriseThatApplicationNeedsModification.unit.test.ts @@ -22,7 +22,6 @@ import { CustomTimeGateway } from "../../../../adapters/secondary/core/TimeGatew import { UuidV4Generator } from "../../../../adapters/secondary/core/UuidGeneratorImplementations"; import { InMemoryUowPerformer } from "../../../../adapters/secondary/InMemoryUowPerformer"; import { DeterministShortLinkIdGeneratorGateway } from "../../../../adapters/secondary/shortLinkIdGeneratorGateway/DeterministShortLinkIdGeneratorGateway"; -import { makeCreateNewEvent } from "../../../core/eventBus/EventBus"; import { TimeGateway } from "../../../core/ports/TimeGateway"; import { makeShortLinkUrl } from "../../../core/ShortLink"; import { makeSaveNotificationAndRelatedEvent } from "../../../generic/notifications/entities/Notification"; @@ -72,9 +71,7 @@ describe("NotifyBeneficiaryAndEnterpriseThatApplicationNeedsModification", () => shortLinkIdGateway = new DeterministShortLinkIdGeneratorGateway(); const uuidGenerator = new UuidV4Generator(); - const createNewEvent = makeCreateNewEvent({ uuidGenerator, timeGateway }); const saveNotificationAndRelatedEvent = makeSaveNotificationAndRelatedEvent( - createNewEvent, uuidGenerator, timeGateway, ); diff --git a/back/src/domain/convention/useCases/notifications/NotifyConventionReminder.unit.test.ts b/back/src/domain/convention/useCases/notifications/NotifyConventionReminder.unit.test.ts index 9f2915e0c9..75d8558d35 100644 --- a/back/src/domain/convention/useCases/notifications/NotifyConventionReminder.unit.test.ts +++ b/back/src/domain/convention/useCases/notifications/NotifyConventionReminder.unit.test.ts @@ -33,10 +33,6 @@ import { CustomTimeGateway } from "../../../../adapters/secondary/core/TimeGatew import { UuidV4Generator } from "../../../../adapters/secondary/core/UuidGeneratorImplementations"; import { InMemoryUowPerformer } from "../../../../adapters/secondary/InMemoryUowPerformer"; import { DeterministShortLinkIdGeneratorGateway } from "../../../../adapters/secondary/shortLinkIdGeneratorGateway/DeterministShortLinkIdGeneratorGateway"; -import { - CreateNewEvent, - makeCreateNewEvent, -} from "../../../core/eventBus/EventBus"; import { ReminderKind } from "../../../core/eventsPayloads/ConventionReminderPayload"; import { TimeGateway } from "../../../core/ports/TimeGateway"; import { makeShortLinkUrl } from "../../../core/ShortLink"; @@ -65,7 +61,6 @@ describe("NotifyThatConventionStillNeedToBeSigned use case", () => { let timeGateway: CustomTimeGateway; let shortLinkIdGeneratorGateway: DeterministShortLinkIdGeneratorGateway; let config: AppConfig; - let createNewEvent: CreateNewEvent; let expectSavedNotificationsAndEvents: ExpectSavedNotificationsAndEvents; beforeEach(() => { @@ -74,12 +69,7 @@ describe("NotifyThatConventionStillNeedToBeSigned use case", () => { const uuidGenerator = new UuidV4Generator(); shortLinkIdGeneratorGateway = new DeterministShortLinkIdGeneratorGateway(); uow = createInMemoryUow(); - createNewEvent = makeCreateNewEvent({ - timeGateway, - uuidGenerator, - }); const saveNotificationAndRelatedEvent = makeSaveNotificationAndRelatedEvent( - createNewEvent, uuidGenerator, timeGateway, ); diff --git a/back/src/domain/convention/useCases/notifications/NotifyIcUserAgencyRightChanged.ts b/back/src/domain/convention/useCases/notifications/NotifyIcUserAgencyRightChanged.ts index 52087a3291..3ed6d60dc8 100644 --- a/back/src/domain/convention/useCases/notifications/NotifyIcUserAgencyRightChanged.ts +++ b/back/src/domain/convention/useCases/notifications/NotifyIcUserAgencyRightChanged.ts @@ -8,7 +8,7 @@ import { UnitOfWorkPerformer, } from "../../../core/ports/UnitOfWork"; import { TransactionalUseCase } from "../../../core/UseCase"; -import { NotificationGateway } from "../../../generic/notifications/ports/NotificationGateway"; +import { SaveNotificationAndRelatedEvent } from "../../../generic/notifications/entities/Notification"; export class NotifyIcUserAgencyRightChanged extends TransactionalUseCase< IcUserRoleForAgencyParams, @@ -18,7 +18,7 @@ export class NotifyIcUserAgencyRightChanged extends TransactionalUseCase< constructor( uowPerformer: UnitOfWorkPerformer, - private readonly notificationGateway: NotificationGateway, + private readonly saveNotificationAndRelatedEvent: SaveNotificationAndRelatedEvent, ) { super(uowPerformer); } @@ -41,11 +41,18 @@ export class NotifyIcUserAgencyRightChanged extends TransactionalUseCase< throw new NotFoundError(`User with id ${params.userId} not found`); if (params.role !== "toReview") - await this.notificationGateway.sendEmail({ - type: "IC_USER_RIGHTS_HAS_CHANGED", - recipients: [user.email], - params: { - agencyName: agency.name, + await this.saveNotificationAndRelatedEvent(uow, { + kind: "email", + templatedContent: { + type: "IC_USER_RIGHTS_HAS_CHANGED", + recipients: [user.email], + params: { + agencyName: agency.name, + }, + }, + followedIds: { + agencyId: agency.id, + userId: user.id, }, }); } diff --git a/back/src/domain/convention/useCases/notifications/NotifyIcUserAgencyRightChanged.unit.test.ts b/back/src/domain/convention/useCases/notifications/NotifyIcUserAgencyRightChanged.unit.test.ts index ea32fb59f5..82ed7ec8a4 100644 --- a/back/src/domain/convention/useCases/notifications/NotifyIcUserAgencyRightChanged.unit.test.ts +++ b/back/src/domain/convention/useCases/notifications/NotifyIcUserAgencyRightChanged.unit.test.ts @@ -1,16 +1,21 @@ import { AgencyDtoBuilder, expectPromiseToFailWith, - expectToEqual, IcUserRoleForAgencyParams, InclusionConnectedUser, } from "shared"; +import { + ExpectSavedNotificationsAndEvents, + makeExpectSavedNotificationsAndEvents, +} from "../../../../_testBuilders/makeExpectSavedNotificationsAndEvents"; import { createInMemoryUow, InMemoryUnitOfWork, } from "../../../../adapters/primary/config/uowConfig"; +import { CustomTimeGateway } from "../../../../adapters/secondary/core/TimeGateway/CustomTimeGateway"; +import { UuidV4Generator } from "../../../../adapters/secondary/core/UuidGeneratorImplementations"; import { InMemoryUowPerformer } from "../../../../adapters/secondary/InMemoryUowPerformer"; -import { InMemoryNotificationGateway } from "../../../../adapters/secondary/notificationGateway/InMemoryNotificationGateway"; +import { makeSaveNotificationAndRelatedEvent } from "../../../generic/notifications/entities/Notification"; import { NotifyIcUserAgencyRightChanged } from "./NotifyIcUserAgencyRightChanged"; const icUserRoleParams: IcUserRoleForAgencyParams = { @@ -20,18 +25,28 @@ const icUserRoleParams: IcUserRoleForAgencyParams = { }; describe("SendEmailWhenAgencyIsActivated", () => { - let notificationGateway: InMemoryNotificationGateway; let uow: InMemoryUnitOfWork; let uowPerformer: InMemoryUowPerformer; let notifyIcUserAgencyRightChanged: NotifyIcUserAgencyRightChanged; + let expectSavedNotificationsAndEvents: ExpectSavedNotificationsAndEvents; beforeEach(() => { - notificationGateway = new InMemoryNotificationGateway(); uow = createInMemoryUow(); uowPerformer = new InMemoryUowPerformer(uow); + expectSavedNotificationsAndEvents = makeExpectSavedNotificationsAndEvents( + uow.notificationRepository, + uow.outboxRepository, + ); + + const timeGateway = new CustomTimeGateway(); + const uuidGenerator = new UuidV4Generator(); + const saveNotificationAndRelatedEvent = makeSaveNotificationAndRelatedEvent( + uuidGenerator, + timeGateway, + ); notifyIcUserAgencyRightChanged = new NotifyIcUserAgencyRightChanged( uowPerformer, - notificationGateway, + saveNotificationAndRelatedEvent, ); }); it("throw error when no agency found", async () => { @@ -40,7 +55,9 @@ describe("SendEmailWhenAgencyIsActivated", () => { `Unable to send mail. No agency config found for ${icUserRoleParams.agencyId}`, ); - expectToEqual(notificationGateway.getSentEmails(), []); + expectSavedNotificationsAndEvents({ + emails: [], + }); }); it("throw error when no user found", async () => { @@ -56,7 +73,9 @@ describe("SendEmailWhenAgencyIsActivated", () => { `User with id ${icUserRoleParams.userId} not found`, ); - expectToEqual(notificationGateway.getSentEmails(), []); + expectSavedNotificationsAndEvents({ + emails: [], + }); }); it("Sends an email to validators with agency name", async () => { @@ -84,15 +103,17 @@ describe("SendEmailWhenAgencyIsActivated", () => { await notifyIcUserAgencyRightChanged.execute(icUserRoleParams); - const sentEmails = notificationGateway.getSentEmails(); - expectToEqual(sentEmails, [ - { - type: "IC_USER_RIGHTS_HAS_CHANGED", - params: { agencyName: agency.name }, - recipients: [icUser.email], - }, - ]); + expectSavedNotificationsAndEvents({ + emails: [ + { + type: "IC_USER_RIGHTS_HAS_CHANGED", + params: { agencyName: agency.name }, + recipients: [icUser.email], + }, + ], + }); }); + it("Should not sends an email to validators with agency name when the new role is: to review", async () => { const agency = new AgencyDtoBuilder() .withId("agency-1") @@ -122,7 +143,8 @@ describe("SendEmailWhenAgencyIsActivated", () => { userId: "jbab-123", }); - const sentEmails = notificationGateway.getSentEmails(); - expect(sentEmails).toHaveLength(0); + expectSavedNotificationsAndEvents({ + emails: [], + }); }); }); diff --git a/back/src/domain/convention/useCases/notifications/NotifyLastSigneeThatConventionHasBeenSigned.unit.test.ts b/back/src/domain/convention/useCases/notifications/NotifyLastSigneeThatConventionHasBeenSigned.unit.test.ts index a3d6c981d0..3e6f3bfb6d 100644 --- a/back/src/domain/convention/useCases/notifications/NotifyLastSigneeThatConventionHasBeenSigned.unit.test.ts +++ b/back/src/domain/convention/useCases/notifications/NotifyLastSigneeThatConventionHasBeenSigned.unit.test.ts @@ -17,7 +17,6 @@ import { import { CustomTimeGateway } from "../../../../adapters/secondary/core/TimeGateway/CustomTimeGateway"; import { UuidV4Generator } from "../../../../adapters/secondary/core/UuidGeneratorImplementations"; import { InMemoryUowPerformer } from "../../../../adapters/secondary/InMemoryUowPerformer"; -import { makeCreateNewEvent } from "../../../core/eventBus/EventBus"; import { makeSaveNotificationAndRelatedEvent } from "../../../generic/notifications/entities/Notification"; import { missingConventionMessage, @@ -50,9 +49,7 @@ describe("NotifyLastSigneeThatConventionHasBeenSigned", () => { timeGateway = new CustomTimeGateway(); const uuidGenerator = new UuidV4Generator(); - const createNewEvent = makeCreateNewEvent({ uuidGenerator, timeGateway }); const saveNotificationAndRelatedEvent = makeSaveNotificationAndRelatedEvent( - createNewEvent, uuidGenerator, timeGateway, ); diff --git a/back/src/domain/convention/useCases/notifications/NotifyNewApplicationNeedsReview.unit.test.ts b/back/src/domain/convention/useCases/notifications/NotifyNewApplicationNeedsReview.unit.test.ts index dd4a83268b..04f1c60d12 100644 --- a/back/src/domain/convention/useCases/notifications/NotifyNewApplicationNeedsReview.unit.test.ts +++ b/back/src/domain/convention/useCases/notifications/NotifyNewApplicationNeedsReview.unit.test.ts @@ -20,7 +20,6 @@ import { CustomTimeGateway } from "../../../../adapters/secondary/core/TimeGatew import { UuidV4Generator } from "../../../../adapters/secondary/core/UuidGeneratorImplementations"; import { InMemoryUowPerformer } from "../../../../adapters/secondary/InMemoryUowPerformer"; import { DeterministShortLinkIdGeneratorGateway } from "../../../../adapters/secondary/shortLinkIdGeneratorGateway/DeterministShortLinkIdGeneratorGateway"; -import { makeCreateNewEvent } from "../../../core/eventBus/EventBus"; import { makeShortLinkUrl } from "../../../core/ShortLink"; import { makeSaveNotificationAndRelatedEvent } from "../../../generic/notifications/entities/Notification"; import { NotifyNewApplicationNeedsReview } from "./NotifyNewApplicationNeedsReview"; @@ -48,9 +47,7 @@ describe("NotifyImmersionApplicationNeedsReview", () => { uow.outboxRepository, ); const uuidGenerator = new UuidV4Generator(); - const createNewEvent = makeCreateNewEvent({ uuidGenerator, timeGateway }); const saveNotificationAndRelatedEvent = makeSaveNotificationAndRelatedEvent( - createNewEvent, uuidGenerator, timeGateway, ); diff --git a/back/src/domain/convention/useCases/notifications/NotifyToAgencyApplicationSubmitted.unit.test.ts b/back/src/domain/convention/useCases/notifications/NotifyToAgencyApplicationSubmitted.unit.test.ts index e3acaffcfd..fb996f3db3 100644 --- a/back/src/domain/convention/useCases/notifications/NotifyToAgencyApplicationSubmitted.unit.test.ts +++ b/back/src/domain/convention/useCases/notifications/NotifyToAgencyApplicationSubmitted.unit.test.ts @@ -22,7 +22,6 @@ import { CustomTimeGateway } from "../../../../adapters/secondary/core/TimeGatew import { UuidV4Generator } from "../../../../adapters/secondary/core/UuidGeneratorImplementations"; import { InMemoryUowPerformer } from "../../../../adapters/secondary/InMemoryUowPerformer"; import { DeterministShortLinkIdGeneratorGateway } from "../../../../adapters/secondary/shortLinkIdGeneratorGateway/DeterministShortLinkIdGeneratorGateway"; -import { makeCreateNewEvent } from "../../../core/eventBus/EventBus"; import { makeShortLinkUrl } from "../../../core/ShortLink"; import { makeSaveNotificationAndRelatedEvent } from "../../../generic/notifications/entities/Notification"; import { NotifyToAgencyApplicationSubmitted } from "./NotifyToAgencyApplicationSubmitted"; @@ -98,9 +97,7 @@ describe("NotifyToAgencyApplicationSubmitted", () => { }); const uuidGenerator = new UuidV4Generator(); - const createNewEvent = makeCreateNewEvent({ uuidGenerator, timeGateway }); const saveNotificationAndRelatedEvent = makeSaveNotificationAndRelatedEvent( - createNewEvent, uuidGenerator, timeGateway, ); diff --git a/back/src/domain/generic/notifications/entities/Notification.ts b/back/src/domain/generic/notifications/entities/Notification.ts index 20dc3e09a0..9722c3928f 100644 --- a/back/src/domain/generic/notifications/entities/Notification.ts +++ b/back/src/domain/generic/notifications/entities/Notification.ts @@ -1,12 +1,16 @@ import { AgencyId, + AuthenticatedUserId, ConventionId, Flavor, SiretDto, TemplatedEmail, TemplatedSms, } from "shared"; -import { CreateNewEvent } from "../../../core/eventBus/EventBus"; +import { + CreateNewEvent, + makeCreateNewEvent, +} from "../../../core/eventBus/EventBus"; import { DateStr, TimeGateway } from "../../../core/ports/TimeGateway"; import { UnitOfWork } from "../../../core/ports/UnitOfWork"; import { UuidGenerator } from "../../../core/ports/UuidGenerator"; @@ -17,6 +21,7 @@ export type FollowedIds = { conventionId?: ConventionId; establishmentSiret?: SiretDto; agencyId?: AgencyId; + userId?: AuthenticatedUserId; }; export type NotificationKind = (typeof notificationKinds)[number]; @@ -53,9 +58,12 @@ export type SaveNotificationAndRelatedEvent = ReturnType< >; export const makeSaveNotificationAndRelatedEvent = ( - createNewEvent: CreateNewEvent, uuidGenerator: UuidGenerator, timeGateway: TimeGateway, + createNewEvent: CreateNewEvent = makeCreateNewEvent({ + uuidGenerator, + timeGateway, + }), ) => async ( uow: UnitOfWork, diff --git a/back/src/domain/immersionOffer/useCases/RequestEditFormEstablishment.ts b/back/src/domain/immersionOffer/useCases/RequestEditFormEstablishment.ts index 5afe8fa709..0a4048723d 100644 --- a/back/src/domain/immersionOffer/useCases/RequestEditFormEstablishment.ts +++ b/back/src/domain/immersionOffer/useCases/RequestEditFormEstablishment.ts @@ -10,14 +10,14 @@ import { CreateNewEvent } from "../../core/eventBus/EventBus"; import { TimeGateway } from "../../core/ports/TimeGateway"; import { UnitOfWork, UnitOfWorkPerformer } from "../../core/ports/UnitOfWork"; import { TransactionalUseCase } from "../../core/UseCase"; -import { NotificationGateway } from "../../generic/notifications/ports/NotificationGateway"; +import { SaveNotificationAndRelatedEvent } from "../../generic/notifications/entities/Notification"; export class RequestEditFormEstablishment extends TransactionalUseCase { inputSchema = siretSchema; constructor( uowPerformer: UnitOfWorkPerformer, - private notificationGateway: NotificationGateway, + private readonly saveNotificationAndRelatedEvent: SaveNotificationAndRelatedEvent, private timeGateway: TimeGateway, private generateEditFormEstablishmentUrl: GenerateEditFormEstablishmentJwt, private createNewEvent: CreateNewEvent, @@ -60,11 +60,17 @@ export class RequestEditFormEstablishment extends TransactionalUseCase const editFrontUrl = this.generateEditFormEstablishmentUrl(payload); - await this.notificationGateway.sendEmail({ - type: "EDIT_FORM_ESTABLISHMENT_LINK", - recipients: [contact.email], - cc: contact.copyEmails, - params: { editFrontUrl }, + await this.saveNotificationAndRelatedEvent(uow, { + kind: "email", + templatedContent: { + type: "EDIT_FORM_ESTABLISHMENT_LINK", + recipients: [contact.email], + cc: contact.copyEmails, + params: { editFrontUrl }, + }, + followedIds: { + establishmentSiret: siret, + }, }); const event = this.createNewEvent({ diff --git a/back/src/domain/immersionOffer/useCases/RequestEditFormEstablishment.unit.test.ts b/back/src/domain/immersionOffer/useCases/RequestEditFormEstablishment.unit.test.ts index f9442be205..807052701e 100644 --- a/back/src/domain/immersionOffer/useCases/RequestEditFormEstablishment.unit.test.ts +++ b/back/src/domain/immersionOffer/useCases/RequestEditFormEstablishment.unit.test.ts @@ -1,19 +1,16 @@ -import { - EstablishmentJwtPayload, - expectPromiseToFailWithError, - TemplatedEmail, -} from "shared"; +import { EstablishmentJwtPayload, expectPromiseToFailWithError } from "shared"; import { ContactEntityBuilder } from "../../../_testBuilders/ContactEntityBuilder"; import { EstablishmentAggregateBuilder } from "../../../_testBuilders/EstablishmentAggregateBuilder"; +import { makeExpectSavedNotificationsAndEvents } from "../../../_testBuilders/makeExpectSavedNotificationsAndEvents"; import { createInMemoryUow } from "../../../adapters/primary/config/uowConfig"; import { BadRequestError } from "../../../adapters/primary/helpers/httpErrors"; import { CustomTimeGateway } from "../../../adapters/secondary/core/TimeGateway/CustomTimeGateway"; import { UuidV4Generator } from "../../../adapters/secondary/core/UuidGeneratorImplementations"; import { InMemoryUowPerformer } from "../../../adapters/secondary/InMemoryUowPerformer"; -import { InMemoryNotificationGateway } from "../../../adapters/secondary/notificationGateway/InMemoryNotificationGateway"; -import { makeCreateNewEvent } from "../../../domain/core/eventBus/EventBus"; -import { EstablishmentAggregateRepository } from "../../../domain/immersionOffer/ports/EstablishmentAggregateRepository"; -import { RequestEditFormEstablishment } from "../../../domain/immersionOffer/useCases/RequestEditFormEstablishment"; +import { makeCreateNewEvent } from "../../core/eventBus/EventBus"; +import { makeSaveNotificationAndRelatedEvent } from "../../generic/notifications/entities/Notification"; +import { EstablishmentAggregateRepository } from "../ports/EstablishmentAggregateRepository"; +import { RequestEditFormEstablishment } from "./RequestEditFormEstablishment"; const siret = "12345678912345"; const contactEmail = "jerome@gmail.com"; @@ -40,32 +37,40 @@ const prepareUseCase = () => { const outboxQueries = uow.outboxQueries; const establishmentAggregateRepository = uow.establishmentAggregateRepository; + const expectSavedNotificationsAndEvents = + makeExpectSavedNotificationsAndEvents( + uow.notificationRepository, + uow.outboxRepository, + ); + setMethodGetContactEmailFromSiret(establishmentAggregateRepository); // In most of the tests, we need the contact to be defined const timeGateway = new CustomTimeGateway(); - const notificationGateway = new InMemoryNotificationGateway(); const uuidGenerator = new UuidV4Generator(); + const createNewEvent = makeCreateNewEvent({ uuidGenerator, timeGateway }); + const saveNotificationAndRelatedEvent = makeSaveNotificationAndRelatedEvent( + uuidGenerator, + timeGateway, + createNewEvent, + ); const generateEditFormEstablishmentUrl = (payload: EstablishmentJwtPayload) => `www.immersion-facile.fr/edit?jwt=jwtOfSiret[${payload.siret}]`; const useCase = new RequestEditFormEstablishment( new InMemoryUowPerformer(uow), - notificationGateway, + saveNotificationAndRelatedEvent, timeGateway, generateEditFormEstablishmentUrl, - makeCreateNewEvent({ - timeGateway, - uuidGenerator, - }), + createNewEvent, ); return { useCase, outboxQueries, outboxRepository, establishmentAggregateRepository, - notificationGateway, timeGateway, + expectSavedNotificationsAndEvents, }; }; @@ -89,24 +94,26 @@ describe("RequestUpdateFormEstablishment", () => { describe("If no email has been sent yet.", () => { it("Sends an email to the contact of the establishment with eventually email in CC", async () => { // Prepare - const { useCase, notificationGateway } = prepareUseCase(); + const { useCase, expectSavedNotificationsAndEvents } = prepareUseCase(); // Act await useCase.execute(siret); // Assert - const actualSentEmails = notificationGateway.getSentEmails(); - expect(actualSentEmails).toHaveLength(1); - const expectedEmail: TemplatedEmail = { - type: "EDIT_FORM_ESTABLISHMENT_LINK", - recipients: [contactEmail], - cc: copyEmails, - params: { - editFrontUrl: `www.immersion-facile.fr/edit?jwt=jwtOfSiret[${siret}]`, - }, - }; - expect(actualSentEmails[0]).toEqual(expectedEmail); + expectSavedNotificationsAndEvents({ + emails: [ + { + type: "EDIT_FORM_ESTABLISHMENT_LINK", + recipients: [contactEmail], + cc: copyEmails, + params: { + editFrontUrl: `www.immersion-facile.fr/edit?jwt=jwtOfSiret[${siret}]`, + }, + }, + ], + }); }); + it("Saves an event in outbox repo", async () => { // Prepare const { useCase, outboxRepository } = prepareUseCase(); @@ -115,8 +122,8 @@ describe("RequestUpdateFormEstablishment", () => { await useCase.execute(siret); // Assert - expect(outboxRepository.events).toHaveLength(1); - expect(outboxRepository.events[0]).toMatchObject({ + expect(outboxRepository.events).toHaveLength(2); + expect(outboxRepository.events[1]).toMatchObject({ topic: "FormEstablishmentEditLinkSent", payload: { siret }, }); @@ -154,7 +161,7 @@ describe("RequestUpdateFormEstablishment", () => { useCase, outboxRepository, outboxQueries, - notificationGateway, + expectSavedNotificationsAndEvents, timeGateway, } = prepareUseCase(); @@ -172,7 +179,19 @@ describe("RequestUpdateFormEstablishment", () => { await useCase.execute(siret); // Assert - expect(notificationGateway.getSentEmails()).toHaveLength(1); - expect(outboxRepository.events).toHaveLength(1); + expectSavedNotificationsAndEvents({ + emails: [ + { + type: "EDIT_FORM_ESTABLISHMENT_LINK", + recipients: ["jerome@gmail.com"], + cc: ["copy@gmail.com"], + params: { + editFrontUrl: + "www.immersion-facile.fr/edit?jwt=jwtOfSiret[12345678912345]", + }, + }, + ], + }); + expect(outboxRepository.events).toHaveLength(2); }); }); diff --git a/back/src/domain/immersionOffer/useCases/notifications/NotifyConfirmationEstablishmentCreated.unit.test.ts b/back/src/domain/immersionOffer/useCases/notifications/NotifyConfirmationEstablishmentCreated.unit.test.ts index 0dec1991e5..7f40931814 100644 --- a/back/src/domain/immersionOffer/useCases/notifications/NotifyConfirmationEstablishmentCreated.unit.test.ts +++ b/back/src/domain/immersionOffer/useCases/notifications/NotifyConfirmationEstablishmentCreated.unit.test.ts @@ -7,7 +7,6 @@ import { createInMemoryUow } from "../../../../adapters/primary/config/uowConfig import { CustomTimeGateway } from "../../../../adapters/secondary/core/TimeGateway/CustomTimeGateway"; import { UuidV4Generator } from "../../../../adapters/secondary/core/UuidGeneratorImplementations"; import { InMemoryUowPerformer } from "../../../../adapters/secondary/InMemoryUowPerformer"; -import { makeCreateNewEvent } from "../../../core/eventBus/EventBus"; import { makeSaveNotificationAndRelatedEvent } from "../../../generic/notifications/entities/Notification"; import { NotifyConfirmationEstablishmentCreated } from "./NotifyConfirmationEstablishmentCreated"; @@ -21,9 +20,7 @@ describe("NotifyConfirmationEstablismentCreated", () => { const uowPerformer = new InMemoryUowPerformer(uow); const uuidGenerator = new UuidV4Generator(); const timeGateway = new CustomTimeGateway(); - const createNewEvent = makeCreateNewEvent({ uuidGenerator, timeGateway }); const saveNotificationAndRelatedEvent = makeSaveNotificationAndRelatedEvent( - createNewEvent, uuidGenerator, timeGateway, ); diff --git a/back/src/domain/immersionOffer/useCases/notifications/NotifyContactRequest.unit.test.ts b/back/src/domain/immersionOffer/useCases/notifications/NotifyContactRequest.unit.test.ts index 99201ecd44..18bc4763cf 100644 --- a/back/src/domain/immersionOffer/useCases/notifications/NotifyContactRequest.unit.test.ts +++ b/back/src/domain/immersionOffer/useCases/notifications/NotifyContactRequest.unit.test.ts @@ -15,7 +15,6 @@ import { TEST_ROME_LABEL, } from "../../../../adapters/secondary/immersionOffer/InMemoryEstablishmentAggregateRepository"; import { InMemoryUowPerformer } from "../../../../adapters/secondary/InMemoryUowPerformer"; -import { makeCreateNewEvent } from "../../../core/eventBus/EventBus"; import { makeSaveNotificationAndRelatedEvent } from "../../../generic/notifications/entities/Notification"; import { NotifyContactRequest } from "./NotifyContactRequest"; @@ -53,9 +52,7 @@ describe("NotifyContactRequest", () => { const uuidGenerator = new UuidV4Generator(); const timeGateway = new CustomTimeGateway(); - const createNewEvent = makeCreateNewEvent({ uuidGenerator, timeGateway }); const saveNotificationAndRelatedEvent = makeSaveNotificationAndRelatedEvent( - createNewEvent, uuidGenerator, timeGateway, ); diff --git a/back/src/domain/peConnect/useCases/NotifyPoleEmploiUserAdvisorOnConventionFullySigned.unit.test.ts b/back/src/domain/peConnect/useCases/NotifyPoleEmploiUserAdvisorOnConventionFullySigned.unit.test.ts index 97ce118b85..109636ef96 100644 --- a/back/src/domain/peConnect/useCases/NotifyPoleEmploiUserAdvisorOnConventionFullySigned.unit.test.ts +++ b/back/src/domain/peConnect/useCases/NotifyPoleEmploiUserAdvisorOnConventionFullySigned.unit.test.ts @@ -16,7 +16,6 @@ import { import { CustomTimeGateway } from "../../../adapters/secondary/core/TimeGateway/CustomTimeGateway"; import { UuidV4Generator } from "../../../adapters/secondary/core/UuidGeneratorImplementations"; import { InMemoryUowPerformer } from "../../../adapters/secondary/InMemoryUowPerformer"; -import { makeCreateNewEvent } from "../../core/eventBus/EventBus"; import { makeSaveNotificationAndRelatedEvent } from "../../generic/notifications/entities/Notification"; import { PeUserAndAdvisor } from "../dto/PeConnect.dto"; import { PeConnectImmersionAdvisorDto } from "../dto/PeConnectAdvisor.dto"; @@ -37,9 +36,7 @@ describe("NotifyPoleEmploiUserAdvisorOnConventionFullySigned", () => { uow.outboxRepository, ); const uuidGenerator = new UuidV4Generator(); - const createNewEvent = makeCreateNewEvent({ uuidGenerator, timeGateway }); const saveNotificationAndRelatedEvent = makeSaveNotificationAndRelatedEvent( - createNewEvent, uuidGenerator, timeGateway, ); diff --git a/back/src/utils/notifyDiscord.manual.test.ts b/back/src/utils/notifyDiscord.manual.test.ts index 9bc4786f7a..c27281322c 100644 --- a/back/src/utils/notifyDiscord.manual.test.ts +++ b/back/src/utils/notifyDiscord.manual.test.ts @@ -28,6 +28,7 @@ describe("Notify Discord", () => { emails: ["test@mail.com"], magicLink: "http://0000magicLink00000", conventionStatusLink: "http://0000conventionStatusLink00000", + conventionId: "123", }, publications: [ {