diff --git a/tests/data b/tests/data index e48b26e52..f43634e5b 160000 --- a/tests/data +++ b/tests/data @@ -1 +1 @@ -Subproject commit e48b26e5250cbbab9d3ee6c66c0eb85b667a4bb8 +Subproject commit f43634e5b7c7f773c9c3dbec461b143c21a8f6d3 diff --git a/tests/extras/extras.integration.ts b/tests/extras/extras.integration.ts index e62895e15..be5ddd8e8 100644 --- a/tests/extras/extras.integration.ts +++ b/tests/extras/extras.integration.ts @@ -15,7 +15,9 @@ describe("Mindee Client Integration Tests", async () => { "tests/data/products/invoices/default_sample.jpg" ); await sample.init(); - const response = await client.parse(mindee.product.InvoiceV4, sample, { cropper: true }); + const response = await client.parse( + mindee.product.InvoiceV4, sample, { cropper: true } + ); expect(response.document.inference.pages[0]?.extras?.cropper).to.exist; }).timeout(60000); @@ -24,8 +26,36 @@ describe("Mindee Client Integration Tests", async () => { "tests/data/products/international_id/default_sample.jpg" ); await sample.init(); - const response = await client.enqueueAndParse(mindee.product.InternationalIdV2, sample, { fullText: true }); + const response = await client.enqueueAndParse( + mindee.product.InternationalIdV2, sample, { fullText: true } + ); expect(response.document?.extras?.fullTextOcr).to.exist; }).timeout(60000); + + it("should send OCR words synchronously", async () => { + const sample = client.docFromPath( + "tests/data/products/financial_document/default_sample.jpg" + ); + await sample.init(); + const response = await client.parse( + mindee.product.FinancialDocumentV1, sample, { allWords: true } + ); + expect(response.document?.ocr).to.exist; + expect(response.document?.ocr?.toString()).to.not.be.empty; + + }).timeout(65000); + + it("should send OCR words asynchronously", async () => { + const sample = client.docFromPath( + "tests/data/products/financial_document/default_sample.jpg" + ); + await sample.init(); + const response = await client.enqueueAndParse( + mindee.product.FinancialDocumentV1, sample, { allWords: true } + ); + expect(response.document?.ocr).to.exist; + expect(response.document?.ocr?.toString()).to.not.be.empty; + + }).timeout(65000); }); diff --git a/tests/workflows/workflow.integration.ts b/tests/workflows/workflow.integration.ts index 0c151d8ac..c3cb7666c 100644 --- a/tests/workflows/workflow.integration.ts +++ b/tests/workflows/workflow.integration.ts @@ -9,41 +9,60 @@ import { RAGExtra } from "../../src/parsing/common/extras/ragExtra"; describe("Workflow calls", () => { let client: mindee.Client; let sample: LocalInputSource; + let workflowId: string; + beforeEach(async () => { client = new mindee.Client(); + workflowId = process.env["WORKFLOW_ID"] ?? ""; sample = client.docFromPath( "tests/data/products/financial_document/default_sample.jpg" ); await sample.init(); }); + it("should retrieve a correct response from the API.", async () => { const currentDateTime = new Date().toISOString().replace(/T/, "-").replace(/\..+/, ""); const response = await client.executeWorkflow( sample, - process.env["WORKFLOW_ID"] ?? "", + workflowId, { alias: `node-${currentDateTime}`, priority: ExecutionPriority.low, rag: true }); expect(response.execution.priority).to.equal(ExecutionPriority.low); expect(response.execution.file.alias).to.equal(`node-${currentDateTime}`); }).timeout(60000); - it("should poll with rag enabled", async () => { + it("should poll with RAG disabled", async () => { const asyncParams: OptionalAsyncOptions = { - rag: true, - workflowId: process.env["WORKFLOW_ID"] ?? undefined + workflowId: workflowId }; const response = await client.enqueueAndParse( FinancialDocumentV1, sample, asyncParams ); + expect(response.document?.toString()).to.not.be.empty; + expect(response.document?.inference.extras?.rag).to.be.undefined; + }).timeout(60000); + it("should poll with RAG disabled and OCR words", async () => { + const asyncParams: OptionalAsyncOptions = { + workflowId: workflowId, + allWords: true + }; + const response = await client.enqueueAndParse( + FinancialDocumentV1, + sample, + asyncParams + ); expect(response.document?.toString()).to.not.be.empty; - expect(((response.document?.inference.extras?.rag) as RAGExtra).matchingDocumentId).to.not.be.empty; + expect(response.document?.inference.extras?.rag).to.be.undefined; + expect(response.document?.ocr).to.exist; + expect(response.document?.ocr?.toString()).to.not.be.empty; }).timeout(60000); - it("should poll with rag disabled", async () => { + it("should poll with RAG enabled", async () => { const asyncParams: OptionalAsyncOptions = { - workflowId: process.env["WORKFLOW_ID"] ?? undefined + workflowId: workflowId, + rag: true }; const response = await client.enqueueAndParse( FinancialDocumentV1, @@ -52,6 +71,23 @@ describe("Workflow calls", () => { ); expect(response.document?.toString()).to.not.be.empty; - expect(response.document?.inference.extras?.rag).to.be.undefined; + expect(((response.document?.inference.extras?.rag) as RAGExtra).matchingDocumentId).to.not.be.empty; + }).timeout(60000); + + it("should poll with RAG enabled and OCR words", async () => { + const asyncParams: OptionalAsyncOptions = { + workflowId: workflowId, + rag: true, + allWords: true + }; + const response = await client.enqueueAndParse( + FinancialDocumentV1, + sample, + asyncParams + ); + expect(response.document?.toString()).to.not.be.empty; + expect(((response.document?.inference.extras?.rag) as RAGExtra).matchingDocumentId).to.not.be.empty; + expect(response.document?.ocr).to.exist; + expect(response.document?.ocr?.toString()).to.not.be.empty; }).timeout(60000); });