11import { expect } from "chai" ;
22import path from "node:path" ;
33
4- import { ClientV2 , InferenceParameters , PathInput , UrlInput } from "../../src" ;
4+ import { ClientV2 , InferenceParameters , PathInput , UrlInput , Base64Input } from "../../src" ;
55import { SimpleField } from "../../src/parsing/v2/field" ;
66import { MindeeHttpErrorV2 } from "../../src/errors/mindeeError" ;
7+ import * as fs from "node:fs" ;
78
89describe ( "MindeeClientV2 – integration tests (V2)" , ( ) => {
910 let client : ClientV2 ;
@@ -22,6 +23,11 @@ describe("MindeeClientV2 – integration tests (V2)", () => {
2223 "financial_document" ,
2324 "default_sample.jpg" ,
2425 ) ;
26+ const sampleBase64Path = path . join (
27+ dataDir ,
28+ "file_types" ,
29+ "receipt.txt" ,
30+ ) ;
2531
2632 beforeEach ( async ( ) => {
2733 const apiKey = process . env [ "MINDEE_V2_API_KEY" ] ?? "" ;
@@ -30,7 +36,7 @@ describe("MindeeClientV2 – integration tests (V2)", () => {
3036 client = new ClientV2 ( { apiKey } ) ;
3137 } ) ;
3238
33- it ( "Empty, multi-page PDF – enqueue & get inference must succeed" , async ( ) => {
39+ it ( "Empty, multi-page PDF – PathInput - enqueueAndGetInference must succeed" , async ( ) => {
3440 const source = new PathInput ( { inputPath : emptyPdfPath } ) ;
3541 const params : InferenceParameters = {
3642 modelId,
@@ -61,16 +67,16 @@ describe("MindeeClientV2 – integration tests (V2)", () => {
6167 expect ( inference . activeOptions ?. confidence ) . to . be . false ;
6268 } ) . timeout ( 60000 ) ;
6369
64- it ( "Filled, single-page image – enqueue & get inference must succeed" , async ( ) => {
70+ it ( "Filled, single-page image – PathInput - enqueueAndGetInference must succeed" , async ( ) => {
6571 const source = new PathInput ( { inputPath : sampleImagePath } ) ;
6672 const params : InferenceParameters = {
6773 modelId,
6874 rag : false ,
6975 rawText : true ,
70- polygon : false ,
76+ polygon : true ,
7177 confidence : false ,
7278 webhookIds : [ ] ,
73- alias : "ts_integration_filled_single "
79+ alias : "ts_integration_binary_filled_single "
7480 } ;
7581
7682 const response = await client . enqueueAndGetInference ( source , params ) ;
@@ -86,17 +92,49 @@ describe("MindeeClientV2 – integration tests (V2)", () => {
8692 expect ( supplierField ) . to . be . instanceOf ( SimpleField ) ;
8793 expect ( supplierField . value ) . to . equal ( "John Smith" ) ;
8894
89-
9095 expect ( inference . result . rawText ) . to . exist ;
9196 expect ( inference . activeOptions ) . to . not . be . null ;
9297 expect ( inference . activeOptions ?. rag ) . to . be . false ;
9398 expect ( inference . activeOptions ?. rawText ) . to . be . true ;
94- expect ( inference . activeOptions ?. polygon ) . to . be . false ;
99+ expect ( inference . activeOptions ?. polygon ) . to . be . true ;
95100 expect ( inference . activeOptions ?. confidence ) . to . be . false ;
96101
97102 expect ( inference . result . rawText ?. pages ) . to . have . lengthOf ( 1 ) ;
98103 } ) . timeout ( 120000 ) ;
99104
105+ it ( "Filled, single-page image – Base64Input - enqueueAndGetInference must succeed" , async ( ) => {
106+ const data = fs . readFileSync ( sampleBase64Path , "utf8" ) ;
107+ const source = new Base64Input ( { inputString : data , filename : "receipt.jpg" } ) ;
108+ const params : InferenceParameters = {
109+ modelId,
110+ rag : false ,
111+ rawText : false ,
112+ polygon : false ,
113+ confidence : false ,
114+ webhookIds : [ ] ,
115+ alias : "ts_integration_base64_filled_single"
116+ } ;
117+
118+ const response = await client . enqueueAndGetInference ( source , params ) ;
119+
120+ const inference = response . inference ;
121+ expect ( inference . file ?. name ) . to . equal ( "receipt.jpg" ) ;
122+ expect ( inference . model ?. id ) . to . equal ( modelId ) ;
123+
124+ expect ( inference . result ) . to . exist ;
125+ expect ( inference . result . rawText ) . to . be . undefined ;
126+
127+ const supplierField = inference . result . fields . get ( "supplier_name" ) as SimpleField ;
128+ expect ( supplierField ) . to . be . instanceOf ( SimpleField ) ;
129+ expect ( supplierField . value ) . to . equal ( "Clachan" ) ;
130+
131+ expect ( inference . activeOptions ) . to . not . be . null ;
132+ expect ( inference . activeOptions ?. rag ) . to . be . false ;
133+ expect ( inference . activeOptions ?. rawText ) . to . be . false ;
134+ expect ( inference . activeOptions ?. polygon ) . to . be . false ;
135+ expect ( inference . activeOptions ?. confidence ) . to . be . false ;
136+ } ) . timeout ( 120000 ) ;
137+
100138 it ( "Invalid model ID – enqueue must raise 422" , async ( ) => {
101139 const source = new PathInput ( { inputPath : emptyPdfPath } ) ;
102140 const badParams : InferenceParameters = { modelId : "INVALID MODEL ID" } ;
0 commit comments