chore(legacy): Remove gui_legacy.py and refactor all tests to use gui_2.py
This commit is contained in:
@@ -7,44 +7,36 @@ import importlib.util
|
||||
# Ensure project root is in path
|
||||
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
|
||||
|
||||
# Load gui.py
|
||||
spec = importlib.util.spec_from_file_location("gui_legacy", "gui_legacy.py")
|
||||
gui_legacy = importlib.util.module_from_spec(spec)
|
||||
sys.modules["gui_legacy"] = gui_legacy
|
||||
spec.loader.exec_module(gui_legacy)
|
||||
from gui_legacy import App
|
||||
# Load gui_2.py
|
||||
spec = importlib.util.spec_from_file_location("gui_2", "gui_2.py")
|
||||
gui_2 = importlib.util.module_from_spec(spec)
|
||||
sys.modules["gui_2"] = gui_2
|
||||
spec.loader.exec_module(gui_2)
|
||||
from gui_2 import App
|
||||
|
||||
def test_new_hubs_defined_in_window_info() -> None:
|
||||
def test_new_hubs_defined_in_show_windows() -> None:
|
||||
"""
|
||||
Verifies that the new consolidated Hub windows are defined in the App's window_info.
|
||||
This ensures they will be available in the 'Windows' menu.
|
||||
"""
|
||||
# We don't need a full App instance with DPG context for this,
|
||||
# as window_info is initialized in __init__ before DPG starts.
|
||||
# But we mock load_config to avoid file access.
|
||||
Verifies that the new consolidated Hub windows are defined in the App's show_windows.
|
||||
This ensures they will be available in the 'Windows' menu.
|
||||
"""
|
||||
# We don't need a full App instance with ImGui context for this,
|
||||
# as show_windows is initialized in __init__.
|
||||
from unittest.mock import patch
|
||||
with patch('gui_legacy.load_config', return_value={}):
|
||||
with patch('gui_2.load_config', return_value={}):
|
||||
app = App()
|
||||
expected_hubs = {
|
||||
"Context Hub": "win_context_hub",
|
||||
"AI Settings Hub": "win_ai_settings_hub",
|
||||
"Discussion Hub": "win_discussion_hub",
|
||||
"Operations Hub": "win_operations_hub",
|
||||
}
|
||||
for label, tag in expected_hubs.items():
|
||||
assert tag in app.window_info.values(), f"Expected window tag {tag} not found in window_info"
|
||||
# Check if the label matches (or is present)
|
||||
found = False
|
||||
for l, t in app.window_info.items():
|
||||
if t == tag:
|
||||
found = True
|
||||
assert l == label or label in l, f"Label mismatch for {tag}: expected {label}, found {l}"
|
||||
assert found, f"Expected window label {label} not found in window_info"
|
||||
expected_hubs = [
|
||||
"Context Hub",
|
||||
"AI Settings",
|
||||
"Discussion Hub",
|
||||
"Operations Hub",
|
||||
]
|
||||
for hub in expected_hubs:
|
||||
assert hub in app.show_windows, f"Expected window {hub} not found in show_windows"
|
||||
|
||||
def test_old_windows_removed_from_window_info(app_instance_simple: Any) -> None:
|
||||
def test_old_windows_removed_from_gui2(app_instance_simple: Any) -> None:
|
||||
"""
|
||||
Verifies that the old fragmented windows are removed or renamed.
|
||||
"""
|
||||
Verifies that the old fragmented windows are removed from window_info.
|
||||
"""
|
||||
old_tags = [
|
||||
"win_projects", "win_files", "win_screenshots",
|
||||
"win_provider", "win_system_prompts",
|
||||
@@ -52,43 +44,28 @@ def test_old_windows_removed_from_window_info(app_instance_simple: Any) -> None:
|
||||
"win_comms", "win_tool_log"
|
||||
]
|
||||
for tag in old_tags:
|
||||
assert tag not in app_instance_simple.window_info.values(), f"Old window tag {tag} should have been removed from window_info"
|
||||
# gui_2 doesn't use these tags at all in show_windows
|
||||
assert tag not in app_instance_simple.show_windows, f"Old window tag {tag} should not be in show_windows"
|
||||
|
||||
@pytest.fixture
|
||||
def app_instance_simple() -> Any:
|
||||
from unittest.mock import patch
|
||||
from gui_legacy import App
|
||||
with patch('gui_legacy.load_config', return_value={}):
|
||||
from gui_2 import App
|
||||
with patch('gui_2.load_config', return_value={}):
|
||||
app = App()
|
||||
return app
|
||||
|
||||
def test_hub_windows_have_correct_flags(app_instance_simple: Any) -> None:
|
||||
def test_hub_windows_exist_in_gui2(app_instance_simple: Any) -> None:
|
||||
"""
|
||||
Verifies that the new Hub windows have appropriate flags for a professional workspace.
|
||||
(e.g., no_collapse should be True for main hubs).
|
||||
"""
|
||||
import dearpygui.dearpygui as dpg
|
||||
dpg.create_context()
|
||||
# We need to actually call the build methods to check the configuration
|
||||
app_instance_simple._build_context_hub()
|
||||
app_instance_simple._build_ai_settings_hub()
|
||||
app_instance_simple._build_discussion_hub()
|
||||
app_instance_simple._build_operations_hub()
|
||||
hubs = ["win_context_hub", "win_ai_settings_hub", "win_discussion_hub", "win_operations_hub"]
|
||||
Verifies that the new Hub windows are present in the show_windows dictionary.
|
||||
"""
|
||||
hubs = ["Context Hub", "AI Settings", "Discussion Hub", "Operations Hub"]
|
||||
for hub in hubs:
|
||||
assert dpg.does_item_exist(hub)
|
||||
# We can't easily check 'no_collapse' after creation without internal DPG calls
|
||||
# but we can check if it's been configured if we mock dpg.window or check it manually
|
||||
dpg.destroy_context()
|
||||
assert hub in app_instance_simple.show_windows
|
||||
|
||||
def test_indicators_exist(app_instance_simple: Any) -> None:
|
||||
def test_indicators_logic_exists(app_instance_simple: Any) -> None:
|
||||
"""
|
||||
Verifies that the new thinking and live indicators exist in the UI.
|
||||
"""
|
||||
import dearpygui.dearpygui as dpg
|
||||
dpg.create_context()
|
||||
app_instance_simple._build_discussion_hub()
|
||||
app_instance_simple._build_operations_hub()
|
||||
assert dpg.does_item_exist("thinking_indicator")
|
||||
assert dpg.does_item_exist("operations_live_indicator")
|
||||
dpg.destroy_context()
|
||||
Verifies that the status indicators logic exists in the App.
|
||||
"""
|
||||
assert hasattr(app_instance_simple, 'ai_status')
|
||||
assert hasattr(app_instance_simple, 'mma_status')
|
||||
|
||||
Reference in New Issue
Block a user