mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-10 00:31:22 +00:00
test: harden Telegram approval fallback coverage
This commit is contained in:
@@ -243,6 +243,34 @@ describe("TelegramExecApprovalHandler", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("delivers plugin approvals when the agent only exists in the Telegram session key", async () => {
|
||||
const cfg = {
|
||||
channels: {
|
||||
telegram: {
|
||||
execApprovals: {
|
||||
enabled: true,
|
||||
approvers: ["8460800771"],
|
||||
agentFilter: ["main"],
|
||||
target: "dm",
|
||||
},
|
||||
},
|
||||
},
|
||||
} as OpenClawConfig;
|
||||
const { handler, sendMessage } = createHandler(cfg);
|
||||
|
||||
await handler.handleRequested({
|
||||
...pluginRequest,
|
||||
request: {
|
||||
...pluginRequest.request,
|
||||
agentId: undefined,
|
||||
},
|
||||
});
|
||||
|
||||
const [chatId, text] = sendMessage.mock.calls[0] ?? [];
|
||||
expect(chatId).toBe("8460800771");
|
||||
expect(text).toContain("Plugin approval required");
|
||||
});
|
||||
|
||||
it("does not deliver plugin approvals for a different Telegram account", async () => {
|
||||
const cfg = {
|
||||
channels: {
|
||||
|
||||
@@ -80,6 +80,7 @@ const telegramExecApprovalProfile = createChannelExecApprovalProfile({
|
||||
normalizeAccountId(boundAccountId) === normalizeAccountId(accountId)
|
||||
);
|
||||
},
|
||||
// Telegram session keys often carry the only stable agent ID for approval routing.
|
||||
fallbackAgentIdFromSessionKey: true,
|
||||
requireClientEnabledForLocalPromptSuppression: false,
|
||||
});
|
||||
|
||||
@@ -82,6 +82,7 @@ export function createChannelExecApprovalProfile(params: {
|
||||
normalizeSenderId?: (value: string) => string | undefined;
|
||||
isTargetRecipient?: (params: ApprovalProfileParams & { senderId?: string | null }) => boolean;
|
||||
matchesRequestAccount?: (params: ApprovalProfileParams & { request: ApprovalRequest }) => boolean;
|
||||
// Some channels encode the effective agent only in sessionKey for forwarded approvals.
|
||||
fallbackAgentIdFromSessionKey?: boolean;
|
||||
requireClientEnabledForLocalPromptSuppression?: boolean;
|
||||
}) {
|
||||
|
||||
Reference in New Issue
Block a user