Files
magpie/internal/gui/gateway_groups_test.go
T
yetone 30c072713d gui: the Gateway's models say what they take — reasoning levels, images, context at each row's end, in full in a tooltip — and the search finds a group by its models (ARNO on Discord: 希望网关里的模型列表支持搜索查找,支持显示模型或者模型组更多的信息,比如该支持的推理强度,是否支持图像等) — each model row on the Gateway page now ends, before its copy button, with small muted chips: the reasoning levels agents are offered ("low–xhigh", or "low / medium" for two; the levels kept, not all it has, and none for a model whose levels aren't known), a picture glyph when it accepts images, and its context ("400K", "1M"; the 1M badge after the name moved there). Their tooltip says it in full: "Reasoning: low, medium, high, xhigh", "Accepts images" or "Text only", "Context: 400,000 tokens". A routing group's are what agents are told of it, as of a model: /api/providers' gateway.groups now carry the catalog entry's efforts, images, context and output, and members (provider/model, in its order); its tooltip says images are every model's, the context the least of its models', its output, and names its models. The search (already there, shown from 8 models) shows from 5, has a tooltip saying what it matches, and also matches a group's models, so "kimi" finds the group sending to it. Strings in zh. TestGatewayGroupsSayWhatTheyTake checks a group's listed members and that its efforts, images, context and output are the catalog's; gateway-model-info.test.cjs (webkit) checks the chips and tooltips of models and a group, the search by id, name, provider and a group's models, Escape, and that a click on the chips picks the model without moving the row. Related GUI tests (gateway-*, click-scroll, list-sort, public-url, request-archive, sse-body, web-page, api-key-theme) pass; go vet, go build -tags nogui ./... and go test -tags nogui -count=1 ./... under a temp HOME pass but TestProvidersAnswerWhileListsComeIn, a timing test that passes alone.
2026-10-03 22:34:36 +08:00

56 lines
1.8 KiB
Go

package gui
import (
"os"
"slices"
"testing"
"github.com/yetone/magpie/internal/provider"
)
// The Gateway view's routing groups say what agents are told of them, as
// its models do — their reasoning levels, images, context and output — and
// name the models they send to, for the model list's tooltip and search
// (ARNO on Discord).
func TestGatewayGroupsSayWhatTheyTake(t *testing.T) {
t.Setenv("HOME", t.TempDir())
t.Setenv("USERPROFILE", os.Getenv("HOME"))
t.Setenv("XDG_CONFIG_HOME", t.TempDir())
t.Setenv("XDG_CACHE_HOME", t.TempDir())
for _, p := range []provider.Provider{
{ID: "ra", Name: "Relay A", Key: "k", Chat: "http://127.0.0.1:1/v1", Models: []string{"gpt-5.5"}},
{ID: "rb", Name: "Relay B", Key: "k", Chat: "http://127.0.0.1:1/v1", Models: []string{"gpt-5.5", "glm-5"}},
} {
if err := provider.Save(p); err != nil {
t.Fatal(err)
}
}
if err := provider.SaveGroup(provider.Group{ID: "mix", Name: "Mix", Members: []string{"ra/gpt-5.5:high", "rb/glm-5"}}); err != nil {
t.Fatal(err)
}
var entry provider.Entry
for _, e := range provider.Catalog() {
if e.ID == "group/mix" {
entry = e
}
}
if entry.ID == "" {
t.Fatal("group/mix isn't in the catalog")
}
var got *gwGroupJSON
for _, g := range providersState().Gateway.Groups {
if g.ID == "group/mix" {
got = &g
}
}
if got == nil {
t.Fatal("group/mix isn't listed")
}
if !slices.Equal(got.Members, []string{"ra/gpt-5.5", "rb/glm-5"}) {
t.Errorf("members %v", got.Members)
}
if !slices.Equal(got.Efforts, entry.Efforts) || got.Images != entry.Images || got.Context != entry.Context || got.Output != entry.Output {
t.Errorf("listed %v %v %d %d, the catalog says %v %v %d %d", got.Efforts, got.Images, got.Context, got.Output, entry.Efforts, entry.Images, entry.Context, entry.Output)
}
}