test(buzz): align send-recovery tests with the composed mention ladder
Follow-up for salvaged PRs #82646 + #83414: resolution probes precede publishes, the presentation-escape retry precedes the self-mention downgrade, and a new test pins the escape-retry-delivers path.
This commit is contained in:
@@ -1393,11 +1393,15 @@ class TestBuzzAdapterSend:
|
||||
|
||||
assert result.success is True
|
||||
assert result.message_id == "evt124"
|
||||
assert len(cli.calls) == 2
|
||||
assert cli.calls[0][1] == (
|
||||
# Composed with #83414 mention resolution: resolution probes
|
||||
# (channels members / messages get) precede the sends; assert on the
|
||||
# publish calls only.
|
||||
sends = [c for c in cli.calls if tuple(c[0][:2]) == ("messages", "send")]
|
||||
assert len(sends) == 2
|
||||
assert sends[0][1] == (
|
||||
"Continue in @session:default/20260809_092321_24aa09."
|
||||
)
|
||||
assert cli.calls[1][1] == (
|
||||
assert sends[1][1] == (
|
||||
"Continue in @\u200bsession:default/20260809_092321_24aa09."
|
||||
)
|
||||
|
||||
@@ -1417,7 +1421,10 @@ class TestBuzzAdapterSend:
|
||||
result = await adapter.send(CHANNEL, "hello @session")
|
||||
|
||||
assert result.success is False
|
||||
assert len(cli.calls) == 1
|
||||
# Unrelated failures never retry the publish (mention-resolution
|
||||
# probes for "@" content are not sends).
|
||||
sends = [c for c in cli.calls if tuple(c[0][:2]) == ("messages", "send")]
|
||||
assert len(sends) == 1
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_send_image_retries_unresolved_presentation_mention(self, tmp_path):
|
||||
@@ -1814,6 +1821,7 @@ class TestStandaloneSend:
|
||||
*,
|
||||
relay_url,
|
||||
private_key,
|
||||
auth_tag="",
|
||||
input_text=None,
|
||||
timeout=30.0,
|
||||
):
|
||||
|
||||
@@ -286,6 +286,34 @@ class TestSendRecovery:
|
||||
adapter = _make_adapter()
|
||||
cli = _wire(adapter, _ScriptedCli())
|
||||
cli.script("channels", "members", _members()) # nobody to resolve
|
||||
unresolved = json.dumps({
|
||||
"error": "user_error",
|
||||
"message": "mention '@-mention' does not match a current channel member",
|
||||
})
|
||||
# Composed ladder (#82646 + #83414): the presentation-escape retry
|
||||
# fires first; when the CLI still rejects, the self-mention downgrade
|
||||
# is the last rung.
|
||||
cli.script("messages", "send", "", code=1, stderr=unresolved)
|
||||
cli.script("messages", "send", "", code=1, stderr=unresolved)
|
||||
cli.script("messages", "send", {"accepted": True, "event_id": "e3"})
|
||||
|
||||
result = await adapter.send(CHANNEL, "just @-mention me")
|
||||
|
||||
assert result.success
|
||||
sends = self._send_calls(cli)
|
||||
assert len(sends) == 3
|
||||
# Rung 3: escaped presentation token, no mention flags.
|
||||
assert "--mention" not in sends[1][0]
|
||||
assert "\u200b" in (sends[1][1] or "")
|
||||
# Rung 4: self-mention downgrade with the original content.
|
||||
assert ["--mention", SELF_PUBKEY] == sends[2][0][-2:]
|
||||
assert sends[2][1] == "just @-mention me"
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_unresolvable_token_escape_retry_delivers(self):
|
||||
adapter = _make_adapter()
|
||||
cli = _wire(adapter, _ScriptedCli())
|
||||
cli.script("channels", "members", _members())
|
||||
cli.script(
|
||||
"messages", "send", "",
|
||||
code=1,
|
||||
@@ -294,11 +322,12 @@ class TestSendRecovery:
|
||||
"message": "mention '@-mention' does not match a current channel member",
|
||||
}),
|
||||
)
|
||||
cli.script("messages", "send", {"accepted": True, "event_id": "e3"})
|
||||
cli.script("messages", "send", {"accepted": True, "event_id": "e4"})
|
||||
|
||||
result = await adapter.send(CHANNEL, "just @-mention me")
|
||||
|
||||
assert result.success
|
||||
sends = self._send_calls(cli)
|
||||
assert len(sends) == 2
|
||||
assert ["--mention", SELF_PUBKEY] == sends[1][0][-2:]
|
||||
assert "--mention" not in sends[1][0]
|
||||
assert sends[1][1] == "just @\u200b-mention me"
|
||||
|
||||
Reference in New Issue
Block a user