From d949d600f8a1a4ccb16c51d56153ddaa09e8059c Mon Sep 17 00:00:00 2001 From: Niko1221 Date: Thu, 15 Oct 2026 17:40:14 +0200 Subject: [PATCH] updates: shell bridge tests, host test that a start never reaches the update step, install hint --- apps/desktop/src-tauri/src/updater.rs | 38 ++++++++++++++++++++++ apps/host/tests/component-updates.test.mjs | 11 +++++++ strata_cli/cli.py | 3 +- 3 files changed, 51 insertions(+), 1 deletion(-) diff --git a/apps/desktop/src-tauri/src/updater.rs b/apps/desktop/src-tauri/src/updater.rs index b000abc9..ca608def 100644 --- a/apps/desktop/src-tauri/src/updater.rs +++ b/apps/desktop/src-tauri/src/updater.rs @@ -200,3 +200,41 @@ pub fn apply_env(cmd: &mut std::process::Command, app: &AppHandle, bridge: Optio cmd.env("STRATA_SHELL_BRIDGE", &bridge.url).env("STRATA_SHELL_TOKEN", &bridge.token); } } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn token_comparison_needs_every_byte() { + assert!(same("abc123", "abc123")); + assert!(!same("abc123", "abc124")); + assert!(!same("abc123", "abc12")); + assert!(!same("", "x")); + } + + #[test] + fn progress_reports_idle_until_something_starts() { + let idle = Progress::default().json(); + assert_eq!(idle["state"], "idle"); + let p = Progress { state: "downloading", downloaded: 10, total: 100, version: Some("0.2.0".into()), error: None }; + assert_eq!(p.json()["downloaded"], 10); + assert_eq!(p.json()["version"], "0.2.0"); + } + + #[test] + fn only_https_or_loopback_endpoints_may_override_the_configured_one() { + for (value, ok) in [ + ("https://updates.example.com/latest.json", true), + ("http://127.0.0.1:19080/app/latest.json", true), + ("http://localhost:19080/latest.json", true), + ("http://example.com/latest.json", false), + ("file:///etc/passwd", false), + ] { + std::env::set_var(ENDPOINT_ENV, value); + assert_eq!(endpoint_override().is_some(), ok, "{value}"); + } + std::env::remove_var(ENDPOINT_ENV); + assert!(endpoint_override().is_none()); + } +} diff --git a/apps/host/tests/component-updates.test.mjs b/apps/host/tests/component-updates.test.mjs index e0c6b2b0..cc43fbe3 100644 --- a/apps/host/tests/component-updates.test.mjs +++ b/apps/host/tests/component-updates.test.mjs @@ -263,3 +263,14 @@ test('without the shell bridge "Update Strata" still updates Control and says no assert.doesNotMatch(job.summary, /Strata 0\.2\.0/); } finally { await f.native.close(); f.cleanup(); } }); + +test('packaged: opening the app, listing models and loading one never reach the update step', async () => { + const f = fixture(); + try { + await f.native.refresh(true); + const load = await finish(f.native, f.native.operation('load', { model: 'iq2_xs' }).id); + assert.equal(load.state, 'done', load.error); + assert.deepEqual(f.calls, [], 'no update, check or rollback call: downloads happen only when the user presses Update'); + assert.equal(f.spawned.length, 0); + } finally { await f.native.close(); f.cleanup(); } +}); diff --git a/strata_cli/cli.py b/strata_cli/cli.py index 99264220..bbd6b74a 100644 --- a/strata_cli/cli.py +++ b/strata_cli/cli.py @@ -1716,7 +1716,8 @@ def _install(a: argparse.Namespace) -> int: if not installer.is_file(): return _error("this folder has no installer (setup.py). Engines, models and updates are installed from a " "full Strata folder with SETUP.bat / ./setup.sh and UPDATE.bat / ./update.sh; " - "set STRATA_INSTALL_DIR to that folder to run it from here", 5) + "set STRATA_INSTALL_DIR to that folder to run it from here. To update the engine and Control " + "from the signed update feed, run `strata update`", 5) extra = [x for x in a.setup_args if x != "--"] return subprocess.call([sys.executable, str(installer), "--update" if a.update else "--setup", *extra], cwd=str(installer.parent))