cb9f0c389f
build / build (push) Successful in 1m10s
去掉看板个人月明细;十一卡悬停和键盘可读的真实统计范围、公式与排除数。 自然月独立计算;跨月周取周一所在月,保留旧周证据和已存周报正文。 验证:make verify;一次性PG全镜像套件-race;真实恢复数据7个月与周报calc_metrics对拍。 真实浏览器十一卡逐项悬停、Tab/Escape、30秒刷新、跨月周、390px和完整PNG通过。 没有写DobotAI源问答、触发付费模型、外发或应用新迁移。
34 lines
1.7 KiB
Go
34 lines
1.7 KiB
Go
package qaopsmirror
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func monthlyTestTime(t *testing.T, value string) time.Time {
|
|
t.Helper()
|
|
at, err := time.Parse(time.RFC3339, value)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
return at
|
|
}
|
|
|
|
func TestQualityMonthCrossingWeekIsPreviousMonthReport(t *testing.T) {
|
|
for _, c := range []struct{ name, start, end, now, wantStart, wantEnd string }{
|
|
{"cross-month", "2026-09-28T00:00:00+08:00", "2026-10-05T00:00:00+08:00", "2026-10-21T08:00:00+08:00", "2026-09-01T00:00:00+08:00", "2026-10-01T00:00:00+08:00"},
|
|
{"within-month", "2026-10-05T00:00:00+08:00", "2026-10-12T00:00:00+08:00", "2026-10-21T08:00:00+08:00", "2026-10-01T00:00:00+08:00", "2026-10-12T00:00:00+08:00"},
|
|
{"current-week-clamps-now", "2026-10-19T00:00:00+08:00", "2026-10-26T00:00:00+08:00", "2026-10-21T08:00:00+08:00", "2026-10-01T00:00:00+08:00", "2026-10-21T08:00:00+08:00"},
|
|
{"cross-year", "2025-12-29T00:00:00+08:00", "2026-01-05T00:00:00+08:00", "2026-10-21T08:00:00+08:00", "2025-12-01T00:00:00+08:00", "2026-01-01T00:00:00+08:00"},
|
|
{"utc-same-boundary", "2026-09-27T16:00:00Z", "2026-10-04T16:00:00Z", "2026-10-21T00:00:00Z", "2026-09-01T00:00:00+08:00", "2026-10-01T00:00:00+08:00"},
|
|
{"crossing-week-before-month-complete", "2026-09-28T00:00:00+08:00", "2026-09-29T08:00:00+08:00", "2026-09-29T08:00:00+08:00", "2026-09-01T00:00:00+08:00", "2026-09-29T08:00:00+08:00"},
|
|
} {
|
|
t.Run(c.name, func(t *testing.T) {
|
|
begin, end := dashboardQualityMonth(monthlyTestTime(t, c.start), monthlyTestTime(t, c.end), monthlyTestTime(t, c.now))
|
|
if !begin.Equal(monthlyTestTime(t, c.wantStart)) || !end.Equal(monthlyTestTime(t, c.wantEnd)) {
|
|
t.Fatalf("quality month = [%s,%s), want [%s,%s)", begin, end, c.wantStart, c.wantEnd)
|
|
}
|
|
})
|
|
}
|
|
}
|