@@ -167,10 +167,11 @@ describe('Roast API Integration Tests (Production Mock Mode)', () => {
167167 . set ( 'Authorization' , authToken )
168168 . send ( {
169169 text : 'Test with persona' ,
170- persona : {
170+ // Persona must be sent as JSON string per API spec
171+ persona : JSON . stringify ( {
171172 lo_que_me_define : 'Developer' ,
172173 lo_que_no_tolero : 'Bad code'
173- }
174+ } )
174175 } ) ;
175176
176177 expect ( response . status ) . toBe ( 200 ) ;
@@ -237,9 +238,11 @@ describe('Roast API Integration Tests (Production Mock Mode)', () => {
237238
238239 if ( response . status === 200 ) {
239240 expect ( response . body . success ) . toBe ( true ) ;
240- expect ( response . body ) . toHaveProperty ( 'plan' ) ;
241- expect ( response . body ) . toHaveProperty ( 'analysisCountRemaining' ) ;
242- expect ( response . body ) . toHaveProperty ( 'roastsRemaining' ) ;
241+ // Credits endpoint returns nested structure: { data: { plan, credits, status } }
242+ expect ( response . body . data ) . toHaveProperty ( 'plan' ) ;
243+ expect ( response . body . data ) . toHaveProperty ( 'credits' ) ;
244+ expect ( response . body . data . credits ) . toHaveProperty ( 'remaining' ) ;
245+ expect ( response . body . data . credits ) . toHaveProperty ( 'limit' ) ;
243246 }
244247 } ) ;
245248
@@ -357,7 +360,8 @@ describe('Roast API Integration Tests (Production Mock Mode)', () => {
357360 return ;
358361 }
359362
360- const beforeAnalysis = initialCredits . body . analysisCountRemaining ;
363+ // Access nested structure: data.credits.remaining
364+ const beforeAnalysis = initialCredits . body . data . credits . remaining ;
361365
362366 // Generate preview (consumes analysis credit)
363367 const preview = await request ( app )
@@ -375,9 +379,9 @@ describe('Roast API Integration Tests (Production Mock Mode)', () => {
375379 . set ( 'Authorization' , authToken ) ;
376380
377381 if ( afterCredits . status === 200 ) {
378- const afterAnalysis = afterCredits . body . analysisCountRemaining ;
382+ const afterAnalysis = afterCredits . body . data . credits . remaining ;
379383
380- // Analysis credit should be consumed
384+ // Analysis credit should be consumed (or remain same if unlimited)
381385 expect ( afterAnalysis ) . toBeLessThanOrEqual ( beforeAnalysis ) ;
382386 }
383387 } ) ;
0 commit comments