vibe/tests/cli/test_copy_shortcuts.py
Clément Drouin c2cb612ac1
v2.16.0 (#798)
Co-authored-by: Hdandria <henri.dandria@mistral.ai>
Co-authored-by: Liam Lyons <65613603+lyons-liam@users.noreply.github.com>
Co-authored-by: Mathias Gesbert <mathias.gesbert@mistral.ai>
Co-authored-by: Pierre Rossinès <pierre.rossines@mistral.ai>
Co-authored-by: Quentin <quentin.torroba@mistral.ai>
Co-authored-by: allansimon-mistral <allan.simon@ext.mistral.ai>
Co-authored-by: angelapopopo <angele.lenglemetz@mistral.ai>
Co-authored-by: Mistral Vibe <vibe@mistral.ai>
2026-06-15 17:36:21 +02:00

53 lines
1.9 KiB
Python

from __future__ import annotations
from unittest.mock import patch
import pytest
from tests.conftest import build_test_vibe_app, build_test_vibe_config
@pytest.mark.asyncio
async def test_ctrl_y_triggers_copy_selection() -> None:
"""Test that ctrl+y keybinding triggers copy_selection_to_clipboard."""
app = build_test_vibe_app()
with patch("vibe.cli.textual_ui.app.copy_selection_to_clipboard") as mock_copy:
async with app.run_test() as pilot:
await pilot.press("ctrl+y")
mock_copy.assert_called_once_with(app, show_toast=False)
@pytest.mark.asyncio
async def test_ctrl_shift_c_triggers_copy_selection() -> None:
"""Test that ctrl+shift+c keybinding triggers copy_selection_to_clipboard."""
app = build_test_vibe_app()
with patch("vibe.cli.textual_ui.app.copy_selection_to_clipboard") as mock_copy:
async with app.run_test() as pilot:
await pilot.press("ctrl+shift+c")
mock_copy.assert_called_once_with(app, show_toast=False)
@pytest.mark.asyncio
async def test_mouse_up_respects_autocopy_config_enabled() -> None:
"""Test that mouse up copies when autocopy_to_clipboard is True."""
app = build_test_vibe_app(config=build_test_vibe_config(autocopy_to_clipboard=True))
with patch("vibe.cli.textual_ui.app.copy_selection_to_clipboard") as mock_copy:
async with app.run_test() as pilot:
await pilot.click()
mock_copy.assert_called_once_with(app, show_toast=False)
@pytest.mark.asyncio
async def test_mouse_up_respects_autocopy_config_disabled() -> None:
"""Test that mouse up does not copy when autocopy_to_clipboard is False."""
app = build_test_vibe_app(
config=build_test_vibe_config(autocopy_to_clipboard=False)
)
with patch("vibe.cli.textual_ui.app.copy_selection_to_clipboard") as mock_copy:
async with app.run_test() as pilot:
await pilot.click()
mock_copy.assert_not_called()