chore(product): Update the events emitted from the product module (#9557)
This commit is contained in:
committed by
GitHub
parent
b40fa6353e
commit
d8b7f90689
@@ -1,5 +1,11 @@
|
||||
import { IProductModuleService } from "@medusajs/framework/types"
|
||||
import { CommonEvents, Modules, ProductStatus } from "@medusajs/framework/utils"
|
||||
import {
|
||||
CommonEvents,
|
||||
composeMessage,
|
||||
Modules,
|
||||
ProductEvents,
|
||||
ProductStatus,
|
||||
} from "@medusajs/framework/utils"
|
||||
import { Product, ProductCollection } from "@models"
|
||||
import {
|
||||
MockEventBusService,
|
||||
@@ -313,10 +319,12 @@ moduleIntegrationTestRunner<IProductModuleService>({
|
||||
expect(eventBusSpy).toHaveBeenCalledTimes(1)
|
||||
expect(eventBusSpy).toHaveBeenCalledWith(
|
||||
[
|
||||
{
|
||||
composeMessage(ProductEvents.PRODUCT_COLLECTION_UPDATED, {
|
||||
data: { id: collectionId },
|
||||
name: "product-collection.updated",
|
||||
},
|
||||
object: "product_collection",
|
||||
source: Modules.PRODUCT,
|
||||
action: CommonEvents.UPDATED,
|
||||
}),
|
||||
],
|
||||
{
|
||||
internal: true,
|
||||
@@ -514,10 +522,12 @@ moduleIntegrationTestRunner<IProductModuleService>({
|
||||
expect(eventBusSpy).toHaveBeenCalledTimes(1)
|
||||
expect(eventBusSpy).toHaveBeenCalledWith(
|
||||
[
|
||||
{
|
||||
composeMessage(ProductEvents.PRODUCT_COLLECTION_CREATED, {
|
||||
data: { id: collections[0].id },
|
||||
name: "product-collection.created",
|
||||
},
|
||||
object: "product_collection",
|
||||
source: Modules.PRODUCT,
|
||||
action: CommonEvents.CREATED,
|
||||
}),
|
||||
],
|
||||
{
|
||||
internal: true,
|
||||
|
||||
@@ -3,7 +3,14 @@ import {
|
||||
ProductCategoryDTO,
|
||||
ProductTagDTO,
|
||||
} from "@medusajs/framework/types"
|
||||
import { Modules, ProductStatus, kebabCase } from "@medusajs/framework/utils"
|
||||
import {
|
||||
CommonEvents,
|
||||
composeMessage,
|
||||
kebabCase,
|
||||
Modules,
|
||||
ProductEvents,
|
||||
ProductStatus,
|
||||
} from "@medusajs/framework/utils"
|
||||
import {
|
||||
Product,
|
||||
ProductCategory,
|
||||
@@ -376,10 +383,12 @@ moduleIntegrationTestRunner<IProductModuleService>({
|
||||
expect(eventBusSpy).toHaveBeenCalledTimes(1)
|
||||
expect(eventBusSpy).toHaveBeenCalledWith(
|
||||
[
|
||||
{
|
||||
name: "product.updated",
|
||||
composeMessage(ProductEvents.PRODUCT_UPDATED, {
|
||||
data: { id: productOne.id },
|
||||
},
|
||||
object: "product",
|
||||
source: Modules.PRODUCT,
|
||||
action: CommonEvents.UPDATED,
|
||||
}),
|
||||
],
|
||||
{
|
||||
internal: true,
|
||||
@@ -731,10 +740,12 @@ moduleIntegrationTestRunner<IProductModuleService>({
|
||||
expect(eventBusSpy).toHaveBeenCalledTimes(1)
|
||||
expect(eventBusSpy).toHaveBeenCalledWith(
|
||||
[
|
||||
{
|
||||
name: "product.created",
|
||||
composeMessage(ProductEvents.PRODUCT_CREATED, {
|
||||
data: { id: products[0].id },
|
||||
},
|
||||
object: "product",
|
||||
source: Modules.PRODUCT,
|
||||
action: CommonEvents.CREATED,
|
||||
}),
|
||||
],
|
||||
{
|
||||
internal: true,
|
||||
@@ -824,12 +835,30 @@ moduleIntegrationTestRunner<IProductModuleService>({
|
||||
|
||||
await service.softDeleteProducts([products[0].id])
|
||||
|
||||
expect(eventBusSpy).toHaveBeenCalledWith(
|
||||
expect(eventBusSpy).toHaveBeenNthCalledWith(
|
||||
1,
|
||||
[
|
||||
{
|
||||
name: "product.created",
|
||||
composeMessage(ProductEvents.PRODUCT_CREATED, {
|
||||
data: { id: products[0].id },
|
||||
},
|
||||
object: "product",
|
||||
source: Modules.PRODUCT,
|
||||
action: CommonEvents.CREATED,
|
||||
}),
|
||||
],
|
||||
{
|
||||
internal: true,
|
||||
}
|
||||
)
|
||||
|
||||
expect(eventBusSpy).toHaveBeenNthCalledWith(
|
||||
2,
|
||||
[
|
||||
composeMessage(ProductEvents.PRODUCT_DELETED, {
|
||||
data: { id: [products[0].id] },
|
||||
object: "product",
|
||||
source: Modules.PRODUCT,
|
||||
action: CommonEvents.DELETED,
|
||||
}),
|
||||
],
|
||||
{
|
||||
internal: true,
|
||||
|
||||
Reference in New Issue
Block a user