fix(trigger): require names for trigger creation
This commit is contained in:
@@ -867,7 +867,7 @@ async def test_slash_new_is_blocked_for_disallowed_user() -> None:
|
||||
assert handled == []
|
||||
|
||||
|
||||
@pytest.mark.parametrize("slash_name", ["stop", "restart", "status", "history", "model", "trigger"])
|
||||
@pytest.mark.parametrize("slash_name", ["stop", "restart", "status", "history", "model"])
|
||||
@pytest.mark.asyncio
|
||||
async def test_slash_commands_forward_via_handle_message(slash_name: str) -> None:
|
||||
channel = DiscordChannel(DiscordConfig(enabled=True, allow_from=["*"]), MessageBus())
|
||||
@@ -919,7 +919,7 @@ async def test_slash_model_forwards_optional_preset() -> None:
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_slash_trigger_forwards_optional_name() -> None:
|
||||
async def test_slash_trigger_forwards_required_name() -> None:
|
||||
channel = DiscordChannel(DiscordConfig(enabled=True, allow_from=["*"]), MessageBus())
|
||||
handled: list[dict] = []
|
||||
|
||||
|
||||
@@ -1577,6 +1577,7 @@ def test_telegram_bus_slash_command_regex_matches_agent_loop_commands() -> None:
|
||||
assert pat.fullmatch("/history")
|
||||
assert pat.fullmatch("/history 5")
|
||||
assert pat.fullmatch("/goal ship the feature")
|
||||
assert pat.fullmatch("/trigger")
|
||||
assert pat.fullmatch("/trigger PR review")
|
||||
assert pat.fullmatch("/pairing list")
|
||||
assert pat.fullmatch("/model fast")
|
||||
|
||||
@@ -45,5 +45,33 @@ async def test_trigger_command_creates_session_bound_local_trigger(tmp_path: Pat
|
||||
assert f"nanobot trigger {trigger.id} \"message\"" in response.content
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_trigger_command_without_name_returns_usage_only(tmp_path: Path) -> None:
|
||||
router = CommandRouter()
|
||||
register_builtin_commands(router)
|
||||
store = ExternalTriggerStore(tmp_path)
|
||||
loop = SimpleNamespace(workspace=tmp_path, external_trigger_store=store)
|
||||
msg = InboundMessage(
|
||||
channel="websocket",
|
||||
sender_id="user",
|
||||
chat_id="chat-1",
|
||||
content="/trigger@nanobot_bot",
|
||||
metadata={"webui": True},
|
||||
)
|
||||
ctx = CommandContext(
|
||||
msg=msg,
|
||||
session=None,
|
||||
key="websocket:chat-1",
|
||||
raw="/trigger@nanobot_bot",
|
||||
loop=loop,
|
||||
)
|
||||
|
||||
response = await router.dispatch(ctx)
|
||||
|
||||
assert response is not None
|
||||
assert "Usage: /trigger <name>" in response.content
|
||||
assert store.list_for_session("websocket:chat-1") == []
|
||||
|
||||
|
||||
def test_trigger_command_is_in_help_text() -> None:
|
||||
assert "/trigger [name]" in build_help_text()
|
||||
assert "/trigger <name>" in build_help_text()
|
||||
|
||||
Reference in New Issue
Block a user