v2.11.0 (#717)
Co-authored-by: Clément Drouin <clement.drouin@mistral.ai> Co-authored-by: Clément Sirieix <clement.sirieix@mistral.ai> Co-authored-by: Guillaume LE GOFF <guillaume.lgf@gmail.com> Co-authored-by: Mathias Gesbert <mathias.gesbert@mistral.ai> Co-authored-by: Michel Thomazo <51709227+michelTho@users.noreply.github.com> Co-authored-by: Pierre Rossinès <pierre.rossines@mistral.ai> Co-authored-by: Vincent G <10739306+VinceOPS@users.noreply.github.com> Co-authored-by: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
parent
f71bfd3b8c
commit
adb1ca74ce
202 changed files with 5828 additions and 1968 deletions
93
tests/cli/test_ui_theme_picker.py
Normal file
93
tests/cli/test_ui_theme_picker.py
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
|
||||
from tests.conftest import build_test_vibe_app, build_test_vibe_config
|
||||
from vibe.cli.textual_ui.app import BottomApp
|
||||
from vibe.cli.textual_ui.widgets.theme_picker import ThemePickerApp
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_theme_opens_theme_picker() -> None:
|
||||
app = build_test_vibe_app(config=build_test_vibe_config())
|
||||
async with app.run_test() as pilot:
|
||||
await pilot.pause(0.1)
|
||||
await app._show_theme()
|
||||
await pilot.pause(0.2)
|
||||
|
||||
assert app._current_bottom_app == BottomApp.ThemePicker
|
||||
assert len(app.query(ThemePickerApp)) == 1
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_theme_picker_lists_themes_and_marks_current() -> None:
|
||||
config = build_test_vibe_config()
|
||||
config.theme = "dracula"
|
||||
app = build_test_vibe_app(config=config)
|
||||
async with app.run_test() as pilot:
|
||||
await pilot.pause(0.1)
|
||||
await app._show_theme()
|
||||
await pilot.pause(0.2)
|
||||
|
||||
picker = app.query_one(ThemePickerApp)
|
||||
assert "dracula" in picker._theme_names
|
||||
assert "ansi-dark" in picker._theme_names
|
||||
assert picker._current_theme == "dracula"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_theme_picker_escape_restores_original_theme() -> None:
|
||||
config = build_test_vibe_config()
|
||||
config.theme = "ansi-dark"
|
||||
app = build_test_vibe_app(config=config)
|
||||
async with app.run_test() as pilot:
|
||||
await pilot.pause(0.1)
|
||||
await app._show_theme()
|
||||
await pilot.pause(0.2)
|
||||
|
||||
# Move highlight to a different theme to trigger preview.
|
||||
await pilot.press("down")
|
||||
await pilot.pause(0.2)
|
||||
|
||||
with patch("vibe.cli.textual_ui.app.VibeConfig.save_updates") as mock_save:
|
||||
await pilot.press("escape")
|
||||
await pilot.pause(0.2)
|
||||
|
||||
mock_save.assert_not_called()
|
||||
|
||||
assert app._current_bottom_app == BottomApp.Input
|
||||
assert len(app.query(ThemePickerApp)) == 0
|
||||
assert app.config.theme == "ansi-dark"
|
||||
assert app.theme == "ansi-dark"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_theme_picker_select_persists_and_applies() -> None:
|
||||
config = build_test_vibe_config()
|
||||
config.theme = "ansi-dark"
|
||||
app = build_test_vibe_app(config=config)
|
||||
async with app.run_test() as pilot:
|
||||
await pilot.pause(0.1)
|
||||
await app._show_theme()
|
||||
await pilot.pause(0.2)
|
||||
|
||||
picker = app.query_one(ThemePickerApp)
|
||||
names = picker._theme_names
|
||||
current_index = names.index("ansi-dark")
|
||||
target_index = (current_index + 1) % len(names)
|
||||
target = names[target_index]
|
||||
|
||||
await pilot.press("down")
|
||||
|
||||
with patch("vibe.cli.textual_ui.app.VibeConfig.save_updates") as mock_save:
|
||||
await pilot.press("enter")
|
||||
await pilot.pause(0.2)
|
||||
|
||||
mock_save.assert_called_once_with({"theme": target})
|
||||
|
||||
assert app._current_bottom_app == BottomApp.Input
|
||||
assert len(app.query(ThemePickerApp)) == 0
|
||||
assert app.config.theme == target
|
||||
assert app.theme == target
|
||||
Loading…
Add table
Add a link
Reference in a new issue