Files
openclaw/extensions/bluebubbles/src/conversation-bindings.test.ts
2026-04-10 19:12:02 -05:00

61 lines
1.7 KiB
TypeScript

import type { OpenClawConfig } from "openclaw/plugin-sdk/config-runtime";
import { getSessionBindingService } from "openclaw/plugin-sdk/conversation-runtime";
import { beforeEach, describe, expect, it } from "vitest";
import { __testing, createBlueBubblesConversationBindingManager } from "./conversation-bindings.js";
const baseCfg = {
session: { mainKey: "main", scope: "per-sender" },
} satisfies OpenClawConfig;
describe("BlueBubbles conversation bindings", () => {
beforeEach(() => {
__testing.resetBlueBubblesConversationBindingsForTests();
});
it("preserves existing metadata when rebinding the same conversation", async () => {
const manager = createBlueBubblesConversationBindingManager({
cfg: baseCfg,
accountId: "default",
});
manager.bindConversation({
conversationId: "chat-guid-1",
targetKind: "subagent",
targetSessionKey: "agent:main:subagent:child",
metadata: {
agentId: "codex",
label: "child",
boundBy: "system",
},
});
await getSessionBindingService().bind({
targetSessionKey: "agent:main:subagent:child",
targetKind: "subagent",
conversation: {
channel: "bluebubbles",
accountId: "default",
conversationId: "chat-guid-1",
},
placement: "current",
metadata: {
label: "child",
},
});
expect(
getSessionBindingService().resolveByConversation({
channel: "bluebubbles",
accountId: "default",
conversationId: "chat-guid-1",
}),
).toMatchObject({
metadata: expect.objectContaining({
agentId: "codex",
label: "child",
boundBy: "system",
}),
});
});
});