@@ -234,11 +234,11 @@ describe('POST /api/tools/netsuite/objects', () => {
234234 } )
235235 } )
236236
237- it ( 'normalizes, deduplicates, sorts, and caps record types' , async ( ) => {
238- const items = Array . from ( { length : 1_001 } , ( _ , index ) => ( {
239- name : `record_${ String ( 1_000 - index ) . padStart ( 4 , '0' ) } ` ,
237+ it ( 'normalizes, deduplicates, and sorts up to 1,000 unique record types' , async ( ) => {
238+ const items = Array . from ( { length : 1_000 } , ( _ , index ) => ( {
239+ name : `record_${ String ( 999 - index ) . padStart ( 4 , '0' ) } ` ,
240240 } ) )
241- items . push ( { name : 'record_0000' } )
241+ items . push ( { name : 'record_0000' } , { name : 'record_0999' } )
242242 mockListRecordTypes . mockResolvedValueOnce ( success ( { items } ) )
243243
244244 const response = await POST ( request ( RECORD_TYPES_BODY ) , { } )
@@ -250,6 +250,21 @@ describe('POST /api/tools/netsuite/objects', () => {
250250 expect ( ( body . objects as { id : string } [ ] ) . at ( - 1 ) ?. id ) . toBe ( 'record_0999' )
251251 } )
252252
253+ it ( 'fails closed instead of returning a partial record-type catalog' , async ( ) => {
254+ mockListRecordTypes . mockResolvedValueOnce (
255+ success ( {
256+ items : Array . from ( { length : 1_001 } , ( _ , index ) => ( { name : `record_${ index } ` } ) ) ,
257+ } )
258+ )
259+
260+ const response = await POST ( request ( RECORD_TYPES_BODY ) , { } )
261+
262+ expect ( response . status ) . toBe ( 502 )
263+ expect ( await json ( response ) ) . toEqual ( {
264+ error : 'NetSuite returned an invalid object-discovery response.' ,
265+ } )
266+ } )
267+
253268 it ( 'fails closed on a malformed provider envelope' , async ( ) => {
254269 mockListRecordTypes . mockResolvedValueOnce ( success ( { items : [ { name : 42 } ] } ) )
255270
0 commit comments