mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-28 13:26:04 -06:00
test(telegram): prove empty account capability fallback
This commit is contained in:
@@ -90,6 +90,10 @@ export function mergeTelegramAccountConfig(
|
||||
baseAllowFrom: base.allowFrom,
|
||||
accountAllowFrom: account.allowFrom,
|
||||
});
|
||||
const capabilities =
|
||||
Array.isArray(account.capabilities) && account.capabilities.length === 0
|
||||
? base.capabilities
|
||||
: (account.capabilities ?? base.capabilities);
|
||||
|
||||
return { ...base, ...account, allowFrom, groups };
|
||||
return { ...base, ...account, allowFrom, capabilities, groups };
|
||||
}
|
||||
|
||||
@@ -1703,6 +1703,25 @@ describe("handleTelegramAction", () => {
|
||||
expect(sendMessageTelegram).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("allows inline buttons when legacy capabilities are empty", async () => {
|
||||
await handleTelegramAction(
|
||||
{
|
||||
action: "sendMessage",
|
||||
to: "@testchannel",
|
||||
content: "Choose",
|
||||
presentation: {
|
||||
blocks: [{ type: "buttons", buttons: [{ label: "Ok", value: "cmd:ok" }] }],
|
||||
},
|
||||
},
|
||||
telegramConfig({ capabilities: [] }),
|
||||
);
|
||||
const call = mockCall(sendMessageTelegram, 0, "empty legacy capabilities");
|
||||
expect(call[0]).toBe("@testchannel");
|
||||
expect(requireRecord(call[2], "empty legacy capabilities options").buttons).toEqual([
|
||||
[{ text: "Ok", callback_data: "cmd:ok" }],
|
||||
]);
|
||||
});
|
||||
|
||||
it("uses interactive button labels as fallback text when message text is omitted", async () => {
|
||||
await handleTelegramAction(
|
||||
{
|
||||
|
||||
@@ -123,6 +123,25 @@ describe("resolveTelegramInlineButtonsScope (#75433 SecretRef tolerance)", () =>
|
||||
expect(isTelegramInlineButtonsEnabled({ cfg })).toBe(true);
|
||||
});
|
||||
|
||||
it("inherits the channel scope when an account legacy capabilities array is empty", () => {
|
||||
const cfg = {
|
||||
channels: {
|
||||
telegram: {
|
||||
capabilities: { inlineButtons: "off" },
|
||||
accounts: {
|
||||
ops: {
|
||||
botToken: "123:telegram-ops-token",
|
||||
capabilities: [],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
} as unknown as OpenClawConfig;
|
||||
|
||||
expect(resolveTelegramInlineButtonsScope({ cfg, accountId: "ops" })).toBe("off");
|
||||
expect(isTelegramInlineButtonsEnabled({ cfg, accountId: "ops" })).toBe(false);
|
||||
});
|
||||
|
||||
it('preserves configured "off" when botToken is an unresolved SecretRef', () => {
|
||||
const cfg = {
|
||||
channels: {
|
||||
|
||||
Reference in New Issue
Block a user