added some more tests
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { IdMap } from "medusa-test-utils"
|
||||
import { request } from "../../../../../helpers/test-request"
|
||||
import { OrderServiceMock } from "../../../../../services/__mocks__/order"
|
||||
import { EventBusServiceMock } from "../../../../../services/__mocks__/event-bus"
|
||||
|
||||
describe("POST /admin/orders/:id/fulfillment", () => {
|
||||
describe("successfully fulfills an order", () => {
|
||||
@@ -42,6 +43,7 @@ describe("POST /admin/orders/:id/fulfillment", () => {
|
||||
quantity: 1,
|
||||
},
|
||||
],
|
||||
undefined,
|
||||
undefined
|
||||
)
|
||||
})
|
||||
@@ -51,5 +53,6 @@ describe("POST /admin/orders/:id/fulfillment", () => {
|
||||
expect(subject.body.order.id).toEqual(IdMap.getId("test-order"))
|
||||
expect(subject.body.order.fulfillment_status).toEqual("fulfilled")
|
||||
})
|
||||
|
||||
})
|
||||
})
|
||||
|
||||
@@ -24,6 +24,9 @@ import { defaultRelations, defaultFields } from "./"
|
||||
* quantity:
|
||||
* description: The quantity of the Line Item to fulfill.
|
||||
* type: integer
|
||||
* no_notification:
|
||||
* description: If set to true no notification will be send related to this Swap.
|
||||
* type: boolean
|
||||
* metadata:
|
||||
* description: An optional set of key-value pairs to hold additional information.
|
||||
* type: object
|
||||
@@ -49,6 +52,7 @@ export default async (req, res) => {
|
||||
quantity: Validator.number().required(),
|
||||
})
|
||||
.required(),
|
||||
no_notification: Validator.boolean().optional(),
|
||||
metadata: Validator.object().optional(),
|
||||
})
|
||||
|
||||
@@ -60,7 +64,7 @@ export default async (req, res) => {
|
||||
try {
|
||||
const orderService = req.scope.resolve("orderService")
|
||||
|
||||
await orderService.createFulfillment(id, value.items, value.metadata)
|
||||
await orderService.createFulfillment(id, value.items, value.no_notification, value.metadata)
|
||||
|
||||
const order = await orderService.retrieve(id, {
|
||||
select: defaultFields,
|
||||
|
||||
@@ -21,6 +21,9 @@ import { defaultRelations, defaultFields } from "./"
|
||||
* type: array
|
||||
* items:
|
||||
* type: string
|
||||
* no_notification:
|
||||
* description: If set to true no notification will be send related to this Claim.
|
||||
* type: boolean
|
||||
* tags:
|
||||
* - Order
|
||||
* responses:
|
||||
@@ -41,6 +44,7 @@ export default async (req, res) => {
|
||||
tracking_numbers: Validator.array()
|
||||
.items(Validator.string())
|
||||
.optional(),
|
||||
no_notification: Validator.boolean().optional(),
|
||||
})
|
||||
|
||||
const { value, error } = schema.validate(req.body)
|
||||
@@ -54,7 +58,8 @@ export default async (req, res) => {
|
||||
await orderService.createShipment(
|
||||
id,
|
||||
value.fulfillment_id,
|
||||
value.tracking_numbers.map(n => ({ tracking_number: n }))
|
||||
value.tracking_numbers.map(n => ({ tracking_number: n })),
|
||||
value.no_notification,
|
||||
)
|
||||
|
||||
const order = await orderService.retrieve(id, {
|
||||
|
||||
@@ -54,6 +54,7 @@ export default async (req, res) => {
|
||||
})
|
||||
|
||||
const { value, error } = schema.validate(req.body)
|
||||
|
||||
if (error) {
|
||||
throw new MedusaError(MedusaError.Types.INVALID_DATA, error.details)
|
||||
}
|
||||
|
||||
@@ -54,10 +54,13 @@ export default async (req, res) => {
|
||||
})
|
||||
|
||||
const { value, error } = schema.validate(req.body)
|
||||
|
||||
if (error) {
|
||||
console.log(error)
|
||||
throw new MedusaError(MedusaError.Types.INVALID_DATA, error.details)
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
const returnService = req.scope.resolve("returnService")
|
||||
const orderService = req.scope.resolve("orderService")
|
||||
|
||||
Reference in New Issue
Block a user