feat(matrix): land QA follow-ups and refresh docs
- harden Matrix onboarding/chat lifecycle after manual QA - refresh README and Matrix docs to match current behavior - add local ignores for runtime artifacts and include current planning/report docs Closes #7 Closes #9 Closes #14
This commit is contained in:
parent
7fce4c9b3e
commit
6ced154124
35 changed files with 8380 additions and 67 deletions
|
|
@ -3,6 +3,8 @@ from __future__ import annotations
|
|||
from types import SimpleNamespace
|
||||
from unittest.mock import AsyncMock
|
||||
|
||||
from nio.api import RoomVisibility
|
||||
|
||||
from adapter.matrix.bot import build_runtime
|
||||
from adapter.matrix.handlers.auth import handle_invite
|
||||
from adapter.matrix.store import get_room_meta, get_user_meta, set_user_meta
|
||||
|
|
@ -28,11 +30,25 @@ async def test_mat01_invite_creates_space_and_chat1():
|
|||
room = SimpleNamespace(room_id="!dm:example.org", display_name="Alice")
|
||||
event = SimpleNamespace(sender="@alice:example.org", membership="invite")
|
||||
|
||||
await handle_invite(client, room, event, runtime.platform, runtime.store, runtime.auth_mgr)
|
||||
await handle_invite(
|
||||
client,
|
||||
room,
|
||||
event,
|
||||
runtime.platform,
|
||||
runtime.store,
|
||||
runtime.auth_mgr,
|
||||
runtime.chat_mgr,
|
||||
)
|
||||
|
||||
first_call = client.room_create.call_args_list[0]
|
||||
assert first_call.kwargs.get("space") is True
|
||||
assert first_call.kwargs.get("visibility") is RoomVisibility.private
|
||||
assert first_call.kwargs.get("invite") == ["@alice:example.org"]
|
||||
second_call = client.room_create.call_args_list[1]
|
||||
assert second_call.kwargs.get("visibility") is RoomVisibility.private
|
||||
assert second_call.kwargs.get("invite") == ["@alice:example.org"]
|
||||
assert client.room_create.await_count == 2
|
||||
client.room_invite.assert_not_awaited()
|
||||
|
||||
client.room_put_state.assert_awaited_once()
|
||||
kwargs = client.room_put_state.call_args.kwargs
|
||||
|
|
@ -50,6 +66,10 @@ async def test_mat01_invite_creates_space_and_chat1():
|
|||
assert room_meta["space_id"] == "!space:example.org"
|
||||
assert user_meta["next_chat_index"] == 5
|
||||
|
||||
chats = await runtime.chat_mgr.list_active("@alice:example.org")
|
||||
assert [chat.chat_id for chat in chats] == ["C4"]
|
||||
assert [chat.surface_ref for chat in chats] == ["!chat1:example.org"]
|
||||
|
||||
|
||||
async def test_mat02_invite_idempotent():
|
||||
runtime = build_runtime(platform=MockPlatformClient())
|
||||
|
|
@ -57,8 +77,24 @@ async def test_mat02_invite_idempotent():
|
|||
room = SimpleNamespace(room_id="!dm:example.org", display_name="Alice")
|
||||
event = SimpleNamespace(sender="@alice:example.org", membership="invite")
|
||||
|
||||
await handle_invite(client, room, event, runtime.platform, runtime.store, runtime.auth_mgr)
|
||||
await handle_invite(client, room, event, runtime.platform, runtime.store, runtime.auth_mgr)
|
||||
await handle_invite(
|
||||
client,
|
||||
room,
|
||||
event,
|
||||
runtime.platform,
|
||||
runtime.store,
|
||||
runtime.auth_mgr,
|
||||
runtime.chat_mgr,
|
||||
)
|
||||
await handle_invite(
|
||||
client,
|
||||
room,
|
||||
event,
|
||||
runtime.platform,
|
||||
runtime.store,
|
||||
runtime.auth_mgr,
|
||||
runtime.chat_mgr,
|
||||
)
|
||||
|
||||
assert client.room_create.await_count == 2
|
||||
|
||||
|
|
@ -70,7 +106,15 @@ async def test_mat03_no_hardcoded_c1():
|
|||
room = SimpleNamespace(room_id="!dm:example.org", display_name="Alice")
|
||||
event = SimpleNamespace(sender="@alice:example.org", membership="invite")
|
||||
|
||||
await handle_invite(client, room, event, runtime.platform, runtime.store, runtime.auth_mgr)
|
||||
await handle_invite(
|
||||
client,
|
||||
room,
|
||||
event,
|
||||
runtime.platform,
|
||||
runtime.store,
|
||||
runtime.auth_mgr,
|
||||
runtime.chat_mgr,
|
||||
)
|
||||
|
||||
room_meta = await get_room_meta(runtime.store, "!chat1:example.org")
|
||||
assert room_meta is not None
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue