fix(confidence-engine): retain successful provider path

This commit is contained in:
2026-09-05 17:12:31 +01:00
parent dabd9e2245
commit 46b9bd8b03
5 changed files with 34 additions and 3 deletions
+5 -1
View File
@@ -14,7 +14,7 @@ describe("OllamaLlmProvider chat capability detection", () => {
try {
const { getProvider } = await import("@/lib/llm/provider.js");
await getProvider().generateReconstruction("prompt", "configured-model");
const result = await getProvider().generateReconstruction("prompt", "configured-model");
expect(JSON.parse(fetchSpy.mock.calls[0][1].body)).toMatchObject({
model: "configured-model",
@@ -23,6 +23,10 @@ describe("OllamaLlmProvider chat capability detection", () => {
expect(fetchSpy.mock.calls[0][0]).toBe("http://ollama.test/api/chat");
expect(fetchSpy.mock.calls[1][0]).toBe("http://ollama.test/api/chat");
expect(fetchSpy.mock.calls[1][0]).not.toContain("/api/generate");
expect(result).toMatchObject({
response: {},
providerApiPath: "/api/chat",
});
} finally {
vi.unstubAllGlobals();
if (originalBaseUrl === undefined) delete process.env.OLLAMA_BASE_URL;
@@ -210,6 +210,8 @@ describe("analyseScenario compatibility", () => {
it("preserves nested validation issues and complete raw output on reconstruction failure", async () => {
mockGenerateReconstruction.mockResolvedValue({
providerApiPath: "/api/chat",
response: {
inputClassification: {
primaryType: "unexplained_change",
secondaryTypes: [],
@@ -239,6 +241,7 @@ describe("analyseScenario compatibility", () => {
reason: "reason",
expectedInformationValue: "high",
},
},
});
const { analyseScenario } = await import("@/lib/analysis.js");
@@ -253,6 +256,7 @@ describe("analyseScenario compatibility", () => {
code: "invalid_type",
message: "Required",
}));
expect(result.providerApiPath).toBe("/api/chat");
expect(result.errors).toContain("reconstruction: Required");
});