feat(medusa): complete cart create reservation (#7250)
This commit is contained in:
committed by
GitHub
parent
a736e728b8
commit
5228b14ca9
@@ -709,10 +709,9 @@ medusaIntegrationTestRunner({
|
||||
|
||||
expect(errors).toEqual([
|
||||
{
|
||||
action: "confirm-item-inventory-as-step",
|
||||
action: "validate-variant-prices",
|
||||
handlerType: "invoke",
|
||||
error: expect.objectContaining({
|
||||
// TODO: FIX runAsStep nested errors
|
||||
message: expect.stringContaining(
|
||||
`Variants with IDs ${product.variants[0].id} do not have a price`
|
||||
),
|
||||
|
||||
@@ -1480,6 +1480,8 @@ medusaIntegrationTestRunner({
|
||||
let shippingProfile
|
||||
let fulfillmentSet
|
||||
let shippingOption
|
||||
let stockLocation
|
||||
let inventoryItem
|
||||
|
||||
beforeEach(async () => {
|
||||
await setupTaxStructure(taxModule)
|
||||
@@ -1510,7 +1512,6 @@ medusaIntegrationTestRunner({
|
||||
variants: [
|
||||
{
|
||||
title: "Test variant",
|
||||
inventory_quantity: 10,
|
||||
prices: [
|
||||
{
|
||||
currency_code: "usd",
|
||||
@@ -1528,7 +1529,7 @@ medusaIntegrationTestRunner({
|
||||
)
|
||||
).data.product
|
||||
|
||||
const stockLocation = (
|
||||
stockLocation = (
|
||||
await api.post(
|
||||
`/admin/stock-locations`,
|
||||
{ name: "test location" },
|
||||
@@ -1536,6 +1537,25 @@ medusaIntegrationTestRunner({
|
||||
)
|
||||
).data.stock_location
|
||||
|
||||
inventoryItem = (
|
||||
await api.post(
|
||||
`/admin/inventory-items`,
|
||||
{
|
||||
sku: "12345",
|
||||
},
|
||||
adminHeaders
|
||||
)
|
||||
).data.inventory_item
|
||||
|
||||
await api.post(
|
||||
`/admin/inventory-items/${inventoryItem.id}/location-levels`,
|
||||
{
|
||||
location_id: stockLocation.id,
|
||||
stocked_quantity: 10,
|
||||
},
|
||||
adminHeaders
|
||||
)
|
||||
|
||||
await api.post(
|
||||
`/admin/stock-locations/${stockLocation.id}/sales-channels`,
|
||||
{ add: [salesChannel.id] },
|
||||
@@ -1563,6 +1583,14 @@ medusaIntegrationTestRunner({
|
||||
[Modules.STOCK_LOCATION]: { stock_location_id: stockLocation.id },
|
||||
[Modules.FULFILLMENT]: { fulfillment_set_id: fulfillmentSet.id },
|
||||
},
|
||||
{
|
||||
[Modules.PRODUCT]: {
|
||||
variant_id: product.variants[0].id,
|
||||
},
|
||||
[Modules.INVENTORY]: {
|
||||
inventory_item_id: inventoryItem.id,
|
||||
},
|
||||
},
|
||||
])
|
||||
|
||||
shippingOption = (
|
||||
@@ -1590,7 +1618,7 @@ medusaIntegrationTestRunner({
|
||||
).data.shipping_option
|
||||
})
|
||||
|
||||
it("should create an order", async () => {
|
||||
it("should create an order and create item reservations", async () => {
|
||||
const cartResponse = await api.post(`/store/carts`, {
|
||||
currency_code: "usd",
|
||||
email: "tony@stark-industries.com",
|
||||
@@ -1602,8 +1630,7 @@ medusaIntegrationTestRunner({
|
||||
province: "ny",
|
||||
postal_code: "94016",
|
||||
},
|
||||
// TODO: inventory isn't being managed on a product level
|
||||
// sales_channel_id: salesChannel.id,
|
||||
sales_channel_id: salesChannel.id,
|
||||
items: [{ quantity: 1, variant_id: product.variants[0].id }],
|
||||
})
|
||||
|
||||
@@ -1661,6 +1688,19 @@ medusaIntegrationTestRunner({
|
||||
}),
|
||||
})
|
||||
)
|
||||
|
||||
const reservation = await api.get(`/admin/reservations`, adminHeaders)
|
||||
const reservationItem = reservation.data.reservations[0]
|
||||
|
||||
expect(reservationItem).toEqual(
|
||||
expect.objectContaining({
|
||||
id: expect.stringContaining("resitem_"),
|
||||
location_id: stockLocation.id,
|
||||
inventory_item_id: inventoryItem.id,
|
||||
quantity: cartResponse.data.cart.items[0].quantity,
|
||||
line_item_id: cartResponse.data.cart.items[0].id,
|
||||
})
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user