@@ -1038,6 +1038,37 @@ describe("ClineProvider - Parallel Mode Support", () => {
10381038 } )
10391039 } )
10401040
1041+ describe ( "provider profile activation" , ( ) => {
1042+ it ( "should sync view-local apiConfiguration when activating an upserted profile" , async ( ) => {
1043+ const provider = new ClineProvider ( mockContext , mockOutputChannel , "sidebar" , new ContextProxy ( mockContext ) )
1044+ await ( provider as any ) . saveViewState ( "apiConfiguration" , {
1045+ apiProvider : "openrouter" ,
1046+ openRouterModelId : "openai/gpt-4.1" ,
1047+ } )
1048+
1049+ const providerSettings = {
1050+ apiProvider : "zai" as const ,
1051+ zaiApiKey : "mock-key" ,
1052+ zaiApiLine : "international_api" as const ,
1053+ apiModelId : "glm-5.1" ,
1054+ }
1055+ vi . spyOn ( provider . providerSettingsManager , "saveConfig" ) . mockResolvedValue ( "zai-profile-id" )
1056+ vi . spyOn ( provider . providerSettingsManager , "listConfig" ) . mockResolvedValue ( [
1057+ { name : "default" , id : "zai-profile-id" , apiProvider : "zai" } ,
1058+ ] )
1059+
1060+ await provider . upsertProviderProfile ( "default" , providerSettings , true )
1061+
1062+ const state = await provider . getState ( )
1063+ expect ( state . currentApiConfigName ) . toBe ( "default" )
1064+ expect ( state . apiConfiguration ) . toMatchObject ( providerSettings )
1065+ expect ( state . apiConfiguration . apiProvider ) . toBe ( "zai" )
1066+ expect ( ( provider as any ) . viewLocalState . apiConfiguration ) . toMatchObject ( providerSettings )
1067+
1068+ await provider . dispose ( )
1069+ } )
1070+ } )
1071+
10411072 describe ( "handleModeSwitch integration" , ( ) => {
10421073 it ( "should update viewLocalState.mode when handleModeSwitch is called" , async ( ) => {
10431074 const postMessage = vi . fn ( )
0 commit comments