mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 16:50:43 +00:00
test: fix ACP and TTS local failures
This commit is contained in:
@@ -199,6 +199,24 @@ function resolveFirstConversationTargetForTest(params: {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function parsePrefixedConversationIdForTest(
|
||||||
|
raw: string | undefined | null,
|
||||||
|
channel: "bluebubbles" | "imessage",
|
||||||
|
): string | undefined {
|
||||||
|
const trimmed = raw
|
||||||
|
?.trim()
|
||||||
|
.replace(new RegExp(`^${channel}:`, "i"), "")
|
||||||
|
.replace(/^chat_guid:/i, "");
|
||||||
|
return trimmed || undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
function resolvePrefixedConversationIdForTest(
|
||||||
|
targets: Array<string | undefined | null>,
|
||||||
|
channel: "bluebubbles" | "imessage",
|
||||||
|
): string | undefined {
|
||||||
|
return targets.map((target) => parsePrefixedConversationIdForTest(target, channel)).find(Boolean);
|
||||||
|
}
|
||||||
|
|
||||||
function setMinimalAcpCommandRegistryForTests(): void {
|
function setMinimalAcpCommandRegistryForTests(): void {
|
||||||
setActivePluginRegistry(
|
setActivePluginRegistry(
|
||||||
createTestRegistry([
|
createTestRegistry([
|
||||||
@@ -300,6 +318,54 @@ function setMinimalAcpCommandRegistryForTests(): void {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
pluginId: "bluebubbles",
|
||||||
|
source: "test",
|
||||||
|
plugin: {
|
||||||
|
...createChannelTestPluginBase({ id: "bluebubbles", label: "BlueBubbles" }),
|
||||||
|
bindings: {
|
||||||
|
resolveCommandConversation: ({
|
||||||
|
originatingTo,
|
||||||
|
commandTo,
|
||||||
|
fallbackTo,
|
||||||
|
}: {
|
||||||
|
originatingTo?: string;
|
||||||
|
commandTo?: string;
|
||||||
|
fallbackTo?: string;
|
||||||
|
}) => {
|
||||||
|
const conversationId = resolvePrefixedConversationIdForTest(
|
||||||
|
[originatingTo, commandTo, fallbackTo],
|
||||||
|
"bluebubbles",
|
||||||
|
);
|
||||||
|
return conversationId ? { conversationId } : null;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
pluginId: "imessage",
|
||||||
|
source: "test",
|
||||||
|
plugin: {
|
||||||
|
...createChannelTestPluginBase({ id: "imessage", label: "iMessage" }),
|
||||||
|
bindings: {
|
||||||
|
resolveCommandConversation: ({
|
||||||
|
originatingTo,
|
||||||
|
commandTo,
|
||||||
|
fallbackTo,
|
||||||
|
}: {
|
||||||
|
originatingTo?: string;
|
||||||
|
commandTo?: string;
|
||||||
|
fallbackTo?: string;
|
||||||
|
}) => {
|
||||||
|
const conversationId = resolvePrefixedConversationIdForTest(
|
||||||
|
[originatingTo, commandTo, fallbackTo],
|
||||||
|
"imessage",
|
||||||
|
);
|
||||||
|
return conversationId ? { conversationId } : null;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
pluginId: "slack",
|
pluginId: "slack",
|
||||||
source: "test",
|
source: "test",
|
||||||
|
|||||||
@@ -2,6 +2,19 @@ import { beforeEach, describe, expect, it, vi } from "vitest";
|
|||||||
|
|
||||||
const loadBundledPluginPublicSurfaceModuleSync = vi.hoisted(() => vi.fn());
|
const loadBundledPluginPublicSurfaceModuleSync = vi.hoisted(() => vi.fn());
|
||||||
const loadActivatedBundledPluginPublicSurfaceModuleSync = vi.hoisted(() => vi.fn());
|
const loadActivatedBundledPluginPublicSurfaceModuleSync = vi.hoisted(() => vi.fn());
|
||||||
|
const createLazyFacadeValue = vi.hoisted(() => {
|
||||||
|
return <TFacade extends object, K extends keyof TFacade>(
|
||||||
|
load: () => TFacade,
|
||||||
|
key: K,
|
||||||
|
): TFacade[K] =>
|
||||||
|
((...args: unknown[]) => {
|
||||||
|
const value = load()[key];
|
||||||
|
if (typeof value !== "function") {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
return (value as (...runtimeArgs: unknown[]) => unknown)(...args);
|
||||||
|
}) as TFacade[K];
|
||||||
|
});
|
||||||
const createLazyFacadeObjectValue = vi.hoisted(() => {
|
const createLazyFacadeObjectValue = vi.hoisted(() => {
|
||||||
return <T extends object>(load: () => T): T =>
|
return <T extends object>(load: () => T): T =>
|
||||||
new Proxy(
|
new Proxy(
|
||||||
@@ -25,6 +38,7 @@ const createLazyFacadeValue = vi.hoisted(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
vi.mock("../plugin-sdk/facade-runtime.js", () => ({
|
vi.mock("../plugin-sdk/facade-runtime.js", () => ({
|
||||||
|
createLazyFacadeValue,
|
||||||
createLazyFacadeObjectValue,
|
createLazyFacadeObjectValue,
|
||||||
createLazyFacadeValue,
|
createLazyFacadeValue,
|
||||||
loadActivatedBundledPluginPublicSurfaceModuleSync,
|
loadActivatedBundledPluginPublicSurfaceModuleSync,
|
||||||
|
|||||||
Reference in New Issue
Block a user