import pytest import sys import os # 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(): client = ApiHookClient() # These should fail initially as they are not implemented assert hasattr(client, 'select_tab') assert hasattr(client, 'select_list_item') def test_select_tab_integration(live_gui): client = ApiHookClient() # We'll need to make sure the tags exist in gui.py # For now, this is a placeholder for the integration test response = client.select_tab("operations_tabs", "tab_tool") assert response == {'status': 'queued'} def test_select_list_item_integration(live_gui): client = ApiHookClient() # Assuming 'Default' discussion exists or we can just test that it queues response = client.select_list_item("disc_listbox", "Default") assert response == {'status': 'queued'} def test_app_processes_new_actions(): import gui from unittest.mock import MagicMock, patch import dearpygui.dearpygui as dpg dpg.create_context() try: with patch('gui.load_config', return_value={}), \ patch('gui.PerformanceMonitor'), \ patch('gui.shell_runner'), \ patch('gui.project_manager'), \ patch.object(gui.App, '_load_active_project'): app = gui.App() with patch('dearpygui.dearpygui.set_value') as mock_set_value, \ patch('dearpygui.dearpygui.does_item_exist', return_value=True), \ patch('dearpygui.dearpygui.get_item_callback') as mock_get_cb: # Test select_tab app._pending_gui_tasks.append({ "action": "select_tab", "tab_bar": "some_tab_bar", "tab": "some_tab" }) app._process_pending_gui_tasks() mock_set_value.assert_any_call("some_tab_bar", "some_tab") # Test select_list_item mock_cb = MagicMock() mock_get_cb.return_value = mock_cb app._pending_gui_tasks.append({ "action": "select_list_item", "listbox": "some_listbox", "item_value": "some_value" }) app._process_pending_gui_tasks() mock_set_value.assert_any_call("some_listbox", "some_value") mock_cb.assert_called_with("some_listbox", "some_value") finally: dpg.destroy_context()