Files
Moltbot/src/auto-reply/media-note.test.ts
Peter Steinberger 1b973f7506 feat: add inbound media understanding
Co-authored-by: Tristan Manchester <tmanchester96@gmail.com>
2026-01-17 03:54:46 +00:00

45 lines
1.4 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { buildInboundMediaNote } from "./media-note.js";
describe("buildInboundMediaNote", () => {
it("formats single MediaPath as a media note", () => {
const note = buildInboundMediaNote({
MediaPath: "/tmp/a.png",
MediaType: "image/png",
MediaUrl: "/tmp/a.png",
});
expect(note).toBe("[media attached: /tmp/a.png (image/png) | /tmp/a.png]");
});
it("formats multiple MediaPaths as numbered media notes", () => {
const note = buildInboundMediaNote({
MediaPaths: ["/tmp/a.png", "/tmp/b.png", "/tmp/c.png"],
MediaUrls: ["/tmp/a.png", "/tmp/b.png", "/tmp/c.png"],
});
expect(note).toBe(
[
"[media attached: 3 files]",
"[media attached 1/3: /tmp/a.png | /tmp/a.png]",
"[media attached 2/3: /tmp/b.png | /tmp/b.png]",
"[media attached 3/3: /tmp/c.png | /tmp/c.png]",
].join("\n"),
);
});
it("skips media notes for attachments with understanding output", () => {
const note = buildInboundMediaNote({
MediaPaths: ["/tmp/a.png", "/tmp/b.png"],
MediaUrls: ["https://example.com/a.png", "https://example.com/b.png"],
MediaUnderstanding: [
{
kind: "audio.transcription",
attachmentIndex: 0,
text: "hello",
provider: "groq",
},
],
});
expect(note).toBe("[media attached: /tmp/b.png | https://example.com/b.png]");
});
});