Files
ten31-database/backend/matrix_intake/test_matrix_io.py
T
Keysat aefb2aa119 Matrix intake: main-timeline nudge, clearer messages, note text in grid
Four bot-side UX fixes surfaced by the live smoke:
- Post a brief pointer in the main timeline (a reply to the user's message)
  alongside the in-thread proposal card, so proposals aren't missed inside a
  thread. Pointer only — approvals still happen in the thread, where the note
  is visible (you can't make an informed yes/no without seeing it).
- A bare yes/no typed in the main timeline while a proposal is pending now
  gets a "reply in the thread" redirect instead of "couldn't tell what to record."
- Clearer commit confirmations: "Created a new grid entry for X" vs
  "Logged a note on X (existing grid entry)."
- Send a blank communication subject when a note is present so the grid's
  one-line note summary shows the note text, not the "(Matrix)" label
  (provenance stays in source="matrix_intake").
2026-06-17 17:14:08 -05:00

38 lines
1.1 KiB
Python

"""Tests for matrix_io content builders — pure dict shaping, no network."""
import os
import sys
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
import matrix_io # noqa: E402
def test_reply_content_is_plain_main_timeline_reply():
c = matrix_io.reply_content("hi", "$evt1")
rel = c["m.relates_to"]
assert rel["m.in_reply_to"]["event_id"] == "$evt1"
# a plain reply must NOT carry a thread relation, or it'd land in the thread
# instead of the main timeline (the whole point of the nudge).
assert "rel_type" not in rel
def test_reply_content_without_target_has_no_relation():
c = matrix_io.reply_content("hi", None)
assert "m.relates_to" not in c
assert c["body"] == "hi"
def test_thread_content_stays_threaded():
c = matrix_io.thread_content("hi", "$root1")
rel = c["m.relates_to"]
assert rel["rel_type"] == "m.thread"
assert rel["event_id"] == "$root1"
if __name__ == "__main__":
fns = [v for k, v in sorted(globals().items()) if k.startswith("test_") and callable(v)]
for fn in fns:
fn()
print(f"ok {fn.__name__}")
print(f"\n{len(fns)} passed")