"""Tests for #1103 — reasoning chip visible on page load.""" import re def test_boot_calls_fetchReasoningChip(): """boot.js must call fetchReasoningChip() during boot initialization.""" with open("static/boot.js") as f: src = f.read() assert "fetchReasoningChip" in src, "fetchReasoningChip must be referenced in boot.js" # Must be called (not just defined) assert re.search(r"fetchReasoningChip\s*\(\s*\)", src), \ "fetchReasoningChip() must be called in boot.js" def test_boot_call_before_session_load(): """fetchReasoningChip() should be called before session load in boot sequence.""" with open("static/boot.js") as f: src = f.read() # Find the boot session load: "const saved=localStorage.getItem('hermes-webui-session')" boot_marker = "const saved=localStorage.getItem('hermes-webui-session')" boot_pos = src.index(boot_marker) fetch_pos = src.index("fetchReasoningChip()") # fetchReasoningChip must be called just before the saved session load assert fetch_pos < boot_pos, \ "fetchReasoningChip() should be called before saved session load in boot.js" def test_boot_call_has_typeof_guard(): """fetchReasoningChip() call in boot.js should have a typeof guard.""" with open("static/boot.js") as f: src = f.read() assert "typeof fetchReasoningChip" in src, \ "fetchReasoningChip call should be guarded with typeof check" def test_reasoning_chip_html_starts_hidden(): """The reasoning wrap must start hidden (display:none) in HTML.""" with open("static/index.html") as f: src = f.read() assert 'id="composerReasoningWrap"' in src, "composerReasoningWrap must exist in HTML" # Extract the element and check for display:none m = re.search( r'