@@ -1195,6 +1195,37 @@ describe("ClineProvider - Parallel Mode Support", () => {
11951195 } )
11961196 } )
11971197
1198+ describe ( "provider profile activation" , ( ) => {
1199+ it ( "should sync view-local apiConfiguration when activating an upserted profile" , async ( ) => {
1200+ const provider = new ClineProvider ( mockContext , mockOutputChannel , "sidebar" , new ContextProxy ( mockContext ) )
1201+ await ( provider as any ) . saveViewState ( "apiConfiguration" , {
1202+ apiProvider : "openrouter" ,
1203+ openRouterModelId : "openai/gpt-4.1" ,
1204+ } )
1205+
1206+ const providerSettings = {
1207+ apiProvider : "zai" as const ,
1208+ zaiApiKey : "mock-key" ,
1209+ zaiApiLine : "international_api" as const ,
1210+ apiModelId : "glm-5.1" ,
1211+ }
1212+ vi . spyOn ( provider . providerSettingsManager , "saveConfig" ) . mockResolvedValue ( "zai-profile-id" )
1213+ vi . spyOn ( provider . providerSettingsManager , "listConfig" ) . mockResolvedValue ( [
1214+ { name : "default" , id : "zai-profile-id" , apiProvider : "zai" } ,
1215+ ] )
1216+
1217+ await provider . upsertProviderProfile ( "default" , providerSettings , true )
1218+
1219+ const state = await provider . getState ( )
1220+ expect ( state . currentApiConfigName ) . toBe ( "default" )
1221+ expect ( state . apiConfiguration ) . toMatchObject ( providerSettings )
1222+ expect ( state . apiConfiguration . apiProvider ) . toBe ( "zai" )
1223+ expect ( ( provider as any ) . viewLocalState . apiConfiguration ) . toMatchObject ( providerSettings )
1224+
1225+ await provider . dispose ( )
1226+ } )
1227+ } )
1228+
11981229 describe ( "handleModeSwitch integration" , ( ) => {
11991230 it ( "should update viewLocalState.mode when handleModeSwitch is called" , async ( ) => {
12001231 const postMessage = vi . fn ( )
0 commit comments