Files
mistral-vibe/tests/cli/test_ui_clipboard_notifications.py
Mathias Gesbert e9a9217cc8 v2.7.4 (#579)
Co-authored-by: Clément Sirieix <clement.sirieix@mistral.ai>
Co-authored-by: Kim-Adeline Miguel <kimadeline.miguel@mistral.ai>
Co-authored-by: Lucas Marandat <31749711+lucasmrdt@users.noreply.github.com>
Co-authored-by: Michel Thomazo <51709227+michelTho@users.noreply.github.com>
Co-authored-by: Paul Cacheux <paul.cacheux@mistral.ai>
Co-authored-by: Peter Evers <pevers90@gmail.com>
Co-authored-by: Pierre Rossinès <pierre.rossines@mistral.ai>
Co-authored-by: Pierre Rossinès <pierre.rossines@protonmail.com>
Co-authored-by: Quentin <quentin.torroba@mistral.ai>
Co-authored-by: Simon Van de Kerckhove <simon.vandekerckhove@mistral.ai>
Co-authored-by: Val <102326092+vdeva@users.noreply.github.com>
Co-authored-by: Vincent G <10739306+VinceOPS@users.noreply.github.com>
Co-authored-by: Mistral Vibe <vibe@mistral.ai>
2026-04-09 18:40:46 +02:00

41 lines
1.3 KiB
Python

from __future__ import annotations
from unittest.mock import patch
import pytest
from textual.selection import Selection
from textual.widget import Widget
from vibe.cli.clipboard import copy_selection_to_clipboard
from vibe.cli.textual_ui.app import VibeApp
class ClipboardSelectionWidget(Widget):
def __init__(self, selected_text: str) -> None:
super().__init__()
self._selected_text = selected_text
@property
def text_selection(self) -> Selection | None:
return Selection(None, None)
def get_selection(self, selection: Selection) -> tuple[str, str] | None:
return (self._selected_text, "\n")
@pytest.mark.asyncio
async def test_ui_clipboard_notification_does_not_crash_on_markup_text(
monkeypatch: pytest.MonkeyPatch, vibe_app: VibeApp
) -> None:
async with vibe_app.run_test(notifications=True) as pilot:
await vibe_app.mount(ClipboardSelectionWidget("[/]"))
with patch("vibe.cli.clipboard._copy_to_clipboard"):
copy_selection_to_clipboard(vibe_app)
await pilot.pause(0.1)
notifications = list(vibe_app._notifications)
assert notifications
notification = notifications[-1]
assert notification.markup is False
assert "Selection copied to clipboard" in notification.message