feat: Returns order previews (#8135)
* work on order previews * fix create return shipping flow * fix http tests * fix tests
This commit is contained in:
@@ -70,7 +70,11 @@ medusaIntegrationTestRunner({
|
||||
},
|
||||
})
|
||||
|
||||
expect(orderChangePreview.shipping_methods[1].actions).toEqual([
|
||||
const shippingMethod = orderChangePreview.shipping_methods?.find(
|
||||
(sm) => sm.shipping_option_id === shippingOptionId
|
||||
)
|
||||
|
||||
expect((shippingMethod as any).actions).toEqual([
|
||||
expect.objectContaining({
|
||||
id: expect.any(String),
|
||||
reference: "order_shipping_method",
|
||||
@@ -95,7 +99,11 @@ medusaIntegrationTestRunner({
|
||||
},
|
||||
})
|
||||
|
||||
expect(orderChangePreview.shipping_methods[1].actions).toEqual([
|
||||
const shippingMethod = orderChangePreview.shipping_methods?.find(
|
||||
(sm) => sm.shipping_option_id === shippingOptionId
|
||||
)
|
||||
|
||||
expect((shippingMethod as any).actions).toEqual([
|
||||
expect.objectContaining({
|
||||
id: expect.any(String),
|
||||
reference: "order_shipping_method",
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import {
|
||||
beginReturnOrderWorkflow,
|
||||
createOrderFulfillmentWorkflow,
|
||||
requestItemReturnWorkflow,
|
||||
} from "@medusajs/core-flows"
|
||||
import { IOrderModuleService, OrderDTO, ReturnDTO } from "@medusajs/types"
|
||||
@@ -37,6 +38,18 @@ medusaIntegrationTestRunner({
|
||||
inventoryItem: fixtures.inventoryItem,
|
||||
})
|
||||
|
||||
await createOrderFulfillmentWorkflow(container).run({
|
||||
input: {
|
||||
order_id: order.id,
|
||||
items: [
|
||||
{
|
||||
quantity: 1,
|
||||
id: order.items![0].id,
|
||||
},
|
||||
],
|
||||
},
|
||||
})
|
||||
|
||||
await beginReturnOrderWorkflow(container).run({
|
||||
input: { order_id: order.id },
|
||||
throwOnError: true,
|
||||
@@ -59,9 +72,7 @@ medusaIntegrationTestRunner({
|
||||
describe("requestItemReturnWorkflow", () => {
|
||||
it("should successfully add a return item to order change", async () => {
|
||||
const item = order.items![0]
|
||||
const {
|
||||
result: [returnItem],
|
||||
} = await requestItemReturnWorkflow(container).run({
|
||||
const { result } = await requestItemReturnWorkflow(container).run({
|
||||
input: {
|
||||
return_id: returnOrder.id,
|
||||
items: [
|
||||
@@ -74,19 +85,18 @@ medusaIntegrationTestRunner({
|
||||
},
|
||||
})
|
||||
|
||||
const returnItem = result.items?.[0]
|
||||
|
||||
expect(returnItem).toEqual(
|
||||
expect.objectContaining({
|
||||
id: expect.any(String),
|
||||
order_id: order.id,
|
||||
return_id: returnOrder.id,
|
||||
reference: "return",
|
||||
reference_id: returnOrder.id,
|
||||
details: {
|
||||
reference_id: item.id,
|
||||
quantity: 1,
|
||||
},
|
||||
internal_note: "test",
|
||||
action: "RETURN_ITEM",
|
||||
title: "Custom Item 2",
|
||||
unit_price: 50,
|
||||
quantity: 1,
|
||||
subtotal: 50,
|
||||
total: 50,
|
||||
fulfilled_total: 50,
|
||||
return_requested_total: 50,
|
||||
})
|
||||
)
|
||||
})
|
||||
@@ -142,7 +152,7 @@ medusaIntegrationTestRunner({
|
||||
const item = order.items![0]
|
||||
|
||||
const [orderChange] = await service.listOrderChanges(
|
||||
{ order_id: order.id },
|
||||
{ order_id: order.id, return_id: returnOrder.id },
|
||||
{}
|
||||
)
|
||||
|
||||
@@ -173,7 +183,7 @@ medusaIntegrationTestRunner({
|
||||
const item = order.items![0]
|
||||
|
||||
const [orderChange] = await service.listOrderChanges(
|
||||
{ order_id: order.id },
|
||||
{ order_id: order.id, return_id: returnOrder.id },
|
||||
{}
|
||||
)
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
"license": "MIT",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"test:integration": "jest --silent --no-cache --maxWorkers=50% --bail --detectOpenHandles --forceExit --logHeapUsage",
|
||||
"test:integration": "jest --silent=false --no-cache --maxWorkers=50% --bail --detectOpenHandles --forceExit --logHeapUsage",
|
||||
"test:integration:chunk": "jest --silent --no-cache --bail --maxWorkers=50% --forceExit --testPathPattern=$(echo $CHUNKS | jq -r \".[${CHUNK}] | .[]\")",
|
||||
"build": "tsc ./src/* --allowJs --outDir ./dist"
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user