diff --git a/webview-ui/src/components/settings/providers/Gemini.tsx b/webview-ui/src/components/settings/providers/Gemini.tsx
index ec2e19353c..f995054437 100644
--- a/webview-ui/src/components/settings/providers/Gemini.tsx
+++ b/webview-ui/src/components/settings/providers/Gemini.tsx
@@ -79,7 +79,7 @@ export const Gemini = ({ apiConfiguration, setApiConfigurationField, fromWelcome
setApiConfigurationField("enableUrlContext", checked)}>
{t("settings:providers.geminiParameters.urlContext.title")}
@@ -89,7 +89,7 @@ export const Gemini = ({ apiConfiguration, setApiConfigurationField, fromWelcome
setApiConfigurationField("enableGrounding", checked)}>
{t("settings:providers.geminiParameters.groundingSearch.title")}
diff --git a/webview-ui/src/components/settings/providers/Vertex.tsx b/webview-ui/src/components/settings/providers/Vertex.tsx
index 1a57f4fa5e..81ae82a2b2 100644
--- a/webview-ui/src/components/settings/providers/Vertex.tsx
+++ b/webview-ui/src/components/settings/providers/Vertex.tsx
@@ -98,7 +98,7 @@ export const Vertex = ({ apiConfiguration, setApiConfigurationField, fromWelcome
setApiConfigurationField("enableUrlContext", checked)}>
{t("settings:providers.geminiParameters.urlContext.title")}
@@ -108,7 +108,7 @@ export const Vertex = ({ apiConfiguration, setApiConfigurationField, fromWelcome
setApiConfigurationField("enableGrounding", checked)}>
{t("settings:providers.geminiParameters.groundingSearch.title")}
diff --git a/webview-ui/src/components/settings/providers/__tests__/Gemini.spec.tsx b/webview-ui/src/components/settings/providers/__tests__/Gemini.spec.tsx
index eaa540c5fb..3d0e45f6fb 100644
--- a/webview-ui/src/components/settings/providers/__tests__/Gemini.spec.tsx
+++ b/webview-ui/src/components/settings/providers/__tests__/Gemini.spec.tsx
@@ -56,6 +56,20 @@ describe("Gemini", () => {
expect(checkbox.checked).toBe(false)
})
+ it("should render URL context checkbox unchecked when enableUrlContext is undefined", () => {
+ const apiConfiguration: ProviderSettings = {
+ geminiApiKey: "",
+ // enableUrlContext is undefined
+ }
+ render(
+ ,
+ )
+
+ const urlContextCheckbox = screen.getByTestId("checkbox-url-context")
+ const checkbox = urlContextCheckbox.querySelector("input[type='checkbox']") as HTMLInputElement
+ expect(checkbox.checked).toBe(false)
+ })
+
it("should render URL context checkbox checked when enableUrlContext is true", () => {
const apiConfiguration = { ...defaultApiConfiguration, enableUrlContext: true }
render(
@@ -83,6 +97,24 @@ describe("Gemini", () => {
expect(mockSetApiConfigurationField).toHaveBeenCalledWith("enableUrlContext", true)
})
+
+ it("should call setApiConfigurationField when toggled from undefined state", async () => {
+ const user = userEvent.setup()
+ const apiConfiguration: ProviderSettings = {
+ geminiApiKey: "",
+ // enableUrlContext is undefined
+ }
+ render(
+ ,
+ )
+
+ const urlContextCheckbox = screen.getByTestId("checkbox-url-context")
+ const checkbox = urlContextCheckbox.querySelector("input[type='checkbox']") as HTMLInputElement
+
+ await user.click(checkbox)
+
+ expect(mockSetApiConfigurationField).toHaveBeenCalledWith("enableUrlContext", true)
+ })
})
describe("Grounding with Google Search Checkbox", () => {
@@ -99,6 +131,20 @@ describe("Gemini", () => {
expect(checkbox.checked).toBe(false)
})
+ it("should render grounding search checkbox unchecked when enableGrounding is undefined", () => {
+ const apiConfiguration: ProviderSettings = {
+ geminiApiKey: "",
+ // enableGrounding is undefined
+ }
+ render(
+ ,
+ )
+
+ const groundingCheckbox = screen.getByTestId("checkbox-grounding-search")
+ const checkbox = groundingCheckbox.querySelector("input[type='checkbox']") as HTMLInputElement
+ expect(checkbox.checked).toBe(false)
+ })
+
it("should render grounding search checkbox checked when enableGrounding is true", () => {
const apiConfiguration = { ...defaultApiConfiguration, enableGrounding: true }
render(
@@ -126,6 +172,24 @@ describe("Gemini", () => {
expect(mockSetApiConfigurationField).toHaveBeenCalledWith("enableGrounding", true)
})
+
+ it("should call setApiConfigurationField when toggled from undefined state", async () => {
+ const user = userEvent.setup()
+ const apiConfiguration: ProviderSettings = {
+ geminiApiKey: "",
+ // enableGrounding is undefined
+ }
+ render(
+ ,
+ )
+
+ const groundingCheckbox = screen.getByTestId("checkbox-grounding-search")
+ const checkbox = groundingCheckbox.querySelector("input[type='checkbox']") as HTMLInputElement
+
+ await user.click(checkbox)
+
+ expect(mockSetApiConfigurationField).toHaveBeenCalledWith("enableGrounding", true)
+ })
})
describe("fromWelcomeView prop", () => {