test: fix ACP and TTS local failures

This commit is contained in:
Peter Steinberger
2026-04-20 15:24:18 +01:00
parent 642a3567b1
commit e753fc9cc7
2 changed files with 80 additions and 0 deletions

View File

@@ -199,6 +199,24 @@ function resolveFirstConversationTargetForTest(params: {
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 {
setActivePluginRegistry(
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",
source: "test",