forked from medusajs/medusa
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(promotion, core-flows): updating cart with removed promotion remo…
…ves adjustments (medusajs#10489)
- Loading branch information
Showing
5 changed files
with
62 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@medusajs/promotion": patch | ||
"@medusajs/core-flows": patch | ||
--- | ||
|
||
fix(promotion, core-flows): updating cart with removed promotion removes adjustments |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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: "[email protected]", | ||
}, | ||
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", () => { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters