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>
70 lines
2.2 KiB
Python
70 lines
2.2 KiB
Python
from __future__ import annotations
|
|
|
|
from typing import cast
|
|
|
|
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.app import VibeApp
|
|
from vibe.cli.textual_ui.widgets.chat_input.container import ChatInputContainer
|
|
|
|
|
|
class QueuedMessagesSnapshotApp(BaseSnapshotTestApp):
|
|
pass
|
|
|
|
|
|
async def _enqueue_while_busy(pilot: Pilot, submissions: list[str]) -> None:
|
|
app = cast(VibeApp, pilot.app)
|
|
chat_input = app.query_one(ChatInputContainer)
|
|
# leave _agent_running set so the queue drain stays blocked for the snapshot
|
|
app._agent_running = True
|
|
for value in submissions:
|
|
chat_input.post_message(ChatInputContainer.Submitted(value))
|
|
await pilot.pause(0.1)
|
|
|
|
|
|
def test_snapshot_queued_user_prompts(snap_compare: SnapCompare) -> None:
|
|
async def run_before(pilot: Pilot) -> None:
|
|
await _enqueue_while_busy(
|
|
pilot, ["first follow-up", "second follow-up", "third follow-up"]
|
|
)
|
|
await pilot.pause(0.2)
|
|
|
|
assert snap_compare(
|
|
"test_ui_snapshot_queued_messages.py:QueuedMessagesSnapshotApp",
|
|
terminal_size=(120, 36),
|
|
run_before=run_before,
|
|
)
|
|
|
|
|
|
def test_snapshot_queued_bash_commands(snap_compare: SnapCompare) -> None:
|
|
async def run_before(pilot: Pilot) -> None:
|
|
await _enqueue_while_busy(pilot, ["!echo first", "!echo second", "!ls /tmp"])
|
|
await pilot.pause(0.2)
|
|
|
|
assert snap_compare(
|
|
"test_ui_snapshot_queued_messages.py:QueuedMessagesSnapshotApp",
|
|
terminal_size=(120, 36),
|
|
run_before=run_before,
|
|
)
|
|
|
|
|
|
def test_snapshot_queued_mixed_prompts_and_bash(snap_compare: SnapCompare) -> None:
|
|
async def run_before(pilot: Pilot) -> None:
|
|
await _enqueue_while_busy(
|
|
pilot,
|
|
[
|
|
"please refactor this",
|
|
"!pytest -x",
|
|
"then commit the change",
|
|
"!git status",
|
|
],
|
|
)
|
|
await pilot.pause(0.2)
|
|
|
|
assert snap_compare(
|
|
"test_ui_snapshot_queued_messages.py:QueuedMessagesSnapshotApp",
|
|
terminal_size=(120, 36),
|
|
run_before=run_before,
|
|
)
|