feat: centraliser le moteur IA via le Référentiel
All checks were successful
Deploy Production / deploy (push) Has been skipped
Deploy Recette / deploy (push) Successful in 1m32s
Validation applicative / TypeScript, tests et build (push) Successful in 2m42s

This commit is contained in:
manus-admin
2026-09-14 08:35:32 +00:00
parent 290e3709e2
commit 9db76af02c
7 changed files with 259 additions and 19 deletions

View File

@@ -0,0 +1,26 @@
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" }] } });
});
});