feat: List shipping options for cart (#6677)

This commit is contained in:
Oli Juhl
2024-03-13 09:08:47 +00:00
committed by GitHub
parent db26dafa85
commit 25d176b851
23 changed files with 855 additions and 142 deletions
@@ -0,0 +1,87 @@
import { ModuleRegistrationName, Modules } from "@medusajs/modules-sdk"
import {
IFulfillmentModuleService,
ISalesChannelModuleService,
IStockLocationServiceNext,
} from "@medusajs/types"
import {
ContainerRegistrationKeys,
remoteQueryObjectFromString,
} from "@medusajs/utils"
import { medusaIntegrationTestRunner } from "medusa-test-utils"
jest.setTimeout(50000)
const env = { MEDUSA_FF_MEDUSA_V2: true }
medusaIntegrationTestRunner({
env,
testSuite: ({ getContainer }) => {
describe("FulfillmentSet and Location", () => {
let appContainer
let fulfillmentModule: IFulfillmentModuleService
let locationModule: IStockLocationServiceNext
let scService: ISalesChannelModuleService
let remoteQuery
let remoteLink
beforeAll(async () => {
appContainer = getContainer()
fulfillmentModule = appContainer.resolve(
ModuleRegistrationName.FULFILLMENT
)
locationModule = appContainer.resolve(
ModuleRegistrationName.STOCK_LOCATION
)
scService = appContainer.resolve(ModuleRegistrationName.SALES_CHANNEL)
remoteQuery = appContainer.resolve(
ContainerRegistrationKeys.REMOTE_QUERY
)
remoteLink = appContainer.resolve(ContainerRegistrationKeys.REMOTE_LINK)
})
it("should query fulfillment set and location link with remote query", async () => {
const fulfillmentSet = await fulfillmentModule.create({
name: "Test fulfillment set",
type: "delivery",
})
const euWarehouse = await locationModule.create({
name: "EU Warehouse",
})
await remoteLink.create([
{
[Modules.FULFILLMENT]: {
fulfillment_set_id: fulfillmentSet.id,
},
[Modules.STOCK_LOCATION]: {
stock_location_id: euWarehouse.id,
},
},
])
const linkQuery = remoteQueryObjectFromString({
entryPoint: "fulfillment_sets",
fields: ["id", "stock_locations.id"],
})
const link = await remoteQuery(linkQuery)
expect(link).toHaveLength(1)
expect(link).toEqual(
expect.arrayContaining([
expect.objectContaining({
id: fulfillmentSet.id,
stock_locations: expect.arrayContaining([
expect.objectContaining({
id: euWarehouse.id,
}),
]),
}),
])
)
})
})
},
})
@@ -56,7 +56,7 @@ medusaIntegrationTestRunner({
sales_channel_id: scWebshop.id,
},
[Modules.STOCK_LOCATION]: {
location_id: euWarehouse.id,
stock_location_id: euWarehouse.id,
},
},
{
@@ -64,7 +64,7 @@ medusaIntegrationTestRunner({
sales_channel_id: scCphStore.id,
},
[Modules.STOCK_LOCATION]: {
location_id: euWarehouse.id,
stock_location_id: euWarehouse.id,
},
},
{
@@ -72,7 +72,7 @@ medusaIntegrationTestRunner({
sales_channel_id: scNycStore.id,
},
[Modules.STOCK_LOCATION]: {
location_id: usWarehouse.id,
stock_location_id: usWarehouse.id,
},
},
])