perf(listings): 优化详情页图片加载链路支持公开变体与分级秒开
This commit is contained in:
@@ -672,3 +672,30 @@ func containsString(values []string, target string) bool {
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func TestApplyPublicScreenshotGroups(t *testing.T) {
|
||||
rawURLs := []string{
|
||||
"/api/files/object?key=listing/coin.png",
|
||||
"/api/files/object?key=listing/skin1.png",
|
||||
}
|
||||
publicURLs := []string{
|
||||
"/api/listings/88/screenshots/0",
|
||||
"/api/listings/88/screenshots/1",
|
||||
}
|
||||
summary := map[string]any{
|
||||
"screenshot_groups": map[string]any{
|
||||
"coin": []any{"/api/files/object?key=listing/coin.png"},
|
||||
"skin": []string{"/api/files/object?key=listing/skin1.png"},
|
||||
},
|
||||
}
|
||||
applyPublicScreenshotGroups(88, summary, rawURLs, publicURLs)
|
||||
groups := summary["screenshot_groups"].(map[string]any)
|
||||
coinList := groups["coin"].([]string)
|
||||
if len(coinList) != 1 || coinList[0] != "/api/listings/88/screenshots/0" {
|
||||
t.Fatalf("expected /api/listings/88/screenshots/0, got %#v", coinList)
|
||||
}
|
||||
skinList := groups["skin"].([]string)
|
||||
if len(skinList) != 1 || skinList[0] != "/api/listings/88/screenshots/1" {
|
||||
t.Fatalf("expected /api/listings/88/screenshots/1, got %#v", skinList)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user