mirror of
https://github.com/mistralai/mistral-vibe
synced 2026-04-25 17:14:55 +02:00
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>
160 lines
5.2 KiB
Python
160 lines
5.2 KiB
Python
from __future__ import annotations
|
|
|
|
from unittest.mock import patch
|
|
|
|
from textual.pilot import Pilot
|
|
|
|
from tests.snapshots.base_snapshot_test_app import BaseSnapshotTestApp, default_config
|
|
from tests.snapshots.snap_compare import SnapCompare
|
|
from tests.stubs.fake_mcp_registry import (
|
|
FakeMCPRegistry,
|
|
FakeMCPRegistryWithBrokenServer,
|
|
)
|
|
from vibe.core.config import MCPHttp, MCPStdio
|
|
|
|
_MCP_PATCH = "vibe.core.agent_loop.MCPRegistry"
|
|
|
|
|
|
class SnapshotTestAppNoMcpServers(BaseSnapshotTestApp):
|
|
def __init__(self) -> None:
|
|
super().__init__(config=default_config())
|
|
|
|
|
|
class SnapshotTestAppWithBrokenMcpServer(BaseSnapshotTestApp):
|
|
def __init__(self) -> None:
|
|
config = default_config()
|
|
config.mcp_servers = [
|
|
MCPStdio(name="filesystem", transport="stdio", command="npx"),
|
|
MCPStdio(
|
|
name="broken-server", transport="stdio", command="nonexistent-cmd"
|
|
),
|
|
MCPHttp(name="search", transport="http", url="http://localhost:8080"),
|
|
]
|
|
super().__init__(config=config)
|
|
|
|
|
|
class SnapshotTestAppWithMcpServers(BaseSnapshotTestApp):
|
|
def __init__(self) -> None:
|
|
config = default_config()
|
|
config.mcp_servers = [
|
|
MCPStdio(name="filesystem", transport="stdio", command="npx"),
|
|
MCPHttp(name="search", transport="http", url="http://localhost:8080"),
|
|
]
|
|
super().__init__(config=config)
|
|
|
|
|
|
async def _run_mcp_command(pilot: Pilot, command: str) -> None:
|
|
await pilot.pause(0.1)
|
|
await pilot.press(*command)
|
|
await pilot.press("enter")
|
|
await pilot.pause(0.1)
|
|
pilot.app.set_focus(None)
|
|
await pilot.pause(0.1)
|
|
|
|
|
|
def test_snapshot_mcp_no_servers(snap_compare: SnapCompare) -> None:
|
|
async def run_before(pilot: Pilot) -> None:
|
|
await _run_mcp_command(pilot, "/mcp")
|
|
|
|
assert snap_compare(
|
|
"test_ui_snapshot_mcp_command.py:SnapshotTestAppNoMcpServers",
|
|
terminal_size=(120, 36),
|
|
run_before=run_before,
|
|
)
|
|
|
|
|
|
def test_snapshot_mcp_broken_server(snap_compare: SnapCompare) -> None:
|
|
async def run_before(pilot: Pilot) -> None:
|
|
await _run_mcp_command(pilot, "/mcp")
|
|
|
|
with patch(_MCP_PATCH, FakeMCPRegistryWithBrokenServer):
|
|
assert snap_compare(
|
|
"test_ui_snapshot_mcp_command.py:SnapshotTestAppWithBrokenMcpServer",
|
|
terminal_size=(120, 36),
|
|
run_before=run_before,
|
|
)
|
|
|
|
|
|
def test_snapshot_mcp_overview(snap_compare: SnapCompare) -> None:
|
|
async def run_before(pilot: Pilot) -> None:
|
|
await _run_mcp_command(pilot, "/mcp")
|
|
|
|
with patch(_MCP_PATCH, FakeMCPRegistry):
|
|
assert snap_compare(
|
|
"test_ui_snapshot_mcp_command.py:SnapshotTestAppWithMcpServers",
|
|
terminal_size=(120, 36),
|
|
run_before=run_before,
|
|
)
|
|
|
|
|
|
def test_snapshot_mcp_overview_navigate_down(snap_compare: SnapCompare) -> None:
|
|
async def run_before(pilot: Pilot) -> None:
|
|
await _run_mcp_command(pilot, "/mcp")
|
|
await pilot.press("down")
|
|
await pilot.pause(0.1)
|
|
|
|
with patch(_MCP_PATCH, FakeMCPRegistry):
|
|
assert snap_compare(
|
|
"test_ui_snapshot_mcp_command.py:SnapshotTestAppWithMcpServers",
|
|
terminal_size=(120, 36),
|
|
run_before=run_before,
|
|
)
|
|
|
|
|
|
def test_snapshot_mcp_enter_drills_into_server(snap_compare: SnapCompare) -> None:
|
|
async def run_before(pilot: Pilot) -> None:
|
|
await _run_mcp_command(pilot, "/mcp")
|
|
await pilot.press("enter")
|
|
await pilot.pause(0.1)
|
|
await pilot.press("down")
|
|
await pilot.pause(0.1)
|
|
await pilot.press("enter")
|
|
|
|
with patch(_MCP_PATCH, FakeMCPRegistry):
|
|
assert snap_compare(
|
|
"test_ui_snapshot_mcp_command.py:SnapshotTestAppWithMcpServers",
|
|
terminal_size=(120, 36),
|
|
run_before=run_before,
|
|
)
|
|
|
|
|
|
def test_snapshot_mcp_server_arg(snap_compare: SnapCompare) -> None:
|
|
async def run_before(pilot: Pilot) -> None:
|
|
await _run_mcp_command(pilot, "/mcp filesystem")
|
|
await pilot.pause(0.1)
|
|
|
|
with patch(_MCP_PATCH, FakeMCPRegistry):
|
|
assert snap_compare(
|
|
"test_ui_snapshot_mcp_command.py:SnapshotTestAppWithMcpServers",
|
|
terminal_size=(120, 36),
|
|
run_before=run_before,
|
|
)
|
|
|
|
|
|
def test_snapshot_mcp_backspace_returns_to_overview(snap_compare: SnapCompare) -> None:
|
|
async def run_before(pilot: Pilot) -> None:
|
|
await _run_mcp_command(pilot, "/mcp filesystem")
|
|
await pilot.press("backspace")
|
|
await pilot.pause(0.1)
|
|
|
|
with patch(_MCP_PATCH, FakeMCPRegistry):
|
|
assert snap_compare(
|
|
"test_ui_snapshot_mcp_command.py:SnapshotTestAppWithMcpServers",
|
|
terminal_size=(120, 36),
|
|
run_before=run_before,
|
|
)
|
|
|
|
|
|
def test_snapshot_mcp_escape_closes(snap_compare: SnapCompare) -> None:
|
|
async def run_before(pilot: Pilot) -> None:
|
|
await _run_mcp_command(pilot, "/mcp")
|
|
await pilot.press("escape")
|
|
await pilot.pause(0.2)
|
|
|
|
with patch(_MCP_PATCH, FakeMCPRegistry):
|
|
assert snap_compare(
|
|
"test_ui_snapshot_mcp_command.py:SnapshotTestAppWithMcpServers",
|
|
terminal_size=(120, 36),
|
|
run_before=run_before,
|
|
)
|