@@ -2343,8 +2343,23 @@ describe.concurrent("handleModelApi", () => {
23432343 it . concurrent ( "list 应返回去掉 apiKey 的模型列表" , async ( ) => {
23442344 const { service, mockModelRepo } = createTestService ( ) ;
23452345 mockModelRepo . listModels . mockResolvedValueOnce ( [
2346- { id : "m1" , name : "GPT-4o" , provider : "openai" , apiBaseUrl : "https://api.openai.com" , apiKey : "sk-secret" , model : "gpt-4o" } ,
2347- { id : "m2" , name : "Claude" , provider : "anthropic" , apiBaseUrl : "https://api.anthropic.com" , apiKey : "ant-secret" , model : "claude-sonnet-4-20250514" , maxTokens : 4096 } ,
2346+ {
2347+ id : "m1" ,
2348+ name : "GPT-4o" ,
2349+ provider : "openai" ,
2350+ apiBaseUrl : "https://api.openai.com" ,
2351+ apiKey : "sk-secret" ,
2352+ model : "gpt-4o" ,
2353+ } ,
2354+ {
2355+ id : "m2" ,
2356+ name : "Claude" ,
2357+ provider : "anthropic" ,
2358+ apiBaseUrl : "https://api.anthropic.com" ,
2359+ apiKey : "ant-secret" ,
2360+ model : "claude-sonnet-4-20250514" ,
2361+ maxTokens : 4096 ,
2362+ } ,
23482363 ] ) ;
23492364
23502365 const result = await service . handleModelApi ( { action : "list" , scriptUuid : "test" } ) ;
@@ -2358,14 +2373,32 @@ describe.concurrent("handleModelApi", () => {
23582373 }
23592374
23602375 // 其他字段保留
2361- expect ( models [ 0 ] ) . toEqual ( { id : "m1" , name : "GPT-4o" , provider : "openai" , apiBaseUrl : "https://api.openai.com" , model : "gpt-4o" } ) ;
2362- expect ( models [ 1 ] ) . toEqual ( { id : "m2" , name : "Claude" , provider : "anthropic" , apiBaseUrl : "https://api.anthropic.com" , model : "claude-sonnet-4-20250514" , maxTokens : 4096 } ) ;
2376+ expect ( models [ 0 ] ) . toEqual ( {
2377+ id : "m1" ,
2378+ name : "GPT-4o" ,
2379+ provider : "openai" ,
2380+ apiBaseUrl : "https://api.openai.com" ,
2381+ model : "gpt-4o" ,
2382+ } ) ;
2383+ expect ( models [ 1 ] ) . toEqual ( {
2384+ id : "m2" ,
2385+ name : "Claude" ,
2386+ provider : "anthropic" ,
2387+ apiBaseUrl : "https://api.anthropic.com" ,
2388+ model : "claude-sonnet-4-20250514" ,
2389+ maxTokens : 4096 ,
2390+ } ) ;
23632391 } ) ;
23642392
23652393 it . concurrent ( "get 存在的模型应返回去掉 apiKey 的结果" , async ( ) => {
23662394 const { service, mockModelRepo } = createTestService ( ) ;
23672395 mockModelRepo . getModel . mockResolvedValueOnce ( {
2368- id : "m1" , name : "GPT-4o" , provider : "openai" , apiBaseUrl : "https://api.openai.com" , apiKey : "sk-secret" , model : "gpt-4o" ,
2396+ id : "m1" ,
2397+ name : "GPT-4o" ,
2398+ provider : "openai" ,
2399+ apiBaseUrl : "https://api.openai.com" ,
2400+ apiKey : "sk-secret" ,
2401+ model : "gpt-4o" ,
23692402 } ) ;
23702403
23712404 const result = await service . handleModelApi ( { action : "get" , id : "m1" , scriptUuid : "test" } ) ;
0 commit comments