test: cover N15 ambiguous strict exit

This commit is contained in:
石头
2026-07-09 17:14:32 +08:00
parent d85fae0852
commit a009128e50

View File

@@ -141,3 +141,51 @@ func TestMarkdownReportDoesNotExposeVisibleText(t *testing.T) {
}
}
}
func TestStrictModeClassifiesAmbiguousMatches(t *testing.T) {
root := &Node{
ControlType: "Window",
AutomationID: "frmMain",
FrameworkID: "WinForm",
Children: []Node{
{ControlType: "Pane", AutomationID: "duplicate", FrameworkID: "WinForm"},
{ControlType: "Pane", AutomationID: "duplicate", FrameworkID: "WinForm"},
},
}
catalog := []Selector{
{
ID: "duplicate_panel",
Description: "duplicate structural selector",
AllowedUse: AllowedUseReadOnlyLocate,
Required: Criteria{AutomationID: "duplicate", ControlType: "Pane", FrameworkID: "WinForm"},
StabilityScore: 80,
Evidence: Evidence{CaptureID: "unit-test", UIAPath: "root/duplicate"},
},
}
report := RunCatalogReport("synthetic-ambiguous.json", root, catalog, fixedReportTime())
if !report.OK {
t.Fatalf("report OK=false: %#v", report.Error)
}
if report.CatalogSize != 1 {
t.Fatalf("catalog_size = %d, want 1", report.CatalogSize)
}
if report.MatchedCount != 1 {
t.Fatalf("matched_count = %d, want 1", report.MatchedCount)
}
if report.UnmatchedCount != 0 {
t.Fatalf("unmatched_count = %d, want 0", report.UnmatchedCount)
}
if report.AmbiguousCount != 1 {
t.Fatalf("ambiguous_count = %d, want 1", report.AmbiguousCount)
}
if len(report.Selectors) != 1 {
t.Fatalf("len(selectors) = %d, want 1", len(report.Selectors))
}
if got := report.Selectors[0].MatchCount; got != 2 {
t.Fatalf("selector match_count = %d, want 2", got)
}
if got := StrictExitCode(report); got != StrictExitAmbiguous {
t.Fatalf("StrictExitCode = %d, want %d", got, StrictExitAmbiguous)
}
}