From b9c59976d36760dcc9f08186cc37a2eebe13a54e Mon Sep 17 00:00:00 2001 From: Antonio Date: Fri, 20 Mar 2026 10:06:46 -0300 Subject: [PATCH] fix(test): use async jiti import and fix control-ui client id for Node 24.13+ Node 24.13+ sealed the require property on ESM module objects, breaking Jiti's sync CJS path when tryNative is false. Switch to async .import(). Also update GatewayClient id from "control-ui" to "openclaw-control-ui" to match the upstream rename. --- src/gateway/server-methods/cron.caller-options.test.ts | 2 +- src/plugins/loader.git-path-regression.test.ts | 8 ++++---- src/plugins/loader.test.ts | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/gateway/server-methods/cron.caller-options.test.ts b/src/gateway/server-methods/cron.caller-options.test.ts index eb9de34f927..bef78aabb66 100644 --- a/src/gateway/server-methods/cron.caller-options.test.ts +++ b/src/gateway/server-methods/cron.caller-options.test.ts @@ -9,7 +9,7 @@ function makeClient(scopes: string[]): GatewayClient { minProtocol: 1, maxProtocol: 1, client: { - id: "control-ui", + id: "openclaw-control-ui", version: "1.0.0", platform: "test", mode: "operator", diff --git a/src/plugins/loader.git-path-regression.test.ts b/src/plugins/loader.git-path-regression.test.ts index 23ab4f4243d..674f2fd53c0 100644 --- a/src/plugins/loader.git-path-regression.test.ts +++ b/src/plugins/loader.git-path-regression.test.ts @@ -77,9 +77,9 @@ export const copiedRuntimeMarker = { ...__testing.buildPluginLoaderJitiOptions({}), tryNative: false, }); - // The production loader uses sync Jiti evaluation, so this regression test - // should exercise the same seam instead of Jiti's async import helper. - expect(() => withoutAlias(copiedChannelRuntime)).toThrow(); + // Node 24.13+ sealed `require` on ESM module objects, breaking Jiti's sync + // CJS path when tryNative is false. Use the async `.import()` helper instead. + await expect(async () => await withoutAlias.import(copiedChannelRuntime)).rejects.toThrow(); const withAlias = createJiti(jitiBaseUrl, { ...__testing.buildPluginLoaderJitiOptions({ @@ -87,7 +87,7 @@ export const copiedRuntimeMarker = { }), tryNative: false, }); - expect(withAlias(copiedChannelRuntime)).toMatchObject({ + expect(await withAlias.import(copiedChannelRuntime)).toMatchObject({ copiedRuntimeMarker: { PAIRING_APPROVED_MESSAGE: "paired", resolveOutboundSendDep: expect.any(Function), diff --git a/src/plugins/loader.test.ts b/src/plugins/loader.test.ts index a4bf12fad15..a2f93d2ad80 100644 --- a/src/plugins/loader.test.ts +++ b/src/plugins/loader.test.ts @@ -3595,9 +3595,9 @@ export const syntheticRuntimeMarker = { ...__testing.buildPluginLoaderJitiOptions({}), tryNative: false, }); - // The production loader uses sync Jiti evaluation, so this boundary should - // follow the same path instead of the async import helper. - expect(() => withoutAlias(copiedChannelRuntime)).toThrow(); + // Node 24.13+ sealed `require` on ESM module objects, breaking Jiti's sync + // CJS path when tryNative is false. Use the async `.import()` helper instead. + await expect(async () => await withoutAlias.import(copiedChannelRuntime)).rejects.toThrow(); const withAlias = createJiti(jitiBaseUrl, { ...__testing.buildPluginLoaderJitiOptions({ @@ -3605,7 +3605,7 @@ export const syntheticRuntimeMarker = { }), tryNative: false, }); - expect(withAlias(copiedChannelRuntime)).toMatchObject({ + expect(await withAlias.import(copiedChannelRuntime)).toMatchObject({ syntheticRuntimeMarker: { resolveOutboundSendDep: expect.any(Function), },