From 91cd38f4d4349ccf8cf306380d351743bbb83ad5 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sun, 22 Mar 2026 22:12:00 +0000 Subject: [PATCH] fix(test): repair main CI drift --- CHANGELOG.md | 1 - src/infra/outbound/targets.test-helpers.ts | 19 +++++++----- src/infra/outbound/targets.test.ts | 1 - src/plugins/conversation-binding.test.ts | 34 +++++++++++++--------- src/plugins/loader.test.ts | 3 +- 5 files changed, 34 insertions(+), 24 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 98af9321ada..f197ca82588 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -254,7 +254,6 @@ Docs: https://docs.openclaw.ai - Discord/ACP: forward worker abort signals into ACP turns so timed-out Discord jobs cancel the running turn instead of silently leaving the bound ACP session working in the background. - Gateway/openresponses: preserve assistant commentary and session continuity across hosted-tool `/v1/responses` turns, and emit streamed tool-call payloads before finalization so client tool loops stay resumable. (#52171) Thanks @CharZhou. - Android/Talk: serialize `TalkModeManager` player teardown so rapid interrupt/restart cycles stop double-releasing or overlapping TTS playback. (#52310) Thanks @Kaneki-x. -<<<<<<< HEAD - WhatsApp/reconnect: preserve the last inbound timestamp across reconnect attempts so the watchdog can still recycle linked-but-dead listeners after a restart instead of leaving them stuck connected forever. - Gateway/network discovery: guard LAN, tailnet, and pairing interface enumeration so WSL2 and restricted hosts degrade to missing-address fallbacks instead of crashing on `uv_interface_addresses` errors. (#44180, #47590) - Gateway/bonjour: suppress the non-fatal `@homebridge/ciao` IPv4-loss assertion during interface churn so WiFi/VPN/sleep-wake changes no longer take down the gateway. (#38628, #47159, #52431) diff --git a/src/infra/outbound/targets.test-helpers.ts b/src/infra/outbound/targets.test-helpers.ts index 1aba8fa21a3..db8b35c5ccc 100644 --- a/src/infra/outbound/targets.test-helpers.ts +++ b/src/infra/outbound/targets.test-helpers.ts @@ -27,12 +27,15 @@ function parseTelegramTargetForTest(raw: string): { } function normalizeWhatsAppTargetForTest(raw: string): string | null { - const trimmed = raw.trim().replace(/^whatsapp:/i, "").trim(); + const trimmed = raw + .trim() + .replace(/^whatsapp:/i, "") + .trim(); if (!trimmed) { return null; } const lowered = trimmed.toLowerCase(); - if (/@g\.us$/u.test(lowered)) { + if (lowered.endsWith("@g.us")) { const normalized = lowered.replace(/\s+/gu, ""); return /^\d+@g\.us$/u.test(normalized) ? normalized : null; } @@ -41,9 +44,7 @@ function normalizeWhatsAppTargetForTest(raw: string): string | null { return /^\+\d{7,15}$/u.test(normalized) ? normalized : null; } -function createWhatsAppResolveTarget( - label = "WhatsApp", -): ChannelOutboundAdapter["resolveTarget"] { +function createWhatsAppResolveTarget(label = "WhatsApp"): ChannelOutboundAdapter["resolveTarget"] { return ({ to }) => { const normalized = to ? normalizeWhatsAppTargetForTest(to) : null; if (!normalized) { @@ -133,7 +134,9 @@ export function createTelegramTestPlugin(): ChannelPlugin { }, messaging: telegramMessagingForTest, resolveDefaultTo: ({ cfg }) => - typeof cfg.channels?.telegram?.defaultTo === "string" ? cfg.channels.telegram.defaultTo : undefined, + typeof cfg.channels?.telegram?.defaultTo === "string" + ? cfg.channels.telegram.defaultTo + : undefined, }); } @@ -148,7 +151,9 @@ export function createWhatsAppTestPlugin(): ChannelPlugin { }, messaging: whatsappMessagingForTest, resolveDefaultTo: ({ cfg }) => - typeof cfg.channels?.whatsapp?.defaultTo === "string" ? cfg.channels.whatsapp.defaultTo : undefined, + typeof cfg.channels?.whatsapp?.defaultTo === "string" + ? cfg.channels.whatsapp.defaultTo + : undefined, }); } diff --git a/src/infra/outbound/targets.test.ts b/src/infra/outbound/targets.test.ts index 48c6107b4a1..11d22f33a27 100644 --- a/src/infra/outbound/targets.test.ts +++ b/src/infra/outbound/targets.test.ts @@ -18,7 +18,6 @@ import { createTargetsTestRegistry, createTelegramTestPlugin, createWhatsAppTestPlugin, - telegramMessagingForTest, } from "./targets.test-helpers.js"; runResolveOutboundTargetCoreTests(); diff --git a/src/plugins/conversation-binding.test.ts b/src/plugins/conversation-binding.test.ts index a4e1235048b..594c183d0d8 100644 --- a/src/plugins/conversation-binding.test.ts +++ b/src/plugins/conversation-binding.test.ts @@ -7,23 +7,31 @@ import type { SessionBindingAdapter, SessionBindingRecord, } from "../infra/outbound/session-binding-service.js"; +import type { PluginRegistry } from "./registry.js"; const tempRoot = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-plugin-binding-")); const approvalsPath = path.join(tempRoot, "plugin-binding-approvals.json"); -type PluginBindingRegistryStub = { - conversationBindingResolvedHandlers: Array<{ - pluginId: string; - pluginRoot?: string; - handler: (event: unknown) => void | Promise; - source: string; - rootDir?: string; - }>; -}; - -function createEmptyPluginRegistry(): PluginBindingRegistryStub { +function createEmptyPluginRegistry(): PluginRegistry { return { + plugins: [], + tools: [], + hooks: [], + typedHooks: [], + channels: [], + channelSetups: [], + providers: [], + speechProviders: [], + mediaUnderstandingProviders: [], + imageGenerationProviders: [], + webSearchProviders: [], + gatewayHandlers: {}, + httpRoutes: [], + cliRegistrars: [], + services: [], + commands: [], conversationBindingResolvedHandlers: [], + diagnostics: [], }; } @@ -98,7 +106,7 @@ const sessionBindingState = vi.hoisted(() => { }); const pluginRuntimeState = vi.hoisted(() => ({ - registry: createEmptyPluginRegistry() as PluginBindingRegistryStub, + registry: createEmptyPluginRegistry(), })); vi.mock("../infra/home-dir.js", async (importOriginal) => { @@ -116,7 +124,7 @@ vi.mock("../infra/home-dir.js", async (importOriginal) => { vi.mock("./runtime.js", () => ({ getActivePluginRegistry: () => pluginRuntimeState.registry, - setActivePluginRegistry: (registry: PluginBindingRegistryStub) => { + setActivePluginRegistry: (registry: ReturnType) => { pluginRuntimeState.registry = registry; }, })); diff --git a/src/plugins/loader.test.ts b/src/plugins/loader.test.ts index f6bd735bb77..3e7d0cdd11c 100644 --- a/src/plugins/loader.test.ts +++ b/src/plugins/loader.test.ts @@ -2,7 +2,6 @@ import fs from "node:fs"; import os from "node:os"; import path from "node:path"; import { afterAll, afterEach, describe, expect, it } from "vitest"; -import packageJson from "../../package.json" with { type: "json" }; import { emitDiagnosticEvent, resetDiagnosticEventsForTest } from "../infra/diagnostic-events.js"; import { buildMemoryPromptSection, registerMemoryPromptSection } from "../memory/prompt-section.js"; import { withEnv } from "../test-utils/env.js"; @@ -814,7 +813,7 @@ describe("loadOpenClawPlugins", () => { expect(memory?.status).toBe("loaded"); expect(memory?.origin).toBe("bundled"); expect(memory?.name).toBe("Memory (Core)"); - expect(memory?.version).toBe(packageJson.version); + expect(memory?.version).toBe("1.2.3"); }); it("handles config-path and scoped plugin loads", () => { const scenarios = [