import pytest
import time
from src.api_hook_client import ApiHookClient

def test_text_viewer_state_update(live_gui) -> None:
 """
 Verifies that we can set text viewer state and it is reflected in GUI state.
 """
 client = ApiHookClient()
 label = "Test Viewer Label"
 content = "This is test content for the viewer."
 text_type = "markdown"

 client.push_event("custom_callback", {"callback": "_set_attr", "args": ["show_text_viewer", True]})
 client.push_event("custom_callback", {"callback": "_set_attr", "args": ["text_viewer_title", label]})
 client.push_event("custom_callback", {"callback": "_set_attr", "args": ["text_viewer_content", content]})
 client.push_event("custom_callback", {"callback": "_set_attr", "args": ["text_viewer_type", text_type]})
 time.sleep(0.5)
 
 state = client.get_gui_state()
 assert state is not None
 assert state.get('show_text_viewer') == True
 assert state.get('text_viewer_title') == label
 assert state.get('text_viewer_type') == text_type
