chore: Treat internal event differently, primarely do not display info logs for those events (#8767)

* chore: Treat internal event differently, primarely do not display info log for those events

* revert doc

* add few tests

* only set internal option if present

* revert to previous condition

* start including feedback after discussion

* include feedback

* fix modules integration tests

* fix modules integration tests

* fix event bus local
This commit is contained in:
Adrien de Peretti
2024-08-28 16:46:40 +02:00
committed by GitHub
parent 6cfe9bd874
commit 5bec38538a
27 changed files with 915 additions and 465 deletions
@@ -1,10 +1,10 @@
import { INotificationModuleService } from "@medusajs/types"
import {
CommonEvents,
composeMessage,
Module,
Modules,
NotificationEvents,
composeMessage,
} from "@medusajs/utils"
import {
MockEventBusService,
@@ -94,14 +94,19 @@ moduleIntegrationTestRunner({
const result = await service.createNotifications(notification)
expect(eventBusEmitSpy.mock.calls[0][0]).toHaveLength(1)
expect(eventBusEmitSpy).toHaveBeenCalledWith([
composeMessage(NotificationEvents.NOTIFICATION_CREATED, {
data: { id: result.id },
object: "notification",
source: Modules.NOTIFICATION,
action: CommonEvents.CREATED,
}),
])
expect(eventBusEmitSpy).toHaveBeenCalledWith(
[
composeMessage(NotificationEvents.NOTIFICATION_CREATED, {
data: { id: result.id },
object: "notification",
source: Modules.NOTIFICATION,
action: CommonEvents.CREATED,
}),
],
{
internal: true,
}
)
})
it("ensures the same notification is not sent twice", async () => {