@@ -575,6 +575,69 @@ describe('QuickBooks customer and vendor mutations', () => {
575575 expect ( ( ) => parseQuickBooksAddress ( '{}' , 'billingAddress' ) ) . toThrow ( 'at least one' )
576576 } )
577577
578+ it ( 'rejects malformed addresses in direct mutation tool calls' , ( ) => {
579+ expect ( ( ) =>
580+ quickbooksCreateCustomerTool . request . body ! ( {
581+ ...authParams ,
582+ displayName : 'Sanitized Customer' ,
583+ billingAddress : 'not-an-object' as never ,
584+ } )
585+ ) . toThrow ( 'billingAddress must be valid JSON' )
586+
587+ expect ( ( ) =>
588+ quickbooksUpdateCustomerTool . request . body ! ( {
589+ ...authParams ,
590+ customerId : '12' ,
591+ syncToken : '3' ,
592+ shippingAddress : [ ] as never ,
593+ } )
594+ ) . toThrow ( 'shippingAddress must be a JSON object' )
595+
596+ expect ( ( ) =>
597+ quickbooksCreateVendorTool . request . body ! ( {
598+ ...authParams ,
599+ displayName : 'Sanitized Vendor' ,
600+ billingAddress : { unknown : 'value' } as never ,
601+ } )
602+ ) . toThrow ( 'billingAddress contains unsupported field' )
603+
604+ expect ( ( ) =>
605+ quickbooksUpdateVendorTool . request . body ! ( {
606+ ...authParams ,
607+ vendorId : '21' ,
608+ syncToken : '4' ,
609+ billingAddress : { } as never ,
610+ } )
611+ ) . toThrow ( 'billingAddress must contain at least one supported address field' )
612+ } )
613+
614+ it ( 'treats omitted active status as unchanged in direct update calls' , ( ) => {
615+ expect (
616+ quickbooksUpdateCustomerTool . request . body ! ( {
617+ ...authParams ,
618+ customerId : '12' ,
619+ syncToken : '3' ,
620+ companyName : 'Updated Company' ,
621+ } )
622+ ) . toEqual ( {
623+ Id : '12' ,
624+ SyncToken : '3' ,
625+ sparse : true ,
626+ CompanyName : 'Updated Company' ,
627+ } )
628+
629+ for ( const tool of [
630+ quickbooksUpdateCustomerTool ,
631+ quickbooksUpdateVendorTool ,
632+ quickbooksUpdateItemTool ,
633+ ] ) {
634+ expect ( tool . params . activeStatus ) . toMatchObject ( {
635+ required : false ,
636+ default : 'unchanged' ,
637+ } )
638+ }
639+ } )
640+
578641 it ( 'removes vendor tax identifiers from mutation output' , async ( ) => {
579642 const response = {
580643 Vendor : {
0 commit comments