feat(medusa, medusa-js, medusa-react): Support listing order edits (#2436)
* feat(medusa, medusa-js, medusa-react): Support listing order edits * feat(medusa): Update OAS * fix oas Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com>
This commit is contained in:
co-authored by
Oliver Windall Juhl
parent
69e579758f
commit
143f8543e5
@@ -229,6 +229,155 @@ describe("[MEDUSA_FF_ORDER_EDITING] /admin/order-edits", () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe("GET /admin/order-edits/", () => {
|
||||
const orderEditId = IdMap.getId("order-edit-1")
|
||||
const prodId1 = IdMap.getId("prodId1")
|
||||
const prodId2 = IdMap.getId("prodId2")
|
||||
const lineItemId1 = IdMap.getId("line-item-1")
|
||||
const lineItemId2 = IdMap.getId("line-item-2")
|
||||
|
||||
beforeEach(async () => {
|
||||
await adminSeeder(dbConnection)
|
||||
|
||||
const product1 = await simpleProductFactory(dbConnection, {
|
||||
id: prodId1,
|
||||
})
|
||||
const product2 = await simpleProductFactory(dbConnection, {
|
||||
id: prodId2,
|
||||
})
|
||||
|
||||
const order = await simpleOrderFactory(dbConnection, {
|
||||
email: "test@testson.com",
|
||||
tax_rate: null,
|
||||
fulfillment_status: "fulfilled",
|
||||
payment_status: "captured",
|
||||
region: {
|
||||
id: "test-region",
|
||||
name: "Test region",
|
||||
tax_rate: 12.5,
|
||||
},
|
||||
line_items: [
|
||||
{
|
||||
id: lineItemId1,
|
||||
variant_id: product1.variants[0].id,
|
||||
quantity: 1,
|
||||
fulfilled_quantity: 1,
|
||||
shipped_quantity: 1,
|
||||
unit_price: 1000,
|
||||
tax_lines: [
|
||||
{
|
||||
rate: 10,
|
||||
code: "code1",
|
||||
name: "code1",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
id: lineItemId2,
|
||||
variant_id: product2.variants[0].id,
|
||||
quantity: 1,
|
||||
fulfilled_quantity: 1,
|
||||
shipped_quantity: 1,
|
||||
unit_price: 1000,
|
||||
tax_lines: [
|
||||
{
|
||||
rate: 10,
|
||||
code: "code2",
|
||||
name: "code2",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
})
|
||||
|
||||
await simpleOrderEditFactory(dbConnection, {
|
||||
id: orderEditId,
|
||||
order_id: order.id,
|
||||
created_by: "admin_user",
|
||||
internal_note: "test internal note",
|
||||
})
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
const db = useDb()
|
||||
return await db.teardown()
|
||||
})
|
||||
|
||||
it("list order edits", async () => {
|
||||
const api = useApi()
|
||||
|
||||
const response = await api.get(`/admin/order-edits`, adminHeaders)
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.count).toEqual(1)
|
||||
expect(response.data.offset).toEqual(0)
|
||||
expect(response.data.limit).toEqual(20)
|
||||
expect(response.data.order_edits).toHaveLength(1)
|
||||
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,
|
||||
}),
|
||||
])
|
||||
)
|
||||
})
|
||||
|
||||
it("list order edits with free text search", async () => {
|
||||
const api = useApi()
|
||||
|
||||
let response = await api.get(`/admin/order-edits?q=test`, adminHeaders)
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.count).toEqual(1)
|
||||
expect(response.data.offset).toEqual(0)
|
||||
expect(response.data.limit).toEqual(20)
|
||||
expect(response.data.order_edits).toHaveLength(1)
|
||||
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,
|
||||
}),
|
||||
])
|
||||
)
|
||||
|
||||
response = await api.get(`/admin/order-edits?q=test2`, adminHeaders)
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.count).toEqual(0)
|
||||
expect(response.data.offset).toEqual(0)
|
||||
expect(response.data.limit).toEqual(20)
|
||||
expect(response.data.order_edits).toHaveLength(0)
|
||||
})
|
||||
})
|
||||
|
||||
describe("DELETE /admin/order-edits/:id", () => {
|
||||
beforeEach(async () => {
|
||||
await adminSeeder(dbConnection)
|
||||
|
||||
Reference in New Issue
Block a user