"""Tests for the AgentScout CLI."""

from typer.testing import CliRunner

from agent_scout_cli.main import app

runner = CliRunner()


def test_version_command():
    result = runner.invoke(app, ["version"])
    assert result.exit_code == 0
    assert "AgentScout" in result.output
    assert "0.1.0" in result.output


def test_help():
    result = runner.invoke(app, ["--help"])
    assert result.exit_code == 0
    assert "agent-scout" in result.output.lower() or "AgentScout" in result.output


def test_status_command():
    result = runner.invoke(app, ["status"])
    assert result.exit_code == 0
    assert "Model" in result.output or "model" in result.output


def test_config_show():
    result = runner.invoke(app, ["config", "show"])
    assert result.exit_code == 0
    assert "Configuration" in result.output or "Setting" in result.output


def test_history_no_db():
    result = runner.invoke(app, ["history"])
    assert result.exit_code == 0
    # Either shows "no history" or shows a table
    assert "History" in result.output or "No task" in result.output


def test_schedule_list():
    result = runner.invoke(app, ["schedule", "list"])
    assert result.exit_code == 0


def test_schedule_add_missing_args():
    result = runner.invoke(app, ["schedule", "add"])
    assert result.exit_code == 1


def test_run_help():
    result = runner.invoke(app, ["run", "--help"])
    assert result.exit_code == 0
    assert "task" in result.output.lower()
