99 "github.com/GrayCodeAI/hawk/internal/engine"
1010)
1111
12- func TestConfigGatewaysView_CatalogHeaderWithoutKeys (t * testing.T ) {
12+ func TestConfigGatewaysView_RequiresKeyForModelCounts (t * testing.T ) {
1313 hawkconfig .InvalidateConfigUICache ()
1414 store := & credentials.MapStore {}
1515 credentials .SetDefaultStore (store )
@@ -23,8 +23,11 @@ func TestConfigGatewaysView_CatalogHeaderWithoutKeys(t *testing.T) {
2323 if ! strings .Contains (view , "Catalog" ) {
2424 t .Fatalf ("expected Catalog column header, got:\n %s" , view )
2525 }
26- if ! strings .Contains (view , "add key in Keys tab" ) {
27- t .Fatalf ("expected keys hint without credentials, got:\n %s" , view )
26+ if ! strings .Contains (view , "key required" ) {
27+ t .Fatalf ("expected key-required model cells without credentials, got:\n %s" , view )
28+ }
29+ if ! strings .Contains (view , "Catalog count appears after a saved key" ) {
30+ t .Fatalf ("expected key requirement hint without credentials, got:\n %s" , view )
2831 }
2932}
3033
@@ -77,6 +80,38 @@ func TestConfigGatewayRefreshTargetIndex_UsesFocusOnRefreshRow(t *testing.T) {
7780 }
7881}
7982
83+ func TestFocusConfigActiveGateway_SelectsActiveRow (t * testing.T ) {
84+ hawkconfig .InvalidateConfigUICache ()
85+ store := & credentials.MapStore {}
86+ credentials .SetDefaultStore (store )
87+ t .Cleanup (func () {
88+ credentials .SetDefaultStore (nil )
89+ hawkconfig .InvalidateConfigUICache ()
90+ })
91+ _ = store .Set (t .Context (), credentials .AccountForEnv ("OPENROUTER_API_KEY" ), "sk-or-test-key-1234567890" )
92+ hawkconfig .InvalidateConfigUICache ()
93+
94+ sess := & engine.Session {}
95+ sess .SetProvider ("openrouter" )
96+ m := chatModel {
97+ configTab : configTabGateways ,
98+ session : sess ,
99+ configModelProvider : "openrouter" ,
100+ }
101+ next := m .focusConfigActiveGateway ()
102+ rows := next .configGatewayRows ()
103+ active := next .activeGatewayRowIndex (rows )
104+ if active < 0 {
105+ t .Fatal ("expected active gateway row" )
106+ }
107+ if next .configSel != active {
108+ t .Fatalf ("configSel = %d, want active row %d" , next .configSel , active )
109+ }
110+ if next .configScroll > next .configSel || next .configSel >= next .configScroll + configWindowSize {
111+ t .Fatalf ("active row not visible: sel=%d scroll=%d" , next .configSel , next .configScroll )
112+ }
113+ }
114+
80115func TestHandleConfigGatewaysSelect_NoKeyRedirectsToKeys (t * testing.T ) {
81116 hawkconfig .InvalidateConfigUICache ()
82117 store := & credentials.MapStore {}
0 commit comments