feat(medusa,stock-location,inventory): Integration tests (#3149)
This commit is contained in:
@@ -12,9 +12,9 @@ export const buildLevelsByInventoryItemId = (
|
||||
inventoryLevels: InventoryLevelDTO[],
|
||||
locationIds: string[]
|
||||
) => {
|
||||
const filteredLevels = inventoryLevels.filter((level) =>
|
||||
locationIds?.includes(level.location_id)
|
||||
)
|
||||
const filteredLevels = inventoryLevels.filter((level) => {
|
||||
return !locationIds.length || locationIds.includes(level.location_id)
|
||||
})
|
||||
|
||||
return filteredLevels.reduce((acc, level) => {
|
||||
acc[level.inventory_item_id] = acc[level.inventory_item_id] ?? []
|
||||
@@ -58,6 +58,7 @@ export const joinLevels = async (
|
||||
locationIds,
|
||||
inventoryService
|
||||
)
|
||||
|
||||
return inventoryItems.map((inventoryItem) => ({
|
||||
...inventoryItem,
|
||||
location_levels: levelsByItemId[inventoryItem.id] || [],
|
||||
|
||||
@@ -82,12 +82,7 @@ export const createVariantTransaction = async (
|
||||
const productVariantServiceTx = productVariantService.withTransaction(manager)
|
||||
|
||||
async function createVariant(variantInput: CreateProductVariantInput) {
|
||||
const variant = await productVariantServiceTx.create(
|
||||
productId,
|
||||
variantInput
|
||||
)
|
||||
|
||||
return { variant }
|
||||
return await productVariantServiceTx.create(productId, variantInput)
|
||||
}
|
||||
|
||||
async function removeVariant(variant: ProductVariant) {
|
||||
@@ -101,7 +96,7 @@ export const createVariantTransaction = async (
|
||||
return
|
||||
}
|
||||
|
||||
const inventoryItem = await inventoryServiceTx!.createInventoryItem({
|
||||
return await inventoryServiceTx!.createInventoryItem({
|
||||
sku: variant.sku,
|
||||
origin_country: variant.origin_country,
|
||||
hs_code: variant.hs_code,
|
||||
@@ -112,8 +107,6 @@ export const createVariantTransaction = async (
|
||||
height: variant.height,
|
||||
width: variant.width,
|
||||
})
|
||||
|
||||
return { inventoryItem }
|
||||
}
|
||||
|
||||
async function removeInventoryItem(inventoryItem: InventoryItemDTO) {
|
||||
|
||||
Reference in New Issue
Block a user