fix(promotion, core-flows): updating cart with removed promotion removes adjustments (#10489)

This commit is contained in:
Riqwan Thamir
2024-12-08 13:13:31 +01:00
committed by GitHub
parent 864f53011b
commit f95c4e240c
5 changed files with 62 additions and 76 deletions

View File

@@ -1344,6 +1344,52 @@ medusaIntegrationTestRunner({
})
)
})
it("should remove promotion adjustments when promotion is deleted", async () => {
let cartBeforeRemovingPromotion = (
await api.get(`/store/carts/${cart.id}`, storeHeaders)
).data.cart
expect(cartBeforeRemovingPromotion).toEqual(
expect.objectContaining({
id: cart.id,
items: expect.arrayContaining([
expect.objectContaining({
adjustments: [
{
id: expect.any(String),
code: "PROMOTION_APPLIED",
promotion_id: promotion.id,
amount: 100,
},
],
}),
]),
})
)
await api.delete(`/admin/promotions/${promotion.id}`, adminHeaders)
let response = await api.post(
`/store/carts/${cart.id}`,
{
email: "test@test.com",
},
storeHeaders
)
expect(response.status).toEqual(200)
expect(response.data.cart).toEqual(
expect.objectContaining({
id: cart.id,
items: expect.arrayContaining([
expect.objectContaining({
adjustments: [],
}),
]),
})
)
})
})
describe("POST /store/carts/:id/customer", () => {