File tree Expand file tree Collapse file tree 2 files changed +13
-4
lines changed
webview-ui/src/components/settings Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -130,6 +130,7 @@ export const ModelPicker = ({
130130 onValueChange = { setSearchValue }
131131 placeholder = "Search"
132132 className = "h-9 mr-4"
133+ data-testid = "model-input"
133134 />
134135 { searchValue . length > 0 && (
135136 < div className = "absolute right-2 top-0 bottom-0 flex items-center justify-center" >
Original file line number Diff line number Diff line change 1- // cd webview-ui && npx jest src/components/settings/__tests__/ModelPicker.test.ts
1+ // npx jest src/components/settings/__tests__/ModelPicker.test.ts
22
33import { screen , fireEvent , render } from "@testing-library/react"
44import { act } from "react"
5+
56import { ModelPicker } from "../ModelPicker"
67
78jest . mock ( "../../../context/ExtensionStateContext" , ( ) => ( {
@@ -69,9 +70,16 @@ describe("ModelPicker", () => {
6970 } )
7071
7172 await act ( async ( ) => {
72- // Find and click the model item by its value.
73- const modelItem = screen . getByTestId ( "model-input" )
74- fireEvent . input ( modelItem , { target : { value : "model2" } } )
73+ // Find and set the input value
74+ const modelInput = screen . getByTestId ( "model-input" )
75+ fireEvent . input ( modelInput , { target : { value : "model2" } } )
76+ } )
77+
78+ // Need to find and click the CommandItem to trigger onSelect
79+ await act ( async ( ) => {
80+ // Find the CommandItem for model2 and click it
81+ const modelItem = screen . getByText ( "model2" )
82+ fireEvent . click ( modelItem )
7583 } )
7684
7785 // Verify the API config was updated.
You can’t perform that action at this time.
0 commit comments