import pytest
import time
import sys
import os

sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "src")))

from src import api_hook_client

@pytest.mark.integration
@pytest.mark.timeout(300)
def test_ui_cache_controls(live_gui) -> None:
 client = api_hook_client.ApiHookClient()
 assert client.wait_for_server(timeout=15), "Hook server did not start"
 
 # Simply click the new clear cache button
 client.click('btn_clear_summary_cache')
 time.sleep(1.0)
 
 # Ensure GUI is still responsive
 res = client.get_status()
 assert res.get('status') == 'ok', "GUI crashed during cache clear"
 print("[SIM] Cache controls UI test PASSED.")
