vibe/tests/snapshots/test_ui_snapshot_ask_user_question.py
Guillaume LE GOFF cafb6d4147
v2.15.0 (#773)
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: Nelson PROIA <144663685+Nelson-PROIA@users.noreply.github.com>
Co-authored-by: Paul VEZIA <166131032+le-codeur-rapide@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: 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-06-12 13:16:04 +02:00

80 lines
2.5 KiB
Python

from __future__ import annotations
from textual.pilot import Pilot
from tests.snapshots.base_snapshot_test_app import BaseSnapshotTestApp
from tests.snapshots.snap_compare import SnapCompare
from vibe.cli.textual_ui.widgets.tools import ToolResultMessage
from vibe.core.tools.builtins.ask_user_question import (
Answer,
AskUserQuestion,
AskUserQuestionResult,
)
from vibe.core.types import ToolResultEvent
class AskUserQuestionResultApp(BaseSnapshotTestApp):
"""Test app that displays an AskUserQuestion tool result."""
async def on_mount(self) -> None:
await super().on_mount()
result = AskUserQuestionResult(
answers=[
Answer(
question="What programming language are you currently working with?",
answer="Rust",
is_other=False,
),
Answer(
question="What type of project are you building?",
answer="Web Application",
is_other=False,
),
Answer(
question="What editor or IDE do you prefer?",
answer="VS Code",
is_other=True,
),
],
cancelled=False,
)
event = ToolResultEvent(
tool_name="ask_user_question",
tool_class=AskUserQuestion,
result=result,
tool_call_id="test_call_id",
)
messages_area = self.query_one("#messages")
tool_result = ToolResultMessage(event)
await messages_area.mount(tool_result)
def test_snapshot_ask_user_question_collapsed(snap_compare: SnapCompare) -> None:
"""Test collapsed AskUserQuestion result shows summary."""
async def run_before(pilot: Pilot) -> None:
await pilot.pause(0.1)
assert snap_compare(
"test_ui_snapshot_ask_user_question.py:AskUserQuestionResultApp",
terminal_size=(120, 20),
run_before=run_before,
)
def test_snapshot_ask_user_question_expanded(snap_compare: SnapCompare) -> None:
"""Test expanded AskUserQuestion result shows formatted Q&A pairs."""
async def run_before(pilot: Pilot) -> None:
await pilot.pause(0.1)
await pilot.press("ctrl+o")
await pilot.pause(0.1)
assert snap_compare(
"test_ui_snapshot_ask_user_question.py:AskUserQuestionResultApp",
terminal_size=(120, 30),
run_before=run_before,
)