feat: render N14 selector reports
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package uiaselector
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
@@ -96,3 +97,47 @@ func TestReportRejectsNonReadOnlyCatalogEntries(t *testing.T) {
|
||||
t.Fatalf("StrictExitCode = %d, want %d", got, StrictExitInvalidCatalog)
|
||||
}
|
||||
}
|
||||
|
||||
func TestReportDoesNotExposeVisibleText(t *testing.T) {
|
||||
report := RunCatalogReport(
|
||||
"testdata/n12r-2026-07-09-uia-redacted.json",
|
||||
loadN14Fixture(t),
|
||||
DefaultCatalog(),
|
||||
fixedReportTime(),
|
||||
)
|
||||
body, err := RenderReportJSON(report)
|
||||
if err != nil {
|
||||
t.Fatalf("RenderReportJSON: %v", err)
|
||||
}
|
||||
jsonText := string(body)
|
||||
for _, forbidden := range []string{`"name"`, `"value"`, "国网甘肃省电力公司"} {
|
||||
if strings.Contains(jsonText, forbidden) {
|
||||
t.Fatalf("JSON report exposed forbidden text %q in %s", forbidden, jsonText)
|
||||
}
|
||||
}
|
||||
for _, required := range []string{`"has_name"`, `"name_length"`, `"selector_id"`, `"automation_id"`} {
|
||||
if !strings.Contains(jsonText, required) {
|
||||
t.Fatalf("JSON report missing required structural field %q in %s", required, jsonText)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarkdownReportDoesNotExposeVisibleText(t *testing.T) {
|
||||
report := RunCatalogReport(
|
||||
"testdata/n12r-2026-07-09-uia-redacted.json",
|
||||
loadN14Fixture(t),
|
||||
DefaultCatalog(),
|
||||
fixedReportTime(),
|
||||
)
|
||||
markdown := RenderReportMarkdown(report)
|
||||
for _, forbidden := range []string{"国网甘肃省电力公司", "| name |", "| value |"} {
|
||||
if strings.Contains(markdown, forbidden) {
|
||||
t.Fatalf("Markdown report exposed forbidden text %q in %s", forbidden, markdown)
|
||||
}
|
||||
}
|
||||
for _, required := range []string{"# N14 UIA Selector Report", "## Summary", "automation_id", "control_type", "class_name", "has_name", "name_length"} {
|
||||
if !strings.Contains(markdown, required) {
|
||||
t.Fatalf("Markdown report missing %q in %s", required, markdown)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user