diff options
Diffstat (limited to 'packages/meshbay-node/tests/test_packaging_win.py')
| -rw-r--r-- | packages/meshbay-node/tests/test_packaging_win.py | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/packages/meshbay-node/tests/test_packaging_win.py b/packages/meshbay-node/tests/test_packaging_win.py index 31816d2..21aaf29 100644 --- a/packages/meshbay-node/tests/test_packaging_win.py +++ b/packages/meshbay-node/tests/test_packaging_win.py @@ -316,6 +316,57 @@ def test_service_status_reports_state_without_admin(): "calls status/run/end directly, unelevated") +HUB_STATIC = ROOT / "packages" / "meshbay-hub" / "src" / "meshbay_hub" / "static" + + +def test_service_mode_toggle_elevates_the_same_script_the_installer_runs(): + """ + The installer's own mode question is effectively one-shot (it skips + itself the moment the firewall rules exist for any reason, and per-user + mode sets those up on its own with no Scheduled Task involved) -- so + declining once, or the rules existing for any other reason, is a dead + end through setup alone. The Node page's toggle is the other door in + (and out), and it must drive service-mode.ps1 -- the exact script + installer.nsh runs -- so the two paths can never disagree about what + "service mode" means. One elevation (-Verb RunAs), no stored password. + """ + main_js = (CLIENT / "src" / "main.js").read_text(encoding="utf-8") + assert "winElevateServiceMode" in main_js + fn = main_js.split("function winElevateServiceMode", 1)[1] + fn = fn[:fn.index("\n }\n")] + assert "service-mode.ps1" in fn + assert "-Verb RunAs" in fn or "'-Verb', 'RunAs'" in fn or "-Verb', 'RunAs'" in fn + assert "Get-Credential" not in fn + + handler = main_js.split("ipcMain.handle('node:service-mode'", 1)[1] + handler = handler[:handler.index("ipcMain.handle(")] + assert "winElevateServiceMode" in handler + assert "'install'" in handler or '"install"' in handler + assert "'remove'" in handler or '"remove"' in handler + + +def test_node_page_service_mode_toggle_is_wired_end_to_end(): + """preload.js -> platform.js -> node-page.js, the same three-layer shape + the existing autostart toggle uses. A break anywhere in this chain means + the checkbox renders but does nothing, or never renders at all.""" + preload = (CLIENT / "src" / "preload.js").read_text(encoding="utf-8") + assert "serviceMode:" in preload + assert "'node:service-mode'" in preload + + platform_js = (HUB_STATIC / "platform.js").read_text(encoding="utf-8") + assert "serviceMode:" in platform_js + assert "bridge.node.serviceMode('install')" in platform_js + assert "bridge.node.serviceMode('remove')" in platform_js + + node_page = (HUB_STATIC / "node-page.js").read_text(encoding="utf-8") + assert "platform.node.serviceMode.available" in node_page + assert "platform.node.serviceMode.install()" in node_page + assert "platform.node.serviceMode.remove()" in node_page + # Checked state must reflect the CURRENT mode, not a separate flag -- + # otherwise the toggle and the status panel above it could disagree. + assert "info.mode === 'service'" in node_page + + def test_the_help_smoke_test_joins_multiline_output_before_matching(): """ `& exe --help 2>&1` is an ARRAY once the output wraps past one line, which |