feat(medusa,stock-location,inventory): Integration tests (#3149)

This commit is contained in:
Carlos R. L. Rodrigues
2023-02-06 09:02:43 -03:00
committed by GitHub
parent 71fdd28198
commit 923ccece24
17 changed files with 2019 additions and 32 deletions
@@ -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) {