diff --git a/webview-ui/src/components/settings/providers/__tests__/Bedrock.spec.tsx b/webview-ui/src/components/settings/providers/__tests__/Bedrock.spec.tsx
index a2f6774563..9b5e816bb7 100644
--- a/webview-ui/src/components/settings/providers/__tests__/Bedrock.spec.tsx
+++ b/webview-ui/src/components/settings/providers/__tests__/Bedrock.spec.tsx
@@ -59,17 +59,29 @@ vi.mock("@src/i18n/TranslationContext", () => ({
}),
}))
+// Store mock callbacks globally for test access
+const mockSelectCallbacks: { [key: string]: any } = {}
+
// Mock the UI components
vi.mock("@src/components/ui", () => ({
- Select: ({ children, onValueChange }: any) => {
- // Store the onValueChange callback on the window for testing
+ Select: ({ children, onValueChange, value }: any) => {
+ // Store the onValueChange callback on the window for testing (for new tests)
if (typeof window !== "undefined") {
;(window as any).__selectOnValueChange = onValueChange
}
- return
{children}
+ // Also store the callback for test access (for existing tests)
+ if (onValueChange) {
+ mockSelectCallbacks.onValueChange = onValueChange
+ }
+
+ return (
+
+ {children}
+
+ )
},
SelectContent: ({ children }: any) => {children}
,
- SelectItem: () => Item
,
+ SelectItem: ({ value }: any) => Item
,
SelectTrigger: ({ children }: any) => {children}
,
SelectValue: () => Value
,
StandardTooltip: ({ children }: any) => {children}
,
@@ -451,13 +463,12 @@ describe("Bedrock Component", () => {
// Custom region input should not be visible initially
expect(screen.queryByTestId("custom-region-input")).not.toBeInTheDocument()
- // Mock the Select component to simulate selecting "custom"
- // Since we're mocking the Select component, we need to simulate the onValueChange call
- const selectComponent = screen.getByRole("combobox", { hidden: true })
- if (selectComponent) {
- // Simulate selecting "custom" region
- const onValueChange = (selectComponent as any).onValueChange || (() => {})
- onValueChange("custom")
+ // Verify the Select component is rendered
+ expect(screen.getByTestId("select-component")).toBeInTheDocument()
+
+ // Call the onValueChange callback directly
+ if (mockSelectCallbacks.onValueChange) {
+ mockSelectCallbacks.onValueChange("custom")
}
// Verify that setApiConfigurationField was called with "custom"
@@ -482,11 +493,12 @@ describe("Bedrock Component", () => {
expect(screen.getByTestId("custom-region-input")).toBeInTheDocument()
expect(screen.getByTestId("custom-region-input")).toHaveValue("us-west-3")
- // Mock selecting a standard region
- const selectComponent = screen.getByRole("combobox", { hidden: true })
- if (selectComponent) {
- const onValueChange = (selectComponent as any).onValueChange || (() => {})
- onValueChange("us-east-1")
+ // Verify the Select component is rendered
+ expect(screen.getByTestId("select-component")).toBeInTheDocument()
+
+ // Call the onValueChange callback directly
+ if (mockSelectCallbacks.onValueChange) {
+ mockSelectCallbacks.onValueChange("us-east-1")
}
// Verify that both awsRegion and awsCustomRegion were updated