fix(core-flows): Locations levels check in draft order and order edit flows (#12881)
* fix: Inventory check * mend * centralise fields * Create few-owls-push.md
This commit is contained in:
@@ -25,6 +25,7 @@ medusaIntegrationTestRunner({
|
||||
let inventoryItem
|
||||
let inventoryItemExtra
|
||||
let location
|
||||
let locationTwo
|
||||
let productExtra
|
||||
const shippingProviderId = "manual_test-provider"
|
||||
|
||||
@@ -553,10 +554,29 @@ medusaIntegrationTestRunner({
|
||||
)
|
||||
).data.stock_location
|
||||
|
||||
locationTwo = (
|
||||
await api.post(
|
||||
`/admin/stock-locations`,
|
||||
{
|
||||
name: "Test location two",
|
||||
},
|
||||
adminHeaders
|
||||
)
|
||||
).data.stock_location
|
||||
|
||||
await api.post(
|
||||
`/admin/inventory-items/${inventoryItemLarge.id}/location-levels`,
|
||||
{
|
||||
location_id: location.id,
|
||||
stocked_quantity: 0,
|
||||
},
|
||||
adminHeaders
|
||||
)
|
||||
|
||||
await api.post(
|
||||
`/admin/inventory-items/${inventoryItemLarge.id}/location-levels`,
|
||||
{
|
||||
location_id: locationTwo.id,
|
||||
stocked_quantity: 10,
|
||||
},
|
||||
adminHeaders
|
||||
@@ -766,6 +786,14 @@ medusaIntegrationTestRunner({
|
||||
stock_location_id: location.id,
|
||||
},
|
||||
},
|
||||
{
|
||||
[Modules.SALES_CHANNEL]: {
|
||||
sales_channel_id: salesChannel.id,
|
||||
},
|
||||
[Modules.STOCK_LOCATION]: {
|
||||
stock_location_id: locationTwo.id,
|
||||
},
|
||||
},
|
||||
])
|
||||
})
|
||||
|
||||
@@ -860,6 +888,60 @@ medusaIntegrationTestRunner({
|
||||
])
|
||||
)
|
||||
})
|
||||
|
||||
it("should manage inventory across locations in order edit", async () => {
|
||||
let edit = (
|
||||
await api.post(
|
||||
`/admin/order-edits`,
|
||||
{ order_id: order.id },
|
||||
adminHeaders
|
||||
)
|
||||
).data.order_change
|
||||
|
||||
// Add item
|
||||
await api.post(
|
||||
`/admin/order-edits/${order.id}/items`,
|
||||
{
|
||||
items: [
|
||||
{
|
||||
variant_id: product.variants.find((v) => v.title === "L shirt")
|
||||
.id,
|
||||
quantity: 1,
|
||||
},
|
||||
],
|
||||
},
|
||||
adminHeaders
|
||||
)
|
||||
|
||||
edit = (
|
||||
await api.post(
|
||||
`/admin/order-edits/${order.id}/request`,
|
||||
{},
|
||||
adminHeaders
|
||||
)
|
||||
).data.order_change
|
||||
|
||||
edit = (
|
||||
await api.post(
|
||||
`/admin/order-edits/${order.id}/confirm`,
|
||||
{},
|
||||
adminHeaders
|
||||
)
|
||||
).data.order_change
|
||||
|
||||
order = (await api.get(`/admin/orders/${order.id}`, adminHeaders)).data
|
||||
.order
|
||||
|
||||
expect(order.items.length).toBe(3)
|
||||
expect(order.items).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
subtitle: "L shirt",
|
||||
quantity: 2,
|
||||
}),
|
||||
])
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe("Order Edit Shipping Methods", () => {
|
||||
|
||||
Reference in New Issue
Block a user