服务端媒体源导入/保存/客户端输出链路修复:支持 snake/camel、subcategories/sources,默认客户端可见,保存后发布兼容 media-types.json。
build-winui / winui (push) Waiting to run
build-winui / winui (push) Waiting to run
新增数据库同步 Job API、持久化状态、实时输出、最新任务恢复,以及系统日志聚合接口。 管理端优化:日志中心、运维实时状态框、同步输出自动滚动、仪表盘“输出”列、真实延迟空态、本地 favicon/avatar。 新增 server/unified-management/assets/favicon.ico 和 developer-avatar.png,并接好 /favicon.ico、/admin/favicon.ico、/setup/favicon.ico、/assets/*。 WinUI 随机放映室卡片优先显示子接口原始 Description。 Inno 安装器输出框改为选区末尾 + SendMessage 滚动到底部。
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
@@ -229,6 +230,63 @@ func TestCheckOneResolvesTextMediaURL(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestImportLegacyMediaTypesRestoresClientVisibleSources(t *testing.T) {
|
||||
cfg, store := testStore(t)
|
||||
if err := os.MkdirAll(cfg.UpdatePublicDir, 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
mediaTypes := `{
|
||||
"categories": [{
|
||||
"categoryId": "image",
|
||||
"name": "Images",
|
||||
"sources": [{
|
||||
"sourceId": "random-card",
|
||||
"name": "Random Card",
|
||||
"description": "Card description from source",
|
||||
"apiUrl": "https://example.test/random-card",
|
||||
"thumbnailUrl": "https://example.test/thumb.webp",
|
||||
"supportedFormats": ["webp"],
|
||||
"mediaType": "image"
|
||||
}]
|
||||
}]
|
||||
}`
|
||||
if err := os.WriteFile(filepath.Join(cfg.UpdatePublicDir, "media-types.json"), []byte(mediaTypes), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := store.UpsertSource(db.Source{
|
||||
CategoryID: "hidden",
|
||||
CategoryName: "Hidden",
|
||||
SourceID: "hidden-source",
|
||||
Name: "Hidden",
|
||||
APIURL: "https://example.test/hidden",
|
||||
Enabled: false,
|
||||
ClientVisible: false,
|
||||
EnabledSet: true,
|
||||
ClientVisibleSet: true,
|
||||
}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
service := NewService(cfg, store)
|
||||
if err := service.ImportLegacyMediaTypesIfEmpty(context.Background()); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
visible, err := store.CountClientVisibleSources()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if visible != 1 {
|
||||
t.Fatalf("visible source count = %d, want 1", visible)
|
||||
}
|
||||
catalog, err := service.Catalog(false)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
sub := catalog["categories"].([]map[string]any)[0]["subcategories"].([]map[string]any)[0]
|
||||
if sub["description"] != "Card description from source" || sub["apiUrl"] != "https://example.test/random-card" || sub["mediaType"] != "image" {
|
||||
t.Fatalf("catalog did not expose stable source fields: %#v", sub)
|
||||
}
|
||||
}
|
||||
|
||||
func testStore(t *testing.T) (*config.Config, *db.Store) {
|
||||
t.Helper()
|
||||
dir := t.TempDir()
|
||||
|
||||
Reference in New Issue
Block a user