@@ -368,6 +368,35 @@ describe('QuickBooks master-data reader', () => {
368368 expect ( byIdResult . output . item ) . not . toHaveProperty ( 'BankAccountNumber' )
369369 } )
370370
371+ it ( 'removes vendor tax identifiers from list and by-ID output' , async ( ) => {
372+ const vendor = {
373+ Id : '3' ,
374+ SyncToken : '1' ,
375+ DisplayName : 'Sanitized Vendor' ,
376+ TaxIdentifier : 'sensitive-tax-id' ,
377+ }
378+ const vendorParams : QuickBooksReadMasterDataParams = {
379+ ...listParams ,
380+ recordType : 'vendor' ,
381+ }
382+
383+ const listResult = await quickbooksReadMasterDataTool . transformResponse ! (
384+ Response . json ( { QueryResponse : { Vendor : [ vendor ] } } ) ,
385+ vendorParams
386+ )
387+ expect ( listResult . output . items ?. [ 0 ] ) . toEqual ( {
388+ Id : '3' ,
389+ SyncToken : '1' ,
390+ DisplayName : 'Sanitized Vendor' ,
391+ } )
392+
393+ const byIdResult = await quickbooksReadMasterDataTool . transformResponse ! (
394+ Response . json ( { Vendor : vendor } ) ,
395+ { ...vendorParams , readMode : 'by_id' , recordId : '3' }
396+ )
397+ expect ( byIdResult . output . item ) . not . toHaveProperty ( 'TaxIdentifier' )
398+ } )
399+
371400 it ( 'rejects missing IDs, unknown types and unknown modes before a request' , ( ) => {
372401 const requestUrl = quickbooksReadMasterDataTool . request . url as (
373402 params : QuickBooksReadMasterDataParams
@@ -504,6 +533,28 @@ describe('QuickBooks customer and vendor mutations', () => {
504533 expect ( ( ) => parseQuickBooksAddress ( '{"city":123}' , 'billingAddress' ) ) . toThrow (
505534 'must be a string'
506535 )
536+ expect ( ( ) => parseQuickBooksAddress ( '{}' , 'billingAddress' ) ) . toThrow ( 'at least one' )
537+ } )
538+
539+ it ( 'removes vendor tax identifiers from mutation output' , async ( ) => {
540+ const response = {
541+ Vendor : {
542+ Id : '21' ,
543+ SyncToken : '0' ,
544+ DisplayName : 'Sanitized Vendor' ,
545+ TaxIdentifier : 'sensitive-tax-id' ,
546+ } ,
547+ time : 'test-time' ,
548+ }
549+
550+ for ( const tool of [ quickbooksCreateVendorTool , quickbooksUpdateVendorTool ] ) {
551+ const result = await tool . transformResponse ! ( Response . json ( response ) )
552+ expect ( result . output . record ) . toEqual ( {
553+ Id : '21' ,
554+ SyncToken : '0' ,
555+ DisplayName : 'Sanitized Vendor' ,
556+ } )
557+ }
507558 } )
508559} )
509560
@@ -567,6 +618,7 @@ describe('QuickBooks item mutations', () => {
567618 ...authParams ,
568619 itemId : '44' ,
569620 syncToken : '2' ,
621+ itemType : 'service' ,
570622 activeStatus : 'unchanged' ,
571623 unitPrice : 15.75 ,
572624 expenseAccountId : '80' ,
@@ -578,7 +630,13 @@ describe('QuickBooks item mutations', () => {
578630 UnitPrice : 15.75 ,
579631 ExpenseAccountRef : { value : '80' } ,
580632 } )
581- expect ( quickbooksUpdateItemTool . params ) . not . toHaveProperty ( 'itemType' )
633+ expect ( quickbooksUpdateItemTool . params . itemType ) . toMatchObject ( { required : true } )
634+ expect ( ( ) =>
635+ quickbooksUpdateItemTool . request . body ! ( {
636+ ...params ,
637+ itemType : 'inventory' as QuickBooksUpdateItemParams [ 'itemType' ] ,
638+ } )
639+ ) . toThrow ( 'Unsupported writable' )
582640 } )
583641
584642 it ( 'returns the native mutation record and convenient identifiers' , async ( ) => {
@@ -779,7 +837,7 @@ describe('QuickBooks tool and block boundaries', () => {
779837 } )
780838 expect ( subBlocks . itemType . condition ) . toEqual ( {
781839 field : 'operation' ,
782- value : 'quickbooks_create_item' ,
840+ value : [ 'quickbooks_create_item' , 'quickbooks_update_item' ] ,
783841 } )
784842 } )
785843} )
0 commit comments