experiment(confidence-engine): route UI journey provider centrally
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
const mockSynthesize = vi.fn();
|
||||
|
||||
vi.mock("@/lib/graph/investigation-overview-synthesis.js", () => ({
|
||||
synthesizeInvestigationOverview: (...args) => mockSynthesize(...args),
|
||||
}));
|
||||
|
||||
vi.mock("@/lib/llm/provider.js", () => ({
|
||||
getProvider: () => ({ generateReconstruction() {} }),
|
||||
getProviderModelName: () => "gpt-5.6-terra",
|
||||
}));
|
||||
|
||||
describe("POST /api/cases/overview provider routing", () => {
|
||||
beforeEach(() => mockSynthesize.mockClear());
|
||||
|
||||
it("passes the central provider and model resolution to overview synthesis", async () => {
|
||||
mockSynthesize.mockResolvedValue({ understanding: "Understanding", plausibleInterpretations: "None" });
|
||||
const { POST } = await import("@/app/api/cases/overview/route.js");
|
||||
const response = await POST(new Request("http://localhost/api/cases/overview", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ situationGraph: { nodes: [], edges: [] }, findings: [], plausibleInterpretations: [] }),
|
||||
}));
|
||||
|
||||
expect(response.status).toBe(200);
|
||||
expect(mockSynthesize.mock.calls[0][1]).toMatchObject({ modelName: "gpt-5.6-terra" });
|
||||
});
|
||||
});
|
||||
@@ -39,6 +39,8 @@ describe("app/api/cases/start route", () => {
|
||||
await POST(request);
|
||||
|
||||
expect(mockStartCase).toHaveBeenCalledWith({ scenario: "Scenario text" });
|
||||
expect(mockStartCase.mock.calls[0][0]).not.toHaveProperty("provider");
|
||||
expect(mockStartCase.mock.calls[0][0]).not.toHaveProperty("modelName");
|
||||
});
|
||||
|
||||
it("returns 200 on success", async () => {
|
||||
|
||||
@@ -72,6 +72,8 @@ describe("app/api/cases/update route", () => {
|
||||
);
|
||||
|
||||
expect(mockUpdateCase).toHaveBeenCalledWith(body, { applyProposal: true });
|
||||
expect(mockUpdateCase.mock.calls[0][0]).not.toHaveProperty("provider");
|
||||
expect(mockUpdateCase.mock.calls[0][0]).not.toHaveProperty("modelName");
|
||||
});
|
||||
|
||||
it("invalid JSON returns 400", async () => {
|
||||
|
||||
@@ -10,6 +10,7 @@ vi.mock("@/lib/graph/current-understanding-synthesis.js", () => ({
|
||||
|
||||
vi.mock("@/lib/llm/provider.js", () => ({
|
||||
getProvider: () => ({}),
|
||||
getProviderModelName: () => "gpt-5.6-terra",
|
||||
}));
|
||||
|
||||
// ── Helpers ─────────────────────────────────────────────────
|
||||
@@ -45,6 +46,7 @@ describe("POST /api/cases/synthesis — valid request", () => {
|
||||
expect(data.success).toBe(true);
|
||||
expect(data.currentUnderstanding).toBe("Synthesized result");
|
||||
expect(mockSynthesize).toHaveBeenCalledTimes(1);
|
||||
expect(mockSynthesize.mock.calls[0][1]).toMatchObject({ modelName: "gpt-5.6-terra" });
|
||||
});
|
||||
|
||||
it("returns narrative result on success", async () => {
|
||||
|
||||
Reference in New Issue
Block a user