From 8d43a56409d2cb2090c6ebb6cbd5c490b5ce88b3 Mon Sep 17 00:00:00 2001 From: Sawyer Cutler Date: Sun, 23 Aug 2026 00:35:26 -0700 Subject: [PATCH] Add inherited Ollama default regression tests --- ...ench-service.inherit-parent-ollama.test.ts | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 packages/chat/src/workbench-service.inherit-parent-ollama.test.ts diff --git a/packages/chat/src/workbench-service.inherit-parent-ollama.test.ts b/packages/chat/src/workbench-service.inherit-parent-ollama.test.ts new file mode 100644 index 00000000..7ea85a8c --- /dev/null +++ b/packages/chat/src/workbench-service.inherit-parent-ollama.test.ts @@ -0,0 +1,69 @@ +import { describe, expect, test } from "bun:test"; +import type { ResolvedOffering } from "@intx/db"; +import type { Capability } from "@intx/types"; +import { selectDefaultInferencePreferences } from "./inference-preferences"; + +function offering( + overrides: Partial<{ + offeringId: string; + priority: number; + canonicalName: string; + providerName: string; + credentialId: string | null; + capabilities: readonly Capability[]; + origin: ResolvedOffering["origin"]; + }> = {}, +): ResolvedOffering { + const { + offeringId = "off_1", + priority = 0, + canonicalName = "claude-sonnet-5", + providerName = "anthropic", + credentialId = "cred_1", + capabilities = ["plain-text"], + origin = { tenantId: "tnt_bench", direct: true }, + } = overrides; + return { + offering: { + id: offeringId, + priority, + capabilities, + } as ResolvedOffering["offering"], + model: { canonicalName } as ResolvedOffering["model"], + provider: { + name: providerName, + credentialId, + } as ResolvedOffering["provider"], + origin, + }; +} + +describe("workbench inherit parent ollama", () => { + test("New child-tenant workbench + parent-space Ollama chat offering/credential only", () => { + const inherited = offering({ + offeringId: "off_ollama_chat", + priority: 0, + canonicalName: "qwen3:8b", + providerName: "ollama", + credentialId: "cred_ollama", + capabilities: ["plain-text"], + origin: { tenantId: "tnt_parent", direct: false }, + }); + expect(selectDefaultInferencePreferences([inherited])).toEqual([ + { provider: "ollama", model: "qwen3:8b" }, + ]); + }); + + test("New child-tenant workbench + parent-space Ollama chat offering/credential only — inherited provider with no credential is not Connected", () => { + const inherited = offering({ + offeringId: "off_ollama_chat", + priority: 0, + canonicalName: "qwen3:8b", + providerName: "ollama", + credentialId: null, + capabilities: ["plain-text"], + origin: { tenantId: "tnt_parent", direct: false }, + }); + expect(selectDefaultInferencePreferences([inherited])).toEqual([]); + }); +});