Files
veille-reglementaire/server/ai-reference.test.ts
Santinova Deployment 5ed673773a
Some checks failed
Deploy Production / deploy (push) Has been skipped
Deploy Recette / deploy (push) Successful in 1m38s
Validation applicative / TypeScript, tests et build (push) Failing after 1m54s
feat: normaliser les URL recette par entité
2026-10-24 17:06:48 +00:00

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" });
});
});