fix: deliver validated AI insight responses
This commit is contained in:
23
internal/growth/ranking_test.go
Normal file
23
internal/growth/ranking_test.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package growth
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestRankEventPrefersMerchantFitAndHistoricalEvidence(t *testing.T) {
|
||||
base := Event{ImportanceBPS: 8_000, ConfidenceBPS: 9_000, Categories: []string{"فروشگاه"}, Tags: []string{"وبسایت"}, LeadDays: 14, CommercialPosture: "PROMOTE"}
|
||||
strong := RankEvent(base, RankInput{MerchantTerms: []string{"فروشگاه", "وبسایت"}, WithinPreparationWindow: true, HistoricalUpliftBPS: 12_000, HistoricalEligible: true})
|
||||
weak := RankEvent(base, RankInput{MerchantTerms: []string{"نامرتبط"}})
|
||||
if strong.ScoreBPS <= weak.ScoreBPS {
|
||||
t.Fatalf("merchant fit and history must increase rank: strong=%d weak=%d", strong.ScoreBPS, weak.ScoreBPS)
|
||||
}
|
||||
if len(strong.Factors) < 3 {
|
||||
t.Fatalf("rank factors = %+v, want actionable factors", strong.Factors)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRankEventNeverPromotesMourningOrNoPromotionEvents(t *testing.T) {
|
||||
for _, event := range []Event{{CommercialPosture: "NO_PROMOTION"}, {CommercialPosture: "PROMOTE", Tone: "MOURNING"}} {
|
||||
if got := RankEvent(event, RankInput{WithinPreparationWindow: true}); got.Promotable {
|
||||
t.Fatalf("event %+v is promotable", event)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user