chore: ability to group events on redis event bus (#7655)

* chore: ability to group events on redis event bus

* chore: fix tests

* Update packages/modules/event-bus-redis/src/services/event-bus-redis.ts

Co-authored-by: Adrien de Peretti <adrien.deperetti@gmail.com>

* chore: change shape of input and body data

* chore: fix builds

* chore: address comments

* chore: fix unit test

---------

Co-authored-by: Adrien de Peretti <adrien.deperetti@gmail.com>
This commit is contained in:
Riqwan Thamir
2024-06-10 22:15:43 +02:00
committed by GitHub
co-authored by Adrien de Peretti
parent 3b8160b564
commit 39ddba2491
24 changed files with 924 additions and 732 deletions
@@ -291,8 +291,9 @@ moduleIntegrationTestRunner<IProductModuleService>({
})
expect(eventBusSpy).toHaveBeenCalledTimes(1)
expect(eventBusSpy).toHaveBeenCalledWith("product-category.created", {
id: category.id,
expect(eventBusSpy).toHaveBeenCalledWith({
data: { id: category.id },
eventName: "product-category.created",
})
})
@@ -380,8 +381,9 @@ moduleIntegrationTestRunner<IProductModuleService>({
})
expect(eventBusSpy).toHaveBeenCalledTimes(1)
expect(eventBusSpy).toHaveBeenCalledWith("product-category.updated", {
id: productCategoryZero.id,
expect(eventBusSpy).toHaveBeenCalledWith({
data: { id: productCategoryZero.id },
eventName: "product-category.updated",
})
})
@@ -547,8 +549,9 @@ moduleIntegrationTestRunner<IProductModuleService>({
await service.deleteCategory(productCategoryOne.id)
expect(eventBusSpy).toHaveBeenCalledTimes(1)
expect(eventBusSpy).toHaveBeenCalledWith("product-category.deleted", {
id: productCategoryOne.id,
expect(eventBusSpy).toHaveBeenCalledWith({
data: { id: productCategoryOne.id },
eventName: "product-category.deleted",
})
})
@@ -298,8 +298,8 @@ moduleIntegrationTestRunner<IProductModuleService>({
expect(eventBusSpy).toHaveBeenCalledTimes(1)
expect(eventBusSpy).toHaveBeenCalledWith([
{
eventName: "product-collection.updated",
data: { id: collectionId },
eventName: "product-collection.updated",
},
])
})
@@ -488,16 +488,14 @@ moduleIntegrationTestRunner<IProductModuleService>({
const eventBusSpy = jest.spyOn(MockEventBusService.prototype, "emit")
const collections = await service.createCollections([
{
title: "New Collection",
},
{ title: "New Collection" },
])
expect(eventBusSpy).toHaveBeenCalledTimes(1)
expect(eventBusSpy).toHaveBeenCalledWith([
{
eventName: "product-collection.created",
data: { id: collections[0].id },
eventName: "product-collection.created",
},
])
})