Co-authored-by: Alexis Tacnet <alexis@mistral.ai> Co-authored-by: Clément Drouin <clement.drouin@mistral.ai> Co-authored-by: Guillaume LE GOFF <guillaume.lgf@gmail.com> Co-authored-by: Lucas Marandat <31749711+lucasmrdt@users.noreply.github.com> Co-authored-by: Maxime Dolores <maxime.dolores@ext.mistral.ai> 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: p.vezia <166131032+le-codeur-rapide@users.noreply.github.com> Co-authored-by: Hiba Chaabnia <Hiba-Chaabnia@users.noreply.github.com> Co-authored-by: Nikhil Bhima <nikhilbhima@users.noreply.github.com> Co-authored-by: Nkipohcs <Nkipohcs@users.noreply.github.com> Co-authored-by: Mistral Vibe <vibe@mistral.ai>
71 lines
2.5 KiB
Python
71 lines
2.5 KiB
Python
from __future__ import annotations
|
|
|
|
from textual.containers import VerticalScroll
|
|
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.approval_app import ApprovalApp
|
|
from vibe.core.tools.builtins.write_file import WriteFileArgs
|
|
|
|
WF_CONTENT_LONG = "\n".join(f"line_{i:03d} = {i * 7}" for i in range(1, 101))
|
|
WF_CONTENT_SHORT = "line_001 = 7"
|
|
|
|
|
|
class WriteApprovalLongContentApp(BaseSnapshotTestApp):
|
|
async def on_ready(self) -> None:
|
|
args = WriteFileArgs(path="src/example.py", content=WF_CONTENT_LONG)
|
|
await self._switch_to_approval_app("write_file", args)
|
|
|
|
|
|
class WriteApprovalShortContentApp(BaseSnapshotTestApp):
|
|
async def on_ready(self) -> None:
|
|
args = WriteFileArgs(path="src/example.py", content=WF_CONTENT_SHORT)
|
|
await self._switch_to_approval_app("write_file", args)
|
|
|
|
|
|
def test_snapshot_write_approval_long_content_bottom_lines_hidden(
|
|
snap_compare: SnapCompare,
|
|
) -> None:
|
|
async def run_before(pilot: Pilot) -> None:
|
|
await pilot.pause(0.3)
|
|
approval = pilot.app.query_one(ApprovalApp)
|
|
scroll = approval.query_one(".approval-tool-info-scroll", VerticalScroll)
|
|
scroll.scroll_end(animate=False, immediate=True)
|
|
await pilot.pause(0.2)
|
|
|
|
assert snap_compare(
|
|
"test_ui_snapshot_diff_view_truncation.py:WriteApprovalLongContentApp",
|
|
terminal_size=(100, 30),
|
|
run_before=run_before,
|
|
)
|
|
|
|
|
|
def test_snapshot_write_approval_short_content(snap_compare: SnapCompare) -> None:
|
|
async def run_before(pilot: Pilot) -> None:
|
|
await pilot.pause(0.3)
|
|
|
|
assert snap_compare(
|
|
"test_ui_snapshot_diff_view_truncation.py:WriteApprovalShortContentApp",
|
|
terminal_size=(100, 30),
|
|
run_before=run_before,
|
|
)
|
|
|
|
|
|
def test_snapshot_write_approval_long_content_after_resize(
|
|
snap_compare: SnapCompare,
|
|
) -> None:
|
|
async def run_before(pilot: Pilot) -> None:
|
|
await pilot.pause(0.3)
|
|
await pilot.resize_terminal(120, 40)
|
|
await pilot.pause(0.2)
|
|
approval = pilot.app.query_one(ApprovalApp)
|
|
scroll = approval.query_one(".approval-tool-info-scroll", VerticalScroll)
|
|
scroll.scroll_end(animate=False, immediate=True)
|
|
await pilot.pause(0.2)
|
|
|
|
assert snap_compare(
|
|
"test_ui_snapshot_diff_view_truncation.py:WriteApprovalLongContentApp",
|
|
terminal_size=(100, 30),
|
|
run_before=run_before,
|
|
)
|