62 lines
2.2 KiB
Python
62 lines
2.2 KiB
Python
import pytest
|
|
import sys
|
|
import os
|
|
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", "gui.py")
|
|
gui = importlib.util.module_from_spec(spec)
|
|
sys.modules["gui"] = gui
|
|
spec.loader.exec_module(gui)
|
|
from gui import App
|
|
|
|
def test_new_hubs_defined_in_window_info():
|
|
"""
|
|
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.
|
|
from unittest.mock import patch
|
|
with patch('gui.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"
|
|
|
|
def test_old_windows_removed_from_window_info():
|
|
"""
|
|
Verifies that the old fragmented windows are removed from window_info.
|
|
"""
|
|
from unittest.mock import patch
|
|
with patch('gui.load_config', return_value={}):
|
|
app = App()
|
|
|
|
old_tags = [
|
|
"win_projects", "win_files", "win_screenshots",
|
|
"win_provider", "win_system_prompts",
|
|
"win_discussion", "win_message", "win_response",
|
|
"win_comms", "win_tool_log", "win_diagnostics"
|
|
]
|
|
|
|
for tag in old_tags:
|
|
assert tag not in app.window_info.values(), f"Old window tag {tag} should have been removed from window_info"
|