@@ -32,6 +32,7 @@ vi.mock(import("./useScopedSettings"), async (original) => ({
3232 useScopedSettings : ( ( ) => ( {
3333 ...DEFAULT_UNIFIED_SETTINGS ,
3434 sourceControlWritingStyle : state . styles [ 0 ] ,
35+ providerInstances : state . providerInstances ,
3536 } ) ) as never ,
3637 useScopedSettingsMixed : ( keys ) =>
3738 ! keys . includes ( "reviewGuidesEnabled" ) &&
@@ -42,8 +43,12 @@ vi.mock(import("./SettingsScopeContext"), async (original) => ({
4243 ...( await original ( ) ) ,
4344 useSettingsScope : ( ( ) => ( {
4445 scope : { kind : "all" , environmentIds : [ ] } ,
45- environment : null ,
46- connectedEnvironments : [ ] ,
46+ environment : { environmentId : EnvironmentId . make ( "representative" ) , serverConfig : { } } ,
47+ connectedEnvironments : [ ...state . providers . keys ( ) ] . map ( ( environmentId ) => ( {
48+ environmentId,
49+ serverConfig : { } ,
50+ } ) ) ,
51+ representative : { environmentId : EnvironmentId . make ( "representative" ) } ,
4752 targets : state . styles . map ( ( style , index ) => ( {
4853 environmentId : EnvironmentId . make ( `environment-${ index } ` ) ,
4954 settings : {
@@ -138,6 +143,7 @@ describe("mixed source control instructions", () => {
138143} ) ;
139144
140145it ( "rejects a scoped model when another environment requires extensions for it" , async ( ) => {
146+ state . updateSettings . mockReset ( ) ;
141147 state . styles = [ DEFAULT_UNIFIED_SETTINGS . sourceControlWritingStyle ] ;
142148 const instanceId = ProviderInstanceId . make ( "pi" ) ;
143149 state . providerInstances = {
@@ -157,6 +163,7 @@ it("rejects a scoped model when another environment requires extensions for it",
157163 models : [ { slug : "demo/model" , name : "Demo" , isCustom : false , capabilities : { } } ] ,
158164 } ;
159165 state . providers = new Map ( [
166+ [ EnvironmentId . make ( "representative" ) , [ provider ] ] ,
160167 [
161168 EnvironmentId . make ( "environment-0" ) ,
162169 [
@@ -184,7 +191,18 @@ it("rejects a scoped model when another environment requires extensions for it",
184191 </ >
185192 ) ;
186193 }
187- await using screen = await render ( < Availability /> ) ;
194+ const availability = ( ) => (
195+ < >
196+ < Availability />
197+ < SourceControlWritingSettingsSection />
198+ </ >
199+ ) ;
200+ await using screen = await render ( availability ( ) ) ;
201+ await userEvent . click ( screen . getByRole ( "button" , { name : "Advanced" } ) ) ;
202+ await userEvent . click (
203+ screen . getByRole ( "switch" , { name : "Use a separate source control writer model" } ) ,
204+ ) ;
205+ expect ( state . updateSettings ) . not . toHaveBeenCalled ( ) ;
188206 await expect . element ( screen . getByText ( "Available for threads" ) ) . toBeVisible ( ) ;
189207 await expect
190208 . element (
@@ -193,4 +211,15 @@ it("rejects a scoped model when another environment requires extensions for it",
193211 ) ,
194212 )
195213 . toBeVisible ( ) ;
214+ state . providers = new Map ( [
215+ [ EnvironmentId . make ( "representative" ) , [ provider ] ] ,
216+ [ EnvironmentId . make ( "environment-0" ) , [ provider ] ] ,
217+ ] ) ;
218+ await screen . rerender ( availability ( ) ) ;
219+ await userEvent . click (
220+ screen . getByRole ( "switch" , { name : "Use a separate source control writer model" } ) ,
221+ ) ;
222+ expect ( state . updateSettings ) . toHaveBeenCalledWith ( {
223+ sourceControlWriterModelSelection : { instanceId, model : "demo/model" } ,
224+ } ) ;
196225} ) ;
0 commit comments