87f97a2f9b
build / build (push) Successful in 1m7s
详情使用共享主表字典,稀疏修改所选字段并保留原始问答及旧复核审计。 月周统计提供文本和下拉双入口;每租户每周一份持久草稿,按技能六节双语模板真实预填。 加入幂等自动保存、冲突保留、未知响应重试、切周及离开保护和schema58非破坏降级保护。 验证:完整make verify、隔离PostgreSQL全mirror竞态回归、真实恢复库浏览器验收通过。 浏览器实测字段精确读回、月周双输入、模板预填、MD/CSV、自动保存、冲突、失败重试与API重启恢复。 未连接或改写DobotAI生产源库,未运行付费模型;提交时尚未部署。
62 lines
3.3 KiB
Go
62 lines
3.3 KiB
Go
package qaopsmirror
|
|
|
|
import (
|
|
"encoding/json"
|
|
"knowledge-governance/internal/qaopsquality"
|
|
"strings"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestWeeklyTemplateHistoricalRatesKeepSourceWeekKeyAndUseMatchingBoundaries(t *testing.T) {
|
|
now := time.Date(2026, 10, 19, 12, 0, 0, 0, time.UTC)
|
|
start, end, e := weeklyDraftBounds("2026-W40", now)
|
|
if e != nil {
|
|
t.Fatal(e)
|
|
}
|
|
data := Dashboard{Start: start, End: end, MonthStart: dashboardDay(end.Add(-time.Second)), ReportedWeeks: []DashboardReported{{Week: "2026WK40", WeekStart: start, WeekEnd: end, CoveragePercent: 57.23, CorrectnessPercent: 92.34, Source: "user_provided_history"}}}
|
|
md, seed, e := renderWeeklyTemplate("2026-W40", data, now)
|
|
if e != nil {
|
|
t.Fatal(e)
|
|
}
|
|
var meta map[string]any
|
|
if json.Unmarshal(seed, &meta) != nil {
|
|
t.Fatal("invalid seed")
|
|
}
|
|
if !strings.Contains(md, "Coverage Rate: 57.23%") || !strings.Contains(md, "Accuracy Rate: 92.34%") || meta["quality_source"] != "reported-history" || meta["quality_source_week_key"] != "2026WK40" {
|
|
t.Fatalf("historical source key must remain verbatim and match by real week boundaries: %s", md)
|
|
}
|
|
if data.ReportedWeeks[0].Week != "2026WK40" {
|
|
t.Fatal("rewrote source week identifier")
|
|
}
|
|
}
|
|
|
|
func TestWeeklyTemplateUsesExactBilingualSixSectionsAndRealMetricValues(t *testing.T) {
|
|
now := time.Date(2026, 10, 19, 12, 0, 0, 0, time.UTC)
|
|
start, end, e := weeklyDraftBounds("2026-W41", now)
|
|
if e != nil {
|
|
t.Fatal(e)
|
|
}
|
|
p := func(v float64) *float64 { return &v }
|
|
data := Dashboard{Start: start, End: end, MonthStart: time.Date(2026, 10, 1, 0, 0, 0, 0, dashboardLocation), TotalIssues: 1234, NewThisWeek: 12, Quality: qaopsquality.Summary{Rates: qaopsquality.Rates{Coverage: qaopsquality.Rate{Percent: p(0)}, Correctness: qaopsquality.Rate{}}}, Regions: []DashboardRegion{{ID: "a", Name: "APAC", Frequency: p(0), UsageCoverage: qaopsquality.Rate{Percent: p(10)}}, {ID: "b", Name: "America", Frequency: p(2), UsageCoverage: qaopsquality.Rate{Percent: p(5)}}, {ID: "c", Name: "unassigned\n## fake", Frequency: nil}}}
|
|
md, seed, e := renderWeeklyTemplate("2026-W41", data, now)
|
|
if e != nil {
|
|
t.Fatal(e)
|
|
}
|
|
if strings.Count(md, "\n## ") != 12 || !strings.HasPrefix(md, "# Knowledge Base Weekly Report - 2026 WK41") || strings.Index(md, "## 6. Next Week Priorities") > strings.Index(md, "# 知识库周报") || !strings.Contains(md, "问题总数:1234") || !strings.Contains(md, "New This Week: 12") || !strings.Contains(md, "Coverage Rate: 0.00%") || !strings.Contains(md, "Accuracy Rate: —") || strings.Contains(md, "{{") || strings.Contains(md, "\n## fake") {
|
|
t.Fatalf("skill template, trusted values or escaping missing: %s", md)
|
|
}
|
|
if !strings.Contains(md, "[待填写]") || !strings.Contains(md, "[To be completed]") {
|
|
t.Fatal("invented authored highlights instead of leaving placeholders")
|
|
}
|
|
average := md[strings.Index(md, "Regional Average"):strings.Index(md, "## 4.")]
|
|
coverage := md[strings.Index(md, "Regional Usage Coverage"):strings.Index(md, "## 5.")]
|
|
if strings.Index(average, "Americas") > strings.Index(average, "APAC") || strings.Index(coverage, "APAC") > strings.Index(coverage, "Americas") {
|
|
t.Fatal("regional rankings not sorted independently")
|
|
}
|
|
var meta map[string]any
|
|
if json.Unmarshal(seed, &meta) != nil || meta["quality_source"] != "live-week" {
|
|
t.Fatal("prefill provenance missing")
|
|
}
|
|
}
|