feat(medusa,types): added buyget support for modules (#6159)
This commit is contained in:
@@ -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,
|
||||
}),
|
||||
})
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user