Skip to content

The agent that grows with you

test(discord): pin the model picker cancel gate

kshitijk4poor67e5ef6b9dcb
diff --git a/tests/gateway/test_discord_component_auth.py b/tests/gateway/test_discord_component_auth.py
index fd6838a9416..f5a9051c4f0 100644
--- a/tests/gateway/test_discord_component_auth.py
+++ b/tests/gateway/test_discord_component_auth.py
@@ -190,6 +190,17 @@ def test_model_picker_view_empty_allowlists_reject_by_default(monkeypatch):
assert view.allowed_role_ids == set()
assert view._check_auth(_interaction(99999)) is False
+ # Cancel is gated too: a stranger cannot close the owner's picker.
+ import asyncio
+ from unittest.mock import AsyncMock
+
+ stranger = _interaction(99999)
+ stranger.response = SimpleNamespace(send_message=AsyncMock())
+ asyncio.run(view._on_cancel(stranger))
+ assert view.resolved is False
+ stranger.response.send_message.assert_awaited_once()
+ assert stranger.response.send_message.await_args.kwargs.get("ephemeral") is True
+
def test_view_empty_allowlists_allow_with_explicit_allow_all(monkeypatch):
monkeypatch.setenv("DISCORD_ALLOW_ALL_USERS", "true")