v2.9.0 (#641)
Co-authored-by: Antoine <33425718+anth2o@users.noreply.github.com> Co-authored-by: Bastien <bastien.baret@gmail.com> Co-authored-by: Clément Sirieix <clement.sirieix@mistral.ai> Co-authored-by: Kim-Adeline Miguel <51720070+kimadeline@users.noreply.github.com> Co-authored-by: Mathias Gesbert <mathias.gesbert@mistral.ai> Co-authored-by: Maxime Dolores <maxime.dolores@ext.mistral.ai> Co-authored-by: Michel Thomazo <51709227+michelTho@users.noreply.github.com> Co-authored-by: Nelson PROIA <144663685+Nelson-PROIA@users.noreply.github.com> Co-authored-by: Pierre Rossinès <pierre.rossines@mistral.ai> Co-authored-by: Quentin <quentin.torroba@mistral.ai> Co-authored-by: Robin Gullo <robin.gullo@mistral.ai> Co-authored-by: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
parent
a83c81ecf5
commit
632ea8c032
253 changed files with 13965 additions and 2525 deletions
53
tests/cli/test_copy_command.py
Normal file
53
tests/cli/test_copy_command.py
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
|
||||
from tests.conftest import build_test_vibe_app
|
||||
from vibe.cli.textual_ui.widgets.messages import AssistantMessage
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_copy_command_copies_last_assistant_message() -> None:
|
||||
app = build_test_vibe_app()
|
||||
second_reply = "\n```python\nprint('second reply')\n```\n"
|
||||
stripped_second_reply = second_reply.strip()
|
||||
async with app.run_test() as pilot:
|
||||
await app._mount_and_scroll(AssistantMessage("first reply"))
|
||||
await app._mount_and_scroll(AssistantMessage(second_reply))
|
||||
with (
|
||||
patch(
|
||||
"vibe.cli.textual_ui.app.copy_text_to_clipboard",
|
||||
return_value=stripped_second_reply,
|
||||
) as mock_copy,
|
||||
patch.object(
|
||||
app.agent_loop.telemetry_client, "send_user_copied_text"
|
||||
) as mock_telemetry,
|
||||
):
|
||||
handled = await app._handle_command("/copy")
|
||||
await pilot.pause()
|
||||
assert handled is True
|
||||
assert stripped_second_reply != second_reply
|
||||
mock_copy.assert_called_once_with(
|
||||
app,
|
||||
stripped_second_reply,
|
||||
success_message="Last agent message copied to clipboard",
|
||||
)
|
||||
mock_telemetry.assert_called_once_with(stripped_second_reply)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_copy_command_warns_when_no_assistant_message() -> None:
|
||||
app = build_test_vibe_app()
|
||||
|
||||
async with app.run_test() as pilot:
|
||||
with patch.object(app, "notify") as mock_notify:
|
||||
handled = await app._handle_command("/copy")
|
||||
|
||||
await pilot.pause()
|
||||
|
||||
assert handled is True
|
||||
mock_notify.assert_called_once_with(
|
||||
"No agent message available to copy", severity="warning", timeout=3
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue