Files
cleveragents-core/robot/tui_help_command.robot
HAL9000 9215894b98
CI / lint (pull_request) Successful in 48s
CI / typecheck (pull_request) Successful in 1m10s
CI / quality (pull_request) Successful in 56s
CI / security (pull_request) Successful in 1m23s
CI / build (pull_request) Successful in 35s
CI / push-validation (pull_request) Successful in 36s
CI / helm (pull_request) Successful in 37s
CI / unit_tests (pull_request) Successful in 7m12s
CI / docker (pull_request) Successful in 1m42s
CI / coverage (pull_request) Successful in 14m19s
CI / integration_tests (pull_request) Successful in 21m38s
CI / status-check (pull_request) Successful in 3s
fix(tests): rewrite Robot for-loop as comprehension to preserve indentation
The Robot Framework `Catenate` keyword treats 2+ consecutive spaces as
field separators and strips them, which breaks Python's mandatory
indentation when a nested `assert` follows a `for` line. As a result
the "TUI Help Command Groups By Namespace" test produced a script with
a de-indented `assert` body, causing an IndentationError under
`python -c` and the test to fail with rc=1.

Rewrite the namespace-presence check as a single-line list
comprehension over the expected group headers, mirroring the pattern
already used by the sibling "Lists All Catalogued Commands" test in
the same file. The check is semantically equivalent — both fail with
the same diagnostic message when a group header is missing — but the
flattened form survives Robot's argument tokenisation intact.

ISSUES CLOSED: #3434
2026-05-31 23:00:02 -04:00

85 lines
4.8 KiB
Plaintext

*** Settings ***
Library Process
Library String
*** Test Cases ***
TUI Help Command Lists All Catalogued Commands
[Documentation] /help with no args must list all commands from SLASH_COMMAND_SPECS,
... not the old hardcoded 3-command string.
${script}= Catenate SEPARATOR=\n
... from cleveragents.tui.slash_catalog import SLASH_COMMAND_SPECS
... from cleveragents.tui.commands import TuiCommandRouter
... from unittest.mock import MagicMock
... registry = MagicMock()
... registry.list_personas.return_value = []
... state = MagicMock()
... router = TuiCommandRouter(persona_registry=registry, persona_state=state)
... result = router.handle("help", session_id="default")
... assert "Available slash commands:" in result, f"Missing header: {result[:200]}"
... missing = [s.command for s in SLASH_COMMAND_SPECS if s.command not in result]
... assert not missing, f"Missing commands: {missing}"
... assert result != "Commands: /persona, /session, /help", "Old hardcoded string returned"
... print("tui-help-all-commands-ok")
${result}= Run Process ${PYTHON} -c ${script} shell=False stderr=STDOUT
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} tui-help-all-commands-ok
TUI Help Command Groups By Namespace
[Documentation] /help output must include group headers for Session, Persona, Plan, Utility.
${script}= Catenate SEPARATOR=\n
... from cleveragents.tui.commands import TuiCommandRouter
... from unittest.mock import MagicMock
... registry = MagicMock()
... registry.list_personas.return_value = []
... state = MagicMock()
... router = TuiCommandRouter(persona_registry=registry, persona_state=state)
... result = router.handle("help", session_id="default")
... missing = [g for g in ("Session:", "Persona:", "Plan:", "Utility:") if g not in result]
... assert not missing, f"Missing group headers: {missing}"
... print("tui-help-groups-ok")
${result}= Run Process ${PYTHON} -c ${script} shell=False stderr=STDOUT
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} tui-help-groups-ok
TUI Help Command With Known Command Returns Specific Help
[Documentation] /help persona:list must return description for that specific command.
${script}= Catenate SEPARATOR=\n
... from cleveragents.tui.commands import TuiCommandRouter
... from unittest.mock import MagicMock
... registry = MagicMock()
... registry.list_personas.return_value = []
... state = MagicMock()
... router = TuiCommandRouter(persona_registry=registry, persona_state=state)
... result = router.handle("help persona:list", session_id="default")
... assert "/persona:list" in result, f"Missing command name in: {result}"
... assert "Display all personas" in result, f"Missing description in: {result}"
... assert "Persona" in result, f"Missing group in: {result}"
... print("tui-help-specific-ok")
${result}= Run Process ${PYTHON} -c ${script} shell=False stderr=STDOUT
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} tui-help-specific-ok
TUI Help Command With Unknown Command Returns Not Found
[Documentation] /help nonexistent must return an "Unknown command" message.
${script}= Catenate SEPARATOR=\n
... from cleveragents.tui.commands import TuiCommandRouter
... from unittest.mock import MagicMock
... registry = MagicMock()
... registry.list_personas.return_value = []
... state = MagicMock()
... router = TuiCommandRouter(persona_registry=registry, persona_state=state)
... result = router.handle("help nonexistent:cmd", session_id="default")
... assert "Unknown command" in result, f"Expected not-found message, got: {result}"
... print("tui-help-unknown-ok")
${result}= Run Process ${PYTHON} -c ${script} shell=False stderr=STDOUT
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} tui-help-unknown-ok
TUI Headless Startup Help Payload Contains All Commands
[Documentation] run_tui --headless JSON payload help field must list all commands.
${result}= Run Process ${PYTHON} -m cleveragents tui --headless shell=False stderr=STDOUT env:CLEVERAGENTS_DATABASE_URL=sqlite:///:memory:
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} Available slash commands:
Should Contain ${result.stdout} persona:list
Should Contain ${result.stdout} session:create