mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 15:24:32 +00:00
Auto-reply: smarter chunking breaks
This commit is contained in:
49
src/auto-reply/reply.chunking.test.ts
Normal file
49
src/auto-reply/reply.chunking.test.ts
Normal file
@@ -0,0 +1,49 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
import type { WarelayConfig } from "../config/config.js";
|
||||
import { autoReplyIfConfigured } from "./reply.js";
|
||||
|
||||
describe("autoReplyIfConfigured chunking", () => {
|
||||
it("sends a single Twilio message for multi-line text under limit", async () => {
|
||||
const body = [
|
||||
"Oh! Hi Peter! 🦞",
|
||||
"",
|
||||
"Sorry, I got a bit trigger-happy with the heartbeat response there. What's up?",
|
||||
"",
|
||||
"Everything working on your end?",
|
||||
].join("\n");
|
||||
|
||||
const config: WarelayConfig = {
|
||||
inbound: {
|
||||
reply: {
|
||||
mode: "text",
|
||||
text: body,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const create = vi.fn().mockResolvedValue({});
|
||||
const client = { messages: { create } } as unknown as Parameters<
|
||||
typeof autoReplyIfConfigured
|
||||
>[0];
|
||||
|
||||
const message = {
|
||||
body: "ping",
|
||||
from: "+15551234567",
|
||||
to: "+15557654321",
|
||||
sid: "SM123",
|
||||
} as Parameters<typeof autoReplyIfConfigured>[1];
|
||||
|
||||
await autoReplyIfConfigured(client, message, config);
|
||||
|
||||
expect(create).toHaveBeenCalledTimes(1);
|
||||
expect(create).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
body,
|
||||
from: message.to,
|
||||
to: message.from,
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user