feat(medusa,types): added buyget support for modules (#6159)

This commit is contained in:
Riqwan Thamir
2024-01-23 21:01:44 +01:00
committed by GitHub
parent 302323916b
commit 68d8daccd2
22 changed files with 1058 additions and 109 deletions
@@ -132,4 +132,58 @@ describe("POST /admin/promotions/:id", () => {
})
)
})
it("should update a buyget promotion successfully", async () => {
const createdPromotion = await promotionModuleService.create({
code: "PROMOTION_TEST",
type: PromotionType.BUYGET,
application_method: {
type: "fixed",
target_type: "items",
allocation: "across",
value: "100",
apply_to_quantity: 1,
buy_rules_min_quantity: 1,
buy_rules: [
{
attribute: "product_collection.id",
operator: "eq",
values: ["pcol_towel"],
},
],
target_rules: [
{
attribute: "product.id",
operator: "eq",
values: "prod_mat",
},
],
},
})
const api = useApi() as any
const response = await api.post(
`/admin/promotions/${createdPromotion.id}`,
{
code: "TEST_TWO",
application_method: {
value: "200",
buy_rules_min_quantity: 6,
},
},
adminHeaders
)
expect(response.status).toEqual(200)
expect(response.data.promotion).toEqual(
expect.objectContaining({
id: expect.any(String),
code: "TEST_TWO",
application_method: expect.objectContaining({
value: 200,
buy_rules_min_quantity: 6,
}),
})
)
})
})