fix(medusa): Validate customer_id when completing a cart (#3967)

This commit is contained in:
Frane Polić
2023-05-07 13:12:06 +02:00
committed by GitHub
parent eff9f4c6f9
commit 0c58ead6d8
4 changed files with 43 additions and 4 deletions
@@ -2152,6 +2152,33 @@ describe("/store/carts", () => {
})
})
it("complete cart throws if there is no customer on the cart", async () => {
const api = useApi()
const product = await simpleProductFactory(dbConnection)
const region = await simpleRegionFactory(dbConnection, { tax_rate: 10 })
const cart = await simpleCartFactory(dbConnection, {
region: region.id,
line_items: [
{
variant_id: product.variants[0].id,
quantity: 1,
unit_price: 1000,
},
],
})
await api.post(`/store/carts/${cart.id}/payment-sessions`)
try {
await api.post(`/store/carts/${cart.id}/complete`)
} catch (err) {
expect(err.response.status).toEqual(400)
expect(err.response.data.message).toEqual(
"Cannot create an order from the cart without a customer"
)
}
})
describe("POST /store/carts/:id/shipping-methods", () => {
beforeEach(async () => {
await cartSeeder(dbConnection)