@@ -1022,6 +1022,37 @@ describe("ClineProvider - Parallel Mode Support", () => {
10221022 } )
10231023 } )
10241024
1025+ describe ( "provider profile activation" , ( ) => {
1026+ it ( "should sync view-local apiConfiguration when activating an upserted profile" , async ( ) => {
1027+ const provider = new ClineProvider ( mockContext , mockOutputChannel , "sidebar" , new ContextProxy ( mockContext ) )
1028+ await ( provider as any ) . saveViewState ( "apiConfiguration" , {
1029+ apiProvider : "openrouter" ,
1030+ openRouterModelId : "openai/gpt-4.1" ,
1031+ } )
1032+
1033+ const providerSettings = {
1034+ apiProvider : "zai" as const ,
1035+ zaiApiKey : "mock-key" ,
1036+ zaiApiLine : "international_api" as const ,
1037+ apiModelId : "glm-5.1" ,
1038+ }
1039+ vi . spyOn ( provider . providerSettingsManager , "saveConfig" ) . mockResolvedValue ( "zai-profile-id" )
1040+ vi . spyOn ( provider . providerSettingsManager , "listConfig" ) . mockResolvedValue ( [
1041+ { name : "default" , id : "zai-profile-id" , apiProvider : "zai" } ,
1042+ ] )
1043+
1044+ await provider . upsertProviderProfile ( "default" , providerSettings , true )
1045+
1046+ const state = await provider . getState ( )
1047+ expect ( state . currentApiConfigName ) . toBe ( "default" )
1048+ expect ( state . apiConfiguration ) . toMatchObject ( providerSettings )
1049+ expect ( state . apiConfiguration . apiProvider ) . toBe ( "zai" )
1050+ expect ( ( provider as any ) . viewLocalState . apiConfiguration ) . toMatchObject ( providerSettings )
1051+
1052+ await provider . dispose ( )
1053+ } )
1054+ } )
1055+
10251056 describe ( "_clearViewLocalState" , ( ) => {
10261057 it ( "should clear all view-local state values" , async ( ) => {
10271058 const provider = new ClineProvider ( mockContext , mockOutputChannel , "sidebar" , new ContextProxy ( mockContext ) )
0 commit comments