@@ -522,6 +522,39 @@ describe('/api/v1/chat/completions POST endpoint', () => {
522522 expect ( response . status ) . toBe ( 200 )
523523 } )
524524
525+ it ( 'lets a freebuff/free-mode request through even for a brand-new unpaid account' , async ( ) => {
526+ const req = new NextRequest (
527+ 'http://localhost:3000/api/v1/chat/completions' ,
528+ {
529+ method : 'POST' ,
530+ headers : { Authorization : 'Bearer test-api-key-new-free' } ,
531+ body : JSON . stringify ( {
532+ model : 'test/test-model' ,
533+ stream : false ,
534+ codebuff_metadata : {
535+ run_id : 'run-123' ,
536+ client_id : 'test-client-id-123' ,
537+ cost_mode : 'free' ,
538+ } ,
539+ } ) ,
540+ } ,
541+ )
542+
543+ const response = await postChatCompletions ( {
544+ req,
545+ getUserInfoFromApiKey : mockGetUserInfoFromApiKey ,
546+ logger : mockLogger ,
547+ trackEvent : mockTrackEvent ,
548+ getUserUsageData : mockGetUserUsageData ,
549+ getAgentRunFromId : mockGetAgentRunFromId ,
550+ fetch : mockFetch ,
551+ insertMessageBigquery : mockInsertMessageBigquery ,
552+ loggerWithContext : mockLoggerWithContext ,
553+ } )
554+
555+ expect ( response . status ) . toBe ( 200 )
556+ } )
557+
525558 it ( 'skips credit check when in FREE mode even with 0 credits' , async ( ) => {
526559 const req = new NextRequest (
527560 'http://localhost:3000/api/v1/chat/completions' ,
0 commit comments