mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 22:30:43 +00:00
70 lines
2.3 KiB
TypeScript
70 lines
2.3 KiB
TypeScript
import { describe, expect, it, vi } from "vitest";
|
|
import { defineChannelMessageAdapter } from "./channel-message.js";
|
|
|
|
describe("defineChannelMessageAdapter", () => {
|
|
it("keeps new and legacy channel plugin SDK subpaths importable", async () => {
|
|
const [
|
|
channelMessage,
|
|
channelMessageRuntime,
|
|
channelMessageRuntimeDirect,
|
|
channelReplyPipeline,
|
|
compat,
|
|
] = await Promise.all([
|
|
import("openclaw/plugin-sdk/channel-message"),
|
|
import("openclaw/plugin-sdk/channel-message-runtime"),
|
|
import("../channels/message/runtime.js"),
|
|
import("openclaw/plugin-sdk/channel-reply-pipeline"),
|
|
import("openclaw/plugin-sdk/compat"),
|
|
]);
|
|
|
|
expect(channelMessage.createChannelMessageReplyPipeline).toBe(
|
|
channelReplyPipeline.createChannelReplyPipeline,
|
|
);
|
|
expect(channelMessage.createReplyPrefixOptions).toBe(
|
|
channelReplyPipeline.createReplyPrefixOptions,
|
|
);
|
|
expect(channelMessage.createTypingCallbacks).toBe(channelReplyPipeline.createTypingCallbacks);
|
|
expect(channelMessageRuntime.sendDurableMessageBatch).toBe(
|
|
channelMessageRuntimeDirect.sendDurableMessageBatch,
|
|
);
|
|
expect(compat.createChannelReplyPipeline).toBe(channelReplyPipeline.createChannelReplyPipeline);
|
|
});
|
|
|
|
it("defaults new message adapters to plugin-owned receive acknowledgement", () => {
|
|
const adapter = defineChannelMessageAdapter({
|
|
id: "demo",
|
|
durableFinal: { capabilities: { text: true } },
|
|
send: {
|
|
text: vi.fn(async () => ({
|
|
receipt: {
|
|
primaryPlatformMessageId: "msg-1",
|
|
platformMessageIds: ["msg-1"],
|
|
parts: [],
|
|
sentAt: 123,
|
|
},
|
|
})),
|
|
},
|
|
});
|
|
|
|
expect(adapter.receive).toEqual({
|
|
defaultAckPolicy: "manual",
|
|
supportedAckPolicies: ["manual"],
|
|
});
|
|
});
|
|
|
|
it("preserves explicit receive acknowledgement policy declarations", () => {
|
|
const adapter = defineChannelMessageAdapter({
|
|
id: "demo",
|
|
receive: {
|
|
defaultAckPolicy: "after_agent_dispatch",
|
|
supportedAckPolicies: ["after_receive_record", "after_agent_dispatch"],
|
|
},
|
|
});
|
|
|
|
expect(adapter.receive).toEqual({
|
|
defaultAckPolicy: "after_agent_dispatch",
|
|
supportedAckPolicies: ["after_receive_record", "after_agent_dispatch"],
|
|
});
|
|
});
|
|
});
|