fix: Add some tests and test cleanup for product module (#6586)

This commit is contained in:
Stevche Radevski
2024-03-05 17:18:46 +01:00
committed by GitHub
parent e5dc918be5
commit a6736c7ee0
16 changed files with 710 additions and 801 deletions
@@ -551,9 +551,10 @@ export default class ProductModuleService<
@MedusaContext() sharedContext: Context = {}
): Promise<ProductTypes.ProductDTO[]> {
const products = await this.create_(data, sharedContext)
const createdProducts = await this.baseRepository_.serialize<
ProductTypes.ProductDTO[]
>(products)
>(products, { populate: true })
await this.eventBusModuleService_?.emit<ProductEventData>(
createdProducts.map(({ id }) => ({
@@ -692,6 +693,14 @@ export default class ProductModuleService<
})
)
// TODO: An ugly hack to populate the options in the entity map. The options and variants are created independently of the product create request,
// so they are not populated in the response. Refactor the create method so this is no longer necessary
await this.productOptionService_.list(
{ id: productOptions.map((po) => po.id) },
{ take: null },
sharedContext
)
return products
}