@@ -1174,6 +1174,37 @@ describe("ClineProvider - Parallel Mode Support", () => {
11741174 } )
11751175 } )
11761176
1177+ describe ( "provider profile activation" , ( ) => {
1178+ it ( "should sync view-local apiConfiguration when activating an upserted profile" , async ( ) => {
1179+ const provider = new ClineProvider ( mockContext , mockOutputChannel , "sidebar" , new ContextProxy ( mockContext ) )
1180+ await ( provider as any ) . saveViewState ( "apiConfiguration" , {
1181+ apiProvider : "openrouter" ,
1182+ openRouterModelId : "openai/gpt-4.1" ,
1183+ } )
1184+
1185+ const providerSettings = {
1186+ apiProvider : "zai" as const ,
1187+ zaiApiKey : "mock-key" ,
1188+ zaiApiLine : "international_api" as const ,
1189+ apiModelId : "glm-5.1" ,
1190+ }
1191+ vi . spyOn ( provider . providerSettingsManager , "saveConfig" ) . mockResolvedValue ( "zai-profile-id" )
1192+ vi . spyOn ( provider . providerSettingsManager , "listConfig" ) . mockResolvedValue ( [
1193+ { name : "default" , id : "zai-profile-id" , apiProvider : "zai" } ,
1194+ ] )
1195+
1196+ await provider . upsertProviderProfile ( "default" , providerSettings , true )
1197+
1198+ const state = await provider . getState ( )
1199+ expect ( state . currentApiConfigName ) . toBe ( "default" )
1200+ expect ( state . apiConfiguration ) . toMatchObject ( providerSettings )
1201+ expect ( state . apiConfiguration . apiProvider ) . toBe ( "zai" )
1202+ expect ( ( provider as any ) . viewLocalState . apiConfiguration ) . toMatchObject ( providerSettings )
1203+
1204+ await provider . dispose ( )
1205+ } )
1206+ } )
1207+
11771208 describe ( "handleModeSwitch integration" , ( ) => {
11781209 it ( "should update viewLocalState.mode when handleModeSwitch is called" , async ( ) => {
11791210 const postMessage = vi . fn ( )
0 commit comments