mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-20 22:40:58 +00:00
refactor: deduplicate reply payload handling
This commit is contained in:
@@ -2,6 +2,7 @@ import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
hasReplyChannelData,
|
||||
hasReplyContent,
|
||||
hasReplyPayloadContent,
|
||||
normalizeInteractiveReply,
|
||||
resolveInteractiveTextFallback,
|
||||
} from "./payload.js";
|
||||
@@ -44,6 +45,41 @@ describe("hasReplyContent", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("hasReplyPayloadContent", () => {
|
||||
it("trims text and falls back to channel data by default", () => {
|
||||
expect(
|
||||
hasReplyPayloadContent({
|
||||
text: " ",
|
||||
channelData: { slack: { blocks: [] } },
|
||||
}),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("accepts explicit channel-data overrides and extra content", () => {
|
||||
expect(
|
||||
hasReplyPayloadContent(
|
||||
{
|
||||
text: " ",
|
||||
channelData: {},
|
||||
},
|
||||
{
|
||||
hasChannelData: true,
|
||||
},
|
||||
),
|
||||
).toBe(true);
|
||||
expect(
|
||||
hasReplyPayloadContent(
|
||||
{
|
||||
text: " ",
|
||||
},
|
||||
{
|
||||
extraContent: true,
|
||||
},
|
||||
),
|
||||
).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("interactive payload helpers", () => {
|
||||
it("normalizes interactive replies and resolves text fallbacks", () => {
|
||||
const interactive = normalizeInteractiveReply({
|
||||
|
||||
Reference in New Issue
Block a user