fix(medusa): Include items.variant relation in order calculation (#2869)
**What** When an order require to decorate the totals, the variant relation should be added FIXES CORE-930
This commit is contained in:
committed by
GitHub
parent
b700c6ba5b
commit
e27b1940c7
@@ -28,6 +28,7 @@ const {
|
||||
simpleOrderFactory,
|
||||
simplePaymentFactory,
|
||||
simpleProductFactory,
|
||||
simpleLineItemFactory,
|
||||
} = require("../../../factories")
|
||||
|
||||
const adminReqConfig = {
|
||||
@@ -70,11 +71,7 @@ describe("/admin/orders", () => {
|
||||
const api = useApi()
|
||||
|
||||
const response = await api
|
||||
.get("/admin/orders", {
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
.get("/admin/orders", adminReqConfig)
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
@@ -110,11 +107,7 @@ describe("/admin/orders", () => {
|
||||
country_code: "us",
|
||||
},
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
adminReqConfig
|
||||
)
|
||||
.catch((err) => {
|
||||
console.log(err.response.data)
|
||||
@@ -225,15 +218,7 @@ describe("/admin/orders", () => {
|
||||
expect(initialInventoryRes.data.variant.inventory_quantity).toEqual(1)
|
||||
|
||||
const response = await api
|
||||
.post(
|
||||
`/admin/orders/test-order-not-payed/cancel`,
|
||||
{},
|
||||
{
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
)
|
||||
.post(`/admin/orders/test-order-not-payed/cancel`, {}, adminReqConfig)
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
@@ -259,15 +244,7 @@ describe("/admin/orders", () => {
|
||||
expect(initialInventoryRes.data.variant.inventory_quantity).toEqual(1)
|
||||
|
||||
const response = await api
|
||||
.post(
|
||||
`/admin/orders/test-order-not-payed/cancel`,
|
||||
{},
|
||||
{
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
)
|
||||
.post(`/admin/orders/test-order-not-payed/cancel`, {}, adminReqConfig)
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
@@ -305,11 +282,7 @@ describe("/admin/orders", () => {
|
||||
],
|
||||
additional_items: [{ variant_id: "test-variant", quantity: 1 }],
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
adminReqConfig
|
||||
)
|
||||
|
||||
expect(swapOnSwap.status).toEqual(200)
|
||||
@@ -351,19 +324,11 @@ describe("/admin/orders", () => {
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
adminReqConfig
|
||||
)
|
||||
expect(response.status).toEqual(200)
|
||||
|
||||
const variant = await api.get("/admin/products", {
|
||||
headers: {
|
||||
authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
const variant = await api.get("/admin/products", adminReqConfig)
|
||||
|
||||
// find test variant and verify that its inventory quantity has changed
|
||||
const toTest = variant.data.products[0].variants.find(
|
||||
@@ -430,11 +395,7 @@ describe("/admin/orders", () => {
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
adminReqConfig
|
||||
)
|
||||
.catch((err) => console.log(err))
|
||||
expect(response.status).toEqual(200)
|
||||
@@ -464,11 +425,7 @@ describe("/admin/orders", () => {
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
adminReqConfig
|
||||
)
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
@@ -508,11 +465,7 @@ describe("/admin/orders", () => {
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
adminReqConfig
|
||||
)
|
||||
expect(response.status).toEqual(200)
|
||||
|
||||
@@ -576,11 +529,7 @@ describe("/admin/orders", () => {
|
||||
],
|
||||
return_shipping: { option_id: "test-return-option", price: 0 },
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
adminReqConfig
|
||||
)
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
@@ -642,11 +591,7 @@ describe("/admin/orders", () => {
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
adminReqConfig
|
||||
)
|
||||
expect(response.status).toEqual(200)
|
||||
|
||||
@@ -660,11 +605,7 @@ describe("/admin/orders", () => {
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
authorization: "bearer test_token",
|
||||
},
|
||||
}
|
||||
adminReqConfig
|
||||
)
|
||||
|
||||
expect(status).toEqual(200)
|
||||
@@ -701,11 +642,7 @@ describe("/admin/orders", () => {
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
adminReqConfig
|
||||
)
|
||||
expect(response.status).toEqual(200)
|
||||
|
||||
@@ -728,11 +665,7 @@ describe("/admin/orders", () => {
|
||||
],
|
||||
})),
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
authorization: "bearer test_token",
|
||||
},
|
||||
}
|
||||
adminReqConfig
|
||||
)
|
||||
|
||||
expect(status).toEqual(200)
|
||||
@@ -788,11 +721,7 @@ describe("/admin/orders", () => {
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
adminReqConfig
|
||||
)
|
||||
expect(response.status).toEqual(200)
|
||||
|
||||
@@ -812,11 +741,7 @@ describe("/admin/orders", () => {
|
||||
],
|
||||
})),
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
authorization: "bearer test_token",
|
||||
},
|
||||
}
|
||||
adminReqConfig
|
||||
)
|
||||
|
||||
expect(status).toEqual(200)
|
||||
@@ -871,11 +796,7 @@ describe("/admin/orders", () => {
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
adminReqConfig
|
||||
)
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
@@ -885,11 +806,7 @@ describe("/admin/orders", () => {
|
||||
const fulRes = await api.post(
|
||||
`/admin/orders/test-order/claims/${cid}/fulfillments`,
|
||||
{},
|
||||
{
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
adminReqConfig
|
||||
)
|
||||
expect(fulRes.status).toEqual(200)
|
||||
expect(fulRes.data.order.claims).toHaveLength(1)
|
||||
@@ -951,11 +868,7 @@ describe("/admin/orders", () => {
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
adminReqConfig
|
||||
)
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
@@ -965,11 +878,7 @@ describe("/admin/orders", () => {
|
||||
const fulRes = await api.post(
|
||||
`/admin/orders/test-order/claims/${cid}/fulfillments`,
|
||||
{},
|
||||
{
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
adminReqConfig
|
||||
)
|
||||
|
||||
const claimItemIdToClaim =
|
||||
@@ -1001,11 +910,7 @@ describe("/admin/orders", () => {
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
adminReqConfig
|
||||
)
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
@@ -1038,11 +943,7 @@ describe("/admin/orders", () => {
|
||||
],
|
||||
additional_items: [{ variant_id: "test-variant-2", quantity: 1 }],
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
adminReqConfig
|
||||
)
|
||||
.catch((e) => console.log(e))
|
||||
|
||||
@@ -1065,11 +966,7 @@ describe("/admin/orders", () => {
|
||||
.post(
|
||||
`/admin/orders/test-order/swaps/${sid}/fulfillments`,
|
||||
{},
|
||||
{
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
adminReqConfig
|
||||
)
|
||||
.catch((e) => console.log(e))
|
||||
|
||||
@@ -1080,11 +977,7 @@ describe("/admin/orders", () => {
|
||||
{
|
||||
fulfillment_id: fulRes.data.order.swaps[0].fulfillments[0].id,
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
adminReqConfig
|
||||
)
|
||||
.catch((e) => console.log(e))
|
||||
|
||||
@@ -1113,11 +1006,7 @@ describe("/admin/orders", () => {
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
adminReqConfig
|
||||
)
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
@@ -1206,11 +1095,7 @@ describe("/admin/orders", () => {
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
adminReqConfig
|
||||
)
|
||||
} catch (e) {
|
||||
expect(e.response.status).toEqual(400)
|
||||
@@ -1257,11 +1142,7 @@ describe("/admin/orders", () => {
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
adminReqConfig
|
||||
)
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
@@ -1306,11 +1187,7 @@ describe("/admin/orders", () => {
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
adminReqConfig
|
||||
)
|
||||
expect(response.status).toEqual(200)
|
||||
|
||||
@@ -1342,11 +1219,7 @@ describe("/admin/orders", () => {
|
||||
],
|
||||
receive_now: true,
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
adminReqConfig
|
||||
)
|
||||
|
||||
// Find variant that should have its inventory_quantity updated
|
||||
@@ -1377,11 +1250,7 @@ describe("/admin/orders", () => {
|
||||
],
|
||||
receive_now: true,
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
adminReqConfig
|
||||
)
|
||||
|
||||
// Find variant that should have its inventory_quantity updated
|
||||
@@ -1410,11 +1279,7 @@ describe("/admin/orders", () => {
|
||||
it("lists all orders", async () => {
|
||||
const api = useApi()
|
||||
|
||||
const response = await api.get("/admin/orders?fields=id", {
|
||||
headers: {
|
||||
authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
const response = await api.get("/admin/orders?fields=id", adminReqConfig)
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.orders).toHaveLength(6)
|
||||
@@ -1450,11 +1315,7 @@ describe("/admin/orders", () => {
|
||||
const response = await api
|
||||
.get(
|
||||
"/admin/orders?fulfillment_status[]=fulfilled&payment_status[]=captured",
|
||||
{
|
||||
headers: {
|
||||
authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
adminReqConfig
|
||||
)
|
||||
.catch((err) => console.log(err))
|
||||
|
||||
@@ -1477,11 +1338,7 @@ describe("/admin/orders", () => {
|
||||
const api = useApi()
|
||||
|
||||
await api
|
||||
.get("/admin/orders?status[]=test", {
|
||||
headers: {
|
||||
authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
.get("/admin/orders?status[]=test", adminReqConfig)
|
||||
.catch((err) => {
|
||||
expect(err.response.status).toEqual(400)
|
||||
expect(err.response.data.type).toEqual("invalid_data")
|
||||
@@ -1496,11 +1353,7 @@ describe("/admin/orders", () => {
|
||||
|
||||
const response = await api.get(
|
||||
"/admin/orders?fields=id,email&q=test@email",
|
||||
{
|
||||
headers: {
|
||||
authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
adminReqConfig
|
||||
)
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
@@ -1519,11 +1372,7 @@ describe("/admin/orders", () => {
|
||||
it("list all orders with matching shipping_address first name", async () => {
|
||||
const api = useApi()
|
||||
|
||||
const response = await api.get("/admin/orders?q=lebron", {
|
||||
headers: {
|
||||
authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
const response = await api.get("/admin/orders?q=lebron", adminReqConfig)
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.count).toEqual(2)
|
||||
@@ -1546,11 +1395,7 @@ describe("/admin/orders", () => {
|
||||
|
||||
const response = await api.get(
|
||||
"/admin/orders?fields=id&created_at[gt]=01-26-1990",
|
||||
{
|
||||
headers: {
|
||||
authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
adminReqConfig
|
||||
)
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
@@ -1585,11 +1430,7 @@ describe("/admin/orders", () => {
|
||||
|
||||
const response = await api.get(
|
||||
"/admin/orders?fields=id&created_at[gt]=01-26-2000",
|
||||
{
|
||||
headers: {
|
||||
authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
adminReqConfig
|
||||
)
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
@@ -1601,11 +1442,7 @@ describe("/admin/orders", () => {
|
||||
|
||||
const response = await api.get(
|
||||
"/admin/orders?fields=id&created_at[lt]=01-26-2000",
|
||||
{
|
||||
headers: {
|
||||
authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
adminReqConfig
|
||||
)
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
@@ -1640,11 +1477,7 @@ describe("/admin/orders", () => {
|
||||
|
||||
const response = await api.get(
|
||||
"/admin/orders?fields=id&created_at[lt]=01-26-1990",
|
||||
{
|
||||
headers: {
|
||||
authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
adminReqConfig
|
||||
)
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
@@ -1656,11 +1489,7 @@ describe("/admin/orders", () => {
|
||||
|
||||
const response = await api.get(
|
||||
"/admin/orders?fields=id&created_at[gt]=633351600",
|
||||
{
|
||||
headers: {
|
||||
authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
adminReqConfig
|
||||
)
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
@@ -1778,11 +1607,7 @@ describe("/admin/orders", () => {
|
||||
price: 400,
|
||||
},
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
adminReqConfig
|
||||
)
|
||||
expect(response.status).toEqual(200)
|
||||
})
|
||||
@@ -1803,20 +1628,15 @@ describe("/admin/orders", () => {
|
||||
],
|
||||
additional_items: [{ variant_id: "test-variant-2", quantity: 1 }],
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
adminReqConfig
|
||||
)
|
||||
|
||||
const swapCartId = response.data.order.swaps[0].cart_id
|
||||
|
||||
const swapCartRes = await api.get(`/store/carts/${swapCartId}`, {
|
||||
headers: {
|
||||
authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
const swapCartRes = await api.get(
|
||||
`/store/carts/${swapCartId}`,
|
||||
adminReqConfig
|
||||
)
|
||||
const cart = swapCartRes.data.cart
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
@@ -1861,11 +1681,7 @@ describe("/admin/orders", () => {
|
||||
],
|
||||
additional_items: [{ variant_id: "test-variant", quantity: 1 }],
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
adminReqConfig
|
||||
)
|
||||
|
||||
const swapCartId = createSwapRes.data.order.swaps[0].cart_id
|
||||
@@ -1876,11 +1692,7 @@ describe("/admin/orders", () => {
|
||||
variant_id: "test-variant-2",
|
||||
quantity: 1,
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
adminReqConfig
|
||||
)
|
||||
|
||||
const cart = response.data.cart
|
||||
@@ -1915,11 +1727,7 @@ describe("/admin/orders", () => {
|
||||
additional_items: [{ variant_id: "test-variant-2", quantity: 1 }],
|
||||
custom_shipping_options: [{ option_id: "test-option", price: 0 }],
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
adminReqConfig
|
||||
)
|
||||
|
||||
const swap = response.data.order.swaps[0]
|
||||
@@ -1955,11 +1763,7 @@ describe("/admin/orders", () => {
|
||||
],
|
||||
receive_now: true,
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
adminReqConfig
|
||||
)
|
||||
|
||||
expect(returnedOrderFirst.status).toEqual(200)
|
||||
@@ -1975,11 +1779,7 @@ describe("/admin/orders", () => {
|
||||
],
|
||||
receive_now: true,
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
adminReqConfig
|
||||
)
|
||||
|
||||
// find item to test returned quantity for
|
||||
@@ -2005,11 +1805,7 @@ describe("/admin/orders", () => {
|
||||
],
|
||||
additional_items: [{ variant_id: "test-variant-2", quantity: 1 }],
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
adminReqConfig
|
||||
)
|
||||
|
||||
expect(createdSwapOrder.status).toEqual(200)
|
||||
@@ -2026,11 +1822,7 @@ describe("/admin/orders", () => {
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
adminReqConfig
|
||||
)
|
||||
|
||||
expect(receivedSwap.status).toEqual(200)
|
||||
@@ -2051,11 +1843,7 @@ describe("/admin/orders", () => {
|
||||
],
|
||||
additional_items: [{ variant_id: "test-variant", quantity: 1 }],
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
adminReqConfig
|
||||
)
|
||||
|
||||
expect(swapOnSwap.status).toEqual(200)
|
||||
@@ -2074,11 +1862,7 @@ describe("/admin/orders", () => {
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
adminReqConfig
|
||||
)
|
||||
|
||||
expect(received.status).toEqual(200)
|
||||
@@ -2098,11 +1882,7 @@ describe("/admin/orders", () => {
|
||||
],
|
||||
return_shipping: { option_id: "test-return-option", price: 0 },
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
adminReqConfig
|
||||
)
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
@@ -2145,11 +1925,7 @@ describe("/admin/orders", () => {
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
adminReqConfig
|
||||
)
|
||||
|
||||
expect(returnOnSwap.status).toEqual(200)
|
||||
@@ -2168,24 +1944,12 @@ describe("/admin/orders", () => {
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
adminReqConfig
|
||||
)
|
||||
|
||||
expect(returnOnOrder.status).toEqual(200)
|
||||
|
||||
await api.post(
|
||||
"/admin/orders/test-order/capture",
|
||||
{},
|
||||
{
|
||||
headers: {
|
||||
authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
)
|
||||
await api.post("/admin/orders/test-order/capture", {}, adminReqConfig)
|
||||
|
||||
const returnId = returnOnOrder.data.order.returns[0].id
|
||||
|
||||
@@ -2199,11 +1963,7 @@ describe("/admin/orders", () => {
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
adminReqConfig
|
||||
)
|
||||
|
||||
expect(received.status).toEqual(200)
|
||||
@@ -2261,6 +2021,8 @@ describe("/admin/orders", () => {
|
||||
})
|
||||
|
||||
describe("GET /admin/orders/:id", () => {
|
||||
const testOrderId = "test-order"
|
||||
|
||||
beforeEach(async () => {
|
||||
await adminSeeder(dbConnection)
|
||||
await orderSeeder(dbConnection)
|
||||
@@ -2275,12 +2037,8 @@ describe("/admin/orders", () => {
|
||||
const api = useApi()
|
||||
|
||||
const order = await api.get(
|
||||
"/admin/orders/test-order?fields=id&expand=region",
|
||||
{
|
||||
headers: {
|
||||
authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
`/admin/orders/${testOrderId}?fields=id&expand=region`,
|
||||
adminReqConfig
|
||||
)
|
||||
|
||||
expect(order.status).toEqual(200)
|
||||
@@ -2294,11 +2052,10 @@ describe("/admin/orders", () => {
|
||||
it("retrieves an order should include the items totals", async () => {
|
||||
const api = useApi()
|
||||
|
||||
const order = await api.get("/admin/orders/test-order", {
|
||||
headers: {
|
||||
authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
const order = await api.get(
|
||||
`/admin/orders/${testOrderId}`,
|
||||
adminReqConfig
|
||||
)
|
||||
|
||||
expect(order.status).toEqual(200)
|
||||
expect(order.data.order).toEqual(
|
||||
@@ -2313,6 +2070,52 @@ describe("/admin/orders", () => {
|
||||
})
|
||||
})
|
||||
|
||||
it("retrieves an order should include deleted items variants", async () => {
|
||||
const api = useApi()
|
||||
|
||||
const variantTitle = "test variant"
|
||||
|
||||
const product = await simpleProductFactory(dbConnection, {
|
||||
variants: [
|
||||
{
|
||||
title: variantTitle,
|
||||
},
|
||||
],
|
||||
})
|
||||
|
||||
const lineItem = await simpleLineItemFactory(dbConnection, {
|
||||
order_id: testOrderId,
|
||||
variant_id: product.variants[0].id,
|
||||
})
|
||||
|
||||
await dbConnection.manager.query(
|
||||
`UPDATE product_variant
|
||||
set deleted_at = NOW()
|
||||
WHERE id = '${product.variants[0].id}';`
|
||||
)
|
||||
|
||||
const order = await api.get(
|
||||
`/admin/orders/${testOrderId}`,
|
||||
adminReqConfig
|
||||
)
|
||||
|
||||
expect(order.status).toEqual(200)
|
||||
expect(order.data.order).toEqual(
|
||||
expect.objectContaining({
|
||||
id: "test-order",
|
||||
items: expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
id: lineItem.id,
|
||||
variant: expect.objectContaining({
|
||||
id: product.variants[0].id,
|
||||
deleted_at: expect.any(String),
|
||||
}),
|
||||
}),
|
||||
]),
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
it("retrieves an order should include a deleted region", async () => {
|
||||
const api = useApi()
|
||||
|
||||
@@ -2322,11 +2125,10 @@ describe("/admin/orders", () => {
|
||||
WHERE id = 'test-region';`
|
||||
)
|
||||
|
||||
const order = await api.get("/admin/orders/test-order", {
|
||||
headers: {
|
||||
authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
const order = await api.get(
|
||||
`/admin/orders/${testOrderId}`,
|
||||
adminReqConfig
|
||||
)
|
||||
|
||||
expect(order.status).toEqual(200)
|
||||
expect(order.data.order).toEqual(
|
||||
|
||||
Reference in New Issue
Block a user