feat(listing): 优化优质号主发布与极品专区体验

This commit is contained in:
yml2213
2026-11-04 15:59:53 +08:00
parent 98174c0e33
commit e9102026ae
22 changed files with 812 additions and 88 deletions
@@ -106,6 +106,54 @@ func TestNormalizePublishOptionsValuePreservesCurrentSchema(t *testing.T) {
}
}
func TestNormalizePublishOptionsValueDefaultsQualityOwnerRatioDiscount(t *testing.T) {
legacy := `{
"schema_version": 2,
"ratio_config": {
"insurance_base_ratios": [{"insurance": "3*3", "ratio": 40}]
}
}`
normalized, err := normalizePublishOptionsValue(legacy)
if err != nil {
t.Fatalf("规范化失败: %v", err)
}
var got PublishOptionsDTO
if err := json.Unmarshal([]byte(normalized), &got); err != nil {
t.Fatalf("解析规范化结果失败: %v", err)
}
if got.RatioConfig.QualityOwnerRatioDiscount != 1 {
t.Fatalf(
"quality_owner_ratio_discount = %v, want 1",
got.RatioConfig.QualityOwnerRatioDiscount,
)
}
}
func TestNormalizePublishOptionsValuePreservesExplicitZeroQualityOwnerDiscount(t *testing.T) {
options := DefaultPublishOptions()
options.RatioConfig.QualityOwnerRatioDiscount = 0
raw, err := json.Marshal(options)
if err != nil {
t.Fatalf("构造配置失败: %v", err)
}
normalized, err := normalizePublishOptionsValue(string(raw))
if err != nil {
t.Fatalf("规范化失败: %v", err)
}
var got PublishOptionsDTO
if err := json.Unmarshal([]byte(normalized), &got); err != nil {
t.Fatalf("解析规范化结果失败: %v", err)
}
if got.RatioConfig.QualityOwnerRatioDiscount != 0 {
t.Fatalf(
"quality_owner_ratio_discount = %v, want explicit 0",
got.RatioConfig.QualityOwnerRatioDiscount,
)
}
}
func TestNormalizePublishOptionsValueMigratesSchemaV1Switches(t *testing.T) {
legacy := `{"schema_version":1,"next_season_pass_enabled":false,"server_options":["QQ"]}`