Files
llmgw/internal/web/images_test.go
T
Ilker ManapandClaude Opus 5.5 62db7c5586 A page that makes pictures, beside the chat
/images offers the models that make pictures, and the chat no longer
offers them. Like the chat, the browser holds a session and never a key;
the page's request is rebuilt from its own fields and sent down the path
every /v1/images/generations request takes. Size, how many, seed, steps
and a negative prompt; each picture shown with its seed, a download link
and a way to make it again. Nothing is kept but the usage. The menu
offers the page while some model makes pictures.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-09 22:24:43 +02:00

37 lines
1.2 KiB
Go

package web
import (
"net/http/httptest"
"strings"
"testing"
"gitea.mynodes.xyz/ilker/llmgw/internal/store"
)
func TestThePicturesPageDrawsInEveryLanguage(t *testing.T) {
for _, lang := range []string{"en", "tr"} {
req := httptest.NewRequest("GET", "/images", nil)
req.Header.Set("Accept-Language", lang)
rec := httptest.NewRecorder()
Images(store.User{Email: "a@b.c"}, []ChatModel{{Name: "flux-schnell", Hardware: []string{"6000-24g"}}},
[]ChatContext{{Value: "personal", Label: "Personal"}}, "personal", "v0")(rec, req)
if rec.Code != 200 {
t.Fatalf("%s: %d %s", lang, rec.Code, rec.Body.String())
}
page := rec.Body.String()
for _, want := range []string{`<option value="flux-schnell">`, `id="prompt"`, `/images/generate`} {
if !strings.Contains(page, want) {
t.Errorf("%s: %s missing", lang, want)
}
}
if strings.Contains(page, "images.") {
t.Errorf("%s: an untranslated key is on the page", lang)
}
}
rec := httptest.NewRecorder()
Images(store.User{}, nil, nil, "", "v0")(rec, httptest.NewRequest("GET", "/images", nil))
if !strings.Contains(rec.Body.String(), `class="empty"`) {
t.Error("no models, and the page does not say so")
}
}