From 780e0898b0cefcbe96404cc04644da8c59b8546e Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sat, 11 Apr 2026 01:34:16 +0100 Subject: [PATCH] test: simplify typed conversions --- src/agents/openclaw-tools.camera.test.ts | 2 +- .../openclaw-tools.sessions-visibility.test.ts | 2 +- ...ols.subagents.sessions-spawn-depth-limits.test.ts | 2 +- src/agents/pi-bundle-mcp-runtime.test.ts | 2 +- ...-embedded-runner.sanitize-session-history.test.ts | 2 +- src/agents/subagent-spawn.test.ts | 2 +- src/agents/tools/image-tool.test.ts | 4 +--- src/agents/tools/web-fetch.cf-markdown.test.ts | 2 +- src/auto-reply/reply/commands-export-session.test.ts | 2 +- src/auto-reply/reply/dispatch-from-config.test.ts | 2 +- src/auto-reply/skill-commands.test.ts | 2 +- src/channels/plugins/group-policy-warnings.test.ts | 2 +- src/cli/update-cli.test.ts | 2 +- src/commands/auth-choice.apply-helpers.test.ts | 2 +- src/commands/auth-choice.test.ts | 4 +--- src/commands/channels.add.test.ts | 2 +- src/commands/status.command-sections.test.ts | 2 +- src/cron/isolated-agent.helpers.test.ts | 2 +- src/gateway/gateway.test.ts | 2 +- src/gateway/server-methods/agents-mutate.test.ts | 2 +- .../server.agent.gateway-server-agent-a.test.ts | 2 +- src/gateway/server.auth.browser-hardening.test.ts | 2 +- src/gateway/server.legacy-migration.test.ts | 2 +- src/hooks/install.test.ts | 2 +- .../heartbeat-runner.returns-default-unset.test.ts | 3 +-- src/infra/outbound/message.channels.test.ts | 4 +--- .../provider-usage.auth.normalizes-keys.test.ts | 2 +- src/infra/push-apns.test.ts | 6 +++--- src/infra/run-node.test.ts | 2 +- src/plugin-sdk/provider-stream.test.ts | 2 +- src/plugin-sdk/provider-tools.ts | 12 +++--------- src/plugin-sdk/webhook-targets.test.ts | 2 +- src/wizard/setup.test.ts | 2 +- ui/src/ui/controllers/usage.node.test.ts | 2 +- 34 files changed, 38 insertions(+), 51 deletions(-) diff --git a/src/agents/openclaw-tools.camera.test.ts b/src/agents/openclaw-tools.camera.test.ts index ff6be1ea926..ac393ba9977 100644 --- a/src/agents/openclaw-tools.camera.test.ts +++ b/src/agents/openclaw-tools.camera.test.ts @@ -312,7 +312,7 @@ describe("nodes camera_clip", () => { node: NODE_ID, facing: "front", }); - const filePath = String((result.content?.[0] as { text?: string } | undefined)?.text ?? "") + const filePath = ((result.content?.[0] as { text?: string } | undefined)?.text ?? "") .replace(/^FILE:/, "") .trim(); await expect(readFileUtf8AndCleanup(filePath)).resolves.toBe("url-clip"); diff --git a/src/agents/openclaw-tools.sessions-visibility.test.ts b/src/agents/openclaw-tools.sessions-visibility.test.ts index a901c633ef4..9bc5935410b 100644 --- a/src/agents/openclaw-tools.sessions-visibility.test.ts +++ b/src/agents/openclaw-tools.sessions-visibility.test.ts @@ -58,7 +58,7 @@ describe("sessions tools visibility", () => { return { sessions: [{ key: "subagent:child-1" }] }; } if (req.method === "sessions.resolve") { - const key = typeof req.params?.key === "string" ? String(req.params?.key) : ""; + const key = typeof req.params?.key === "string" ? req.params.key : ""; return { key }; } return undefined; diff --git a/src/agents/openclaw-tools.subagents.sessions-spawn-depth-limits.test.ts b/src/agents/openclaw-tools.subagents.sessions-spawn-depth-limits.test.ts index c408fdf7678..aa83da9821d 100644 --- a/src/agents/openclaw-tools.subagents.sessions-spawn-depth-limits.test.ts +++ b/src/agents/openclaw-tools.subagents.sessions-spawn-depth-limits.test.ts @@ -332,7 +332,7 @@ describe("sessions_spawn depth + child limits", () => { expect(result.details).toMatchObject({ status: "error", }); - expect(String((result.details as { error?: string }).error ?? "")).toContain("invalid model"); + expect((result.details as { error?: string }).error ?? "").toContain("invalid model"); expect( callGatewayMock.mock.calls.some( (call) => (call[0] as { method?: string }).method === "agent", diff --git a/src/agents/pi-bundle-mcp-runtime.test.ts b/src/agents/pi-bundle-mcp-runtime.test.ts index ca90cea4721..81576f3c6b5 100644 --- a/src/agents/pi-bundle-mcp-runtime.test.ts +++ b/src/agents/pi-bundle-mcp-runtime.test.ts @@ -57,7 +57,7 @@ describe("session MCP runtime", () => { })), }), callTool: async (_serverName, toolName) => ({ - content: [{ type: "text", text: String(toolName) }], + content: [{ type: "text", text: toolName }], isError: false, }), dispose: async () => {}, diff --git a/src/agents/pi-embedded-runner.sanitize-session-history.test.ts b/src/agents/pi-embedded-runner.sanitize-session-history.test.ts index dafbb8c1a62..14fa4da8678 100644 --- a/src/agents/pi-embedded-runner.sanitize-session-history.test.ts +++ b/src/agents/pi-embedded-runner.sanitize-session-history.test.ts @@ -35,7 +35,7 @@ vi.mock("../plugins/provider-runtime.js", async () => { provider === "openrouter" || provider === "github-copilot" ? { buildReplayPolicy: (context?: { modelId?: string | null }) => { - const modelId = String(context?.modelId ?? "").toLowerCase(); + const modelId = (context?.modelId ?? "").toLowerCase(); if (provider === "openrouter") { return { applyAssistantFirstOrderingFix: false, diff --git a/src/agents/subagent-spawn.test.ts b/src/agents/subagent-spawn.test.ts index 389d270bbdb..1b5cd806876 100644 --- a/src/agents/subagent-spawn.test.ts +++ b/src/agents/subagent-spawn.test.ts @@ -279,7 +279,7 @@ describe("spawnSubagentDirect seam flow", () => { status: "error", childSessionKey: expect.stringMatching(/^agent:main:subagent:/), }); - expect(String(result.error ?? "")).toContain("invalid model"); + expect(result.error ?? "").toContain("invalid model"); expect( hoisted.callGatewayMock.mock.calls.some( (call) => (call[0] as { method?: string }).method === "agent", diff --git a/src/agents/tools/image-tool.test.ts b/src/agents/tools/image-tool.test.ts index 6dcd37f05e0..f3c2acd1de8 100644 --- a/src/agents/tools/image-tool.test.ts +++ b/src/agents/tools/image-tool.test.ts @@ -1281,9 +1281,7 @@ describe("image tool MiniMax VLM routing", () => { const [url, init] = fetch.mock.calls[0]; expect(String(url)).toBe("https://api.minimax.io/v1/coding_plan/vlm"); expect(init?.method).toBe("POST"); - expect(String((init?.headers as Record)?.Authorization)).toBe( - "Bearer minimax-test", - ); + expect((init?.headers as Record)?.Authorization).toBe("Bearer minimax-test"); expect(String(init?.body)).toContain('"prompt":"Describe the image."'); expect(String(init?.body)).toContain('"image_url":"data:image/png;base64,'); diff --git a/src/agents/tools/web-fetch.cf-markdown.test.ts b/src/agents/tools/web-fetch.cf-markdown.test.ts index cae3bd14063..b12df8ef42d 100644 --- a/src/agents/tools/web-fetch.cf-markdown.test.ts +++ b/src/agents/tools/web-fetch.cf-markdown.test.ts @@ -161,7 +161,7 @@ describe("web_fetch Cloudflare Markdown for Agents", () => { expect.stringContaining("x-markdown-tokens: 1500 (https://example.com/...)"), ); const tokenLogs = logSpy.mock.calls - .map(([message]) => String(message)) + .map(([message]) => message) .filter((message) => message.includes("x-markdown-tokens")); expect(tokenLogs).toHaveLength(1); expect(tokenLogs[0]).not.toContain("token=secret"); diff --git a/src/auto-reply/reply/commands-export-session.test.ts b/src/auto-reply/reply/commands-export-session.test.ts index bf78859eb15..26eeac6ea78 100644 --- a/src/auto-reply/reply/commands-export-session.test.ts +++ b/src/auto-reply/reply/commands-export-session.test.ts @@ -61,7 +61,7 @@ vi.mock("node:fs", async () => { mkdirSync: hoisted.mkdirSyncMock, writeFileSync: hoisted.writeFileSyncMock, readFileSync: vi.fn((filePath: string) => { - if (String(filePath).endsWith("template.html")) { + if (filePath.endsWith("template.html")) { return "{{CSS}}{{JS}}{{SESSION_DATA}}{{MARKED_JS}}{{HIGHLIGHT_JS}}"; } return ""; diff --git a/src/auto-reply/reply/dispatch-from-config.test.ts b/src/auto-reply/reply/dispatch-from-config.test.ts index 052eaa240ea..c3c6a25b46f 100644 --- a/src/auto-reply/reply/dispatch-from-config.test.ts +++ b/src/auto-reply/reply/dispatch-from-config.test.ts @@ -449,7 +449,7 @@ function createMockAcpSessionManager() { meta: entry.acp, }; } - return String(params.sessionKey).startsWith("agent:") + return params.sessionKey.startsWith("agent:") ? { kind: "stale" as const, sessionKey: params.sessionKey, diff --git a/src/auto-reply/skill-commands.test.ts b/src/auto-reply/skill-commands.test.ts index 463f6091c7a..755eb40f47f 100644 --- a/src/auto-reply/skill-commands.test.ts +++ b/src/auto-reply/skill-commands.test.ts @@ -58,7 +58,7 @@ function buildWorkspaceSkillCommandSpecs( ) { const used = new Set(); for (const reserved of opts?.reservedNames ?? []) { - used.add(String(reserved).toLowerCase()); + used.add(reserved.toLowerCase()); } const agentSkills = opts?.config?.agents?.list?.find((entry) => entry.id === opts?.agentId); const filter = diff --git a/src/channels/plugins/group-policy-warnings.test.ts b/src/channels/plugins/group-policy-warnings.test.ts index ce3d73fb9b2..de73b2fc62c 100644 --- a/src/channels/plugins/group-policy-warnings.test.ts +++ b/src/channels/plugins/group-policy-warnings.test.ts @@ -93,7 +93,7 @@ describe("group policy warning builders", () => { { account: { accountId: string }; cfg: OpenClawConfig } >( (cfg: OpenClawConfig) => cfg.channels ?? {}, - ({ account, cfg }) => [String(account.accountId), Object.keys(cfg).join(",") || "none"], + ({ account, cfg }) => [account.accountId, Object.keys(cfg).join(",") || "none"], ); expect( diff --git a/src/cli/update-cli.test.ts b/src/cli/update-cli.test.ts index 9cb4c579cca..418a12bdc0d 100644 --- a/src/cli/update-cli.test.ts +++ b/src/cli/update-cli.test.ts @@ -818,7 +818,7 @@ describe("update-cli", () => { ); expect(installCall).toBeDefined(); - const installCommand = String(installCall?.[0][0] ?? ""); + const installCommand = installCall?.[0][0] ?? ""; expect(installCommand).not.toBe("npm"); expect(path.isAbsolute(installCommand)).toBe(true); expect(path.normalize(installCommand)).toContain(path.normalize(brewPrefix)); diff --git a/src/commands/auth-choice.apply-helpers.test.ts b/src/commands/auth-choice.apply-helpers.test.ts index 495eb4ed173..da4517e244e 100644 --- a/src/commands/auth-choice.apply-helpers.test.ts +++ b/src/commands/auth-choice.apply-helpers.test.ts @@ -375,7 +375,7 @@ describe("ensureApiKeyFromEnvOrPrompt", () => { }); expect(result).toBe("sk-minimax-redacted-value"); - const noteMessages = note.mock.calls.map((call) => String(call.at(0) ?? "")).join("\n"); + const noteMessages = note.mock.calls.map((call) => call.at(0) ?? "").join("\n"); expect(noteMessages).toContain("Validated environment variable MINIMAX_API_KEY."); expect(noteMessages).not.toContain("sk-minimax-redacted-value"); }); diff --git a/src/commands/auth-choice.test.ts b/src/commands/auth-choice.test.ts index d2ea7314d03..3c769e3cd97 100644 --- a/src/commands/auth-choice.test.ts +++ b/src/commands/auth-choice.test.ts @@ -281,9 +281,7 @@ function createDefaultProviderPlugins() { run: async (ctx) => { const state = "state-test"; ctx.runtime.log(`Open this URL: https://api.chutes.ai/idp/authorize?state=${state}`); - const redirect = String( - await ctx.prompter.text({ message: "Paste the redirect URL or code" }), - ); + const redirect = await ctx.prompter.text({ message: "Paste the redirect URL or code" }); const params = new URLSearchParams(redirect.startsWith("?") ? redirect.slice(1) : redirect); const code = params.get("code") ?? redirect; const tokenResponse = await fetch("https://api.chutes.ai/idp/token", { diff --git a/src/commands/channels.add.test.ts b/src/commands/channels.add.test.ts index 631d78ab9e9..3125e294d40 100644 --- a/src/commands/channels.add.test.ts +++ b/src/commands/channels.add.test.ts @@ -84,7 +84,7 @@ function createTelegramAddTestPlugin(): ChannelPlugin { const resolvedAccountId = accountId || DEFAULT_ACCOUNT_ID; const scoped = telegram?.accounts?.[resolvedAccountId]; return { - token: String(scoped?.botToken ?? telegram?.botToken ?? ""), + token: scoped?.botToken ?? telegram?.botToken ?? "", enabled: typeof scoped?.enabled === "boolean" ? scoped.enabled diff --git a/src/commands/status.command-sections.test.ts b/src/commands/status.command-sections.test.ts index 3c79d638491..2cca1d8fa63 100644 --- a/src/commands/status.command-sections.test.ts +++ b/src/commands/status.command-sections.test.ts @@ -167,7 +167,7 @@ describe("status.command-sections", () => { { severity: "warn" as const, message: "extra" }, ], limit: 2, - formatNotice: (notice) => String(notice.message), + formatNotice: (notice) => notice.message, warn: (value) => `warn(${value})`, muted: (value) => `muted(${value})`, }), diff --git a/src/cron/isolated-agent.helpers.test.ts b/src/cron/isolated-agent.helpers.test.ts index e8228f4e9b3..74b140bc105 100644 --- a/src/cron/isolated-agent.helpers.test.ts +++ b/src/cron/isolated-agent.helpers.test.ts @@ -57,7 +57,7 @@ describe("resolveCronPayloadOutcome", () => { payloads: [{ text: "a".repeat(2001) }], }); - expect(String(result.summary ?? "")).toMatch(/…$/); + expect(result.summary ?? "").toMatch(/…$/); }); it("preserves all successful deliverable payloads when no final assistant text is available", () => { diff --git a/src/gateway/gateway.test.ts b/src/gateway/gateway.test.ts index 3c61689c2d6..09b6e85c445 100644 --- a/src/gateway/gateway.test.ts +++ b/src/gateway/gateway.test.ts @@ -358,7 +358,7 @@ module.exports = { await prompter.note("write token"); const token = await prompter.text({ message: "token" }); await writeConfigFile({ - gateway: { auth: { mode: "token", token: String(token) } }, + gateway: { auth: { mode: "token", token } }, }); await prompter.outro("ok"); }, diff --git a/src/gateway/server-methods/agents-mutate.test.ts b/src/gateway/server-methods/agents-mutate.test.ts index 10e620ff848..d96825823b4 100644 --- a/src/gateway/server-methods/agents-mutate.test.ts +++ b/src/gateway/server-methods/agents-mutate.test.ts @@ -235,7 +235,7 @@ function mergeAgentConfig(cfg: unknown, opts: unknown): MockConfig { identity?: MockIdentity; }) ?? { agentId: "" }; const list = getAgentList(config); - const agentId = String(params.agentId ?? ""); + const agentId = params.agentId ?? ""; const index = list.findIndex((entry) => entry.id === agentId); const base = index >= 0 ? list[index] : { id: agentId }; const nextEntry: MockAgentEntry = { diff --git a/src/gateway/server.agent.gateway-server-agent-a.test.ts b/src/gateway/server.agent.gateway-server-agent-a.test.ts index bbe045394ef..0562dddf61f 100644 --- a/src/gateway/server.agent.gateway-server-agent-a.test.ts +++ b/src/gateway/server.agent.gateway-server-agent-a.test.ts @@ -118,7 +118,7 @@ const createStubChannelPlugin = (params: { } const first = allowFrom?.[0]; if (first) { - return { ok: true, to: String(first) }; + return { ok: true, to: first }; } return { ok: false, diff --git a/src/gateway/server.auth.browser-hardening.test.ts b/src/gateway/server.auth.browser-hardening.test.ts index 50d838021a0..eae1c333d1d 100644 --- a/src/gateway/server.auth.browser-hardening.test.ts +++ b/src/gateway/server.auth.browser-hardening.test.ts @@ -363,7 +363,7 @@ describe("gateway auth browser hardening", () => { clientId: TEST_OPERATOR_CLIENT.id, clientMode: TEST_OPERATOR_CLIENT.mode, identityPath: path.join(os.tmpdir(), `openclaw-browser-device-${randomUUID()}.json`), - nonce: String(nonce ?? ""), + nonce: nonce ?? "", }); const res = await connectReq(browserWs, { token: "secret", diff --git a/src/gateway/server.legacy-migration.test.ts b/src/gateway/server.legacy-migration.test.ts index 71321390888..23f34b592c0 100644 --- a/src/gateway/server.legacy-migration.test.ts +++ b/src/gateway/server.legacy-migration.test.ts @@ -33,7 +33,7 @@ async function expectHeartbeatValidationError(legacyParsed: Record { const packedName = "test-hooks-0.0.1.tgz"; run.mockImplementation(async (argv, opts) => { if (argv[0] === "npm" && argv[1] === "pack") { - packTmpDir = String(typeof opts === "number" ? "" : (opts.cwd ?? "")); + packTmpDir = typeof opts === "number" ? "" : (opts.cwd ?? ""); fs.writeFileSync(path.join(packTmpDir, packedName), npmPackHooksBuffer); return { code: 0, diff --git a/src/infra/heartbeat-runner.returns-default-unset.test.ts b/src/infra/heartbeat-runner.returns-default-unset.test.ts index 39ca2c06fae..d520124b916 100644 --- a/src/infra/heartbeat-runner.returns-default-unset.test.ts +++ b/src/infra/heartbeat-runner.returns-default-unset.test.ts @@ -96,8 +96,7 @@ beforeAll(async () => { }); whatsappPlugin.config = { ...whatsappPlugin.config, - resolveAllowFrom: ({ cfg }) => - cfg.channels?.whatsapp?.allowFrom?.map((entry) => String(entry)) ?? [], + resolveAllowFrom: ({ cfg }) => cfg.channels?.whatsapp?.allowFrom?.map((entry) => entry) ?? [], }; const telegramPlugin = createOutboundTestPlugin({ diff --git a/src/infra/outbound/message.channels.test.ts b/src/infra/outbound/message.channels.test.ts index de65a7c5e4f..e6755e45281 100644 --- a/src/infra/outbound/message.channels.test.ts +++ b/src/infra/outbound/message.channels.test.ts @@ -72,9 +72,7 @@ describe("sendMessage channel normalization", () => { deliveryMode: "direct", resolveTarget: ({ to, cfg }) => { seen.resolveCfg = cfg; - const normalized = String(to ?? "") - .trim() - .replace(/^imessage:/i, ""); + const normalized = (to ?? "").trim().replace(/^imessage:/i, ""); return { ok: true, to: normalized }; }, sendText: async ({ cfg, to }) => { diff --git a/src/infra/provider-usage.auth.normalizes-keys.test.ts b/src/infra/provider-usage.auth.normalizes-keys.test.ts index c4658750d96..080b5f91c3f 100644 --- a/src/infra/provider-usage.auth.normalizes-keys.test.ts +++ b/src/infra/provider-usage.auth.normalizes-keys.test.ts @@ -10,7 +10,7 @@ import { createSuiteTempRootTracker } from "../test-helpers/temp-dir.js"; vi.mock("../agents/auth-profiles.js", () => { const normalizeProvider = (provider?: string | null): string => - String(provider ?? "") + (provider ?? "") .trim() .toLowerCase() .replace(/^z-ai$/, "zai"); diff --git a/src/infra/push-apns.test.ts b/src/infra/push-apns.test.ts index 965769389fa..5c60388db89 100644 --- a/src/infra/push-apns.test.ts +++ b/src/infra/push-apns.test.ts @@ -7,9 +7,9 @@ import { sendApnsExecApprovalResolvedWake, } from "./push-apns.js"; -const testAuthPrivateKey = generateKeyPairSync("ec", { namedCurve: "prime256v1" }) - .privateKey.export({ format: "pem", type: "pkcs8" }) - .toString(); +const testAuthPrivateKey = generateKeyPairSync("ec", { + namedCurve: "prime256v1", +}).privateKey.export({ format: "pem", type: "pkcs8" }); function createDirectApnsSendFixture(params: { nodeId: string; diff --git a/src/infra/run-node.test.ts b/src/infra/run-node.test.ts index 4be6113c54d..481f872f8d2 100644 --- a/src/infra/run-node.test.ts +++ b/src/infra/run-node.test.ts @@ -399,7 +399,7 @@ describe("run-node script", () => { } >(() => ({ kill: (signal) => { - child.kill(String(signal ?? "SIGTERM")); + child.kill(signal ?? "SIGTERM"); return true; }, on: (event, cb) => { diff --git a/src/plugin-sdk/provider-stream.test.ts b/src/plugin-sdk/provider-stream.test.ts index e2749a86d50..05c69d01106 100644 --- a/src/plugin-sdk/provider-stream.test.ts +++ b/src/plugin-sdk/provider-stream.test.ts @@ -62,7 +62,7 @@ describe("buildProviderStreamFamilyHooks", () => { let capturedHeaders: Record | undefined; const baseStreamFn: StreamFn = (model, _context, options) => { - capturedModelId = String(model.id); + capturedModelId = model.id; const payload = { config: { thinkingConfig: { thinkingBudget: -1 } } } as Record< string, unknown diff --git a/src/plugin-sdk/provider-tools.ts b/src/plugin-sdk/provider-tools.ts index 0eb205cb470..28aba10f7e4 100644 --- a/src/plugin-sdk/provider-tools.ts +++ b/src/plugin-sdk/provider-tools.ts @@ -187,15 +187,9 @@ function normalizeOpenAIStrictCompatSchema(schema: unknown): unknown { } function shouldApplyOpenAIToolCompat(ctx: ProviderNormalizeToolSchemasContext): boolean { - const provider = String(ctx.model?.provider ?? ctx.provider ?? "") - .trim() - .toLowerCase(); - const api = String(ctx.model?.api ?? ctx.modelApi ?? "") - .trim() - .toLowerCase(); - const baseUrl = String(ctx.model?.baseUrl ?? "") - .trim() - .toLowerCase(); + const provider = (ctx.model?.provider ?? ctx.provider ?? "").trim().toLowerCase(); + const api = (ctx.model?.api ?? ctx.modelApi ?? "").trim().toLowerCase(); + const baseUrl = (ctx.model?.baseUrl ?? "").trim().toLowerCase(); if (provider === "openai") { return api === "openai-responses" && (!baseUrl || isOpenAIResponsesBaseUrl(baseUrl)); diff --git a/src/plugin-sdk/webhook-targets.test.ts b/src/plugin-sdk/webhook-targets.test.ts index 7dfca230e76..4b30e1b3494 100644 --- a/src/plugin-sdk/webhook-targets.test.ts +++ b/src/plugin-sdk/webhook-targets.test.ts @@ -264,7 +264,7 @@ describe("resolveSingleWebhookTarget", () => { { name: "async", run: (targets, isMatch) => - resolveSingleWebhookTargetAsync(targets, async (value) => Boolean(await isMatch(value))), + resolveSingleWebhookTargetAsync(targets, async (value) => isMatch(value)), }, ]; diff --git a/src/wizard/setup.test.ts b/src/wizard/setup.test.ts index 3a896498fe1..f5b74612bf6 100644 --- a/src/wizard/setup.test.ts +++ b/src/wizard/setup.test.ts @@ -83,7 +83,7 @@ const writeConfigFile = vi.hoisted(() => vi.fn(async () => {})); const resolveGatewayPort = vi.hoisted(() => vi.fn((_cfg?: unknown, env?: NodeJS.ProcessEnv) => { const raw = env?.OPENCLAW_GATEWAY_PORT ?? process.env.OPENCLAW_GATEWAY_PORT; - const port = raw ? Number.parseInt(String(raw), 10) : Number.NaN; + const port = raw ? Number.parseInt(raw, 10) : Number.NaN; return Number.isFinite(port) && port > 0 ? port : 18789; }), ); diff --git a/ui/src/ui/controllers/usage.node.test.ts b/ui/src/ui/controllers/usage.node.test.ts index 2ddd3913c53..8ddd6cbce2f 100644 --- a/ui/src/ui/controllers/usage.node.test.ts +++ b/ui/src/ui/controllers/usage.node.test.ts @@ -207,7 +207,7 @@ function createStorageMock() { return store.get(key) ?? null; }, setItem(key: string, value: string) { - store.set(key, String(value)); + store.set(key, value); }, removeItem(key: string) { store.delete(key);