feat(core-flows, dashboard, link-modules,medusa, types, utils): fulfillment shipping changes (#10902)
**What** - product <> shipping profile link - create and update product workflows/endpoints accepts shipping profile - pass shipping option id when creating fulfillment to allow overriding customer selected SO - validate shipping profile delete - dashboard - set shipping profile on product create - manage shipping profile for a product - **update the create fulfillment form** - other - fix create product form infinite rerenders --- CLOSES CMRC-831 CMRC-834 CMRC-836 CMRC-837 CMRC-838 CMRC-857 TRI-761
This commit is contained in:
@@ -11,13 +11,21 @@ jest.setTimeout(300000)
|
||||
|
||||
medusaIntegrationTestRunner({
|
||||
testSuite: ({ dbConnection, getContainer, api }) => {
|
||||
let order, seeder, inventoryItemOverride3, productOverride3
|
||||
let order, seeder, inventoryItemOverride3, productOverride3, shippingProfile
|
||||
|
||||
beforeEach(async () => {
|
||||
const container = getContainer()
|
||||
|
||||
await setupTaxStructure(container.resolve(ModuleRegistrationName.TAX))
|
||||
await createAdminUser(dbConnection, adminHeaders, container)
|
||||
|
||||
shippingProfile = (
|
||||
await api.post(
|
||||
`/admin/shipping-profiles`,
|
||||
{ name: "Test", type: "default" },
|
||||
adminHeaders
|
||||
)
|
||||
).data.shipping_profile
|
||||
})
|
||||
|
||||
describe("POST /orders/:id", () => {
|
||||
@@ -345,9 +353,19 @@ medusaIntegrationTestRunner({
|
||||
|
||||
describe("POST /orders/:id/cancel", () => {
|
||||
beforeEach(async () => {
|
||||
const inventoryItemOverride = (
|
||||
await api.post(
|
||||
`/admin/inventory-items`,
|
||||
{ sku: "test-variant", requires_shipping: false },
|
||||
adminHeaders
|
||||
)
|
||||
).data.inventory_item
|
||||
|
||||
seeder = await createOrderSeeder({
|
||||
api,
|
||||
container: getContainer(),
|
||||
inventoryItemOverride,
|
||||
withoutShipping: true,
|
||||
})
|
||||
order = seeder.order
|
||||
|
||||
@@ -536,8 +554,12 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
describe("POST /orders/:id/fulfillments", () => {
|
||||
let productOverride4WithOverrideShippingProfile,
|
||||
shippingProfileOverride,
|
||||
stockChannelOverride
|
||||
|
||||
beforeEach(async () => {
|
||||
const stockChannelOverride = (
|
||||
stockChannelOverride = (
|
||||
await api.post(
|
||||
`/admin/stock-locations`,
|
||||
{ name: "test location" },
|
||||
@@ -558,6 +580,7 @@ medusaIntegrationTestRunner({
|
||||
"/admin/products",
|
||||
{
|
||||
title: `Test fixture`,
|
||||
shipping_profile_id: shippingProfile.id,
|
||||
options: [
|
||||
{ title: "size", values: ["large", "small"] },
|
||||
{ title: "color", values: ["green"] },
|
||||
@@ -605,6 +628,14 @@ medusaIntegrationTestRunner({
|
||||
)
|
||||
).data.inventory_item
|
||||
|
||||
const inventoryItemOverride4RequiresShipping = (
|
||||
await api.post(
|
||||
`/admin/inventory-items`,
|
||||
{ sku: "test-variant-4", requires_shipping: true },
|
||||
adminHeaders
|
||||
)
|
||||
).data.inventory_item
|
||||
|
||||
await api.post(
|
||||
`/admin/inventory-items/${inventoryItemOverride2.id}/location-levels`,
|
||||
{
|
||||
@@ -623,11 +654,21 @@ medusaIntegrationTestRunner({
|
||||
adminHeaders
|
||||
)
|
||||
|
||||
await api.post(
|
||||
`/admin/inventory-items/${inventoryItemOverride4RequiresShipping.id}/location-levels`,
|
||||
{
|
||||
location_id: stockChannelOverride.id,
|
||||
stocked_quantity: 10,
|
||||
},
|
||||
adminHeaders
|
||||
)
|
||||
|
||||
const productOverride2 = (
|
||||
await api.post(
|
||||
"/admin/products",
|
||||
{
|
||||
title: `Test fixture 2`,
|
||||
shipping_profile_id: shippingProfile.id,
|
||||
options: [
|
||||
{ title: "size", values: ["large", "small"] },
|
||||
{ title: "color", values: ["green"] },
|
||||
@@ -664,6 +705,7 @@ medusaIntegrationTestRunner({
|
||||
"/admin/products",
|
||||
{
|
||||
title: `Test fixture 3`,
|
||||
shipping_profile_id: shippingProfile.id,
|
||||
options: [
|
||||
{ title: "size", values: ["large", "small"] },
|
||||
{ title: "color", values: ["green"] },
|
||||
@@ -695,6 +737,52 @@ medusaIntegrationTestRunner({
|
||||
)
|
||||
).data.product
|
||||
|
||||
shippingProfileOverride = (
|
||||
await api.post(
|
||||
`/admin/shipping-profiles`,
|
||||
{ name: `test-${stockChannelOverride.id}`, type: "default" },
|
||||
adminHeaders
|
||||
)
|
||||
).data.shipping_profile
|
||||
|
||||
productOverride4WithOverrideShippingProfile = (
|
||||
await api.post(
|
||||
"/admin/products",
|
||||
{
|
||||
title: `Test fixture 4`,
|
||||
shipping_profile_id: shippingProfileOverride.id,
|
||||
options: [
|
||||
{ title: "size", values: ["large", "small"] },
|
||||
{ title: "color", values: ["green"] },
|
||||
],
|
||||
variants: [
|
||||
{
|
||||
title: "Test variant 4",
|
||||
sku: "test-variant-4",
|
||||
inventory_items: [
|
||||
{
|
||||
inventory_item_id:
|
||||
inventoryItemOverride4RequiresShipping.id,
|
||||
required_quantity: 1,
|
||||
},
|
||||
],
|
||||
prices: [
|
||||
{
|
||||
currency_code: "usd",
|
||||
amount: 100,
|
||||
},
|
||||
],
|
||||
options: {
|
||||
size: "small",
|
||||
color: "green",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
adminHeaders
|
||||
)
|
||||
).data.product
|
||||
|
||||
seeder = await createOrderSeeder({
|
||||
api,
|
||||
container: getContainer(),
|
||||
@@ -702,9 +790,15 @@ medusaIntegrationTestRunner({
|
||||
additionalProducts: [
|
||||
{ variant_id: productOverride2.variants[0].id, quantity: 1 },
|
||||
{ variant_id: productOverride3.variants[0].id, quantity: 3 },
|
||||
{
|
||||
variant_id:
|
||||
productOverride4WithOverrideShippingProfile.variants[0].id,
|
||||
quantity: 1,
|
||||
},
|
||||
],
|
||||
stockChannelOverride,
|
||||
inventoryItemOverride,
|
||||
shippingProfileOverride: shippingProfile,
|
||||
})
|
||||
order = seeder.order
|
||||
order = (await api.get(`/admin/orders/${order.id}`, adminHeaders)).data
|
||||
@@ -827,6 +921,30 @@ medusaIntegrationTestRunner({
|
||||
)
|
||||
})
|
||||
|
||||
it("should throw if shipping profile of the product doesn't match the shipping profile of the shipping option", async () => {
|
||||
const orderItemId = order.items.find(
|
||||
(i) =>
|
||||
i.variant_id ===
|
||||
productOverride4WithOverrideShippingProfile.variants[0].id
|
||||
).id
|
||||
|
||||
const res = await api
|
||||
.post(
|
||||
`/admin/orders/${order.id}/fulfillments`,
|
||||
{
|
||||
location_id: stockChannelOverride.id,
|
||||
items: [{ id: orderItemId, quantity: 1 }],
|
||||
},
|
||||
adminHeaders
|
||||
)
|
||||
.catch((e) => e)
|
||||
|
||||
expect(res.response.status).toBe(400)
|
||||
expect(res.response.data.message).toBe(
|
||||
`Shipping profile ${seeder.shippingProfile.id} does not match the shipping profile of the order item ${orderItemId}`
|
||||
)
|
||||
})
|
||||
|
||||
it("should only create fulfillments grouped by shipping requirement", async () => {
|
||||
const {
|
||||
response: { data },
|
||||
|
||||
@@ -24,7 +24,21 @@ medusaIntegrationTestRunner({
|
||||
|
||||
await setupTaxStructure(container.resolve(Modules.TAX))
|
||||
await createAdminUser(dbConnection, adminHeaders, container)
|
||||
const seeders = await createOrderSeeder({ api, container })
|
||||
|
||||
const inventoryItemOverride = (
|
||||
await api.post(
|
||||
`/admin/inventory-items`,
|
||||
{ sku: "test-variant", requires_shipping: false },
|
||||
adminHeaders
|
||||
)
|
||||
).data.inventory_item
|
||||
|
||||
const seeders = await createOrderSeeder({
|
||||
api,
|
||||
container,
|
||||
inventoryItemOverride,
|
||||
withoutShipping: true,
|
||||
})
|
||||
order = seeders.order
|
||||
|
||||
shippingProfile = (
|
||||
|
||||
Reference in New Issue
Block a user