CI / test (push) Failing after 6m27s
A site whose catalog had no flux-schnell or triposr showed no Images or 3D page, and nothing said they were one click away. The cluster page now has a Pictures and 3D models card under the models: each preset, what it makes, the classes of card here it fits, whether and by whom it was added, and why the leader has not added it by itself; an Add button, which says first when it would install ComfyUI on the GPU nodes and restart the control planes; and the switch for presets.auto. The console's models screen shows the same under its table: A adds one, asking first in the same case, and P turns automatic adding on or off. `ctl model add PRESET` and `ctl model presets` go through the presets API, so the control plane keeps who added one, and `ctl model presets auto on|off` flips the setting; against a control plane from before, add sends the entry as v0.14.4 did. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
64 lines
2.1 KiB
Go
64 lines
2.1 KiB
Go
package cli
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
|
|
tea "github.com/charmbracelet/bubbletea"
|
|
|
|
"gitea.mynodes.xyz/ilker/llmgw/internal/control/adminapi"
|
|
)
|
|
|
|
func presetsHere() *adminapi.PresetsView {
|
|
return &adminapi.PresetsView{Auto: true, Presets: []adminapi.PresetView{
|
|
{Name: "flux-schnell", Makes: "pictures", Card: "cc 7.0+, 24 GB+", Fits: true, FitsClasses: []string{"v100-32g"},
|
|
Blocked: "the cluster installs no ComfyUI (engines.comfyui); adding it by hand sets that"},
|
|
{Name: "triposr", Makes: "meshes", Card: "cc 7.0+, 8 GB+", Fits: true, InCatalog: true, AddedBy: "auto"},
|
|
}}
|
|
}
|
|
|
|
func TestThePresetsAreOnTheModelsScreen(t *testing.T) {
|
|
m, _ := consoleWith(t, cModels)
|
|
m.data.presets = presetsHere()
|
|
v := m.View()
|
|
for _, want := range []string{"Pictures and 3D models that come with llmgw", "flux-schnell", "v100-32g",
|
|
"installs no ComfyUI", "added by itself", "P pictures and 3D"} {
|
|
if !strings.Contains(v, want) {
|
|
t.Errorf("%q not shown:\n%s", want, v)
|
|
}
|
|
}
|
|
// A control plane that cannot say shows none of it.
|
|
m.data.presets = nil
|
|
if v := m.View(); strings.Contains(v, "come with llmgw") || strings.Contains(v, "P pictures") {
|
|
t.Errorf("presets shown from nothing:\n%s", v)
|
|
}
|
|
}
|
|
|
|
func TestAPresetThatInstallsComfyUIIsAddedOnlyWhenConfirmed(t *testing.T) {
|
|
m, s := consoleWith(t, cModels)
|
|
m.data.presets = presetsHere()
|
|
var tm tea.Model = m
|
|
tm = press(tm, "a")
|
|
f := tm.(consoleModel).formD
|
|
if f == nil || !strings.Contains(f.fields[0].value(), "installs ComfyUI too") {
|
|
t.Fatalf("no add dialog saying what flux-schnell brings: %+v", f)
|
|
}
|
|
tm = press(tm, "enter", "enter", "enter")
|
|
if tm.(consoleModel).confirmD == nil || s.last() != "" {
|
|
t.Fatalf("added without asking: %q", s.last())
|
|
}
|
|
tm = pressRun(tm, "y")
|
|
if got := s.last(); got != "POST /api/v1/presets/flux-schnell {}" {
|
|
t.Fatalf("sent %q", got)
|
|
}
|
|
|
|
tm = press(tm, "esc", "p") // past what the add said
|
|
if c := tm.(consoleModel).confirmD; c == nil || !strings.HasPrefix(c.title, "Stop adding") {
|
|
t.Fatalf("P did not ask to stop: %+v", c)
|
|
}
|
|
_ = pressRun(tm, "y")
|
|
if got := s.last(); got != `PUT /api/v1/presets/auto {"on":false}` {
|
|
t.Fatalf("sent %q", got)
|
|
}
|
|
}
|