Thanks @tristanmanchester. Co-authored-by: Tristan Manchester <[email protected]>
42 lines
1.0 KiB
TypeScript
42 lines
1.0 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
|
|
import type { ClawdbotConfig } from "../../config/config.js";
|
|
import type { TemplateContext } from "../templating.js";
|
|
import { buildThreadingToolContext } from "./agent-runner-utils.js";
|
|
|
|
describe("buildThreadingToolContext", () => {
|
|
const cfg = {} as ClawdbotConfig;
|
|
|
|
it("uses conversation id for WhatsApp", () => {
|
|
const sessionCtx = {
|
|
Provider: "whatsapp",
|
|
From: "[email protected]",
|
|
To: "+15550001",
|
|
} as TemplateContext;
|
|
|
|
const result = buildThreadingToolContext({
|
|
sessionCtx,
|
|
config: cfg,
|
|
hasRepliedRef: undefined,
|
|
});
|
|
|
|
expect(result.currentChannelId).toBe("[email protected]");
|
|
});
|
|
|
|
it("uses the recipient id for other channels", () => {
|
|
const sessionCtx = {
|
|
Provider: "telegram",
|
|
From: "user:42",
|
|
To: "chat:99",
|
|
} as TemplateContext;
|
|
|
|
const result = buildThreadingToolContext({
|
|
sessionCtx,
|
|
config: cfg,
|
|
hasRepliedRef: undefined,
|
|
});
|
|
|
|
expect(result.currentChannelId).toBe("chat:99");
|
|
});
|
|
});
|