Feat(Medusa): Allow custom shipping price on draft orders (#2531)
* create custom shipping option for cart to have custom shipping price on draft orders * Create moody-chefs-stare.md
This commit is contained in:
@@ -71,6 +71,52 @@ describe("/admin/draft-orders", () => {
|
||||
expect(response.status).toEqual(200)
|
||||
})
|
||||
|
||||
it("creates a draft order with a custom shipping option price", async () => {
|
||||
const api = useApi()
|
||||
|
||||
const payload = {
|
||||
email: "oli@test.dk",
|
||||
shipping_address: "oli-shipping",
|
||||
items: [
|
||||
{
|
||||
variant_id: "test-variant",
|
||||
quantity: 2,
|
||||
metadata: {},
|
||||
},
|
||||
],
|
||||
region_id: "test-region",
|
||||
customer_id: "oli-test",
|
||||
shipping_methods: [
|
||||
{
|
||||
option_id: "test-option",
|
||||
price: 500,
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
const response = await api.post("/admin/draft-orders", payload, {
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
expect(response.status).toEqual(200)
|
||||
|
||||
const draftOrderId = response.data.draft_order.id
|
||||
|
||||
const draftOrderResponse = await api.get(
|
||||
`/admin/draft-orders/${draftOrderId}`,
|
||||
{
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
)
|
||||
expect(draftOrderResponse.status).toEqual(200)
|
||||
expect(draftOrderResponse.data.draft_order.cart.shipping_total).toEqual(
|
||||
500
|
||||
)
|
||||
})
|
||||
|
||||
it("creates a draft order with a billing address that is an AddressPayload and a shipping address that is an ID", async () => {
|
||||
const api = useApi()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user