feat: restructure events payload (#8143)

* refactor: restructure events payload

Breaking change: This PR changes the event payload accepted by the event
listeners

* refactor: fix failing tests and implement feedback

* add integration tests

* fix timeout

---------

Co-authored-by: Adrien de Peretti <adrien.deperetti@gmail.com>
This commit is contained in:
Harminder Virk
2024-07-16 17:09:16 +01:00
committed by GitHub
co-authored by Adrien de Peretti
parent 5813216c88
commit f579f0b3be
26 changed files with 194 additions and 111 deletions
@@ -681,7 +681,7 @@ moduleIntegrationTestRunner<IProductModuleService>({
expect(eventBusSpy).toHaveBeenCalledWith([
expect.objectContaining({
data: { id: productCategoryOne.id },
eventName: "product-category.deleted",
name: "product-category.deleted",
metadata: {
action: "",
object: "",
@@ -280,7 +280,7 @@ moduleIntegrationTestRunner<IProductModuleService>({
expect(eventBusSpy).toHaveBeenCalledTimes(1)
expect(eventBusSpy).toHaveBeenCalledWith([
{
eventName: "product-collection.deleted",
name: "product-collection.deleted",
data: { id: collectionId },
metadata: {
action: "",
@@ -309,7 +309,7 @@ moduleIntegrationTestRunner<IProductModuleService>({
expect(eventBusSpy).toHaveBeenCalledWith([
{
data: { id: collectionId },
eventName: "product-collection.updated",
name: "product-collection.updated",
},
])
})
@@ -505,7 +505,7 @@ moduleIntegrationTestRunner<IProductModuleService>({
expect(eventBusSpy).toHaveBeenCalledWith([
{
data: { id: collections[0].id },
eventName: "product-collection.created",
name: "product-collection.created",
},
])
})
@@ -283,7 +283,7 @@ moduleIntegrationTestRunner<IProductModuleService>({
expect(eventBusSpy).toHaveBeenCalledTimes(1)
expect(eventBusSpy).toHaveBeenCalledWith([
{
eventName: "product.updated",
name: "product.updated",
data: { id: productOne.id },
},
])
@@ -631,7 +631,7 @@ moduleIntegrationTestRunner<IProductModuleService>({
expect(eventBusSpy).toHaveBeenCalledTimes(1)
expect(eventBusSpy).toHaveBeenCalledWith([
{
eventName: "product.created",
name: "product.created",
data: { id: products[0].id },
},
])
@@ -721,7 +721,7 @@ moduleIntegrationTestRunner<IProductModuleService>({
expect(eventBusSpy).toHaveBeenCalledWith([
{
eventName: "product.created",
name: "product.created",
data: { id: products[0].id },
},
])