11import { describe , expect , it } from "vitest" ;
2- import zapier from "zapier-platform-core" ;
2+ import zapier , { Bundle } from "zapier-platform-core" ;
33
44import App from "../../../index.js" ;
55import { blankPdfPath } from "../index.js" ;
@@ -9,29 +9,59 @@ const appTester = zapier.createAppTester(App);
99zapier . tools . env . inject ( ) ;
1010
1111const modelId = process . env [ "MINDEE_V2_FINDOC_MODEL_ID" ] ;
12- const bundle : any = {
13- authData : {
14- apiKey : process . env [ "MINDEE_V2_API_KEY" ] ,
15- } ,
16- inputData : {
17- file : fs . readFileSync ( blankPdfPath ) . toString ( "base64" ) ,
18- modelId : modelId ,
19- alias : "zapier-test-enqueue" ,
20- }
21- } ;
12+
13+ async function assertJobResponse ( bundle : Bundle ) {
14+ // @ts -expect-error TBD
15+ const response : any = await appTester ( App . creates [ "v2_enqueue" ] . operation . perform , bundle ) ;
16+
17+ expect ( response ) . toBeInstanceOf ( Object ) ;
18+ expect ( response . job ) . toBeInstanceOf ( Object ) ;
19+ expect ( response . job . status ) . toEqual ( "Processing" ) ;
20+ expect ( response . job . model_id ) . toEqual ( modelId ) ;
21+ expect ( response . job . alias ) . toEqual ( "zapier-test-enqueue" ) ;
22+ expect ( response . job . error ) . toBeNull ;
23+ }
2224
2325describe ( "creates.enqueue" , ( ) => {
24- it ( "should run with default options" , async ( ) => {
25- delete bundle . inputData [ "polygon" ] ;
26- delete bundle . inputData [ "confidence" ] ;
27-
28- // @ts -expect-error TBD
29- const response : any = await appTester ( App . creates [ "v2_enqueue" ] . operation . perform , bundle ) ;
30- expect ( response ) . toBeInstanceOf ( Object ) ;
31- expect ( response . job ) . toBeInstanceOf ( Object ) ;
32- expect ( response . job . status ) . toEqual ( "Processing" ) ;
33- expect ( response . job . model_id ) . toEqual ( modelId ) ;
34- expect ( response . job . alias ) . toEqual ( "zapier-test-enqueue" ) ;
35- expect ( response . job . error ) . toBeNull ;
26+ it ( "should send a base64 file" , async ( ) => {
27+ const bundle : any = {
28+ authData : {
29+ apiKey : process . env [ "MINDEE_V2_API_KEY" ] ,
30+ } ,
31+ inputData : {
32+ file : fs . readFileSync ( blankPdfPath ) . toString ( "base64" ) ,
33+ modelId : modelId ,
34+ alias : "zapier-test-enqueue-base64" ,
35+ }
36+ } ;
37+ assertJobResponse ( bundle ) ;
38+ } , 6000 ) ;
39+
40+ it ( "should send a file stream" , async ( ) => {
41+ const bundle : any = {
42+ authData : {
43+ apiKey : process . env [ "MINDEE_V2_API_KEY" ] ,
44+ } ,
45+ inputData : {
46+ file : fs . createReadStream ( blankPdfPath ) ,
47+ modelId : modelId ,
48+ alias : "zapier-test-enqueue-stream" ,
49+ }
50+ } ;
51+ assertJobResponse ( bundle ) ;
52+ } , 6000 ) ;
53+
54+ it ( "should send a URL" , async ( ) => {
55+ const bundle : any = {
56+ authData : {
57+ apiKey : process . env [ "MINDEE_V2_API_KEY" ] ,
58+ } ,
59+ inputData : {
60+ file : "https://raw.githubusercontent.com/mindee/client-lib-test-data/refs/heads/main/file_types/receipt.jpg" ,
61+ modelId : modelId ,
62+ alias : "zapier-test-enqueue-url" ,
63+ }
64+ } ;
65+ assertJobResponse ( bundle ) ;
3666 } , 6000 ) ;
3767} ) ;
0 commit comments