52 lines
1.8 KiB
Python
52 lines
1.8 KiB
Python
import sys
|
|
import os
|
|
from typing import Any
|
|
from unittest.mock import MagicMock, patch
|
|
|
|
# Ensure project root is in path for imports
|
|
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
|
|
|
|
from api_hook_client import ApiHookClient
|
|
|
|
def test_api_client_has_extensions() -> None:
|
|
client = ApiHookClient()
|
|
# These should exist in the client
|
|
assert hasattr(client, 'select_tab')
|
|
assert hasattr(client, 'select_list_item')
|
|
|
|
def test_select_tab_integration(live_gui: Any) -> None:
|
|
client = ApiHookClient()
|
|
# In gui_2, select_tab might be implemented as a set_value or a custom action
|
|
response = client.select_tab("operations_tabs", "tab_tool")
|
|
assert response == {'status': 'queued'}
|
|
|
|
def test_select_list_item_integration(live_gui: Any) -> None:
|
|
client = ApiHookClient()
|
|
response = client.select_list_item("disc_listbox", "Default")
|
|
assert response == {'status': 'queued'}
|
|
|
|
def test_get_indicator_state_integration(live_gui: Any) -> None:
|
|
client = ApiHookClient()
|
|
# thinking_indicator is usually hidden unless AI is running
|
|
response = client.get_indicator_state("thinking_indicator")
|
|
assert 'shown' in response
|
|
|
|
def test_app_processes_new_actions() -> None:
|
|
import gui_2
|
|
with patch('gui_2.load_config', return_value={}), \
|
|
patch('gui_2.PerformanceMonitor'), \
|
|
patch('gui_2.session_logger'), \
|
|
patch.object(gui_2.App, '_prune_old_logs'), \
|
|
patch.object(gui_2.App, '_load_active_project'):
|
|
app = gui_2.App()
|
|
# Test set_value via _pending_gui_tasks
|
|
# First we need to register a settable field for testing if not present
|
|
app._settable_fields["test_item"] = "ui_ai_input"
|
|
app._pending_gui_tasks.append({
|
|
"action": "set_value",
|
|
"item": "test_item",
|
|
"value": "new_value"
|
|
})
|
|
app._process_pending_gui_tasks()
|
|
assert app.ui_ai_input == "new_value"
|