test(openclaw): assert /menu returns full main menu keyboard
This commit is contained in:
@@ -56,6 +56,43 @@ def test_openclaw_answer_variants_are_menu_wakeup():
|
||||
assert bot._looks_like_wakeup_prompt("你好") is True
|
||||
|
||||
|
||||
def test_menu_command_returns_full_main_menu_keyboard(monkeypatch):
|
||||
from routes import openclaw_bot_routes as bot
|
||||
from services.openclaw_bot import menu_keyboards
|
||||
|
||||
captured = {}
|
||||
|
||||
def fake_send_message(chat_id, text, reply_to=None, keyboard=None, parse_mode="Markdown", **_kwargs):
|
||||
captured["chat_id"] = chat_id
|
||||
captured["text"] = text
|
||||
captured["keyboard"] = keyboard
|
||||
captured["parse_mode"] = parse_mode
|
||||
|
||||
monkeypatch.setattr(bot, "send_typing", lambda _chat_id: None)
|
||||
monkeypatch.setattr(bot, "send_message", fake_send_message)
|
||||
monkeypatch.setattr(bot, "BOT_USERNAME", "@KnownBot")
|
||||
monkeypatch.setattr(bot, "_is_authorized", lambda _chat_type, _chat_id, _uid: True)
|
||||
|
||||
app = _build_request_app()
|
||||
payload = {
|
||||
"update_id": 10002,
|
||||
"message": {
|
||||
"message_id": 56,
|
||||
"chat": {"id": -200, "type": "supergroup"},
|
||||
"from": {"id": 777},
|
||||
"text": "/menu",
|
||||
},
|
||||
}
|
||||
|
||||
with app.test_request_context("/bot/telegram/webhook", method="POST", json=payload):
|
||||
bot.telegram_webhook()
|
||||
|
||||
assert captured["chat_id"] == -200
|
||||
assert captured["keyboard"] == menu_keyboards.main_menu_keyboard()
|
||||
assert captured["parse_mode"] == "Markdown"
|
||||
assert "OpenClaw(小O)" in captured["text"]
|
||||
|
||||
|
||||
def test_private_menu_command_is_allowed_when_no_whitelist_and_fallback_enabled(monkeypatch):
|
||||
from routes import openclaw_bot_routes as bot
|
||||
|
||||
|
||||
Reference in New Issue
Block a user