package qaopsquality import ( "knowledge-governance/internal/dobotaiops" "testing" ) func TestMasterDownvoteRuleOverridesOnlyCorrectnessWithoutChangingReviewEvidence(t *testing.T) { for _, test := range []struct { name string feedback dobotaiops.RecordFeedback correctness string want string }{ {"asker-down-without-counter", dobotaiops.RecordFeedback{AskerValue: "down"}, "correct", "incorrect"}, {"someone-else-down", dobotaiops.RecordFeedback{AskerValue: "up", Up: 10, Down: 1}, "pending", "incorrect"}, {"covered-no-vote-cannot-keep-pending", dobotaiops.RecordFeedback{}, "pending", ""}, {"up-is-not-proof-of-correctness", dobotaiops.RecordFeedback{AskerValue: "up", Up: 1}, "incorrect", "incorrect"}, } { t.Run(test.name, func(t *testing.T) { original := Fields{Coverage: "covered", Correctness: test.correctness, ProductCategory: "MG400", ProblemType: "参数"} review := Review{Revision: 3, Fields: original} v := View{State: "reviewed", Revision: 3, LatestReview: &review, Effective: original} got := ProjectMasterWithEdits(v, map[string]string{}, dobotaiops.CoverageCheck{}, map[string]string{}, test.feedback) if got.Effective.Correctness != test.want || review.Fields != original || got.LatestReview.Fields != original || got.State != "reviewed" || got.Revision != 3 || got.Effective.Coverage != "covered" || got.Effective.ProductCategory != "MG400" { t.Fatalf("feedback rule changed unrelated quality or evidence: %+v", got) } if FeedbackForcesIncorrect(test.feedback) != (got.FeedbackRule == "downvote-is-incorrect-v1") { t.Fatal("feedback provenance missing or invented") } }) } }