Files
hermes-agent/tests/hermes_cli/test_desktop_source_electron_missing.py
Maciej Lisiewski df9ffa977d fix(desktop): rebuild a source build whose linked Electron is gone
A Windows ZIP update drops workspace node_modules. If the reinstall then
failed, the renderer and its receipt stayed current, so
`hermes desktop --source` skipped the build and could not launch.
Treat a missing apps/desktop/node_modules/electron as a needed build.
2026-11-06 04:08:46 +01:00

33 lines
1.5 KiB
Python

"""A current renderer must not hide a source build whose linked Electron is gone.
A Windows ZIP update drops workspace node_modules (pnpm's links do not survive the
copy). If the reinstall then fails, apps/desktop/dist and its freshness receipt are
still current, and `hermes desktop --source` would skip the build and fail to launch
the missing runtime instead of relinking it.
"""
from hermes_cli import main_desktop, source_build
def _source_tree(tmp_path, monkeypatch, *, electron: bool):
desktop = tmp_path / "apps/desktop"
(desktop / "dist").mkdir(parents=True)
(desktop / "dist/index.html").write_text("<html></html>", encoding="utf-8")
if electron:
(desktop / "node_modules/electron").mkdir(parents=True)
(desktop / "node_modules/electron/package.json").write_text("{}", encoding="utf-8")
# The compiler owns receipts; hold that check current to isolate the runtime boundary.
monkeypatch.setattr(source_build, "source_product_current", lambda *_: True)
return tmp_path, desktop
def test_missing_linked_electron_needs_a_source_build(tmp_path, monkeypatch):
root, desktop = _source_tree(tmp_path, monkeypatch, electron=False)
assert main_desktop._desktop_build_needed(desktop, root, source_mode=True)
def test_current_source_build_with_its_electron_is_reused(tmp_path, monkeypatch):
root, desktop = _source_tree(tmp_path, monkeypatch, electron=True)
assert not main_desktop._desktop_build_needed(desktop, root, source_mode=True)