chore: Rename all event keys to uppercase (#7787)
* chore: Rename all event keys to uppercase * fix: Remove main entity from event builder
This commit is contained in:
+17
-7
@@ -1,5 +1,11 @@
|
||||
import { IProductModuleService } from "@medusajs/types"
|
||||
import { Modules, ProductStatus } from "@medusajs/utils"
|
||||
import {
|
||||
Modules,
|
||||
CommonEvents,
|
||||
ProductEvents,
|
||||
ProductStatus,
|
||||
composeMessage,
|
||||
} from "@medusajs/utils"
|
||||
import { Product, ProductCategory } from "@models"
|
||||
import {
|
||||
MockEventBusService,
|
||||
@@ -291,11 +297,13 @@ moduleIntegrationTestRunner<IProductModuleService>({
|
||||
parent_category_id: productCategoryOne.id,
|
||||
})
|
||||
|
||||
expect(eventBusSpy).toHaveBeenCalledTimes(1)
|
||||
expect(eventBusSpy.mock.calls[0][0]).toHaveLength(1)
|
||||
expect(eventBusSpy).toHaveBeenCalledWith([
|
||||
expect.objectContaining({
|
||||
composeMessage(ProductEvents.PRODUCT_CATEGORY_CREATED, {
|
||||
data: { id: category.id },
|
||||
eventName: "productService.product-category.created",
|
||||
object: "product_category",
|
||||
source: Modules.PRODUCT,
|
||||
action: CommonEvents.CREATED,
|
||||
}),
|
||||
])
|
||||
})
|
||||
@@ -384,11 +392,13 @@ moduleIntegrationTestRunner<IProductModuleService>({
|
||||
name: "New Category",
|
||||
})
|
||||
|
||||
expect(eventBusSpy).toHaveBeenCalledTimes(1)
|
||||
expect(eventBusSpy.mock.calls[0][0]).toHaveLength(1)
|
||||
expect(eventBusSpy).toHaveBeenCalledWith([
|
||||
expect.objectContaining({
|
||||
composeMessage(ProductEvents.PRODUCT_CATEGORY_UPDATED, {
|
||||
data: { id: productCategoryZero.id },
|
||||
eventName: "productService.product-category.updated",
|
||||
object: "product_category",
|
||||
source: Modules.PRODUCT,
|
||||
action: CommonEvents.UPDATED,
|
||||
}),
|
||||
])
|
||||
})
|
||||
|
||||
+4
-4
@@ -279,7 +279,7 @@ moduleIntegrationTestRunner<IProductModuleService>({
|
||||
|
||||
expect(eventBusEmitSpy.mock.calls[0][0]).toHaveLength(1)
|
||||
expect(eventBusEmitSpy).toHaveBeenCalledWith([
|
||||
composeMessage(ProductEvents.product_tag_updated, {
|
||||
composeMessage(ProductEvents.PRODUCT_TAG_UPDATED, {
|
||||
data: { id: productTag.id },
|
||||
object: "product_tag",
|
||||
source: Modules.PRODUCT,
|
||||
@@ -321,7 +321,7 @@ moduleIntegrationTestRunner<IProductModuleService>({
|
||||
|
||||
expect(eventBusEmitSpy.mock.calls[0][0]).toHaveLength(1)
|
||||
expect(eventBusEmitSpy).toHaveBeenCalledWith([
|
||||
composeMessage(ProductEvents.product_tag_created, {
|
||||
composeMessage(ProductEvents.PRODUCT_TAG_CREATED, {
|
||||
data: { id: productTag[0].id },
|
||||
object: "product_tag",
|
||||
source: Modules.PRODUCT,
|
||||
@@ -375,13 +375,13 @@ moduleIntegrationTestRunner<IProductModuleService>({
|
||||
|
||||
expect(eventBusEmitSpy.mock.calls[0][0]).toHaveLength(2)
|
||||
expect(eventBusEmitSpy).toHaveBeenCalledWith([
|
||||
composeMessage(ProductEvents.product_tag_created, {
|
||||
composeMessage(ProductEvents.PRODUCT_TAG_CREATED, {
|
||||
data: { id: newTag.id },
|
||||
object: "product_tag",
|
||||
source: Modules.PRODUCT,
|
||||
action: CommonEvents.CREATED,
|
||||
}),
|
||||
composeMessage(ProductEvents.product_tag_updated, {
|
||||
composeMessage(ProductEvents.PRODUCT_TAG_UPDATED, {
|
||||
data: { id: updatedTag.id },
|
||||
object: "product_tag",
|
||||
source: Modules.PRODUCT,
|
||||
|
||||
+3
-3
@@ -213,7 +213,7 @@ moduleIntegrationTestRunner<IProductModuleService>({
|
||||
|
||||
expect(eventBusEmitSpy.mock.calls[0][0]).toHaveLength(1)
|
||||
expect(eventBusEmitSpy).toHaveBeenCalledWith([
|
||||
composeMessage(ProductEvents.product_variant_updated, {
|
||||
composeMessage(ProductEvents.PRODUCT_VARIANT_UPDATED, {
|
||||
data: { id: variantOne.id },
|
||||
object: "product_variant",
|
||||
source: Modules.PRODUCT,
|
||||
@@ -246,7 +246,7 @@ moduleIntegrationTestRunner<IProductModuleService>({
|
||||
|
||||
expect(eventBusEmitSpy.mock.calls[0][0]).toHaveLength(1)
|
||||
expect(eventBusEmitSpy).toHaveBeenCalledWith([
|
||||
composeMessage(ProductEvents.product_variant_updated, {
|
||||
composeMessage(ProductEvents.PRODUCT_VARIANT_UPDATED, {
|
||||
data: { id: variantOne.id },
|
||||
object: "product_variant",
|
||||
source: Modules.PRODUCT,
|
||||
@@ -320,7 +320,7 @@ moduleIntegrationTestRunner<IProductModuleService>({
|
||||
|
||||
expect(eventBusEmitSpy.mock.calls[0][0]).toHaveLength(1)
|
||||
expect(eventBusEmitSpy).toHaveBeenCalledWith([
|
||||
composeMessage(ProductEvents.product_variant_created, {
|
||||
composeMessage(ProductEvents.PRODUCT_VARIANT_CREATED, {
|
||||
data: { id: variant.id },
|
||||
object: "product_variant",
|
||||
source: Modules.PRODUCT,
|
||||
|
||||
@@ -11,21 +11,18 @@ export const eventBuilders = {
|
||||
action: CommonEvents.CREATED,
|
||||
object: "product",
|
||||
eventsEnum: ProductEvents,
|
||||
isMainEntity: true,
|
||||
}),
|
||||
updatedProduct: eventBuilderFactory({
|
||||
source: Modules.PRODUCT,
|
||||
action: CommonEvents.UPDATED,
|
||||
object: "product",
|
||||
eventsEnum: ProductEvents,
|
||||
isMainEntity: true,
|
||||
}),
|
||||
deletedProduct: eventBuilderFactory({
|
||||
source: Modules.PRODUCT,
|
||||
action: CommonEvents.DELETED,
|
||||
object: "product",
|
||||
eventsEnum: ProductEvents,
|
||||
isMainEntity: true,
|
||||
}),
|
||||
createdProductVariant: eventBuilderFactory({
|
||||
source: Modules.PRODUCT,
|
||||
|
||||
Reference in New Issue
Block a user