fix(confidence-engine): propagate start outage classification

This commit is contained in:
2026-09-09 19:36:29 +01:00
parent 707fe1b3c0
commit 60c90bdd6a
3 changed files with 28 additions and 10 deletions
+24 -9
View File
@@ -1,13 +1,20 @@
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
const mockStartCase = vi.fn();
let realStartCase;
let warnSpy;
let errorSpy;
vi.mock("@/lib/graph/orchestrator.js", () => ({
startCase: (...args) => mockStartCase(...args),
vi.mock("@/lib/config.js", () => ({
getConfig: () => ({ ok: true }),
}));
vi.mock("@/lib/graph/orchestrator.js", async (importOriginal) => {
const actual = await importOriginal();
realStartCase = actual.startCase;
return { ...actual, startCase: (...args) => mockStartCase(...args) };
});
vi.mock("@/lib/supabase/api-auth.js", () => ({
withAuthenticatedApi: (handler) => handler,
}));
@@ -128,13 +135,21 @@ describe("app/api/cases/start route", () => {
});
it("returns a sanitized 503 when the provider is unavailable", async () => {
mockStartCase.mockResolvedValue({
success: false,
code: "PROVIDER_UNAVAILABLE",
error: "Ollama /api/generate request timed out after 5 minutes",
providerApiPath: "/api/generate",
providerExecution: { generateRequestAttempted: true },
});
const unavailableError = Object.assign(
new Error("Ollama /api/generate request timed out after 5 minutes"),
{
code: "PROVIDER_UNAVAILABLE",
providerApiPath: "/api/generate",
providerExecution: { generateRequestAttempted: true },
},
);
const reconstructionProvider = {
generateReconstruction: vi.fn().mockRejectedValue(unavailableError),
};
mockStartCase.mockImplementation((body) => realStartCase(body, {
reconstructionProvider,
reconstructionModelName: "configured-model",
}));
const { POST } = await import("@/app/api/cases/start/route.js");
const response = await POST(