package qaopsquality import ( "knowledge-governance/internal/dobotaiops" "testing" ) func TestMasterInlineEditsOverrideLegacyReviewOnlyForSelectedFields(t *testing.T) { v := View{State: "reviewed", Revision: 7, Effective: Fields{Coverage: "covered", Correctness: "incorrect", ProductCategory: "legacy", ProblemType: "故障", RootCause: "知识过期"}, LatestReview: &Review{Revision: 7}} edits := map[string]string{"coverage": "否但不计入", "is_correct": "是", "root_cause": "检索不到"} got := ProjectMasterWithEdits(v, map[string]string{}, dobotaiops.CoverageCheck{}, edits) if got.Effective.Coverage != "excluded" || got.Effective.ExclusionReason == "" || got.Effective.Correctness != "correct" || got.Effective.RootCause != "" || got.Effective.ProductCategory != "legacy" || got.Effective.ProblemType != "故障" || got.LatestReview.Revision != 7 { t.Fatalf("inline override/reset dependency/legacy preservation failed: %+v", got) } reverted := ProjectMasterWithEdits(got, nil, dobotaiops.CoverageCheck{}, map[string]string{"coverage": "否", "is_correct": "待确认", "problem_type": "咨询", "root_cause": "知识缺失"}) if reverted.Effective.Coverage != "uncovered" || reverted.Effective.ExclusionReason != "" || reverted.Effective.Correctness != "pending" || reverted.Effective.ProblemType != "咨询" || reverted.Effective.RootCause != "知识缺失" { t.Fatalf("canonical labels/reset failed: %+v", reverted) } } func TestMasterInlineEditChangesOnlyChosenFieldWithoutFabricatingReview(t *testing.T) { v := View{State: "unreviewed"} stored := map[string]string{"coverage": "是", "product_category": "CRV"} got := ProjectMasterWithEdits(v, stored, dobotaiops.CheckMasterCoverage("existing answer", true), map[string]string{"product_category": "MG400"}) if got.Effective.ProductCategory != "MG400" || got.Effective.Correctness != "" || got.Effective.ProblemType != "" || got.State != "unreviewed" || got.LatestReview != nil { t.Fatalf("single-field edit lost or implicitly created other conclusions: %+v", got) } if stored["product_category"] != "CRV" { t.Fatal("mutated source labels") } }