From a009128e50275c312535cb5e92758078c779b4f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=9F=B3=E5=A4=B4?= <3301352378@qq.com> Date: Thu, 9 Jul 2026 17:14:32 +0800 Subject: [PATCH] test: cover N15 ambiguous strict exit --- internal/uiaselector/report_test.go | 48 +++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/internal/uiaselector/report_test.go b/internal/uiaselector/report_test.go index de36437..f19efa0 100644 --- a/internal/uiaselector/report_test.go +++ b/internal/uiaselector/report_test.go @@ -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) + } +}