Open a repository beneath its row in the mirror's listing
Clicking a repository in the explorer shows its card and files in a row beneath it, fetched from /admin/mirror/repo, and a second click closes it; the list stays where it was. The link still leads to the repository's own page without script or with a modifier key. A repository's files now take one line each, and an importance matrix published beside the quantisations is marked as not a model rather than offered for fetching. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
3fea39feb9
commit
ff86e52126
4 files changed
+211
-69
No files matched your search
@@ -1,6 +1,7 @@
|
||||
package web
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"html"
|
||||
"strings"
|
||||
"testing"
|
||||
@@ -114,3 +115,51 @@ func TestARepositoryShowsItsCard(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestARepositoryOpensAsAFragmentBeneathItsRow(t *testing.T) {
|
||||
reg := &fakeRegistry{repo: hf.Repo{
|
||||
ID: "Qwen/X-GGUF", Revision: "abc123def456", Card: "A **small** model.",
|
||||
Files: []hf.File{{Path: "x.gguf", Bytes: 10}},
|
||||
}}
|
||||
rec := mirrorGet(t, mirrorPageLlama(t, MirrorDeps{Mirror: &fakeMirror{}, Registry: reg}),
|
||||
"/admin/mirror/repo?repo=Qwen/X-GGUF")
|
||||
body := rec.Body.String()
|
||||
if rec.Code != 200 {
|
||||
t.Fatalf("status %d: %s", rec.Code, body)
|
||||
}
|
||||
// The card and the fetch form, and not a page around them.
|
||||
for _, want := range []string{"<strong>small</strong>", `action="/admin/mirror/fetch"`, `name="csrf"`} {
|
||||
if !strings.Contains(body, want) {
|
||||
t.Errorf("missing %s: %s", want, body)
|
||||
}
|
||||
}
|
||||
for _, unwanted := range []string{"<html", "back to the list", "<h3>"} {
|
||||
if strings.Contains(body, unwanted) {
|
||||
t.Errorf("the fragment carries %s", unwanted)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestAFragmentForARegistryThatFailsSaysSo(t *testing.T) {
|
||||
reg := &fakeRegistry{err: errors.New("reaching the model registry: timeout")}
|
||||
rec := mirrorGet(t, mirrorPageLlama(t, MirrorDeps{Mirror: &fakeMirror{}, Registry: reg}),
|
||||
"/admin/mirror/repo?repo=Qwen/X-GGUF")
|
||||
if rec.Code != 502 || !strings.Contains(rec.Body.String(), "timeout") {
|
||||
t.Errorf("status %d: %s", rec.Code, rec.Body.String())
|
||||
}
|
||||
}
|
||||
|
||||
func TestAnImportanceMatrixIsNotOfferedAsAModel(t *testing.T) {
|
||||
reg := &fakeRegistry{repo: hf.Repo{
|
||||
ID: "a/X-GGUF", Revision: "abc123def456", Architecture: "qwen2",
|
||||
Files: []hf.File{{Path: "x-q4_k_m.gguf", Bytes: 10}, {Path: "imatrix-x.gguf", Bytes: 5}},
|
||||
}}
|
||||
body := mirrorGet(t, mirrorPageLlama(t, MirrorDeps{Mirror: &fakeMirror{}, Registry: reg}),
|
||||
"/admin/mirror/repo?repo=a/X-GGUF").Body.String()
|
||||
if !strings.Contains(body, "importance matrix") {
|
||||
t.Errorf("the imatrix should be marked as not a model: %s", body)
|
||||
}
|
||||
if strings.Count(body, `action="/admin/mirror/fetch"`) != 1 {
|
||||
t.Errorf("only the model should have a fetch form: %s", body)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user