mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-18 04:41:56 +00:00
fix(install): skip browser download when system chromium exists
This commit is contained in:
parent
7f08cb5941
commit
52521c937a
4 changed files with 173 additions and 54 deletions
35
tests/test_install_sh_browser_install.py
Normal file
35
tests/test_install_sh_browser_install.py
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
"""Regression tests for install.sh browser setup.
|
||||
|
||||
Browser automation is optional. The installer should not leave Hermes
|
||||
half-installed just because Playwright's managed Chromium download hangs on an
|
||||
unsupported distribution.
|
||||
"""
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parent.parent
|
||||
INSTALL_SH = REPO_ROOT / "scripts" / "install.sh"
|
||||
|
||||
|
||||
def test_install_script_skips_playwright_download_when_system_browser_exists() -> None:
|
||||
text = INSTALL_SH.read_text()
|
||||
|
||||
assert "find_system_browser()" in text
|
||||
assert "google-chrome google-chrome-stable chromium chromium-browser chrome" in text
|
||||
assert "Skipping Playwright browser download; Hermes will use the system browser." in text
|
||||
|
||||
|
||||
def test_install_script_persists_system_browser_for_agent_browser() -> None:
|
||||
text = INSTALL_SH.read_text()
|
||||
|
||||
assert "configure_browser_env_from_system_browser()" in text
|
||||
assert "AGENT_BROWSER_EXECUTABLE_PATH=$browser_path" in text
|
||||
|
||||
|
||||
def test_playwright_installs_are_timeout_guarded() -> None:
|
||||
text = INSTALL_SH.read_text()
|
||||
|
||||
assert "run_browser_install_with_timeout()" in text
|
||||
assert "run_browser_install_with_timeout 600 npx playwright install chromium" in text
|
||||
assert "run_browser_install_with_timeout 600 npx playwright install --with-deps chromium" in text
|
||||
|
|
@ -41,6 +41,16 @@ class TestChromiumSearchRoots:
|
|||
|
||||
|
||||
class TestChromiumInstalled:
|
||||
def test_true_when_plain_chromium_on_path(self, monkeypatch):
|
||||
monkeypatch.delenv("AGENT_BROWSER_EXECUTABLE_PATH", raising=False)
|
||||
monkeypatch.setattr(
|
||||
bt.shutil,
|
||||
"which",
|
||||
lambda name: "/usr/bin/chromium" if name == "chromium" else None,
|
||||
)
|
||||
|
||||
assert bt._chromium_installed() is True
|
||||
|
||||
def test_true_when_chromium_dir_present(self, monkeypatch, tmp_path):
|
||||
monkeypatch.setenv("PLAYWRIGHT_BROWSERS_PATH", str(tmp_path))
|
||||
(tmp_path / "chromium-1208").mkdir()
|
||||
|
|
@ -108,4 +118,3 @@ class TestRunBrowserCommandChromiumGuard:
|
|||
"""
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue