fix: deliver validated AI insight responses

This commit is contained in:
2026-08-22 15:47:38 +08:00
parent ca55c2fb3d
commit 3fba4261ee
68 changed files with 6870 additions and 493 deletions

View File

@@ -46,6 +46,28 @@ func TestMatchUpcomingEventsPrefersFamilyThenTags(t *testing.T) {
}
}
func TestBuildOpportunitiesReturnsThreeNearestCommercialEventsWithoutHistoricalWins(t *testing.T) {
start := date("2026-08-21")
forecast := Forecast{Confidence: ConfidenceMedium}
for day := start; day.Before(start.AddDate(0, 0, 120)); day = day.AddDate(0, 0, 1) {
forecast.Points = append(forecast.Points, ForecastPoint{
Date: day, PaidSessions: Range{P10: 80, P50: 100, P90: 120},
PaidAmountRial: Range{P10: 800, P50: 1000, P90: 1200},
})
}
catalog := filterCatalog(testCatalog(), "مراکز آموزشی مجازی")
got := buildOpportunities(nil, catalog, forecast, start, 3)
if len(got) != 3 {
t.Fatalf("got %d opportunities, want 3: %+v", len(got), got)
}
want := []string{"back-to-school-1405", "autumn-opening-1405", "halloween-2026"}
for index, id := range want {
if got[index].EventID != id {
t.Fatalf("opportunity %d = %q, want %q", index, got[index].EventID, id)
}
}
}
func TestBuildForecastReturnsOrderedNinetyDayIntegerRanges(t *testing.T) {
start := date("2026-07-01")
history := make([]DailyPoint, 0, 112)