test(01-04): add matrix space regression coverage
- add MAT-01..MAT-07 and MAT-09..MAT-12 regression tests for matrix adapter - extend store and dispatcher coverage for pending confirmations and settings dashboard - verify matrix adapter suite and full pytest suite stay green
This commit is contained in:
parent
6f1bdb4077
commit
97a3dc35ea
6 changed files with 382 additions and 0 deletions
52
tests/adapter/matrix/test_send_outgoing.py
Normal file
52
tests/adapter/matrix/test_send_outgoing.py
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
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},
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue