"""Step definitions for tui_help_command_full_catalog.feature.

Tests that TuiCommandRouter.handle('help') dynamically lists all commands
from SLASH_COMMAND_SPECS and that /help <command> returns command-specific help.
"""

from __future__ import annotations

from behave import then

from cleveragents.tui.slash_catalog import SLASH_COMMAND_SPECS


@then("the help result contains all 70 catalogued commands")
def step_help_result_contains_all_commands(context: object) -> None:
    """Verify that every command in SLASH_COMMAND_SPECS appears in the help output."""
    result: str = context.handle_result  # type: ignore[attr-defined]
    missing = [
        spec.command for spec in SLASH_COMMAND_SPECS if spec.command not in result
    ]
    assert not missing, (
        f"The following {len(missing)} commands were missing from /help output: "
        + ", ".join(missing)
    )


@then('the handle result should not be "{unexpected}"')
def step_handle_result_not_equal(context: object, unexpected: str) -> None:
    """Verify the handle result is NOT the given string."""
    result: str = context.handle_result  # type: ignore[attr-defined]
    assert result != unexpected, (
        f"Expected result to differ from {unexpected!r}, but got the same string"
    )
