from __future__ import annotations from types import SimpleNamespace from unittest.mock import AsyncMock from adapter.matrix.bot import send_outgoing from adapter.matrix.store import get_pending_confirm from core.protocol import OutgoingUI, UIButton from core.store import InMemoryStore async def test_mat06_outgoing_ui_renders_text_with_yes_no(): client = SimpleNamespace(room_send=AsyncMock()) store = InMemoryStore() event = OutgoingUI( chat_id="C1", text="Удалить файл?", buttons=[UIButton(label="Подтвердить", action="confirm")], ) await send_outgoing(client, "!room:ex", event, store=store) client.room_send.assert_awaited_once() body = client.room_send.call_args.args[2]["body"] assert "Удалить файл?" in body assert "!yes" in body assert "!no" in body assert "Подтвердить" in body async def test_mat07_outgoing_ui_no_reaction_sent(): client = SimpleNamespace(room_send=AsyncMock()) store = InMemoryStore() event = OutgoingUI( chat_id="C1", text="Confirm action?", buttons=[UIButton(label="OK", action="confirm", payload={"id": 1})], ) await send_outgoing(client, "!room:ex", event, store=store) assert client.room_send.await_count == 1 assert client.room_send.call_args.args[1] == "m.room.message" for call in client.room_send.call_args_list: assert call.args[1] != "m.reaction" pending = await get_pending_confirm(store, "!room:ex") assert pending == { "action_id": "confirm", "description": "Confirm action?", "payload": {"id": 1}, }