feat: list OE by order id (#2457)
**What** - allow passing `order_id` param to OE list endpoint
This commit is contained in:
1 parent
48411157b1
commit
73db8cfca6
2 files changed
+98
-22
No files matched your search
@@ -235,6 +235,7 @@ describe("[MEDUSA_FF_ORDER_EDITING] /admin/order-edits", () => {
|
|||||||
const prodId2 = IdMap.getId("prodId2")
|
const prodId2 = IdMap.getId("prodId2")
|
||||||
const lineItemId1 = IdMap.getId("line-item-1")
|
const lineItemId1 = IdMap.getId("line-item-1")
|
||||||
const lineItemId2 = IdMap.getId("line-item-2")
|
const lineItemId2 = IdMap.getId("line-item-2")
|
||||||
|
const orderId = IdMap.getId("order-1")
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await adminSeeder(dbConnection)
|
await adminSeeder(dbConnection)
|
||||||
@@ -247,6 +248,7 @@ describe("[MEDUSA_FF_ORDER_EDITING] /admin/order-edits", () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const order = await simpleOrderFactory(dbConnection, {
|
const order = await simpleOrderFactory(dbConnection, {
|
||||||
|
id: orderId,
|
||||||
email: "test@testson.com",
|
email: "test@testson.com",
|
||||||
tax_rate: null,
|
tax_rate: null,
|
||||||
fulfillment_status: "fulfilled",
|
fulfillment_status: "fulfilled",
|
||||||
@@ -296,6 +298,20 @@ describe("[MEDUSA_FF_ORDER_EDITING] /admin/order-edits", () => {
|
|||||||
created_by: "admin_user",
|
created_by: "admin_user",
|
||||||
internal_note: "test internal note",
|
internal_note: "test internal note",
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const additionalOrder = await simpleOrderFactory(dbConnection, {
|
||||||
|
id: IdMap.getId("random-order-id"),
|
||||||
|
tax_rate: null,
|
||||||
|
fulfillment_status: "fulfilled",
|
||||||
|
payment_status: "captured",
|
||||||
|
})
|
||||||
|
|
||||||
|
await simpleOrderEditFactory(dbConnection, {
|
||||||
|
id: IdMap.getId("random-oe-id"),
|
||||||
|
order_id: additionalOrder.id,
|
||||||
|
created_by: "admin_user",
|
||||||
|
internal_note: "test unused note",
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(async () => {
|
afterEach(async () => {
|
||||||
@@ -308,6 +324,59 @@ describe("[MEDUSA_FF_ORDER_EDITING] /admin/order-edits", () => {
|
|||||||
|
|
||||||
const response = await api.get(`/admin/order-edits`, adminHeaders)
|
const response = await api.get(`/admin/order-edits`, adminHeaders)
|
||||||
|
|
||||||
|
expect(response.status).toEqual(200)
|
||||||
|
expect(response.data.count).toEqual(2)
|
||||||
|
expect(response.data.offset).toEqual(0)
|
||||||
|
expect(response.data.limit).toEqual(20)
|
||||||
|
expect(response.data.order_edits).toHaveLength(2)
|
||||||
|
expect(response.data.order_edits).toEqual(
|
||||||
|
expect.arrayContaining([
|
||||||
|
expect.objectContaining({
|
||||||
|
id: orderEditId,
|
||||||
|
created_by: "admin_user",
|
||||||
|
requested_by: null,
|
||||||
|
canceled_by: null,
|
||||||
|
confirmed_by: null,
|
||||||
|
internal_note: "test internal note",
|
||||||
|
items: expect.arrayContaining([]),
|
||||||
|
changes: [],
|
||||||
|
shipping_total: 0,
|
||||||
|
gift_card_total: 0,
|
||||||
|
gift_card_tax_total: 0,
|
||||||
|
discount_total: 0,
|
||||||
|
tax_total: 0,
|
||||||
|
total: 0,
|
||||||
|
subtotal: 0,
|
||||||
|
}),
|
||||||
|
expect.objectContaining({
|
||||||
|
order_id: IdMap.getId("random-order-id"),
|
||||||
|
created_by: "admin_user",
|
||||||
|
requested_by: null,
|
||||||
|
canceled_by: null,
|
||||||
|
confirmed_by: null,
|
||||||
|
internal_note: "test unused note",
|
||||||
|
items: expect.arrayContaining([]),
|
||||||
|
changes: [],
|
||||||
|
shipping_total: 0,
|
||||||
|
gift_card_total: 0,
|
||||||
|
gift_card_tax_total: 0,
|
||||||
|
discount_total: 0,
|
||||||
|
tax_total: 0,
|
||||||
|
total: 0,
|
||||||
|
subtotal: 0,
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it("list order edits by order id", async () => {
|
||||||
|
const api = useApi()
|
||||||
|
|
||||||
|
const response = await api.get(
|
||||||
|
`/admin/order-edits?order_id=${orderId}`,
|
||||||
|
adminHeaders
|
||||||
|
)
|
||||||
|
|
||||||
expect(response.status).toEqual(200)
|
expect(response.status).toEqual(200)
|
||||||
expect(response.data.count).toEqual(1)
|
expect(response.data.count).toEqual(1)
|
||||||
expect(response.data.offset).toEqual(0)
|
expect(response.data.offset).toEqual(0)
|
||||||
@@ -317,6 +386,7 @@ describe("[MEDUSA_FF_ORDER_EDITING] /admin/order-edits", () => {
|
|||||||
expect.arrayContaining([
|
expect.arrayContaining([
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
id: orderEditId,
|
id: orderEditId,
|
||||||
|
order_id: orderId,
|
||||||
created_by: "admin_user",
|
created_by: "admin_user",
|
||||||
requested_by: null,
|
requested_by: null,
|
||||||
canceled_by: null,
|
canceled_by: null,
|
||||||
@@ -339,34 +409,35 @@ describe("[MEDUSA_FF_ORDER_EDITING] /admin/order-edits", () => {
|
|||||||
it("list order edits with free text search", async () => {
|
it("list order edits with free text search", async () => {
|
||||||
const api = useApi()
|
const api = useApi()
|
||||||
|
|
||||||
let response = await api.get(`/admin/order-edits?q=test`, adminHeaders)
|
let response = await api.get(
|
||||||
|
`/admin/order-edits?q=internal`,
|
||||||
|
adminHeaders
|
||||||
|
)
|
||||||
|
|
||||||
expect(response.status).toEqual(200)
|
expect(response.status).toEqual(200)
|
||||||
expect(response.data.count).toEqual(1)
|
expect(response.data.count).toEqual(1)
|
||||||
expect(response.data.offset).toEqual(0)
|
expect(response.data.offset).toEqual(0)
|
||||||
expect(response.data.limit).toEqual(20)
|
expect(response.data.limit).toEqual(20)
|
||||||
expect(response.data.order_edits).toHaveLength(1)
|
expect(response.data.order_edits).toHaveLength(1)
|
||||||
expect(response.data.order_edits).toEqual(
|
expect(response.data.order_edits).toEqual([
|
||||||
expect.arrayContaining([
|
expect.objectContaining({
|
||||||
expect.objectContaining({
|
id: orderEditId,
|
||||||
id: orderEditId,
|
created_by: "admin_user",
|
||||||
created_by: "admin_user",
|
requested_by: null,
|
||||||
requested_by: null,
|
canceled_by: null,
|
||||||
canceled_by: null,
|
confirmed_by: null,
|
||||||
confirmed_by: null,
|
internal_note: "test internal note",
|
||||||
internal_note: "test internal note",
|
items: expect.arrayContaining([]),
|
||||||
items: expect.arrayContaining([]),
|
changes: [],
|
||||||
changes: [],
|
shipping_total: 0,
|
||||||
shipping_total: 0,
|
gift_card_total: 0,
|
||||||
gift_card_total: 0,
|
gift_card_tax_total: 0,
|
||||||
gift_card_tax_total: 0,
|
discount_total: 0,
|
||||||
discount_total: 0,
|
tax_total: 0,
|
||||||
tax_total: 0,
|
total: 0,
|
||||||
total: 0,
|
subtotal: 0,
|
||||||
subtotal: 0,
|
}),
|
||||||
}),
|
])
|
||||||
])
|
|
||||||
)
|
|
||||||
|
|
||||||
response = await api.get(`/admin/order-edits?q=test2`, adminHeaders)
|
response = await api.get(`/admin/order-edits?q=test2`, adminHeaders)
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import { IsOptional, IsString } from "class-validator"
|
|||||||
* x-authenticated: true
|
* x-authenticated: true
|
||||||
* parameters:
|
* parameters:
|
||||||
* - (query) q {string} Query used for searching order edit internal note.
|
* - (query) q {string} Query used for searching order edit internal note.
|
||||||
|
* - (query) order_id {string} List order edits by order id.
|
||||||
* - (query) limit=20 {number} The number of items in the response
|
* - (query) limit=20 {number} The number of items in the response
|
||||||
* - (query) offset=0 {number} The offset of items in response
|
* - (query) offset=0 {number} The offset of items in response
|
||||||
* - (query) expand {string} Comma separated list of relations to include in the results.
|
* - (query) expand {string} Comma separated list of relations to include in the results.
|
||||||
@@ -90,4 +91,8 @@ export class GetOrderEditsParams extends extendedFindParamsMixin({
|
|||||||
@IsString()
|
@IsString()
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
q?: string
|
q?: string
|
||||||
|
|
||||||
|
@IsString()
|
||||||
|
@IsOptional()
|
||||||
|
order_id?: string
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user