Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins
TypeScript ai-agentcoding-agentdesktop-appelectronglobali18nlocal-firstmcppipi-agentpi-desktoppluginsreactrusttypescript
test(desktop): align discovery assertions with endpoint cache writes
zhanglinrune9fcb5fc35a7
diff --git a/apps/desktop/test/model-advanced-capabilities.test.mjs b/apps/desktop/test/model-advanced-capabilities.test.mjsindex 641a291bd..efd407fb6 100644--- a/apps/desktop/test/model-advanced-capabilities.test.mjs+++ b/apps/desktop/test/model-advanced-capabilities.test.mjs@@ -182,10 +182,10 @@ test("a configured model keeps its published record when discovery omits it", ()assert.ok(unions.length >= 3, `expected 3+ union sites, saw ${unions.length}`);// Discovery stays the authority on what the service offers: only the rows it// returned are cached as discovered.- const liveReturn = mainSource.slice(- mainSource.indexOf("await cacheForCurrentProvider(models, outcome.complete);"),+ assert.match(+ mainSource,+ /await cacheForCurrentProvider\([\s\S]*?outcome\.complete\);\s*return \{\s*models: withConfiguredBindings\(models\)/,);- assert.match(liveReturn.slice(0, 260), /models: withConfiguredBindings\(models\)/);});test("the published record is not shaped by the stored override", () => {diff --git a/apps/desktop/test/model-discovery-precedence.test.mjs b/apps/desktop/test/model-discovery-precedence.test.mjsindex 5b1bf86a9..e728c9c29 100644--- a/apps/desktop/test/model-discovery-precedence.test.mjs+++ b/apps/desktop/test/model-discovery-precedence.test.mjs@@ -56,8 +56,10 @@ test("a catalog-derived list is reported as such, not as the service's answer",// The live branch keeps its own distinct source value. What it returns may be// widened with the user's configured bindings, but only the rows the endpoint// actually served are cached, which the next test pins.- const liveReturn = handler.slice(handler.indexOf("await cacheForCurrentProvider(models, outcome.complete);"));- assert.match(liveReturn.slice(0, 240), /source: "remote" as const/);+ assert.match(+ handler,+ /await cacheForCurrentProvider\([\s\S]*?outcome\.complete\);\s*return \{[^}]*source: "remote" as const/,+ );});test("only a live answer is written back to the model cache", () => {@@ -65,8 +67,9 @@ test("only a live answer is written back to the model cache", () => {// on the next cold start.const cacheCall = handler.indexOf("await cacheForCurrentProvider(");const catalog = handler.indexOf("modelsDevCatalog.modelsForProvider(");+ assert.notEqual(cacheCall, -1, "live discovery cache write missing");assert.ok(cacheCall < catalog, "the cache write must belong to the live branch");- assert.match(handler, /if \(!provider \|\| req\.source === "cache"\) return;/);+ assert.match(handler, /if \(!host \|\| !provider \|\| req\.source === "cache"\) return;/);// The cache key stays the saved endpoint, so a resolved candidate never// rewrites the cache of a row that has not been saved with it yet.assert.match(handler, /const requestBaseUrl = baseUrl\.replace/);