Skip to content

Commit

Permalink
feat(core-flows, dashboard, link-modules,medusa, types, utils): fulfi…
Browse files Browse the repository at this point in the history
…llment 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
  • Loading branch information
fPolic authored Jan 27, 2025
1 parent 3e81962 commit 864d772
Show file tree
Hide file tree
Showing 78 changed files with 3,544 additions and 809 deletions.
13 changes: 11 additions & 2 deletions integration-tests/http/__tests__/cart/store/cart.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ medusaIntegrationTestRunner({
salesChannel,
cart,
customer,
promotion
promotion,
shippingProfile

beforeAll(async () => {
appContainer = getContainer()
Expand All @@ -68,6 +69,14 @@ medusaIntegrationTestRunner({
},
}

shippingProfile = (
await api.post(
`/admin/shipping-profiles`,
{ name: "default", type: "default" },
adminHeaders
)
).data.shipping_profile

await setupTaxStructure(appContainer.resolve(Modules.TAX))

region = (
Expand All @@ -87,7 +96,7 @@ medusaIntegrationTestRunner({
).data.region

product = (
await api.post("/admin/products", medusaTshirtProduct, adminHeaders)
await api.post("/admin/products", { ...medusaTshirtProduct, shipping_profile_id: shippingProfile.id }, adminHeaders)
).data.product

salesChannel = (
Expand Down
24 changes: 13 additions & 11 deletions integration-tests/http/__tests__/claims/claims.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,17 @@ medusaIntegrationTestRunner({
const container = getContainer()
await createAdminUser(dbConnection, adminHeaders, container)

shippingProfile = (
await api.post(
`/admin/shipping-profiles`,
{
name: "Test",
type: "default",
},
adminHeaders
)
).data.shipping_profile

const region = (
await api.post(
"/admin/regions",
Expand Down Expand Up @@ -72,6 +83,7 @@ medusaIntegrationTestRunner({
{
title: "Test product",
options: [{ title: "size", values: ["large", "small"] }],
shipping_profile_id: shippingProfile.id,
variants: [
{
title: "Test variant",
Expand All @@ -96,6 +108,7 @@ medusaIntegrationTestRunner({
{
title: "Extra product",
options: [{ title: "size", values: ["large", "small"] }],
shipping_profile_id: shippingProfile.id,
variants: [
{
title: "my variant",
Expand Down Expand Up @@ -213,17 +226,6 @@ medusaIntegrationTestRunner({
customer_id: customer.id,
})

shippingProfile = (
await api.post(
`/admin/shipping-profiles`,
{
name: "Test",
type: "default",
},
adminHeaders
)
).data.shipping_profile

location = (
await api.post(
`/admin/stock-locations`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ medusaIntegrationTestRunner({
let baseProduct
let baseProduct1

let shippingProfile

beforeEach(async () => {
const container = getContainer()
await createAdminUser(dbConnection, adminHeaders, container)
Expand Down Expand Up @@ -44,12 +46,21 @@ medusaIntegrationTestRunner({
)
).data.collection

shippingProfile = (
await api.post(
`/admin/shipping-profiles`,
{ name: "Test", type: "default" },
adminHeaders
)
).data.shipping_profile

baseProduct = (
await api.post(
"/admin/products",
{
title: "test-product",
options: [{ title: "size", values: ["x", "l"] }],
shipping_profile_id: shippingProfile.id,
},
adminHeaders
)
Expand All @@ -61,6 +72,7 @@ medusaIntegrationTestRunner({
{
title: "test-product1",
options: [{ title: "size", values: ["x", "l"] }],
shipping_profile_id: shippingProfile.id,
},
adminHeaders
)
Expand Down
24 changes: 13 additions & 11 deletions integration-tests/http/__tests__/exchanges/exchanges.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,17 @@ medusaIntegrationTestRunner({
)
).data.region

shippingProfile = (
await api.post(
`/admin/shipping-profiles`,
{
name: "Test",
type: "default",
},
adminHeaders
)
).data.shipping_profile

const customer = (
await api.post(
"/admin/customers",
Expand All @@ -67,6 +78,7 @@ medusaIntegrationTestRunner({
"/admin/products",
{
title: "Test product",
shipping_profile_id: shippingProfile.id,
options: [{ title: "size", values: ["large", "small"] }],
variants: [
{
Expand All @@ -91,6 +103,7 @@ medusaIntegrationTestRunner({
"/admin/products",
{
title: "Extra product",
shipping_profile_id: shippingProfile.id,
options: [{ title: "size", values: ["large", "small"] }],
variants: [
{
Expand Down Expand Up @@ -203,17 +216,6 @@ medusaIntegrationTestRunner({
customer_id: customer.id,
})

shippingProfile = (
await api.post(
`/admin/shipping-profiles`,
{
name: "Test",
type: "default",
},
adminHeaders
)
).data.shipping_profile

location = (
await api.post(
`/admin/stock-locations`,
Expand Down
30 changes: 23 additions & 7 deletions integration-tests/http/__tests__/fixtures/order.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
AdminInventoryItem,
AdminProduct,
AdminShippingProfile,
AdminStockLocation,
MedusaContainer,
} from "@medusajs/types"
Expand All @@ -18,6 +19,8 @@ export async function createOrderSeeder({
additionalProducts,
stockChannelOverride,
inventoryItemOverride,
shippingProfileOverride,
withoutShipping,
}: {
api: any
container: MedusaContainer
Expand All @@ -26,6 +29,8 @@ export async function createOrderSeeder({
stockChannelOverride?: AdminStockLocation
additionalProducts?: { variant_id: string; quantity: number }[]
inventoryItemOverride?: AdminInventoryItem
shippingProfileOverride?: AdminShippingProfile
withoutShipping?: boolean
}) {
const publishableKey = await generatePublishableKey(container)

Expand Down Expand Up @@ -86,13 +91,15 @@ export async function createOrderSeeder({
adminHeaders
)

const shippingProfile = (
await api.post(
`/admin/shipping-profiles`,
{ name: `test-${stockLocation.id}`, type: "default" },
adminHeaders
)
).data.shipping_profile
const shippingProfile =
shippingProfileOverride ??
(
await api.post(
`/admin/shipping-profiles`,
{ name: `test-${stockLocation.id}`, type: "default" },
adminHeaders
)
).data.shipping_profile

const product =
productOverride ??
Expand All @@ -101,6 +108,7 @@ export async function createOrderSeeder({
"/admin/products",
{
title: `Test fixture ${shippingProfile.id}`,
shipping_profile_id: shippingProfile.id,
options: [
{ title: "size", values: ["large", "small"] },
{ title: "color", values: ["green"] },
Expand Down Expand Up @@ -217,6 +225,14 @@ export async function createOrderSeeder({
)
).data.cart

if (!withoutShipping) {
await api.post(
`/store/carts/${cart.id}/shipping-methods`,
{ option_id: shippingOption.id },
storeHeaders
)
}

const paymentCollection = (
await api.post(
`/store/payment-collections`,
Expand Down
11 changes: 11 additions & 0 deletions integration-tests/http/__tests__/inventory/admin/inventory.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,19 @@ medusaIntegrationTestRunner({
let stockLocation1
let stockLocation2
let stockLocation3

let shippingProfile
beforeEach(async () => {
await createAdminUser(dbConnection, adminHeaders, getContainer())

shippingProfile = (
await api.post(
`/admin/shipping-profiles`,
{ name: "Test", type: "default" },
adminHeaders
)
).data.shipping_profile

stockLocation1 = (
await api.post(`/admin/stock-locations`, { name: "loc1" }, adminHeaders)
).data.stock_location
Expand Down Expand Up @@ -990,6 +1000,7 @@ medusaIntegrationTestRunner({
{
title: "product 1",
options: [{ title: "size", values: ["large"] }],
shipping_profile_id: shippingProfile.id,
variants: [
{
title: "variant 1",
Expand Down
24 changes: 13 additions & 11 deletions integration-tests/http/__tests__/order-edits/order-edits.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,24 @@ medusaIntegrationTestRunner({
)
).data.sales_channel

shippingProfile = (
await api.post(
`/admin/shipping-profiles`,
{
name: "Test",
type: "default",
},
adminHeaders
)
).data.shipping_profile

const product = (
await api.post(
"/admin/products",
{
title: "Test product",
options: [{ title: "size", values: ["large", "small"] }],
shipping_profile_id: shippingProfile.id,
variants: [
{
title: "Test variant",
Expand All @@ -115,6 +127,7 @@ medusaIntegrationTestRunner({
{
title: "Extra product",
options: [{ title: "size", values: ["large", "small"] }],
shipping_profile_id: shippingProfile.id,
variants: [
{
title: "my variant",
Expand Down Expand Up @@ -174,17 +187,6 @@ medusaIntegrationTestRunner({
customer_id: customer.id,
})

shippingProfile = (
await api.post(
`/admin/shipping-profiles`,
{
name: "Test",
type: "default",
},
adminHeaders
)
).data.shipping_profile

location = (
await api.post(
`/admin/stock-locations`,
Expand Down
Loading

0 comments on commit 864d772

Please sign in to comment.