@@ -2,7 +2,7 @@ import { render, screen } from "@testing-library/react"
22import userEvent from "@testing-library/user-event"
33import { Vertex } from "../Vertex"
44import type { ProviderSettings } from "@roo-code/types"
5- import { VERTEX_REGIONS } from "@roo-code/types"
5+ import { ANTHROPIC_VERTEX_1M_CONTEXT_MODEL_ID , VERTEX_REGIONS } from "@roo-code/types"
66
77vi . mock ( "@vscode/webview-ui-toolkit/react" , ( ) => ( {
88 VSCodeTextField : ( { children, value, onInput, type } : any ) => (
@@ -282,4 +282,80 @@ describe("Vertex", () => {
282282 expect ( mockSetApiConfigurationField ) . toHaveBeenCalledTimes ( 2 )
283283 } )
284284 } )
285+
286+ describe ( "1M Context Checkbox" , ( ) => {
287+ it ( "should render 1M context checkbox unchecked by default for Claude Sonnet 4" , ( ) => {
288+ const apiConfiguration = {
289+ ...defaultApiConfiguration ,
290+ apiModelId : ANTHROPIC_VERTEX_1M_CONTEXT_MODEL_ID ,
291+ }
292+ render (
293+ < Vertex apiConfiguration = { apiConfiguration } setApiConfigurationField = { mockSetApiConfigurationField } /> ,
294+ )
295+
296+ const oneMContextCheckbox = screen . getByTestId ( "checkbox-1m-context" )
297+ const checkbox = oneMContextCheckbox . querySelector ( "input[type='checkbox']" ) as HTMLInputElement
298+ expect ( checkbox . checked ) . toBe ( false )
299+ } )
300+
301+ it ( "should NOT render 1M context checkbox for other models" , ( ) => {
302+ const apiConfiguration = { ...defaultApiConfiguration , apiModelId : "gemini-2.0-flash-001" }
303+ render (
304+ < Vertex apiConfiguration = { apiConfiguration } setApiConfigurationField = { mockSetApiConfigurationField } /> ,
305+ )
306+
307+ const oneMContextCheckbox = screen . queryByTestId ( "checkbox-1m-context" )
308+ expect ( oneMContextCheckbox ) . toBeNull ( )
309+ } )
310+
311+ it ( "should NOT render 1M context checkbox when fromWelcomeView is true" , ( ) => {
312+ const apiConfiguration = {
313+ ...defaultApiConfiguration ,
314+ apiModelId : ANTHROPIC_VERTEX_1M_CONTEXT_MODEL_ID ,
315+ }
316+ render (
317+ < Vertex
318+ apiConfiguration = { apiConfiguration }
319+ setApiConfigurationField = { mockSetApiConfigurationField }
320+ fromWelcomeView = { true }
321+ /> ,
322+ )
323+
324+ const oneMContextCheckbox = screen . queryByTestId ( "checkbox-1m-context" )
325+ expect ( oneMContextCheckbox ) . toBeNull ( )
326+ } )
327+
328+ it ( "should render 1M context checkbox checked when vertex1MContext is true for Claude Sonnet 4" , ( ) => {
329+ const apiConfiguration = {
330+ ...defaultApiConfiguration ,
331+ vertex1MContext : true ,
332+ apiModelId : ANTHROPIC_VERTEX_1M_CONTEXT_MODEL_ID ,
333+ }
334+ render (
335+ < Vertex apiConfiguration = { apiConfiguration } setApiConfigurationField = { mockSetApiConfigurationField } /> ,
336+ )
337+
338+ const oneMContextCheckbox = screen . getByTestId ( "checkbox-1m-context" )
339+ const checkbox = oneMContextCheckbox . querySelector ( "input[type='checkbox']" ) as HTMLInputElement
340+ expect ( checkbox . checked ) . toBe ( true )
341+ } )
342+
343+ it ( "should call setApiConfigurationField with correct parameters when 1M context checkbox is toggled" , async ( ) => {
344+ const user = userEvent . setup ( )
345+ const apiConfiguration = {
346+ ...defaultApiConfiguration ,
347+ apiModelId : ANTHROPIC_VERTEX_1M_CONTEXT_MODEL_ID ,
348+ }
349+ render (
350+ < Vertex apiConfiguration = { apiConfiguration } setApiConfigurationField = { mockSetApiConfigurationField } /> ,
351+ )
352+
353+ const oneMContextCheckbox = screen . getByTestId ( "checkbox-1m-context" )
354+ const checkbox = oneMContextCheckbox . querySelector ( "input[type='checkbox']" ) as HTMLInputElement
355+
356+ await user . click ( checkbox )
357+
358+ expect ( mockSetApiConfigurationField ) . toHaveBeenCalledWith ( "vertex1MContext" , true )
359+ } )
360+ } )
285361} )
0 commit comments