@@ -73,7 +73,7 @@ describe("ModelPicker", () => {
7373
7474 await act ( async ( ) => {
7575 // Open the popover by clicking the button.
76- const button = screen . getByRole ( "combobox ")
76+ const button = screen . getByTestId ( "model-picker-button ")
7777 fireEvent . click ( button )
7878 } )
7979
@@ -91,7 +91,7 @@ describe("ModelPicker", () => {
9191 // Need to find and click the CommandItem to trigger onSelect
9292 await act ( async ( ) => {
9393 // Find the CommandItem for model2 and click it
94- const modelItem = screen . getByText ( " model2")
94+ const modelItem = screen . getByTestId ( "model-option- model2")
9595 fireEvent . click ( modelItem )
9696 } )
9797
@@ -104,7 +104,7 @@ describe("ModelPicker", () => {
104104
105105 await act ( async ( ) => {
106106 // Open the popover by clicking the button.
107- const button = screen . getByRole ( "combobox ")
107+ const button = screen . getByTestId ( "model-picker-button ")
108108 fireEvent . click ( button )
109109 } )
110110
@@ -154,6 +154,7 @@ describe("ModelPicker", () => {
154154 } )
155155
156156 // Check that the error message is displayed
157+ expect ( screen . getByTestId ( "api-error-message" ) ) . toBeInTheDocument ( )
157158 expect ( screen . getByText ( errorMessage ) ) . toBeInTheDocument ( )
158159 } )
159160
@@ -180,13 +181,13 @@ describe("ModelPicker", () => {
180181 } )
181182
182183 // Check that both the model selector and error message are present
183- const modelSelector = screen . getByRole ( "combobox" )
184+ const modelSelector = screen . getByTestId ( "model-picker-button" )
185+ const errorContainer = screen . getByTestId ( "api-error-message" )
184186 const errorElement = screen . getByText ( errorMessage )
185187
186188 expect ( modelSelector ) . toBeInTheDocument ( )
189+ expect ( errorContainer ) . toBeInTheDocument ( )
187190 expect ( errorElement ) . toBeInTheDocument ( )
188-
189- // Verify the error message is rendered (positioning is handled by CSS)
190191 expect ( errorElement ) . toBeVisible ( )
191192 } )
192193
@@ -201,6 +202,7 @@ describe("ModelPicker", () => {
201202 )
202203
203204 // Check initial error is displayed
205+ expect ( screen . getByTestId ( "api-error-message" ) ) . toBeInTheDocument ( )
204206 expect ( screen . getByText ( initialError ) ) . toBeInTheDocument ( )
205207
206208 // Update the error message
@@ -211,6 +213,7 @@ describe("ModelPicker", () => {
211213 )
212214
213215 // Check that the error message has been updated
216+ expect ( screen . getByTestId ( "api-error-message" ) ) . toBeInTheDocument ( )
214217 expect ( screen . queryByText ( initialError ) ) . not . toBeInTheDocument ( )
215218 expect ( screen . getByText ( updatedError ) ) . toBeInTheDocument ( )
216219 } )
@@ -225,6 +228,7 @@ describe("ModelPicker", () => {
225228 )
226229
227230 // Check error is initially displayed
231+ expect ( screen . getByTestId ( "api-error-message" ) ) . toBeInTheDocument ( )
228232 expect ( screen . getByText ( errorMessage ) ) . toBeInTheDocument ( )
229233
230234 // Remove the error message
@@ -235,6 +239,7 @@ describe("ModelPicker", () => {
235239 )
236240
237241 // Check that the error message has been removed
242+ expect ( screen . queryByTestId ( "api-error-message" ) ) . not . toBeInTheDocument ( )
238243 expect ( screen . queryByText ( errorMessage ) ) . not . toBeInTheDocument ( )
239244 } )
240245 } )
0 commit comments