533db535f1
build / build (push) Successful in 1m12s
按已确认需求提供独立安全模型配置、真实探测、正式字典字段评估与原问题译中,持久批次支持只补空白、暂停恢复、有限重试、幂等和逐字段依据。覆盖固定规则、本地语言、组织关联与主表有效看板共用治理侧读模型,保留源生产和冻结历史。 验证:完整 make verify 退出0,702项Go与329项前端通过;默认118项外部/隔离集成明确跳过,另跑完整镜像及组织隔离PG竞态。12并发、输入漂移、过期租约、暂停/恢复及有限重试通过。用户授权的百炼 deepseek-v4.1-flash 完成真实后台与浏览器评估/翻译;552行、16列、11块看板及完整PNG、独立配置页测试/保存、重开恢复和零JS异常通过。仅非业务样本外发,自动处理关闭,原payload不变。 上线前治理库已做导出快照原生备份并真实恢复,60表行数与17个QA表内容哈希一致;不修改DobotAI生产或隧道。本提交时尚未部署,线上验收须独立完成。
66 lines
2.7 KiB
Go
66 lines
2.7 KiB
Go
package qaopsmirror
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"knowledge-governance/internal/dobotaiops"
|
|
pg "knowledge-governance/internal/platform/postgres"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestMasterDashboardIncludesMasterOnlyLabelsWithoutChangingLegacyDashboard(t *testing.T) {
|
|
pool := mirrorFixture(t)
|
|
ctx := context.Background()
|
|
s := NewStore(pool, "fixture-master-dashboard")
|
|
queue := pg.NewStore(pool)
|
|
entry := fixtureEntry("source-one", "已有资料")
|
|
var wire map[string]any
|
|
_ = json.Unmarshal(entry.Payload, &wire)
|
|
wire["asked_at"] = "2026-10-06T08:00:00+08:00"
|
|
entry.Payload, _ = json.Marshal(wire)
|
|
job := claimMirrorJob(t, s, queue, "master-dashboard-seed")
|
|
if err := s.HandleSync(ctx, *job, func(context.Context) (Source, error) {
|
|
return &fixtureSource{rows: []dobotaiops.MirrorRecord{entry}}, nil
|
|
}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
_, err := pool.Exec(ctx, `INSERT INTO qa_ops_master_records(tenant_key,id,event_key,origin,asked_at,question,status,identity,quality_hash,payload) SELECT tenant_key,'master-only',repeat('f',64),origin,asked_at,question,status,identity,repeat('e',64),payload||jsonb_build_object('id','master-only','_quality_hash',repeat('e',64),'master_fields',jsonb_build_object('coverage','是','is_correct','否','product_category','MG400','problem_type','参数')) FROM qa_ops_master_records WHERE tenant_key=$1 AND id='source-one'`, s.tenant)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
start, _ := time.Parse(time.RFC3339, "2026-10-05T00:00:00+08:00")
|
|
q := dobotaiops.RecordQuery{Window: dobotaiops.Window{TenantKey: s.tenant, Start: start, End: start.AddDate(0, 0, 7)}}
|
|
got, err := s.ReadMasterDashboard(ctx, q)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if got.TotalIssues != 2 || got.NewThisWeek != 2 || got.Quality.Total != 2 || got.Quality.Rates.Coverage.Numerator != 2 || got.Quality.Rates.Correctness.Denominator != 1 {
|
|
t.Fatalf("master dashboard did not use effective master scope: %+v", got)
|
|
}
|
|
found := false
|
|
for _, row := range got.Products {
|
|
if row.Label == "MG400" && row.Count == 1 {
|
|
found = true
|
|
}
|
|
}
|
|
if !found {
|
|
t.Fatal("stored product labels not counted")
|
|
}
|
|
record, err := s.GetMasterRecord(ctx, s.tenant, "master-only")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
views, err := s.ReadMasterQualityViews(ctx, []dobotaiops.QualityKey{{ID: record.ID, InputHash: record.QualityInputHash}})
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if views[record.ID].Effective.ProductCategory != "MG400" || views[record.ID].Effective.Correctness != "incorrect" {
|
|
t.Fatal("list/summary master projection differs from dashboard")
|
|
}
|
|
legacy, err := s.ReadDashboard(ctx, q)
|
|
if err != nil || legacy.TotalIssues != 1 {
|
|
t.Fatal("master dashboard changed frozen/legacy source scope", err)
|
|
}
|
|
}
|