**What** Update the `MedusaService` class, factory and types to remove the concept of main modules. The idea being that all method will be explicitly named and suffixes to represent the object you are trying to manipulate. This pr also includes various fixes in different modules Co-authored-by: Stevche Radevski <4820812+sradevski@users.noreply.github.com> Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
85 lines
2.4 KiB
TypeScript
85 lines
2.4 KiB
TypeScript
import { ModuleRegistrationName, Modules } from "@medusajs/modules-sdk"
|
|
import {
|
|
IFulfillmentModuleService,
|
|
IStockLocationService,
|
|
} 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: IStockLocationService
|
|
let remoteQuery
|
|
let remoteLink
|
|
|
|
beforeAll(async () => {
|
|
appContainer = getContainer()
|
|
fulfillmentModule = appContainer.resolve(
|
|
ModuleRegistrationName.FULFILLMENT
|
|
)
|
|
locationModule = appContainer.resolve(
|
|
ModuleRegistrationName.STOCK_LOCATION
|
|
)
|
|
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.createFulfillmentSets({
|
|
name: "Test fulfillment set",
|
|
type: "delivery",
|
|
})
|
|
|
|
const euWarehouse = await locationModule.createStockLocations({
|
|
name: "EU Warehouse",
|
|
})
|
|
|
|
await remoteLink.create([
|
|
{
|
|
[Modules.STOCK_LOCATION]: {
|
|
stock_location_id: euWarehouse.id,
|
|
},
|
|
[Modules.FULFILLMENT]: {
|
|
fulfillment_set_id: fulfillmentSet.id,
|
|
},
|
|
},
|
|
])
|
|
|
|
const linkQuery = remoteQueryObjectFromString({
|
|
entryPoint: "stock_locations",
|
|
fields: ["id", "fulfillment_sets.id"],
|
|
})
|
|
|
|
const link = await remoteQuery(linkQuery)
|
|
|
|
expect(link).toHaveLength(1)
|
|
expect(link).toEqual(
|
|
expect.arrayContaining([
|
|
expect.objectContaining({
|
|
id: euWarehouse.id,
|
|
fulfillment_sets: expect.arrayContaining([
|
|
expect.objectContaining({
|
|
id: fulfillmentSet.id,
|
|
}),
|
|
]),
|
|
}),
|
|
])
|
|
)
|
|
})
|
|
})
|
|
},
|
|
})
|