






























@@ -1,4 +1,7 @@
1-import { afterEach, describe, expect, it } from "vitest";
1+import { mkdtemp, rm } from "node:fs/promises";
2+import os from "node:os";
3+import path from "node:path";
4+import { afterEach, describe, expect, it, vi } from "vitest";
25import { createEmptyPluginRegistry } from "../plugins/registry.js";
36import {
47getActivePluginChannelRegistry,
@@ -26,10 +29,13 @@ function createRegistryWithRoute(path: string) {
2629}
27302831describe("createGatewayRuntimeState", () => {
32+const tempDirs: string[] = [];
33+2934afterEach(() => {
3035releasePinnedPluginHttpRouteRegistry();
3136releasePinnedPluginChannelRegistry();
3237resetPluginRuntimeStateForTest();
38+return Promise.all(tempDirs.splice(0).map((dir) => rm(dir, { recursive: true, force: true })));
3339});
34403541it("releases post-bootstrap repinned plugin registries on cleanup", async () => {
@@ -70,4 +76,38 @@ describe("createGatewayRuntimeState", () => {
7076expect(resolveActivePluginHttpRouteRegistry(fallbackRegistry)).toBe(startupRegistry);
7177expect(getActivePluginChannelRegistry()).toBe(startupRegistry);
7278});
79+80+it("creates the canvas host without logging it before HTTP bind", async () => {
81+const root = await mkdtemp(path.join(os.tmpdir(), "openclaw-canvas-runtime-"));
82+tempDirs.push(root);
83+const registry = createEmptyPluginRegistry();
84+const logCanvas = { info: vi.fn(), warn: vi.fn() };
85+86+const runtimeState = await createGatewayRuntimeState({
87+cfg: { canvasHost: { root, liveReload: false } },
88+bindHost: "127.0.0.1",
89+port: 18789,
90+controlUiEnabled: false,
91+controlUiBasePath: "/",
92+openAiChatCompletionsEnabled: false,
93+openResponsesEnabled: false,
94+resolvedAuth: {} as never,
95+getResolvedAuth: () => ({}) as never,
96+hooksConfig: () => null,
97+getHookClientIpConfig: () => ({}) as never,
98+pluginRegistry: registry,
99+deps: {} as never,
100+canvasRuntime: { log: () => {} } as never,
101+canvasHostEnabled: true,
102+allowCanvasHostInTests: true,
103+ logCanvas,
104+log: { info: () => {}, warn: () => {} },
105+logHooks: { info: () => {}, warn: () => {}, error: () => {}, debug: () => {} } as never,
106+logPlugins: { info: () => {}, warn: () => {}, error: () => {}, debug: () => {} } as never,
107+});
108+109+expect(runtimeState.canvasHost?.rootDir).toBe(root);
110+expect(logCanvas.info).not.toHaveBeenCalled();
111+await runtimeState.canvasHost?.close();
112+});
73113});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。