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:
@@ -658,6 +658,7 @@ medusaIntegrationTestRunner({
|
||||
|
||||
describe("POST /store/carts/:id/line-items", () => {
|
||||
let region
|
||||
|
||||
const productData = {
|
||||
title: "Medusa T-Shirt",
|
||||
handle: "t-shirt",
|
||||
@@ -716,8 +717,21 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
it("adding an existing variant should update or create line item depending on metadata", async () => {
|
||||
const shippingProfile =
|
||||
await fulfillmentModule.createShippingProfiles({
|
||||
name: "Test",
|
||||
type: "default",
|
||||
})
|
||||
|
||||
const product = (
|
||||
await api.post(`/admin/products`, productData, adminHeaders)
|
||||
await api.post(
|
||||
`/admin/products`,
|
||||
{
|
||||
...productData,
|
||||
shipping_profile_id: shippingProfile.id,
|
||||
},
|
||||
adminHeaders
|
||||
)
|
||||
).data.product
|
||||
|
||||
const cart = (
|
||||
@@ -1203,6 +1217,7 @@ medusaIntegrationTestRunner({
|
||||
"/admin/products",
|
||||
{
|
||||
title: "Test fixture",
|
||||
shipping_profile_id: shippingProfile.id,
|
||||
options: [
|
||||
{ title: "size", values: ["large", "small"] },
|
||||
{ title: "color", values: ["green"] },
|
||||
|
||||
@@ -30,11 +30,20 @@ medusaIntegrationTestRunner({
|
||||
beforeEach(async () => {
|
||||
await createAdminUser(dbConnection, adminHeaders, getContainer())
|
||||
|
||||
const shippingProfile = (
|
||||
await api.post(
|
||||
`/admin/shipping-profiles`,
|
||||
{ name: "Test", type: "default" },
|
||||
adminHeaders
|
||||
)
|
||||
).data.shipping_profile
|
||||
|
||||
product = (
|
||||
await api.post(
|
||||
"/admin/products",
|
||||
{
|
||||
title: "product 1",
|
||||
shipping_profile_id: shippingProfile.id,
|
||||
options: [{ title: "size", values: ["x", "l"] }],
|
||||
variants: [
|
||||
{
|
||||
|
||||
@@ -31,9 +31,18 @@ medusaIntegrationTestRunner({
|
||||
|
||||
describe("Index engine", () => {
|
||||
it("should search through the indexed data and return the correct results ordered and filtered [1]", async () => {
|
||||
const shippingProfile = (
|
||||
await api.post(
|
||||
`/admin/shipping-profiles`,
|
||||
{ name: "Test", type: "default" },
|
||||
adminHeaders
|
||||
)
|
||||
).data.shipping_profile
|
||||
|
||||
const payload = {
|
||||
title: "Test Giftcard",
|
||||
is_giftcard: true,
|
||||
shipping_profile_id: shippingProfile.id,
|
||||
description: "test-giftcard-description",
|
||||
options: [{ title: "Denominations", values: ["100"] }],
|
||||
variants: new Array(10).fill(0).map((_, i) => ({
|
||||
@@ -101,10 +110,19 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
it("should search through the indexed data and return the correct results ordered and filtered [2]", async () => {
|
||||
const shippingProfile = (
|
||||
await api.post(
|
||||
`/admin/shipping-profiles`,
|
||||
{ name: "Test", type: "default" },
|
||||
adminHeaders
|
||||
)
|
||||
).data.shipping_profile
|
||||
|
||||
const payload = {
|
||||
title: "Test Giftcard",
|
||||
is_giftcard: true,
|
||||
description: "test-giftcard-description",
|
||||
shipping_profile_id: shippingProfile.id,
|
||||
options: [{ title: "Denominations", values: ["100"] }],
|
||||
variants: new Array(10).fill(0).map((_, i) => ({
|
||||
title: `Test variant ${i}`,
|
||||
@@ -171,9 +189,18 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
it.skip("should search through the indexed data and return the correct results ordered and filtered [3]", async () => {
|
||||
const shippingProfile = (
|
||||
await api.post(
|
||||
`/admin/shipping-profiles`,
|
||||
{ name: "Test", type: "default" },
|
||||
adminHeaders
|
||||
)
|
||||
).data.shipping_profile
|
||||
|
||||
const payloads = new Array(50).fill(0).map((_, a) => ({
|
||||
title: "Test Giftcard-" + a,
|
||||
is_giftcard: true,
|
||||
shipping_profile_id: shippingProfile.id,
|
||||
description: "test-giftcard-description" + a,
|
||||
options: [{ title: "Denominations", values: ["100"] }],
|
||||
variants: new Array(10).fill(0).map((_, i) => ({
|
||||
|
||||
@@ -209,9 +209,18 @@ medusaIntegrationTestRunner({
|
||||
beforeEach(async () => {
|
||||
await createAdminUser(dbConnection, adminHeaders, appContainer)
|
||||
|
||||
const shippingProfile = (
|
||||
await api.post(
|
||||
`/admin/shipping-profiles`,
|
||||
{ name: "Test", type: "default" },
|
||||
adminHeaders
|
||||
)
|
||||
).data.shipping_profile
|
||||
|
||||
const payload = {
|
||||
title: "Test Giftcard",
|
||||
is_giftcard: true,
|
||||
shipping_profile_id: shippingProfile.id,
|
||||
description: "test-giftcard-description",
|
||||
options: [{ title: "Denominations", values: ["100"] }],
|
||||
variants: [
|
||||
|
||||
@@ -130,6 +130,17 @@ async function prepareDataFixtures({ container }) {
|
||||
},
|
||||
])
|
||||
|
||||
await remoteLink.create([
|
||||
{
|
||||
[Modules.PRODUCT]: {
|
||||
product_id: product.id,
|
||||
},
|
||||
[Modules.FULFILLMENT]: {
|
||||
shipping_profile_id: shippingProfile.id,
|
||||
},
|
||||
},
|
||||
])
|
||||
|
||||
await remoteLink.create([
|
||||
{
|
||||
[Modules.STOCK_LOCATION]: {
|
||||
|
||||
@@ -124,6 +124,17 @@ async function prepareDataFixtures({ container }) {
|
||||
},
|
||||
])
|
||||
|
||||
await remoteLink.create([
|
||||
{
|
||||
[Modules.PRODUCT]: {
|
||||
product_id: product.id,
|
||||
},
|
||||
[Modules.FULFILLMENT]: {
|
||||
shipping_profile_id: shippingProfile.id,
|
||||
},
|
||||
},
|
||||
])
|
||||
|
||||
await remoteLink.create([
|
||||
{
|
||||
[Modules.STOCK_LOCATION]: {
|
||||
|
||||
@@ -4,7 +4,10 @@ import {
|
||||
batchProductVariantsWorkflow,
|
||||
batchProductVariantsWorkflowId,
|
||||
} from "@medusajs/core-flows"
|
||||
import { IProductModuleService } from "@medusajs/types"
|
||||
import {
|
||||
IFulfillmentModuleService,
|
||||
IProductModuleService,
|
||||
} from "@medusajs/types"
|
||||
import { Modules } from "@medusajs/utils"
|
||||
import { medusaIntegrationTestRunner } from "@medusajs/test-utils"
|
||||
|
||||
@@ -17,9 +20,20 @@ medusaIntegrationTestRunner({
|
||||
let appContainer
|
||||
let service: IProductModuleService
|
||||
|
||||
let fulfullmentService: IFulfillmentModuleService
|
||||
let shippingProfile
|
||||
|
||||
beforeAll(async () => {
|
||||
appContainer = getContainer()
|
||||
service = appContainer.resolve(Modules.PRODUCT)
|
||||
fulfullmentService = appContainer.resolve(Modules.FULFILLMENT)
|
||||
})
|
||||
|
||||
beforeEach(async () => {
|
||||
shippingProfile = await fulfullmentService.createShippingProfiles({
|
||||
name: "Test",
|
||||
type: "default",
|
||||
})
|
||||
})
|
||||
|
||||
describe("batchProductWorkflow", () => {
|
||||
@@ -43,7 +57,8 @@ medusaIntegrationTestRunner({
|
||||
create: [
|
||||
{
|
||||
title: "test3",
|
||||
options: [{ title: "size", options: ["x"] }],
|
||||
shipping_profile_id: shippingProfile.id,
|
||||
options: [{ title: "size", values: ["x"] }],
|
||||
},
|
||||
],
|
||||
update: [{ id: product1.id, title: "test1-updated" }],
|
||||
@@ -94,6 +109,7 @@ medusaIntegrationTestRunner({
|
||||
{
|
||||
title: "test1",
|
||||
options: [{ title: "size", values: ["x", "l", "m"] }],
|
||||
shipping_profile_id: shippingProfile.id,
|
||||
variants: [
|
||||
{
|
||||
title: "variant1",
|
||||
|
||||
Reference in New Issue
Block a user