27 lines
1.1 KiB
TypeScript
27 lines
1.1 KiB
TypeScript
import { describe, expect, it, vi } from "vitest";
|
|
import { ENV } from "./env";
|
|
import { invokeSelectedReference } from "./aiReferenceClient";
|
|
|
|
describe("client Référentiel IA", () => {
|
|
it("transmet seulement le payload métier et restitue la trace résolue", async () => {
|
|
ENV.aiReferentielUrl = "https://referentiel-ia.recette.santinova-soft.org";
|
|
ENV.aiReferentielToken = "token-de-test";
|
|
const fetcher = vi.fn(async () => new Response(JSON.stringify({ choices: [] }), {
|
|
status: 200,
|
|
headers: {
|
|
"x-santinova-ia-provider": "Manus",
|
|
"x-santinova-ia-model": "gemini-2.5-flash",
|
|
"x-santinova-ia-transport": "manus-forge",
|
|
"x-santinova-ia-origin": "manual",
|
|
},
|
|
}));
|
|
|
|
const response = await invokeSelectedReference<{ choices: unknown[] }>({ messages: [{ role: "user", content: "test" }] }, fetcher as typeof fetch);
|
|
|
|
expect(response.choices).toEqual([]);
|
|
expect(fetcher).toHaveBeenCalledOnce();
|
|
const [, options] = fetcher.mock.calls[0] as [string, RequestInit];
|
|
expect(JSON.parse(String(options.body))).toEqual({ payload: { messages: [{ role: "user", content: "test" }] } });
|
|
});
|
|
});
|