chore(core-flows): throw error on invalid promo code (#13140)

* chore(core-flows): throw error on invalid promo code

* add changelog

* better error handling in test

---------

Co-authored-by: william bouchard <williambouchard@williams-MacBook-Pro.local>
Co-authored-by: Carlos R. L. Rodrigues <37986729+carlos-r-l-rodrigues@users.noreply.github.com>
This commit is contained in:
William Bouchard
2025-08-05 09:01:41 -04:00
committed by GitHub
parent ee0b873f82
commit acf6bbc2ec
3 changed files with 57 additions and 11 deletions

View File

@@ -2815,6 +2815,24 @@ medusaIntegrationTestRunner({
)
})
it("should throw an error when adding a promotion that does not exist", async () => {
const invalidPromoCode = "SOME_INVALID_PROMO_CODE"
const { response } = await api
.post(
`/store/carts/${cart.id}/promotions`,
{ promo_codes: [invalidPromoCode] },
storeHeaders
)
.catch((e) => e)
expect(response.status).toEqual(400)
expect(response.data.type).toEqual("invalid_data")
expect(response.data.message).toEqual(
`The promotion code ${invalidPromoCode} is invalid`
)
})
it("should remove promotion adjustments when promotion is deleted", async () => {
let cartBeforeRemovingPromotion = (
await api.get(`/store/carts/${cart.id}`, storeHeaders)