fix(test): deflake two intermittent CI failures

- test_browser_secret_exfil: mock _run_browser_command instead of
  launching real Chrome (secret check is pre-launch, browser is
  irrelevant to the assertion)
- test_web_server: add time.sleep(0.05) after pub.send_text() to
  yield the event loop before receive_text(). TestClient's sync mode
  can race the broadcast handler otherwise, hanging the test.
This commit is contained in:
ethernet 2026-05-22 15:59:17 -04:00 committed by Teknium
parent 510df6eaf4
commit f89afdbd17
3 changed files with 36 additions and 3 deletions

View file

@ -31,7 +31,13 @@ class TestBrowserSecretExfil:
def test_allows_normal_url(self):
"""Normal URLs pass the secret check (may fail for other reasons)."""
from tools.browser_tool import browser_navigate
result = browser_navigate("https://github.com/NousResearch/hermes-agent")
# Patch the actual browser command — we only care that the secret
# check doesn't block a clean URL, not that Chrome starts in CI.
mock_result = {"success": True, "data": {"title": "ok", "url": "https://github.com/NousResearch/hermes-agent"}}
with patch("tools.browser_tool._run_browser_command", return_value=mock_result), \
patch("tools.browser_tool._get_session_info", return_value={"_first_nav": False}), \
patch("tools.browser_tool._is_local_backend", return_value=True):
result = browser_navigate("https://github.com/NousResearch/hermes-agent")
parsed = json.loads(result)
# Should NOT be blocked by secret detection
assert "API key or token" not in parsed.get("error", "")