"""Tests for ``jarvis chat`` interactive REPL command.""" from __future__ import annotations from unittest import mock from click.testing import CliRunner from openjarvis.cli.chat_cmd import _read_input, chat class TestChatCommand: """Test the Click command definition and help output.""" def test_command_exists(self) -> None: result = CliRunner().invoke(chat, ["--help"]) assert result.exit_code == 0 assert "interactive" in result.output.lower() or "chat" in result.output.lower() def test_options(self) -> None: result = CliRunner().invoke(chat, ["--help"]) assert result.exit_code == 0 assert "--engine" in result.output assert "--model" in result.output assert "--agent" in result.output assert "--tools" in result.output assert "--system" in result.output def test_slash_commands_listed(self) -> None: result = CliRunner().invoke(chat, ["--help"]) assert result.exit_code == 0 assert "/quit" in result.output class TestReadInput: """Test the _read_input helper function.""" def test_read_input_eof(self) -> None: with mock.patch("builtins.input", side_effect=EOFError): assert _read_input() is None def test_read_input_keyboard_interrupt(self) -> None: with mock.patch("builtins.input", side_effect=KeyboardInterrupt): assert _read_input() is None def test_read_input_normal(self) -> None: with mock.patch("builtins.input", return_value="hello"): assert _read_input() == "hello"