TEST-INFRA: Add integration test coverage for tui module #10955

Merged
HAL9000 merged 2 commits from feature/1928-add-test-coverage-for-tui-module into master 2026-06-10 14:12:40 +00:00
7 changed files with 370 additions and 0 deletions
+48
View File
@@ -0,0 +1,48 @@
*** Settings ***
Library Process
Library String
*** Test Cases ***
TUI Commands Module Initialization
[Tags] tdd_issue tdd_issue_1928
${script}= Catenate SEPARATOR=\n
... from cleveragents.tui.commands import TuiCommandRouter
... assert callable(TuiCommandRouter), "TuiCommandRouter should be a callable class"
... print("command-handler-ok")
${result}= Run Process ${PYTHON} -c ${script} shell=False
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} command-handler-ok
TUI Slash Catalog Initialization
[Tags] tdd_issue tdd_issue_1928
${script}= Catenate SEPARATOR=\n
... from cleveragents.tui.slash_catalog import SLASH_COMMAND_SPECS, slash_command_names
... names = slash_command_names()
... assert len(names) > 0, "Slash catalog should have commands"
... assert len(SLASH_COMMAND_SPECS) > 0, "SLASH_COMMAND_SPECS should be non-empty"
... print("slash-catalog-ok")
${result}= Run Process ${PYTHON} -c ${script} shell=False
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} slash-catalog-ok
TUI First Run Module Initialization
[Tags] tdd_issue tdd_issue_1928
${script}= Catenate SEPARATOR=\n
... from cleveragents.tui.first_run import is_first_run, create_default_persona_for_actor
... assert callable(is_first_run), "is_first_run should be callable"
... assert callable(create_default_persona_for_actor), "create_default_persona_for_actor should be callable"
... print("first-run-handler-ok")
${result}= Run Process ${PYTHON} -c ${script} shell=False
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} first-run-handler-ok
TUI Quotes Module Initialization
[Tags] tdd_issue tdd_issue_1928
${script}= Catenate SEPARATOR=\n
... from cleveragents.tui.quotes import THROBBER_QUOTES
... assert isinstance(THROBBER_QUOTES, tuple), "THROBBER_QUOTES should be a tuple"
... assert len(THROBBER_QUOTES) > 0, "THROBBER_QUOTES should be non-empty"
... print("quote-provider-ok")
${result}= Run Process ${PYTHON} -c ${script} shell=False
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} quote-provider-ok
+40
View File
@@ -0,0 +1,40 @@
*** Settings ***
Library Process
Library String
*** Test Cases ***
TUI Input Modes Router Initialization
[Tags] tdd_issue tdd_issue_1928
${script}= Catenate SEPARATOR=\n
... from cleveragents.tui.input.modes import InputModeRouter, InputMode
... router = InputModeRouter(command_handler=lambda cmd: "ok")
... mode = router.detect_mode("hello world")
... assert mode == InputMode.NORMAL, f"Expected NORMAL mode, got {mode}"
... print("input-mode-router-ok")
${result}= Run Process ${PYTHON} -c ${script} shell=False
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} input-mode-router-ok
TUI Input Reference Parser Functionality
[Tags] tdd_issue tdd_issue_1928
${script}= Catenate SEPARATOR=\n
Outdated
Review

BLOCKING: ReferenceParser test only checks that parse() returns a non-None result. It does not verify the parsed references are correct, nor does it test error cases like malformed @mentions or empty input. An integration test should validate the parser actually produces correct output.

BLOCKING: ReferenceParser test only checks that parse() returns a non-None result. It does not verify the parsed references are correct, nor does it test error cases like malformed @mentions or empty input. An integration test should validate the parser actually produces correct output.
Outdated
Review

BLOCKING: ReferenceParser test only checks parse() returns non-None. It does not verify parsed references are correct or test error cases like malformed @mentions.

BLOCKING: ReferenceParser test only checks parse() returns non-None. It does not verify parsed references are correct or test error cases like malformed @mentions.
Outdated
Review

BLOCKING: ReferenceParser test only checks parse() returns non-None. Does not verify parsed references are correct or test error cases like malformed @mentions.

BLOCKING: ReferenceParser test only checks parse() returns non-None. Does not verify parsed references are correct or test error cases like malformed @mentions.
Outdated
Review

BLOCKING: ReferenceParser test checks parse() returns non-None but does not verify parsed references are correct or test error cases like malformed @mentions.

BLOCKING: ReferenceParser test checks parse() returns non-None but does not verify parsed references are correct or test error cases like malformed @mentions.
... from cleveragents.tui.input.reference_parser import parse_references, ReferenceParseResult
... text = "check @README and @config.yaml"
... result = parse_references(text)
... assert isinstance(result, ReferenceParseResult), "parse_references should return ReferenceParseResult"
... print("reference-parser-ok")
${result}= Run Process ${PYTHON} -c ${script} shell=False
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} reference-parser-ok
TUI Input Shell Executor Initialization
[Tags] tdd_issue tdd_issue_1928
${script}= Catenate SEPARATOR=\n
... from cleveragents.tui.input.shell_exec import run_shell_command, ShellResult
... assert callable(run_shell_command), "run_shell_command should be callable"
... result = run_shell_command("echo ok")
... assert isinstance(result, ShellResult), "run_shell_command should return ShellResult"
... print("shell-executor-ok")
${result}= Run Process ${PYTHON} -c ${script} shell=False
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} shell-executor-ok
+38
View File
@@ -0,0 +1,38 @@
*** Settings ***
Library Process
Library String
*** Test Cases ***
TUI Permissions Service Initialization
[Tags] tdd_issue tdd_issue_1928
${script}= Catenate SEPARATOR=\n
... from cleveragents.tui.permissions.service import PermissionRequestService
... service = PermissionRequestService()
... assert service is not None, "PermissionRequestService should be initialized"
... print("permission-service-ok")
${result}= Run Process ${PYTHON} -c ${script} shell=False
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} permission-service-ok
TUI Permissions Models Validation
[Tags] tdd_issue tdd_issue_1928
${script}= Catenate SEPARATOR=\n
... from cleveragents.tui.permissions.models import PermissionDecision, FileChangeType, PermissionRequest
... assert PermissionDecision.ALLOW_ONCE == "allow_once", "PermissionDecision.ALLOW_ONCE should equal allow_once"
... assert FileChangeType.MODIFIED == "M", "FileChangeType.MODIFIED should equal M"
... req = PermissionRequest(path="/test/file.py", change_type=FileChangeType.MODIFIED)
... assert req.path == "/test/file.py", "PermissionRequest path should be set"
... print("permission-models-ok")
${result}= Run Process ${PYTHON} -c ${script} shell=False
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} permission-models-ok
TUI Permissions Screen Initialization
[Tags] tdd_issue tdd_issue_1928
${script}= Catenate SEPARATOR=\n
... from cleveragents.tui.permissions.screen import PermissionsScreen
... assert callable(PermissionsScreen), "PermissionsScreen should be a callable class"
... print("permission-screen-ok")
${result}= Run Process ${PYTHON} -c ${script} shell=False
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} permission-screen-ok
+41
View File
@@ -0,0 +1,41 @@
*** Settings ***
Library Process
Library String
*** Test Cases ***
TUI Persona Registry Initialization
[Tags] tdd_issue tdd_issue_1928
${script}= Catenate SEPARATOR=\n
... from cleveragents.tui.persona.registry import PersonaRegistry
... registry = PersonaRegistry()
... assert registry is not None, "PersonaRegistry should be initialized"
... print("persona-registry-ok")
${result}= Run Process ${PYTHON} -c ${script} shell=False
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} persona-registry-ok
TUI Persona Schema Validation
[Tags] tdd_issue tdd_issue_1928
${script}= Catenate SEPARATOR=\n
... from cleveragents.tui.persona.schema import Persona
... persona = Persona(name="test", actor="local/test-actor", description="Test persona")
... assert persona.name == "test", "Persona name should be set"
... assert persona.actor == "local/test-actor", "Persona actor should be set"
... print("persona-schema-ok")
${result}= Run Process ${PYTHON} -c ${script} shell=False
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} persona-schema-ok
TUI Persona State Management
[Tags] tdd_issue tdd_issue_1928
${script}= Catenate SEPARATOR=\n
... from cleveragents.tui.persona.registry import PersonaRegistry
... from cleveragents.tui.persona.state import PersonaState
... registry = PersonaRegistry()
... state = PersonaState(registry=registry)
... assert state is not None, "PersonaState should be initialized"
... assert state.registry is registry, "PersonaState registry should be the one passed in"
... print("persona-state-ok")
${result}= Run Process ${PYTHON} -c ${script} shell=False
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} persona-state-ok
+29
View File
@@ -0,0 +1,29 @@
*** Settings ***
Library Process
Library String
*** Test Cases ***
TUI Search Fuzzy Matcher Initialization
[Tags] tdd_issue tdd_issue_1928
${script}= Catenate SEPARATOR=\n
... from cleveragents.tui.search.fuzzy import rank_candidates, FuzzyCandidate
... assert callable(rank_candidates), "rank_candidates should be callable"
... assert callable(FuzzyCandidate), "FuzzyCandidate should be a callable class"
... print("fuzzy-matcher-ok")
${result}= Run Process ${PYTHON} -c ${script} shell=False
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} fuzzy-matcher-ok
TUI Search Fuzzy Matching Functionality
[Tags] tdd_issue tdd_issue_1928
${script}= Catenate SEPARATOR=\n
... from cleveragents.tui.search.fuzzy import rank_candidates
... items = ["hello", "world", "help"]
... results = rank_candidates("hel", items)
... assert results is not None, "rank_candidates should return results"
... assert len(results) > 0, "rank_candidates should match at least one item"
Outdated
Review

Suggestion: The fuzzy matching test checks matcher.match() returns non-None but does not assert the results contain expected items or that non-matches are excluded. Consider verifying that hel matches hello and help but not world.

Suggestion: The fuzzy matching test checks matcher.match() returns non-None but does not assert the results contain expected items or that non-matches are excluded. Consider verifying that hel matches hello and help but not world.
Outdated
Review

Suggestion: Fuzzy matching test does not assert results contain expected items or exclude non-matches. Verify hel matches hello and help but not world.

Suggestion: Fuzzy matching test does not assert results contain expected items or exclude non-matches. Verify hel matches hello and help but not world.
Outdated
Review

Suggestion: Fuzzy matching test does not assert results contain expected items. Verify hel matches hello and help but not world.

Suggestion: Fuzzy matching test does not assert results contain expected items. Verify hel matches hello and help but not world.
Outdated
Review

Suggestion: Fuzzy matching test does not assert results contain expected items. Verify hel matches hello and help but not world.

Suggestion: Fuzzy matching test does not assert results contain expected items. Verify hel matches hello and help but not world.
... assert results[0].value in ("hello", "help"), f"Top match should be hello or help, got {results[0].value}"
... print("fuzzy-matching-ok")
${result}= Run Process ${PYTHON} -c ${script} shell=False
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} fuzzy-matching-ok
+80
View File
@@ -0,0 +1,80 @@
*** Settings ***
Library Process
Library String
*** Test Cases ***
TUI Shell Safety Service Initialization
[Tags] tdd_issue tdd_issue_1928
${script}= Catenate SEPARATOR=\n
... from cleveragents.tui.shell_safety.safety_service import ShellSafetyService
... service = ShellSafetyService()
... assert service is not None, "ShellSafetyService should be initialized"
... result = service.check_command("echo hello")
... assert result.allowed, "Safe command should be allowed"
... print("safety-service-ok")
${result}= Run Process ${PYTHON} -c ${script} shell=False
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} safety-service-ok
TUI Shell Safety Danger Level Detection
[Tags] tdd_issue tdd_issue_1928
${script}= Catenate SEPARATOR=\n
... from cleveragents.tui.shell_safety.danger_level import ShellDangerLevel
... assert ShellDangerLevel.HIGH is not None, "ShellDangerLevel.HIGH should be defined"
... assert ShellDangerLevel.CRITICAL > ShellDangerLevel.LOW, "CRITICAL should be greater than LOW"
... print("danger-level-ok")
${result}= Run Process ${PYTHON} -c ${script} shell=False
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} danger-level-ok
TUI Shell Safety Pattern Detector
[Tags] tdd_issue tdd_issue_1928
${script}= Catenate SEPARATOR=\n
... from cleveragents.tui.shell_safety.pattern_detector import DangerousPatternDetector
... detector = DangerousPatternDetector()
... assert detector is not None, "DangerousPatternDetector should be initialized"
... warning = detector.check_first("rm -rf /")
... assert warning is not None, "Dangerous command should produce a warning"
... print("pattern-detector-ok")
${result}= Run Process ${PYTHON} -c ${script} shell=False
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} pattern-detector-ok
TUI Shell Safety Pattern Registry
[Tags] tdd_issue tdd_issue_1928
${script}= Catenate SEPARATOR=\n
Outdated
Review

Suggestion: The PatternDetector and SafetyService tests instantiate instances but never call any methods beyond construction. The integration test value comes from exercising the full flow: register a dangerous pattern, feed input through the detector, verify the warning is generated. These behavioral assertions are currently missing.

Suggestion: The PatternDetector and SafetyService tests instantiate instances but never call any methods beyond construction. The integration test value comes from exercising the full flow: register a dangerous pattern, feed input through the detector, verify the warning is generated. These behavioral assertions are currently missing.
Outdated
Review

Suggestion: PatternDetector and SafetyService tests instantiate instances but never call methods beyond construction. The integration value comes from exercising the full flow: register pattern, feed input, verify warning generated.

Suggestion: PatternDetector and SafetyService tests instantiate instances but never call methods beyond construction. The integration value comes from exercising the full flow: register pattern, feed input, verify warning generated.
Outdated
Review

Suggestion: PatternDetector and SafetyService tests instantiate instances but never call methods beyond construction. Integration value comes from exercising the full flow: register pattern, feed input, verify warning generated.

Suggestion: PatternDetector and SafetyService tests instantiate instances but never call methods beyond construction. Integration value comes from exercising the full flow: register pattern, feed input, verify warning generated.
Outdated
Review

Suggestion: PatternDetector and SafetyService tests instantiate instances but never call methods. Integration value comes from exercising the full flow: register pattern, feed input, verify warning generated.

Suggestion: PatternDetector and SafetyService tests instantiate instances but never call methods. Integration value comes from exercising the full flow: register pattern, feed input, verify warning generated.
... from cleveragents.tui.shell_safety.pattern_registry import DEFAULT_PATTERNS
... assert len(DEFAULT_PATTERNS) > 0, "DEFAULT_PATTERNS should be non-empty"
... assert all(hasattr(p, "name") for p in DEFAULT_PATTERNS), "Each pattern should have a name"
... print("pattern-registry-ok")
${result}= Run Process ${PYTHON} -c ${script} shell=False
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} pattern-registry-ok
TUI Shell Safety Dangerous Pattern Models
[Tags] tdd_issue tdd_issue_1928
${script}= Catenate SEPARATOR=\n
... from cleveragents.tui.shell_safety.dangerous_pattern import DangerousPattern
... from cleveragents.tui.shell_safety.danger_level import ShellDangerLevel
... pattern = DangerousPattern(name="test", pattern=r".*test.*", level=ShellDangerLevel.LOW, description="Test pattern")
... assert pattern.name == "test", "Pattern name should be set"
... assert pattern.matches("this is a test"), "Pattern should match 'test'"
... print("dangerous-pattern-ok")
${result}= Run Process ${PYTHON} -c ${script} shell=False
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} dangerous-pattern-ok
TUI Shell Safety Warning Models
[Tags] tdd_issue tdd_issue_1928
${script}= Catenate SEPARATOR=\n
... from cleveragents.tui.shell_safety.warning import DangerousCommandWarning
... from cleveragents.tui.shell_safety.dangerous_pattern import DangerousPattern
... from cleveragents.tui.shell_safety.danger_level import ShellDangerLevel
... pattern = DangerousPattern(name="rm_root", pattern=r"rm -rf /", level=ShellDangerLevel.CRITICAL, description="Deletes root")
... warning = DangerousCommandWarning.from_pattern("rm -rf /", pattern)
... assert warning.message is not None, "Warning message should be set"
... assert warning.danger_level == ShellDangerLevel.CRITICAL, "Danger level should match pattern"
... print("warning-ok")
${result}= Run Process ${PYTHON} -c ${script} shell=False
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} warning-ok
+94
View File
@@ -0,0 +1,94 @@
*** Settings ***
Library Process
Library String
*** Test Cases ***
TUI Widgets Actor Selection Overlay Initialization
[Tags] tdd_issue tdd_issue_1928
${script}= Catenate SEPARATOR=\n
... from cleveragents.tui.widgets.actor_selection_overlay import ActorSelectionOverlay
... assert callable(ActorSelectionOverlay), "ActorSelectionOverlay should be a callable class"
... print("actor-selection-overlay-ok")
${result}= Run Process ${PYTHON} -c ${script} shell=False
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} actor-selection-overlay-ok
TUI Widgets Persona Bar Rendering
[Tags] tdd_issue tdd_issue_1928
${script}= Catenate SEPARATOR=\n
... from cleveragents.tui.widgets.persona_bar import PersonaBar
... assert callable(PersonaBar), "PersonaBar should be a callable class"
... print("persona-bar-ok")
${result}= Run Process ${PYTHON} -c ${script} shell=False
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} persona-bar-ok
TUI Widgets Prompt Input Submission
[Tags] tdd_issue tdd_issue_1928
${script}= Catenate SEPARATOR=\n
... from cleveragents.tui.widgets.prompt import PromptInput
... assert callable(PromptInput), "PromptInput should be a callable class"
... print("prompt-input-ok")
${result}= Run Process ${PYTHON} -c ${script} shell=False
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} prompt-input-ok
TUI Widgets Reference Picker Initialization
[Tags] tdd_issue tdd_issue_1928
${script}= Catenate SEPARATOR=\n
... from cleveragents.tui.widgets.reference_picker import ReferencePickerOverlay
... assert callable(ReferencePickerOverlay), "ReferencePickerOverlay should be a callable class"
... print("reference-picker-ok")
${result}= Run Process ${PYTHON} -c ${script} shell=False
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} reference-picker-ok
TUI Widgets Slash Command Overlay Initialization
[Tags] tdd_issue tdd_issue_1928
${script}= Catenate SEPARATOR=\n
... from cleveragents.tui.widgets.slash_command_overlay import SlashCommandOverlay
... assert callable(SlashCommandOverlay), "SlashCommandOverlay should be a callable class"
... print("slash-command-overlay-ok")
${result}= Run Process ${PYTHON} -c ${script} shell=False
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} slash-command-overlay-ok
TUI Widgets Thought Block Rendering
[Tags] tdd_issue tdd_issue_1928
${script}= Catenate SEPARATOR=\n
... from cleveragents.tui.widgets.thought_block import ThoughtBlockWidget
... assert callable(ThoughtBlockWidget), "ThoughtBlockWidget should be a callable class"
... print("thought-block-ok")
${result}= Run Process ${PYTHON} -c ${script} shell=False
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} thought-block-ok
TUI Widgets Throbber Animation
[Tags] tdd_issue tdd_issue_1928
${script}= Catenate SEPARATOR=\n
... from cleveragents.tui.widgets.throbber import LoadingThrobber
... assert callable(LoadingThrobber), "LoadingThrobber should be a callable class"
... print("throbber-ok")
${result}= Run Process ${PYTHON} -c ${script} shell=False
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} throbber-ok
TUI Widgets Permission Question Widget
[Tags] tdd_issue tdd_issue_1928
${script}= Catenate SEPARATOR=\n
... from cleveragents.tui.widgets.permission_question import PermissionQuestionWidget
... assert callable(PermissionQuestionWidget), "PermissionQuestionWidget should be a callable class"
... print("permission-question-ok")
${result}= Run Process ${PYTHON} -c ${script} shell=False
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} permission-question-ok
TUI Widgets Help Panel Overlay
[Tags] tdd_issue tdd_issue_1928
${script}= Catenate SEPARATOR=\n
... from cleveragents.tui.widgets.help_panel_overlay import HelpPanelOverlay
... assert callable(HelpPanelOverlay), "HelpPanelOverlay should be a callable class"
... print("help-panel-overlay-ok")
${result}= Run Process ${PYTHON} -c ${script} shell=False
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} help-panel-overlay-ok