Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions lark_channel/channel/tests/test_sender.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,41 @@ async def test_reply_via_reply_to():
assert calls[0]["message_id"] == "om_parent"


@pytest.mark.asyncio
async def test_thread_reply_every_chunk_replies_to_root():
"""Issue #5: with reply_in_thread=True, EVERY chunk of a long reply must
reply to the root — otherwise chunks after the first leak out of the
thread into the main timeline."""
d, calls = make_driver()
s = OutboundSender(d, OutboundConfig(text_chunk_limit=10, chunk_mode="none"))
r = await s.send(
OutboundText(text="a" * 25),
reply_to="om_root",
reply_in_thread=True,
)
assert r.success is True
reply_calls = [c for c in calls if c["op"] == "reply"]
assert len(reply_calls) == 3
for c in reply_calls:
assert c["message_id"] == "om_root"
assert c["reply_in_thread"] is True


@pytest.mark.asyncio
async def test_flat_reply_only_first_chunk_quotes_parent():
"""Legacy flat-reply behavior: only the first chunk quote-replies the
parent; subsequent chunks are fresh top-level messages."""
d, calls = make_driver()
s = OutboundSender(d, OutboundConfig(text_chunk_limit=10, chunk_mode="none"))
r = await s.send(OutboundText(text="a" * 25), reply_to="om_parent")
assert r.success is True
reply_calls = [c for c in calls if c["op"] == "reply"]
create_calls = [c for c in calls if c["op"] == "create"]
assert len(reply_calls) == 1
assert reply_calls[0]["message_id"] == "om_parent"
assert len(create_calls) == 2


@pytest.mark.asyncio
async def test_chunks_long_text():
d, calls = make_driver()
Expand Down