fix(medusa): fix update promotion's request type (#8966)
Fix the validator of the update promotion API route to match the update workflow input's type.
This commit is contained in:
@@ -495,24 +495,6 @@ medusaIntegrationTestRunner({
|
||||
)
|
||||
})
|
||||
|
||||
it("should throw an error when both campaign and campaign_id params are passed", async () => {
|
||||
const { response } = await api
|
||||
.post(
|
||||
`/admin/promotions/${promotion.id}`,
|
||||
{
|
||||
campaign: { name: "test campaign" },
|
||||
campaign_id: "test",
|
||||
},
|
||||
adminHeaders
|
||||
)
|
||||
.catch((e) => e)
|
||||
|
||||
expect(response.status).toEqual(400)
|
||||
expect(response.data.message).toContain(
|
||||
`Invalid request: Field 'campaign, campaign_identifier' is required`
|
||||
)
|
||||
})
|
||||
|
||||
it("should update a promotion successfully", async () => {
|
||||
const response = await api.post(
|
||||
`/admin/promotions/${promotion.id}`,
|
||||
|
||||
@@ -138,7 +138,7 @@ export interface UpdatePromotionDTO {
|
||||
/**
|
||||
* The associated application method.
|
||||
*/
|
||||
application_method?: UpdateApplicationMethodDTO
|
||||
application_method?: Omit<UpdateApplicationMethodDTO, "id">
|
||||
|
||||
/**
|
||||
* The associated campaign's ID.
|
||||
|
||||
@@ -132,8 +132,6 @@ export const AdminUpdateApplicationMethod = z
|
||||
type: z.nativeEnum(ApplicationMethodType).optional(),
|
||||
target_type: z.nativeEnum(ApplicationMethodTargetType).optional(),
|
||||
allocation: z.nativeEnum(ApplicationMethodAllocation).optional(),
|
||||
target_rules: z.array(AdminCreatePromotionRule).optional(),
|
||||
buy_rules: z.array(AdminCreatePromotionRule).optional(),
|
||||
apply_to_quantity: z.number().nullish(),
|
||||
buy_rules_min_quantity: z.number().nullish(),
|
||||
})
|
||||
@@ -186,9 +184,7 @@ export const UpdatePromotion = z
|
||||
is_automatic: z.boolean().optional(),
|
||||
type: z.nativeEnum(PromotionType).optional(),
|
||||
campaign_id: z.string().nullish(),
|
||||
campaign: CreateCampaign.optional(),
|
||||
application_method: AdminUpdateApplicationMethod.optional(),
|
||||
rules: z.array(AdminCreatePromotionRule).optional(),
|
||||
})
|
||||
.strict()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user