@@ -418,6 +418,121 @@ it("selects installed Goose with ACP arguments and saves its provider and model"
418418 ) ;
419419} ) ;
420420
421+ for ( const source of [ "saved" , "draft" ] as const ) {
422+ for ( const provider of [ "" , "openai" ] as const ) {
423+ it ( `browses Goose models with a ${ source } Databricks override and ${ provider || "blank" } selector` , async ( ) => {
424+ const run = vi . fn ( async ( ) => ( {
425+ host : "" ,
426+ models : [ { id : "catalog.schema.model" , name : "catalog.schema.model" } ] ,
427+ modelOverridden : false ,
428+ disconnected : false ,
429+ } ) ) ;
430+ setup ( "ready" , ( fixture ) => {
431+ Object . assign ( fixture . agent . harness , {
432+ command : "/fixture/bin/goose" ,
433+ args : [ "acp" ] ,
434+ provider,
435+ environmentKeys : source === "saved" ? [ "GOOSE_PROVIDER" ] : [ ] ,
436+ } ) ;
437+ fixture . data . harnessOptions ?. push ( {
438+ command : "/fixture/bin/goose" ,
439+ label : "Goose" ,
440+ available : true ,
441+ defaultArgs : [ "acp" ] ,
442+ providers : [ { value : "databricks_v2" , label : "Databricks v2" } ] ,
443+ } ) ;
444+ fixture . host . models = {
445+ begin : async ( ) => 1 ,
446+ cancel : async ( ) => { } ,
447+ run,
448+ } ;
449+ } ) ;
450+ const [ card ] = await screen . findAllByRole ( "article" , {
451+ name : "Agent Fixture agent" ,
452+ } ) ;
453+ if ( ! card ) throw Error ( "Missing managed card" ) ;
454+ fireEvent . click (
455+ within ( card ) . getByRole ( "button" , { name : "Actions for Fixture agent" } ) ,
456+ ) ;
457+ fireEvent . click ( await screen . findByRole ( "menuitem" , { name : "Edit" } ) ) ;
458+ const dialog = screen . getByRole ( "dialog" , { name : "Edit agent" } ) ;
459+ if ( source === "draft" ) {
460+ expect (
461+ within ( dialog ) . queryByRole ( "button" , { name : "Browse models" } ) ,
462+ ) . not . toBeInTheDocument ( ) ;
463+ fireEvent . click (
464+ within ( dialog ) . getByRole ( "button" , { name : "Environment" } ) ,
465+ ) ;
466+ fireEvent . change ( within ( dialog ) . getByLabelText ( "Variable name" ) , {
467+ target : { value : "GOOSE_PROVIDER" } ,
468+ } ) ;
469+ fireEvent . click (
470+ within ( dialog ) . getByRole ( "button" , { name : "Add variable" } ) ,
471+ ) ;
472+ fireEvent . change (
473+ within ( dialog ) . getByLabelText ( "Replacement for GOOSE_PROVIDER" ) ,
474+ { target : { value : "databricks_v2" } } ,
475+ ) ;
476+ }
477+ expect (
478+ within ( dialog ) . queryByRole ( "button" , { name : "Refresh models" } ) ,
479+ ) . not . toBeInTheDocument ( ) ;
480+ fireEvent . click (
481+ within ( dialog ) . getByRole ( "button" , { name : "Browse models" } ) ,
482+ ) ;
483+ await waitFor ( ( ) =>
484+ expect ( run ) . toHaveBeenCalledWith (
485+ 1 ,
486+ expect . objectContaining ( {
487+ action : "connect" ,
488+ edit : expect . objectContaining ( {
489+ harness : expect . objectContaining ( { provider } ) ,
490+ environment :
491+ source === "saved" ? { } : { GOOSE_PROVIDER : "databricks_v2" } ,
492+ } ) ,
493+ } ) ,
494+ ) ,
495+ ) ;
496+ } ) ;
497+ }
498+ }
499+
500+ it ( "uses a draft Goose provider override before the Databricks selector" , async ( ) => {
501+ setup ( "ready" , ( fixture ) => {
502+ Object . assign ( fixture . agent . harness , {
503+ command : "/fixture/bin/goose" ,
504+ args : [ "acp" ] ,
505+ provider : "databricks_v2" ,
506+ environmentKeys : [ ] ,
507+ } ) ;
508+ } ) ;
509+ const [ card ] = await screen . findAllByRole ( "article" , {
510+ name : "Agent Fixture agent" ,
511+ } ) ;
512+ if ( ! card ) throw Error ( "Missing managed card" ) ;
513+ fireEvent . click (
514+ within ( card ) . getByRole ( "button" , { name : "Actions for Fixture agent" } ) ,
515+ ) ;
516+ fireEvent . click ( await screen . findByRole ( "menuitem" , { name : "Edit" } ) ) ;
517+ const dialog = screen . getByRole ( "dialog" , { name : "Edit agent" } ) ;
518+ expect (
519+ within ( dialog ) . getByRole ( "button" , { name : "Browse models" } ) ,
520+ ) . toBeVisible ( ) ;
521+ fireEvent . click ( within ( dialog ) . getByRole ( "button" , { name : "Environment" } ) ) ;
522+ fireEvent . change ( within ( dialog ) . getByLabelText ( "Variable name" ) , {
523+ target : { value : "GOOSE_PROVIDER" } ,
524+ } ) ;
525+ fireEvent . click ( within ( dialog ) . getByRole ( "button" , { name : "Add variable" } ) ) ;
526+ fireEvent . change (
527+ within ( dialog ) . getByLabelText ( "Replacement for GOOSE_PROVIDER" ) ,
528+ { target : { value : "openai" } } ,
529+ ) ;
530+ expect (
531+ within ( dialog ) . queryByRole ( "button" , { name : "Browse models" } ) ,
532+ ) . not . toBeInTheDocument ( ) ;
533+ expect ( within ( dialog ) . getByLabelText ( "Model" ) ) . toBeVisible ( ) ;
534+ } ) ;
535+
421536it ( "creates a stopped Goose agent with the selected provider" , async ( ) => {
422537 vi . spyOn ( communityApi , "communityRequest" ) . mockResolvedValue ( { auth : [ ] } ) ;
423538 const commit = vi . fn ( ) ;
0 commit comments