2.0.0
Co-Authored-By: Quentin Torroba <quentin.torroba@mistral.ai> Co-Authored-By: Michel Thomazo <michel.thomazo@mistral.ai> Co-Authored-By: Clément Drouin <clement.drouin@mistral.ai> Co-Authored-By: Vincent Guilloux <vincent.guilloux@mistral.ai> Co-Authored-By: Clément Siriex <clement.sirieix@mistral.ai> Co-Authored-By: Kim-Adeline Miguel <kimadeline.miguel@mistral.ai> Co-Authored-By: Thaddee Tyl <thaddee.tyl@gmail.com> Co-Authored-By: David Brochart <david.brochart@gmail.com> Co-Authored-By: Joseph Guhlin <joseph.guhlin@gmail.com> Co-Authored-By: Thomas Kenbeek <thomaskenbeek@gmail.com> Co-Authored-By: Remenby31 <baptiste.cruvellier31@gmail.com>
This commit is contained in:
parent
79f215d91c
commit
d33db9fff8
217 changed files with 16911 additions and 4305 deletions
82
tests/test_ui_external_editor.py
Normal file
82
tests/test_ui_external_editor.py
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
"""Tests for the external editor UI integration (Ctrl+G keybind)."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from contextlib import contextmanager
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
import pytest
|
||||
|
||||
from vibe.cli.textual_ui.app import VibeApp
|
||||
from vibe.cli.textual_ui.widgets.chat_input.container import ChatInputContainer
|
||||
from vibe.core.agent_loop import AgentLoop
|
||||
from vibe.core.config import SessionLoggingConfig, VibeConfig
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def vibe_config() -> VibeConfig:
|
||||
return VibeConfig(session_logging=SessionLoggingConfig(enabled=False))
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def vibe_app(vibe_config: VibeConfig) -> VibeApp:
|
||||
agent_loop = AgentLoop(vibe_config)
|
||||
return VibeApp(agent_loop=agent_loop)
|
||||
|
||||
|
||||
@contextmanager
|
||||
def mock_suspend():
|
||||
"""Mock context manager to replace app.suspend()."""
|
||||
yield
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_ctrl_g_opens_external_editor_and_updates_input(
|
||||
vibe_app: VibeApp,
|
||||
) -> None:
|
||||
"""Test that Ctrl+G triggers external editor and updates input with result."""
|
||||
with patch(
|
||||
"vibe.cli.textual_ui.widgets.chat_input.text_area.ExternalEditor"
|
||||
) as MockEditor:
|
||||
mock_instance = MagicMock()
|
||||
mock_instance.is_available.return_value = True
|
||||
mock_instance.edit.return_value = "edited content"
|
||||
MockEditor.return_value = mock_instance
|
||||
|
||||
async with vibe_app.run_test() as pilot:
|
||||
chat_input = vibe_app.query_one(ChatInputContainer)
|
||||
chat_input.value = "original"
|
||||
chat_input.focus_input()
|
||||
await pilot.pause()
|
||||
|
||||
with patch.object(vibe_app, "suspend", mock_suspend):
|
||||
await pilot.press("ctrl+g")
|
||||
await pilot.pause()
|
||||
|
||||
mock_instance.edit.assert_called_once_with("original")
|
||||
assert chat_input.value == "edited content"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_ctrl_g_works_with_empty_input(vibe_app: VibeApp) -> None:
|
||||
"""Test that Ctrl+G works when input is empty."""
|
||||
with patch(
|
||||
"vibe.cli.textual_ui.widgets.chat_input.text_area.ExternalEditor"
|
||||
) as MockEditor:
|
||||
mock_instance = MagicMock()
|
||||
mock_instance.is_available.return_value = True
|
||||
mock_instance.edit.return_value = "new content"
|
||||
MockEditor.return_value = mock_instance
|
||||
|
||||
async with vibe_app.run_test() as pilot:
|
||||
chat_input = vibe_app.query_one(ChatInputContainer)
|
||||
assert chat_input.value == ""
|
||||
chat_input.focus_input()
|
||||
await pilot.pause()
|
||||
|
||||
with patch.object(vibe_app, "suspend", mock_suspend):
|
||||
await pilot.press("ctrl+g")
|
||||
await pilot.pause()
|
||||
|
||||
mock_instance.edit.assert_called_once_with("")
|
||||
assert chat_input.value == "new content"
|
||||
Loading…
Add table
Add a link
Reference in a new issue