@@ -10,6 +10,7 @@ import { EloquaBlock } from '@/blocks/blocks/eloqua'
1010import * as eloquaToolExports from '@/tools/eloqua'
1111import {
1212 eloquaActivateCampaignTool ,
13+ eloquaCreateContactExportTool ,
1314 eloquaCreateContactImportTool ,
1415 eloquaGetBulkSyncDataTool ,
1516 eloquaGetBulkSyncTool ,
@@ -525,6 +526,87 @@ describe('Oracle Eloqua tool contracts', () => {
525526 expect ( eloquaStartBulkSyncTool . request . retry ) . toBeUndefined ( )
526527 } )
527528
529+ it ( 'enforces the documented Bulk definition field limits' , ( ) => {
530+ const fields = ( count : number ) =>
531+ Object . fromEntries (
532+ Array . from ( { length : count } , ( _ , index ) => [
533+ `Field${ index } ` ,
534+ `{{Contact.Field(C_Field${ index } )}}` ,
535+ ] )
536+ )
537+
538+ expect ( ( ) =>
539+ eloquaCreateContactImportTool . request . body ?.( {
540+ ...AUTH ,
541+ definition : { fields : fields ( 100 ) } ,
542+ } )
543+ ) . not . toThrow ( )
544+ expect ( ( ) =>
545+ eloquaCreateContactImportTool . request . body ?.( { ...AUTH , definition : { fields : { } } } )
546+ ) . toThrow ( '1 to 100 field aliases' )
547+ expect ( ( ) =>
548+ eloquaCreateContactImportTool . request . body ?.( {
549+ ...AUTH ,
550+ definition : { fields : fields ( 101 ) } ,
551+ } )
552+ ) . toThrow ( '1 to 100 field aliases' )
553+
554+ expect ( ( ) =>
555+ eloquaCreateContactExportTool . request . body ?.( {
556+ ...AUTH ,
557+ definition : { fields : fields ( 250 ) } ,
558+ } )
559+ ) . not . toThrow ( )
560+ expect ( ( ) =>
561+ eloquaCreateContactExportTool . request . body ?.( {
562+ ...AUTH ,
563+ definition : { fields : fields ( 251 ) } ,
564+ } )
565+ ) . toThrow ( '1 to 250 field aliases' )
566+ expect ( ( ) =>
567+ eloquaCreateContactImportTool . request . body ?.( {
568+ ...AUTH ,
569+ definition : { fields : [ ] as unknown as Record < string , string > } ,
570+ } )
571+ ) . toThrow ( 'definition.fields must be a JSON object' )
572+ expect ( ( ) =>
573+ eloquaCreateContactImportTool . request . body ?.( {
574+ ...AUTH ,
575+ definition : { fields : { Email : 42 as unknown as string } } ,
576+ } )
577+ ) . toThrow ( 'must map non-empty aliases to string statements' )
578+ } )
579+
580+ it . each ( [
581+ [ 'eloqua_list_contacts' , 'viewId' ] ,
582+ [ 'eloqua_get_contact' , 'viewId' ] ,
583+ [ 'eloqua_list_accounts' , 'viewId' ] ,
584+ [ 'eloqua_list_accounts' , 'ownedByUserId' ] ,
585+ [ 'eloqua_get_account' , 'viewId' ] ,
586+ [ 'eloqua_list_campaigns' , 'externalSystemId' ] ,
587+ [ 'eloqua_get_campaign' , 'externalSystemId' ] ,
588+ [ 'eloqua_activate_campaign' , 'runAsUserId' ] ,
589+ ] as const ) ( '%s validates %s as a positive safe integer' , ( id , field ) => {
590+ for ( const invalid of [ 0 , 1.5 , Number . MAX_SAFE_INTEGER + 1 ] ) {
591+ expect ( ( ) => requestUrl ( tools [ id ] , { ...toolParams ( id ) , [ field ] : invalid } ) ) . toThrow (
592+ 'must be a positive integer'
593+ )
594+ }
595+ } )
596+
597+ it ( 'keeps selector-backed asset targets core in basic and advanced canvas modes' , ( ) => {
598+ const sentences = EloquaBlock . canvasPresentation ?. sentences . byOperation
599+ expect ( sentences ) . toMatchObject ( {
600+ get_campaign : [ { field : [ 'campaignSelector' , 'campaignIdInput' ] , core : true } ] ,
601+ activate_campaign : [ { field : [ 'campaignSelector' , 'campaignIdInput' ] , core : true } ] ,
602+ deactivate_campaign : [ { field : [ 'campaignSelector' , 'campaignIdInput' ] , core : true } ] ,
603+ get_contact_list : [ { field : [ 'contactListSelector' , 'contactListIdInput' ] , core : true } ] ,
604+ get_segment : [ { field : [ 'segmentSelector' , 'segmentIdInput' ] , core : true } ] ,
605+ get_email : [ { field : [ 'emailSelector' , 'emailIdInput' ] , core : true } ] ,
606+ get_form : [ { field : [ 'formSelector' , 'formIdInput' ] , core : true } ] ,
607+ } )
608+ } )
609+
528610 it ( 'handles a 204 import upload and enforces the 10 MiB inline ceiling' , async ( ) => {
529611 await expect (
530612 transform ( eloquaUploadContactImportDataTool , new Response ( null , { status : 204 } ) , {
0 commit comments