feat(medusa): remove created reservations on subsequent failure for cart completion (#3554)
**What** - If cart completion fails after creating reservations, remove those reservations **Why** - To avoid hanging reservations if something fails at a later point
This commit is contained in:
@@ -2,17 +2,25 @@
|
||||
|
||||
exports[`/store/carts POST /store/carts/:id fails to complete cart with items inventory not/partially covered 1`] = `
|
||||
Object {
|
||||
"code": "insufficient_inventory",
|
||||
"message": "Variant with id: test-variant-2 does not have the required inventory",
|
||||
"type": "not_allowed",
|
||||
"errors": Array [
|
||||
Object {
|
||||
"code": "insufficient_inventory",
|
||||
"message": "Variant with id: test-variant-2 does not have the required inventory",
|
||||
"type": "not_allowed",
|
||||
},
|
||||
],
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`/store/carts POST /store/carts/:id fails to complete swap cart with items inventory not/partially covered 1`] = `
|
||||
Object {
|
||||
"code": "insufficient_inventory",
|
||||
"message": "Variant with id: test-variant-2 does not have the required inventory",
|
||||
"type": "not_allowed",
|
||||
"errors": Array [
|
||||
Object {
|
||||
"code": "insufficient_inventory",
|
||||
"message": "Variant with id: test-variant-2 does not have the required inventory",
|
||||
"type": "not_allowed",
|
||||
},
|
||||
],
|
||||
}
|
||||
`;
|
||||
|
||||
|
||||
@@ -1948,7 +1948,7 @@ describe("/store/carts", () => {
|
||||
await api.post(`/store/carts/test-cart-2/complete-cart`)
|
||||
} catch (e) {
|
||||
expect(e.response.data).toMatchSnapshot({
|
||||
code: "insufficient_inventory",
|
||||
errors: [{ code: "insufficient_inventory" }],
|
||||
})
|
||||
expect(e.response.status).toBe(409)
|
||||
}
|
||||
@@ -1984,7 +1984,7 @@ describe("/store/carts", () => {
|
||||
await api.post(`/store/carts/swap-cart/complete-cart`)
|
||||
} catch (e) {
|
||||
expect(e.response.data).toMatchSnapshot({
|
||||
code: "insufficient_inventory",
|
||||
errors: [{ code: "insufficient_inventory" }],
|
||||
})
|
||||
expect(e.response.status).toBe(409)
|
||||
}
|
||||
|
||||
@@ -343,8 +343,8 @@ describe("/store/carts", () => {
|
||||
})
|
||||
|
||||
expect(responseFail.status).toEqual(409)
|
||||
expect(responseFail.data.type).toEqual("not_allowed")
|
||||
expect(responseFail.data.code).toEqual(
|
||||
expect(responseFail.data.errors[0].type).toEqual("not_allowed")
|
||||
expect(responseFail.data.errors[0].code).toEqual(
|
||||
MedusaError.Codes.INSUFFICIENT_INVENTORY
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user