/3d beside /images, while some model makes meshes: a picture chosen, the
job asked for through the same path an API client's takes, its progress
shown (waiting for the card, n ahead; making it, the node and percent),
and the mesh in a viewer — model-viewer 4.4.0 (Apache 2.0, with three.js
and lit), served from the gateway since the page's policy loads scripts
from nowhere else — with a download and the model's licence. The mesh is
served to its owner from /3d/jobs/{id}/file; another project's person is
told there is no such job.
A job made from the portal acted for a key that does not exist: the
worker now rebuilds a session's principal from the account that made it,
while it is active and still in the project the job is charged to.
ctl 3d list|get|cancel, over /api/v1/client-jobs (/api/v1/jobs is the
control plane's own work, which ctl jobs shows).
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
62 lines
2.1 KiB
Go
62 lines
2.1 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")
|
|
}
|
|
}
|
|
|
|
func TestThe3DPageDrawsInEveryLanguageWithItsViewer(t *testing.T) {
|
|
for _, lang := range []string{"en", "tr"} {
|
|
req := httptest.NewRequest("GET", "/3d", nil)
|
|
req.Header.Set("Accept-Language", lang)
|
|
rec := httptest.NewRecorder()
|
|
Meshes(store.User{Email: "a@b.c"}, []ChatModel{{Name: "triposr"}},
|
|
[]ChatContext{{Value: "personal", Label: "Personal"}}, "personal", "v0")(rec, req)
|
|
page := rec.Body.String()
|
|
if rec.Code != 200 {
|
|
t.Fatalf("%s: %d %s", lang, rec.Code, page)
|
|
}
|
|
for _, want := range []string{`<option value="triposr">`, `id="picture"`, `/3d/generate`, `model-viewer.min.js?v=`} {
|
|
if !strings.Contains(page, want) {
|
|
t.Errorf("%s: %s missing", lang, want)
|
|
}
|
|
}
|
|
if strings.Contains(page, "meshes.") {
|
|
t.Errorf("%s: an untranslated key is on the page", lang)
|
|
}
|
|
if csp := rec.Header().Get("Content-Security-Policy"); !strings.Contains(csp, "script-src 'self'") || !strings.Contains(csp, "blob:") {
|
|
t.Errorf("policy %q", csp)
|
|
}
|
|
}
|
|
}
|