import { describe, expect, it } from "vitest"; import { resolveBotPersona } from "./bot-persona"; import { extractOutgoingHandoff, isClientWorkshopSpecialty, voiceHandoffIdleCaption, voiceHandoffTransferLine, } from "./voice-handoff"; describe("extractOutgoingHandoff", () => { it("returns the latest handoff initiated by this bot", () => { const snapshot = { threadId: "t1", botId: "ux", members: [ { botId: "ux", name: "UX Designer", color: "#fff" }, { botId: "boss", name: "Boss", color: "#000" }, ], messages: [ { id: "m1", role: "bot", runId: "r1", createdAt: "", blocks: [ { kind: "handoff", fromBotId: "ux", toBotId: "boss", text: "Erstelle ein Konzept für die VOICE FIRST AI Talks…", }, ], }, ], run: { id: "r1", status: "running" }, } as never; expect(extractOutgoingHandoff(snapshot, "ux")).toEqual({ messageId: "m1", toBotId: "boss", toBotName: "Boss", text: "Erstelle ein Konzept für die VOICE FIRST AI Talks…", }); expect(extractOutgoingHandoff(snapshot, "boss")).toBeNull(); }); }); describe("voiceHandoffTransferLine", () => { it("names the target without repeating the task brief", () => { const profile = resolveBotPersona({ name: "UX Designer", title: "Lead UX/UI Designer", description: "Voice and mobile UX", }); const line = voiceHandoffTransferLine(profile, "Boss"); expect(line).toContain("Boss"); expect(line.toLowerCase()).toContain("handed"); expect(line).not.toContain("VOICE FIRST"); }); }); describe("voiceHandoffIdleCaption", () => { it("shows hang-up guidance instead of an open invitation", () => { expect(voiceHandoffIdleCaption("Boss")).toBe("Handed to Boss — hang up to continue in text."); }); }); describe("isClientWorkshopSpecialty", () => { it("detects UX Designer as a client-workshop specialty", () => { expect( isClientWorkshopSpecialty({ name: "UX Designer", title: "Lead UX/UI Designer", description: "Mobile-first user experience and Voice First concepts", }), ).toBe(true); }); it("does not treat generic engineers as design workshop bots", () => { expect( isClientWorkshopSpecialty({ name: "DevOps Engineer", title: "Infrastructure", description: "Keeps the cluster healthy", }), ).toBe(false); }); });