fix: allow help navigation outside help mode
This commit is contained in:
1 parent
a11b5aac64
commit
aba1eb4ced
3 files changed
+9
-8
No files matched your search
@@ -387,9 +387,6 @@ async def help_navigation(callback: CallbackQuery, state: FSMContext) -> None:
|
||||
message = callback.message
|
||||
if not isinstance(message, Message):
|
||||
return
|
||||
if await current_mode(state) != "help":
|
||||
await callback.answer("Сначала открой режим /help.", show_alert=True)
|
||||
return
|
||||
section = (callback.data or "help:menu").split(":", 1)[1]
|
||||
if not await edit_rich_message(
|
||||
message,
|
||||
|
||||
@@ -298,7 +298,7 @@ class OnboardingTests(unittest.IsolatedAsyncioTestCase):
|
||||
|
||||
edit.assert_not_awaited()
|
||||
|
||||
async def test_help_callback_is_rejected_outside_help_mode(self):
|
||||
async def test_help_callback_edits_message_outside_help_mode(self):
|
||||
message = Message(
|
||||
message_id=79,
|
||||
date=datetime.now(),
|
||||
@@ -306,11 +306,15 @@ class OnboardingTests(unittest.IsolatedAsyncioTestCase):
|
||||
)
|
||||
callback = self._callback("help:posts", message)
|
||||
|
||||
with patch.object(bot, "edit_rich_message", new=AsyncMock()) as edit:
|
||||
with patch.object(bot, "edit_rich_message", new=AsyncMock(return_value=True)) as edit:
|
||||
await bot.help_navigation(callback, _StubState("lobby"))
|
||||
|
||||
edit.assert_not_awaited()
|
||||
callback.answer.assert_awaited_once_with("Сначала открой режим /help.", show_alert=True)
|
||||
edit.assert_awaited_once_with(
|
||||
message,
|
||||
bot.help_view("posts"),
|
||||
reply_markup=bot.help_inline_keyboard(),
|
||||
)
|
||||
callback.answer.assert_awaited_once_with()
|
||||
|
||||
def test_welcome_message_has_examples_and_help_handoff(self):
|
||||
from help_message import WELCOME_RICH_HTML, rich_to_plain
|
||||
|
||||
Reference in new issue
Block a user