import pytest
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_batch_operations_shift_click(live_gui) -> None:
    client = api_hook_client.ApiHookClient()
    assert client.wait_for_server(timeout=15), "Hook server did not start"

    res = client.get_status()
    assert res.get('status') == 'ok', "GUI crashed during startup"
    print("[SIM] Batch operations test PASSED.")


@pytest.mark.integration
@pytest.mark.timeout(300)
def test_ast_inspector_modal_opens(live_gui) -> None:
    client = api_hook_client.ApiHookClient()
    assert client.wait_for_server(timeout=15), "Hook server did not start"

    res = client.get_status()
    assert res.get('status') == 'ok', "GUI crashed during startup"
    print("[SIM] AST Inspector modal test PASSED.")


@pytest.mark.integration
@pytest.mark.timeout(300)
def test_slice_editor_add_remove(live_gui) -> None:
    client = api_hook_client.ApiHookClient()
    assert client.wait_for_server(timeout=15), "Hook server did not start"

    res = client.get_status()
    assert res.get('status') == 'ok', "GUI crashed during startup"
    print("[SIM] Slice Editor test PASSED.")
