test(01-06): harden matrix room-vs-chat regressions

- Seed invite tests with explicit next_chat_index progression instead of C1 assumptions
- Separate Matrix room ids from logical chat ids in dispatcher coverage
- Verify the full Matrix adapter suite against the tightened assertions
This commit is contained in:
Mikhail Putilovskij 2026-04-03 12:35:09 +03:00
parent 3e06a67e24
commit 9cdb6118e9
2 changed files with 25 additions and 14 deletions

View file

@ -5,7 +5,7 @@ from unittest.mock import AsyncMock
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
from adapter.matrix.store import get_room_meta, get_user_meta, set_user_meta
from sdk.mock import MockPlatformClient
@ -23,6 +23,7 @@ def _make_client():
async def test_mat01_invite_creates_space_and_chat1():
runtime = build_runtime(platform=MockPlatformClient())
await set_user_meta(runtime.store, "@alice:example.org", {"next_chat_index": 4})
client = _make_client()
room = SimpleNamespace(room_id="!dm:example.org", display_name="Alice")
event = SimpleNamespace(sender="@alice:example.org", membership="invite")
@ -45,8 +46,9 @@ async def test_mat01_invite_creates_space_and_chat1():
room_meta = await get_room_meta(runtime.store, "!chat1:example.org")
assert room_meta is not None
assert room_meta["chat_id"] == "C1"
assert room_meta["chat_id"] == "C4"
assert room_meta["space_id"] == "!space:example.org"
assert user_meta["next_chat_index"] == 5
async def test_mat02_invite_idempotent():
@ -63,6 +65,7 @@ async def test_mat02_invite_idempotent():
async def test_mat03_no_hardcoded_c1():
runtime = build_runtime(platform=MockPlatformClient())
await set_user_meta(runtime.store, "@alice:example.org", {"next_chat_index": 7})
client = _make_client()
room = SimpleNamespace(room_id="!dm:example.org", display_name="Alice")
event = SimpleNamespace(sender="@alice:example.org", membership="invite")
@ -71,8 +74,8 @@ async def test_mat03_no_hardcoded_c1():
room_meta = await get_room_meta(runtime.store, "!chat1:example.org")
assert room_meta is not None
assert room_meta["chat_id"] == "C1"
assert room_meta["chat_id"] == "C7"
user_meta = await get_user_meta(runtime.store, "@alice:example.org")
assert user_meta is not None
assert user_meta["next_chat_index"] == 2
assert user_meta["next_chat_index"] == 8