fix: Add some tests and test cleanup for product module (#6586)
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user