#!/usr/bin/env python3

import sys
import os
sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'src'))

import tkinter as tk
from excel_filter.gui_new import ExcelFilterGUI

def test_gui_initialization():
    """Test GUI initialization without running the main loop"""
    print("Testing GUI initialization...")

    # Create a test window
    root = tk.Tk()
    root.title("GUI Test")
    root.geometry("800x600")

    try:
        # Initialize the GUI
        app = ExcelFilterGUI(root)
        print("ExcelFilterGUI initialized successfully")

        # Test that main components exist
        assert hasattr(app, 'root'), "Root window not set"
        assert hasattr(app, 'main_window'), "Main window not set"
        assert hasattr(app, 'config_tab'), "Config tab not set"
        assert hasattr(app, 'execution_tab'), "Execution tab not set"
        assert hasattr(app, 'regex_builder_tab'), "Regex builder tab not set"

        print("All main GUI components initialized successfully")
        print("GUI initialization test passed")

    except Exception as e:
        print(f"GUI initialization failed: {e}")
        raise
    finally:
        # Clean up: destroy the root window without running mainloop
        root.destroy()

if __name__ == "__main__":
    test_gui_initialization()
