mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 08:10:44 +00:00
test(whatsapp): sync auto-reply runtime mock
This commit is contained in:
@@ -252,6 +252,31 @@ function resolveSendableOutboundReplyPartsMock(payload: Record<string, unknown>)
|
||||
};
|
||||
}
|
||||
|
||||
function resolveChannelSourceReplyDeliveryModeMock(params: {
|
||||
cfg: {
|
||||
messages?: {
|
||||
visibleReplies?: "automatic" | "message_tool";
|
||||
groupChat?: { visibleReplies?: "automatic" | "message_tool" };
|
||||
};
|
||||
};
|
||||
ctx: { ChatType?: string; CommandSource?: "text" | "native" };
|
||||
requested?: "automatic" | "message_tool_only";
|
||||
}) {
|
||||
if (params.requested) {
|
||||
return params.requested;
|
||||
}
|
||||
if (params.ctx.CommandSource === "native") {
|
||||
return "automatic";
|
||||
}
|
||||
const chatType = normalizeLowercaseStringOrEmpty(params.ctx.ChatType);
|
||||
if (chatType === "group" || chatType === "channel") {
|
||||
return params.cfg.messages?.groupChat?.visibleReplies === "automatic"
|
||||
? "automatic"
|
||||
: "message_tool_only";
|
||||
}
|
||||
return params.cfg.messages?.visibleReplies === "message_tool" ? "message_tool_only" : "automatic";
|
||||
}
|
||||
|
||||
function toLocationContextMock(location: unknown) {
|
||||
return { Location: location };
|
||||
}
|
||||
@@ -445,7 +470,7 @@ vi.mock("./auto-reply/monitor/inbound-dispatch.runtime.js", () => ({
|
||||
getAgentScopedMediaLocalRoots: () => [] as string[],
|
||||
jidToE164: normalizePhoneLikeToE164,
|
||||
logVerbose: (_msg: string) => undefined,
|
||||
resolveChannelSourceReplyDeliveryMode: () => undefined,
|
||||
resolveChannelSourceReplyDeliveryMode: resolveChannelSourceReplyDeliveryModeMock,
|
||||
resolveChunkMode: () => undefined,
|
||||
resolveIdentityNamePrefix: resolveIdentityNamePrefixMock,
|
||||
resolveInboundLastRouteSessionKey: (params: { sessionKey: string }) => params.sessionKey,
|
||||
@@ -479,8 +504,8 @@ vi.mock("./auto-reply/monitor/runtime-api.js", () => ({
|
||||
normalizeE164: normalizePhoneLikeToE164,
|
||||
readStoreAllowFromForDmPolicy: async () => [] as string[],
|
||||
recordSessionMetaFromInbound: async () => undefined,
|
||||
resolveChannelSourceReplyDeliveryMode: resolveChannelSourceReplyDeliveryModeMock,
|
||||
resolveChannelContextVisibilityMode: resolveChannelContextVisibilityModeMock,
|
||||
resolveChannelSourceReplyDeliveryMode: () => undefined,
|
||||
resolveChunkMode: () => undefined,
|
||||
resolveIdentityNamePrefix: resolveIdentityNamePrefixMock,
|
||||
resolveInboundLastRouteSessionKey: (params: { sessionKey: string }) => params.sessionKey,
|
||||
|
||||
Reference in New Issue
Block a user