feat(medusa,types): GET admin promotion endpoint to fetch by code (#6697)
what: - GET admin promotion endpoint will search for a promotion either through ID or code
This commit is contained in:
@@ -14,7 +14,7 @@ const adminHeaders = {
|
||||
medusaIntegrationTestRunner({
|
||||
env,
|
||||
testSuite: ({ dbConnection, getContainer, api }) => {
|
||||
describe("GET /admin/promotions", () => {
|
||||
describe("GET /admin/promotions/:id", () => {
|
||||
let appContainer
|
||||
let promotionModuleService: IPromotionModuleService
|
||||
|
||||
@@ -36,11 +36,11 @@ medusaIntegrationTestRunner({
|
||||
|
||||
expect(response.status).toEqual(404)
|
||||
expect(response.data.message).toEqual(
|
||||
"Promotion with id: does-not-exist was not found"
|
||||
"Promotion with id or code: does-not-exist was not found"
|
||||
)
|
||||
})
|
||||
|
||||
it("should get the requested promotion", async () => {
|
||||
it("should get the requested promotion by id or codde", async () => {
|
||||
const createdPromotion = await promotionModuleService.create({
|
||||
code: "TEST",
|
||||
type: PromotionType.STANDARD,
|
||||
@@ -51,7 +51,7 @@ medusaIntegrationTestRunner({
|
||||
},
|
||||
})
|
||||
|
||||
const response = await api.get(
|
||||
let response = await api.get(
|
||||
`/admin/promotions/${createdPromotion.id}`,
|
||||
adminHeaders
|
||||
)
|
||||
@@ -59,22 +59,19 @@ medusaIntegrationTestRunner({
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.promotion).toEqual(
|
||||
expect.objectContaining({
|
||||
id: expect.any(String),
|
||||
code: "TEST",
|
||||
campaign: null,
|
||||
is_automatic: false,
|
||||
type: "standard",
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
deleted_at: null,
|
||||
application_method: expect.objectContaining({
|
||||
id: expect.any(String),
|
||||
promotion: expect.any(Object),
|
||||
value: 100,
|
||||
type: "fixed",
|
||||
target_type: "order",
|
||||
allocation: null,
|
||||
}),
|
||||
id: createdPromotion.id,
|
||||
})
|
||||
)
|
||||
|
||||
response = await api.get(
|
||||
`/admin/promotions/${createdPromotion.code}`,
|
||||
adminHeaders
|
||||
)
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.promotion).toEqual(
|
||||
expect.objectContaining({
|
||||
id: createdPromotion.id,
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user