@@ -56,6 +56,20 @@ describe("Gemini", () => {
5656 expect ( checkbox . checked ) . toBe ( false )
5757 } )
5858
59+ it ( "should render URL context checkbox unchecked when enableUrlContext is undefined" , ( ) => {
60+ const apiConfiguration : ProviderSettings = {
61+ geminiApiKey : "" ,
62+ // enableUrlContext is undefined
63+ }
64+ render (
65+ < Gemini apiConfiguration = { apiConfiguration } setApiConfigurationField = { mockSetApiConfigurationField } /> ,
66+ )
67+
68+ const urlContextCheckbox = screen . getByTestId ( "checkbox-url-context" )
69+ const checkbox = urlContextCheckbox . querySelector ( "input[type='checkbox']" ) as HTMLInputElement
70+ expect ( checkbox . checked ) . toBe ( false )
71+ } )
72+
5973 it ( "should render URL context checkbox checked when enableUrlContext is true" , ( ) => {
6074 const apiConfiguration = { ...defaultApiConfiguration , enableUrlContext : true }
6175 render (
@@ -83,6 +97,24 @@ describe("Gemini", () => {
8397
8498 expect ( mockSetApiConfigurationField ) . toHaveBeenCalledWith ( "enableUrlContext" , true )
8599 } )
100+
101+ it ( "should call setApiConfigurationField when toggled from undefined state" , async ( ) => {
102+ const user = userEvent . setup ( )
103+ const apiConfiguration : ProviderSettings = {
104+ geminiApiKey : "" ,
105+ // enableUrlContext is undefined
106+ }
107+ render (
108+ < Gemini apiConfiguration = { apiConfiguration } setApiConfigurationField = { mockSetApiConfigurationField } /> ,
109+ )
110+
111+ const urlContextCheckbox = screen . getByTestId ( "checkbox-url-context" )
112+ const checkbox = urlContextCheckbox . querySelector ( "input[type='checkbox']" ) as HTMLInputElement
113+
114+ await user . click ( checkbox )
115+
116+ expect ( mockSetApiConfigurationField ) . toHaveBeenCalledWith ( "enableUrlContext" , true )
117+ } )
86118 } )
87119
88120 describe ( "Grounding with Google Search Checkbox" , ( ) => {
@@ -99,6 +131,20 @@ describe("Gemini", () => {
99131 expect ( checkbox . checked ) . toBe ( false )
100132 } )
101133
134+ it ( "should render grounding search checkbox unchecked when enableGrounding is undefined" , ( ) => {
135+ const apiConfiguration : ProviderSettings = {
136+ geminiApiKey : "" ,
137+ // enableGrounding is undefined
138+ }
139+ render (
140+ < Gemini apiConfiguration = { apiConfiguration } setApiConfigurationField = { mockSetApiConfigurationField } /> ,
141+ )
142+
143+ const groundingCheckbox = screen . getByTestId ( "checkbox-grounding-search" )
144+ const checkbox = groundingCheckbox . querySelector ( "input[type='checkbox']" ) as HTMLInputElement
145+ expect ( checkbox . checked ) . toBe ( false )
146+ } )
147+
102148 it ( "should render grounding search checkbox checked when enableGrounding is true" , ( ) => {
103149 const apiConfiguration = { ...defaultApiConfiguration , enableGrounding : true }
104150 render (
@@ -126,6 +172,24 @@ describe("Gemini", () => {
126172
127173 expect ( mockSetApiConfigurationField ) . toHaveBeenCalledWith ( "enableGrounding" , true )
128174 } )
175+
176+ it ( "should call setApiConfigurationField when toggled from undefined state" , async ( ) => {
177+ const user = userEvent . setup ( )
178+ const apiConfiguration : ProviderSettings = {
179+ geminiApiKey : "" ,
180+ // enableGrounding is undefined
181+ }
182+ render (
183+ < Gemini apiConfiguration = { apiConfiguration } setApiConfigurationField = { mockSetApiConfigurationField } /> ,
184+ )
185+
186+ const groundingCheckbox = screen . getByTestId ( "checkbox-grounding-search" )
187+ const checkbox = groundingCheckbox . querySelector ( "input[type='checkbox']" ) as HTMLInputElement
188+
189+ await user . click ( checkbox )
190+
191+ expect ( mockSetApiConfigurationField ) . toHaveBeenCalledWith ( "enableGrounding" , true )
192+ } )
129193 } )
130194
131195 describe ( "fromWelcomeView prop" , ( ) => {
0 commit comments