fix(workflow-engine-*): Prevent passing shared context reference (#11873)

* fix(workflow-engine-*): Prevent passing shared context reference

* fix(workflow-engine-*): Prevent passing shared context reference

* prevent tests from hanging

* fix event handling

* add integration tests

* use interval for scheduled in tests

* skip tests for now

* Create silent-glasses-enjoy.md

* fix cancel

* changeset

* push multiple aliases

* test multiple field alias

* increase wait time to index on test

---------

Co-authored-by: Carlos R. L. Rodrigues <37986729+carlos-r-l-rodrigues@users.noreply.github.com>
Co-authored-by: Carlos R. L. Rodrigues <rodrigolr@gmail.com>
This commit is contained in:
Adrien de Peretti
2025-04-09 10:39:29 +02:00
committed by GitHub
parent 2a18a75353
commit 13e159d8ad
18 changed files with 353 additions and 58 deletions

View File

@@ -1,13 +1,13 @@
import { medusaIntegrationTestRunner } from "@medusajs/test-utils"
import { IndexTypes } from "@medusajs/types"
import { defaultCurrencies, Modules } from "@medusajs/utils"
import { medusaIntegrationTestRunner } from "@medusajs/test-utils"
import { setTimeout } from "timers/promises"
import {
adminHeaders,
createAdminUser,
} from "../../../helpers/create-admin-user"
jest.setTimeout(120000)
jest.setTimeout(100000)
process.env.ENABLE_INDEX_MODULE = "true"
@@ -65,7 +65,7 @@ medusaIntegrationTestRunner({
})
// Timeout to allow indexing to finish
await setTimeout(2000)
await setTimeout(4000)
const { data: results } = await indexEngine.query<"product">({
fields: [
@@ -144,7 +144,7 @@ medusaIntegrationTestRunner({
})
// Timeout to allow indexing to finish
await setTimeout(2000)
await setTimeout(4000)
const { data: results } = await indexEngine.query<"product">({
fields: [

View File

@@ -1,6 +1,14 @@
import { RemoteJoiner } from "@medusajs/framework/orchestration"
import CustomerModule from "@medusajs/medusa/customer"
import RegionModule from "@medusajs/medusa/region"
import { MedusaModule } from "@medusajs/modules-sdk"
import { medusaIntegrationTestRunner } from "@medusajs/test-utils"
import { IRegionModuleService, RemoteQueryFunction } from "@medusajs/types"
import { ContainerRegistrationKeys, Modules } from "@medusajs/utils"
import {
IRegionModuleService,
ModuleJoinerConfig,
RemoteQueryFunction,
} from "@medusajs/types"
import { ContainerRegistrationKeys, defineLink, Modules } from "@medusajs/utils"
import { createAdminUser } from "../../..//helpers/create-admin-user"
import { adminHeaders } from "../../../helpers/create-admin-user"
@@ -428,6 +436,90 @@ medusaIntegrationTestRunner({
}),
])
})
it("should handle multiple fieldAlias when multiple links between two modules are defined", async () => {
const customer = CustomerModule.linkable.customer
const customerGroup = CustomerModule.linkable.customerGroup
const region = RegionModule.linkable.region
const country = RegionModule.linkable.country
defineLink(customer, region)
defineLink(customerGroup, region)
defineLink(customer, country)
defineLink(customerGroup, country)
const modulesLoaded = MedusaModule.getLoadedModules().map(
(mod) => Object.values(mod)[0]
)
const servicesConfig_: ModuleJoinerConfig[] = []
for (const mod of modulesLoaded || []) {
if (!mod.__definition.isQueryable) {
continue
}
servicesConfig_!.push(mod.__joinerConfig)
}
const linkDefinition = MedusaModule.getCustomLinks().map(
(linkDefinition: any) => {
const definition = linkDefinition(
MedusaModule.getAllJoinerConfigs()
)
return definition
}
)
servicesConfig_.push(...(linkDefinition as any))
const remoteJoiner = new RemoteJoiner(
servicesConfig_,
(() => {}) as any
)
const fieldAlias = (remoteJoiner as any).getServiceConfig({
entity: "Customer",
}).fieldAlias
expect(fieldAlias).toEqual(
expect.objectContaining({
account_holders: {
path: "account_holder_link.account_holder",
isList: true,
entity: "Customer",
},
region: [
{
path: "region_link.region",
isList: false,
forwardArgumentsOnPath: ["region_link.region"],
entity: "Customer",
},
{
path: "region_link.region",
isList: false,
forwardArgumentsOnPath: ["region_link.region"],
entity: "CustomerGroup",
},
],
country: [
{
path: "country_link.country",
isList: false,
forwardArgumentsOnPath: ["country_link.country"],
entity: "Customer",
},
{
path: "country_link.country",
isList: false,
forwardArgumentsOnPath: ["country_link.country"],
entity: "CustomerGroup",
},
],
})
)
})
})
},
})