fix(core-flows): Lock cart on shipping update (#13535)
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { addShippingMethodToCartWorkflow } from "@medusajs/core-flows"
|
||||
import {
|
||||
AdminInventoryItem,
|
||||
AdminProduct,
|
||||
@@ -242,15 +243,12 @@ export async function createOrderSeeder({
|
||||
|
||||
if (!withoutShipping) {
|
||||
// Create shipping methods for each shipping option so shipping profiles of products in the cart are supported
|
||||
await Promise.all(
|
||||
shippingOptions.map(async (so) => {
|
||||
await api.post(
|
||||
`/store/carts/${cart.id}/shipping-methods`,
|
||||
{ option_id: so.id },
|
||||
storeHeaders
|
||||
)
|
||||
})
|
||||
)
|
||||
await addShippingMethodToCartWorkflow(container).run({
|
||||
input: {
|
||||
cart_id: cart.id,
|
||||
options: shippingOptions.map((so) => ({ id: so.id })),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
const paymentCollection = (
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { medusaIntegrationTestRunner } from "@medusajs/test-utils"
|
||||
import { AdminShippingOption } from "@medusajs/types"
|
||||
import { ModuleRegistrationName } from "@medusajs/utils"
|
||||
import {
|
||||
adminHeaders,
|
||||
@@ -9,7 +10,6 @@ import {
|
||||
import { setupTaxStructure } from "../../../../modules/__tests__/fixtures"
|
||||
import { createOrderSeeder } from "../../fixtures/order"
|
||||
import { createShippingOptionSeeder } from "../../fixtures/shipping"
|
||||
import { AdminShippingOption } from "@medusajs/types"
|
||||
|
||||
jest.setTimeout(300000)
|
||||
|
||||
@@ -980,23 +980,6 @@ medusaIntegrationTestRunner({
|
||||
.order
|
||||
})
|
||||
|
||||
it("should find the order querying it by number", async () => {
|
||||
const userEmail = "tony@stark-industries.com"
|
||||
|
||||
const response = (
|
||||
await api.get(`/admin/orders/?q=non-existing`, adminHeaders)
|
||||
).data
|
||||
|
||||
expect(response.orders).toHaveLength(0)
|
||||
|
||||
const response2 = (
|
||||
await api.get(`/admin/orders/?fields=+email&q=@stark`, adminHeaders)
|
||||
).data
|
||||
|
||||
expect(response2.orders).toHaveLength(1)
|
||||
expect(response2.orders[0].email).toEqual(userEmail)
|
||||
})
|
||||
|
||||
it("should update stock levels correctly when creating partial fulfillment on an order", async () => {
|
||||
const orderItemId = order.items.find(
|
||||
(i) => i.variant_id === productOverride3.variants[0].id
|
||||
|
||||
Reference in New Issue
Block a user