fix: scope page insights to reporting periods

This commit is contained in:
2026-08-22 17:24:37 +08:00
parent 1b6ad4d095
commit 7f9c16be4b
13 changed files with 295 additions and 24 deletions

View File

@@ -8,6 +8,7 @@ import (
func TestDeterministicTransactionCopyDistinguishesPaymentStatesWithoutCausalClaims(t *testing.T) {
copy := deterministicTransactionCopy(
PeriodScope{JalaliLabelFA: "مرداد ۱۴۰۵"},
"تیر ۱۴۰۵",
aggregate{Sessions: 10, Paid: 7, Verified: 5, Unverified: 2, Failed: 2, Reversed: 1},
aggregate{Sessions: 8, Paid: 6},
true,
@@ -29,6 +30,7 @@ func TestDeterministicTransactionCopyDistinguishesPaymentStatesWithoutCausalClai
func TestDeterministicTransactionCopyHandlesEmptyPeriod(t *testing.T) {
copy := deterministicTransactionCopy(
PeriodScope{JalaliLabelFA: "امروز"},
"دیروز",
aggregate{},
aggregate{},
false,
@@ -43,3 +45,23 @@ func TestDeterministicTransactionCopyHandlesEmptyPeriod(t *testing.T) {
t.Fatalf("expected unavailable rates in empty-period copy: %s", copy.LatestObserved.Body)
}
}
func TestDeterministicPeriodCopyUsesSelectedPeriodForOverview(t *testing.T) {
copy := deterministicPeriodCopy(
ModuleOverview,
PeriodScope{JalaliLabelFA: "مرداد ۱۴۰۵"},
"تیر ۱۴۰۵",
aggregate{Sessions: 10, Paid: 7},
aggregate{Sessions: 8, Paid: 6},
true,
TimeContext{},
ConfidenceHigh,
)
if !strings.Contains(copy.LatestObserved.Body, "مرداد ۱۴۰۵") {
t.Fatalf("selected period missing from summary: %s", copy.LatestObserved.Body)
}
if !strings.Contains(copy.Past.Body, "تیر ۱۴۰۵") {
t.Fatalf("exact preceding period missing from comparison: %s", copy.Past.Body)
}
}