import { describe, it, expect } from "vitest"; import { DocumentCaptureService } from "@/src/services/document-capture-service"; import { DocumentExtractionService } from "@/src/services/document-extraction-service"; describe("DocumentExtractionService — refuses to fabricate when unconfigured", () => { it("throws instead of returning an empty/fake success when Document Intelligence has no endpoint/apiKey", async () => { const captureService = new DocumentCaptureService(); const extractionService = new DocumentExtractionService(captureService); // no documentIntelligence opt passed await expect( extractionService.extractDocument("doc_does_not_matter", { tenant_id: "t1", project_id: "p1", actor_id: "a1", correlation_id: "c1", model_id: "prebuilt-invoice", }), ).rejects.toThrow(/not configured/i); }); it("rejects a missing model_id rather than silently picking one", async () => { const captureService = new DocumentCaptureService(); const extractionService = new DocumentExtractionService(captureService, { documentIntelligence: { endpoint: "https://di.example.com", apiKey: "key123" }, }); await expect( extractionService.extractDocument("doc_does_not_matter", { tenant_id: "t1", project_id: "p1", actor_id: "a1", correlation_id: "c1", model_id: "", }), ).rejects.toThrow(/model_id/i); }); });