27 lines
1.7 KiB
TypeScript
27 lines
1.7 KiB
TypeScript
import { describe, expect, it, vi } from "vitest";
|
|
import { getAiEngineStatus } from "./ai-reference";
|
|
|
|
const config = { url: "https://referentiel-ia-santinova.recette.santinova-soft.org", token: "jeton-test", applicationSlug: "veille-reglementaire" };
|
|
const decision = { application: { slug: "veille-reglementaire" }, decision: { selected: { origin: "manual", engine: { name: "Manus Forge", provider: "Manus", slug: "manus-forge" }, connection: { configured: true, model: "gemini-2.5-flash", testStatus: "success" } } } };
|
|
|
|
describe("statut Référentiel IA", () => {
|
|
it("retourne une décision assainie sans exposer le jeton", async () => {
|
|
const fetcher = vi.fn().mockResolvedValue(new Response(JSON.stringify(decision), { status: 200 }));
|
|
const status = await getAiEngineStatus(config, fetcher as typeof fetch);
|
|
expect(status).toMatchObject({ state: "available", engine: { name: "Manus Forge", model: "gemini-2.5-flash", origin: "manual", operationalStatus: "ready" } });
|
|
expect(JSON.stringify(status)).not.toContain("jeton-test");
|
|
});
|
|
|
|
it("rejette une identité applicative incohérente", async () => {
|
|
const fetcher = vi.fn().mockResolvedValue(new Response(JSON.stringify({ ...decision, application: { slug: "autre-app" } }), { status: 200 }));
|
|
const status = await getAiEngineStatus(config, fetcher as typeof fetch);
|
|
expect(status).toMatchObject({ state: "authentication_error" });
|
|
});
|
|
|
|
it("retourne un statut explicite pour un jeton invalide", async () => {
|
|
const fetcher = vi.fn().mockResolvedValue(new Response(null, { status: 401 }));
|
|
const status = await getAiEngineStatus(config, fetcher as typeof fetch);
|
|
expect(status).toMatchObject({ state: "authentication_error" });
|
|
});
|
|
});
|