feat: онбординг после /start — welcome Rich Message + вызов help_command
- help_message.py: добавлен WELCOME_RICH_HTML (приветствие, примеры, скриншоты) - bot.py: send_rich_help -> send_rich_html(html, stage) + send_rich_message с plain-fallback - bot.py: start теперь шлёт welcome Rich Message, пауза 0.8с, затем help_command - help_command вызывает общий send_rich_message — правки HELP_RICH_HTML меняют и онбординг - тесты: OnboardingTests (3), README/IDEA/VERSION 0.1.0+22
This commit is contained in:
1 parent
d618fd8a61
commit
0ff0e1abe7
6 files changed
+78
-44
No files matched your search
@@ -62,5 +62,39 @@ class HelpRoutingTests(unittest.TestCase):
|
||||
self.assertIn(term, text)
|
||||
|
||||
|
||||
class OnboardingTests(unittest.IsolatedAsyncioTestCase):
|
||||
async def test_start_sends_welcome_rich_then_help_command(self):
|
||||
message = AsyncMock()
|
||||
message.from_user.id = 42
|
||||
message.message_thread_id = None
|
||||
calls: list[str] = []
|
||||
|
||||
async def fake_rich(_message, html, _stage):
|
||||
calls.append(html)
|
||||
|
||||
with (
|
||||
patch.object(bot, "notify_development_deploy", new=AsyncMock()),
|
||||
patch.object(bot, "ensure_subscription"),
|
||||
patch.object(bot.asyncio, "to_thread", new=AsyncMock()),
|
||||
patch.object(bot, "send_rich_message", new=fake_rich),
|
||||
):
|
||||
await bot.start(message)
|
||||
self.assertEqual(calls, [bot.WELCOME_RICH_HTML, bot.HELP_RICH_HTML])
|
||||
|
||||
async def test_start_help_step_reuses_help_command(self):
|
||||
from pathlib import Path
|
||||
|
||||
source = Path(bot.__file__).read_text(encoding="utf-8")
|
||||
start_body = source.split("async def start(message: Message) -> None:")[1].split("\nasync def ")[0]
|
||||
self.assertIn("await help_command(message)", start_body)
|
||||
|
||||
def test_welcome_message_has_examples_and_help_handoff(self):
|
||||
from help_message import WELCOME_RICH_HTML, rich_to_plain
|
||||
|
||||
text = rich_to_plain(WELCOME_RICH_HTML)
|
||||
for term in ("Привет", "Напиши пост", "скриншот"):
|
||||
self.assertIn(term, text)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user