mirror of
http://192.168.0.88:13333/lywsvip/openclaw-zero-token.git
synced 2026-05-09 00:34:04 +08:00
Major upgrade from e26988a38 to upstream v2026.3.28 (f9b107928).
Key changes:
- Upstream src/, ui/, extensions/ (89 bundled extensions)
- Zero-token web providers preserved in src/zero-token/
- AskOnce plugin restored and registered as CLI command
- Added missing packages: @anthropic-ai/vertex-sdk, @modelcontextprotocol/sdk
- Fixed tsconfig rootDir, skipLibCheck for plugin-sdk DTS build
- Added askonce to bundled plugin metadata and package.json exports
- Fixed AskOnce CLI command registration (missing commands metadata)
- Restored AskOnce adapter imports (correct 5-level relative paths)
- Removed stale migration artifacts from root directory
109 lines
2.7 KiB
TypeScript
109 lines
2.7 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import {
|
|
hasReplyChannelData,
|
|
hasReplyContent,
|
|
hasReplyPayloadContent,
|
|
normalizeInteractiveReply,
|
|
resolveInteractiveTextFallback,
|
|
} from "./payload.js";
|
|
|
|
describe("hasReplyChannelData", () => {
|
|
it.each([
|
|
{ value: undefined, expected: false },
|
|
{ value: {}, expected: false },
|
|
{ value: [], expected: false },
|
|
{ value: { slack: { blocks: [] } }, expected: true },
|
|
] as const)("accepts non-empty objects only: %j", ({ value, expected }) => {
|
|
expect(hasReplyChannelData(value)).toBe(expected);
|
|
});
|
|
});
|
|
|
|
describe("hasReplyContent", () => {
|
|
it("treats whitespace-only text and empty structured payloads as empty", () => {
|
|
expect(
|
|
hasReplyContent({
|
|
text: " ",
|
|
mediaUrls: ["", " "],
|
|
interactive: { blocks: [] },
|
|
hasChannelData: false,
|
|
}),
|
|
).toBe(false);
|
|
});
|
|
|
|
it.each([
|
|
{
|
|
name: "shared interactive blocks",
|
|
input: {
|
|
interactive: {
|
|
blocks: [{ type: "buttons", buttons: [{ label: "Retry", value: "retry" }] }],
|
|
},
|
|
},
|
|
},
|
|
{
|
|
name: "explicit extra content",
|
|
input: {
|
|
text: " ",
|
|
extraContent: true,
|
|
},
|
|
},
|
|
] as const)("accepts $name", ({ input }) => {
|
|
expect(hasReplyContent(input)).toBe(true);
|
|
});
|
|
});
|
|
|
|
describe("hasReplyPayloadContent", () => {
|
|
it("trims text and falls back to channel data by default", () => {
|
|
expect(
|
|
hasReplyPayloadContent({
|
|
text: " ",
|
|
channelData: { slack: { blocks: [] } },
|
|
}),
|
|
).toBe(true);
|
|
});
|
|
|
|
it.each([
|
|
{
|
|
name: "explicit channel-data overrides",
|
|
payload: {
|
|
text: " ",
|
|
channelData: {},
|
|
},
|
|
options: {
|
|
hasChannelData: true,
|
|
},
|
|
},
|
|
{
|
|
name: "extra content",
|
|
payload: {
|
|
text: " ",
|
|
},
|
|
options: {
|
|
extraContent: true,
|
|
},
|
|
},
|
|
] as const)("accepts $name", ({ payload, options }) => {
|
|
expect(hasReplyPayloadContent(payload, options)).toBe(true);
|
|
});
|
|
});
|
|
|
|
describe("interactive payload helpers", () => {
|
|
it("normalizes interactive replies and resolves text fallbacks", () => {
|
|
const interactive = normalizeInteractiveReply({
|
|
blocks: [
|
|
{ type: "text", text: "First" },
|
|
{ type: "buttons", buttons: [{ label: "Retry", value: "retry" }] },
|
|
{ type: "text", text: "Second" },
|
|
],
|
|
});
|
|
|
|
expect(interactive).toEqual({
|
|
blocks: [
|
|
{ type: "text", text: "First" },
|
|
{ type: "buttons", buttons: [{ label: "Retry", value: "retry" }] },
|
|
{ type: "text", text: "Second" },
|
|
],
|
|
});
|
|
expect(resolveInteractiveTextFallback({ interactive })).toBe("First\n\nSecond");
|
|
});
|
|
});
|