From 6fd398a57098ea594570d4fb815af97e52a653f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ianar=C3=A9=20S=C3=A9vi?= Date: Tue, 15 Jul 2025 17:55:34 +0200 Subject: [PATCH 1/2] :white_check_mark: add mvision tests --- tests/data | 2 +- tests/extras/extras.integration.ts | 34 +++++++++++++++++++++-- tests/workflows/workflow.integration.ts | 36 +++++++++++++++++++------ 3 files changed, 61 insertions(+), 11 deletions(-) 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..9627c31c0 100644 --- a/tests/workflows/workflow.integration.ts +++ b/tests/workflows/workflow.integration.ts @@ -9,27 +9,44 @@ 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 enabled", async () => { + const asyncParams: OptionalAsyncOptions = { + workflowId: workflowId, + rag: true }; const response = await client.enqueueAndParse( FinancialDocumentV1, @@ -41,17 +58,20 @@ describe("Workflow calls", () => { expect(((response.document?.inference.extras?.rag) as RAGExtra).matchingDocumentId).to.not.be.empty; }).timeout(60000); - it("should poll with rag disabled", async () => { + it("should poll with RAG and OCR words", async () => { const asyncParams: OptionalAsyncOptions = { - workflowId: process.env["WORKFLOW_ID"] ?? undefined + 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).to.be.undefined; + 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); }); From 95df8295ddee26e8a5f2b13bf6723995886783d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ianar=C3=A9=20S=C3=A9vi?= Date: Thu, 17 Jul 2025 09:42:29 +0200 Subject: [PATCH 2/2] add another test --- tests/workflows/workflow.integration.ts | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/tests/workflows/workflow.integration.ts b/tests/workflows/workflow.integration.ts index 9627c31c0..c3cb7666c 100644 --- a/tests/workflows/workflow.integration.ts +++ b/tests/workflows/workflow.integration.ts @@ -43,6 +43,22 @@ describe("Workflow calls", () => { 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).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 enabled", async () => { const asyncParams: OptionalAsyncOptions = { workflowId: workflowId, @@ -58,7 +74,7 @@ describe("Workflow calls", () => { expect(((response.document?.inference.extras?.rag) as RAGExtra).matchingDocumentId).to.not.be.empty; }).timeout(60000); - it("should poll with RAG and OCR words", async () => { + it("should poll with RAG enabled and OCR words", async () => { const asyncParams: OptionalAsyncOptions = { workflowId: workflowId, rag: true,