fix(promotion): scope uniqueness index to non deleted promotions (#11624)

what:

- scopes uniqueness index to only non deleted records
- explicit sorting of buy get promotions
  - This error popped up as we removed the uniqueness constraint which seems to have kept a specific order.  
  
  
RESOLVES https://github.com/medusajs/medusa/issues/11606
This commit is contained in:
Riqwan Thamir authored and GitHub committed 2025-02-26 14:25:43 +00:00
1 parent d2d6a29a4a
commit a515e6e0c9
5 files changed
+164 -54

No files matched your search

@@ -5009,26 +5009,31 @@ moduleIntegrationTestRunner({
context
)
expect(JSON.parse(JSON.stringify(result))).toEqual([
{
action: "addItemAdjustment",
item_id: "item_cotton_tshirt2",
amount: 1225,
code: "BUY50GET1000",
},
{
action: "addItemAdjustment",
item_id: "item_cotton_tshirt",
amount: 1275,
code: "BUY50GET1000",
},
{
action: "addItemAdjustment",
item_id: "item_cotton_tshirt2",
amount: 50,
code: "BUY10GET20",
},
])
const serializedResult = JSON.parse(JSON.stringify(result))
expect(serializedResult).toHaveLength(3)
expect(serializedResult).toEqual(
expect.arrayContaining([
{
action: "addItemAdjustment",
item_id: "item_cotton_tshirt2",
amount: 1225,
code: "BUY50GET1000",
},
{
action: "addItemAdjustment",
item_id: "item_cotton_tshirt",
amount: 1275,
code: "BUY50GET1000",
},
{
action: "addItemAdjustment",
item_id: "item_cotton_tshirt2",
amount: 50,
code: "BUY10GET20",
},
])
)
})
it("should compute adjustment accurately across items", async () => {