Skip to content

High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.

fix: remove the always-true audit interactiveElements.visible field (PIN-059)

Luigi Agosticc1684ca4a51
diff --git a/internal/audit/enrich.go b/internal/audit/enrich.go
index d73f0636..66da9775 100644
--- a/internal/audit/enrich.go
+++ b/internal/audit/enrich.go
@@ -209,7 +209,6 @@ func MapInteractiveElements(nodes []observe.A11yNode) []InteractiveElement {
Tag: n.Tag,
Label: n.Label,
Disabled: n.Disabled,
- Visible: !n.Hidden,
})
}
return out
diff --git a/internal/audit/enrich_test.go b/internal/audit/enrich_test.go
index a61819d5..7fcc687c 100644
--- a/internal/audit/enrich_test.go
+++ b/internal/audit/enrich_test.go
@@ -158,7 +158,7 @@ func TestMapInteractiveElementsFiltersRolesAndHidden(t *testing.T) {
{Ref: "e2", Role: "paragraph", Name: "text"},
{Ref: "e3", Role: "link", Name: "x", Hidden: true},
})
- if len(got) != 1 || got[0].Ref != "e1" || !got[0].Visible {
+ if len(got) != 1 || got[0].Ref != "e1" {
t.Errorf("MapInteractiveElements = %+v", got)
}
}
diff --git a/internal/audit/types.go b/internal/audit/types.go
index 061c9093..0d379bb2 100644
--- a/internal/audit/types.go
+++ b/internal/audit/types.go
@@ -79,8 +79,6 @@ type InteractiveElement struct {
Label string `json:"label,omitempty"`
// Disabled reports whether the element is disabled.
Disabled bool `json:"disabled,omitempty"`
- // Visible reports whether the element is visible in the layout.
- Visible bool `json:"visible,omitempty"`
}
// BrowserTimingMetrics holds browser-level performance timings for a page,
diff --git a/internal/audit/types_test.go b/internal/audit/types_test.go
index 5d1143bc..928ccb8f 100644
--- a/internal/audit/types_test.go
+++ b/internal/audit/types_test.go
@@ -3,8 +3,11 @@ package audit
import (
"encoding/json"
"reflect"
+ "strings"
"testing"
"time"
+
+ "github.com/pinchtab/pinchtab/pkg/pinchtabaudit"
)
func roundTrip[T any](t *testing.T, name string, in T) {
@@ -41,7 +44,7 @@ func sampleBrokenAsset() BrokenAsset {
}
func sampleInteractiveElement() InteractiveElement {
- return InteractiveElement{Ref: "e5", Role: "button", Name: "Submit", Tag: "button", Label: "Submit form", Disabled: true, Visible: true}
+ return InteractiveElement{Ref: "e5", Role: "button", Name: "Submit", Tag: "button", Label: "Submit form", Disabled: true}
}
func sampleTimingMetrics() BrowserTimingMetrics {
@@ -136,3 +139,46 @@ func TestNewAuditReportSchemaVersion(t *testing.T) {
t.Fatalf("schemaVersion JSON field = %v, want %q", got, SchemaVersion)
}
}
+
+// The audit snapshot path never measures layout (no bounds pass, no on-screen
+// test), so the report must make no visibility claim at all. The positive
+// assertions are here because an empty payload would satisfy the negative.
+func TestReportJSONHasNoVisibleKeyForInteractiveElements(t *testing.T) {
+ data, err := json.Marshal(sampleAuditReport())
+ if err != nil {
+ t.Fatalf("marshal: %v", err)
+ }
+ report := string(data)
+
+ if strings.Contains(report, "visible") {
+ t.Errorf("audit report JSON carries a visible key:\n%s", report)
+ }
+ for _, want := range []string{`"interactiveElements":[{`, `"ref":"e5"`, `"role":"button"`, `"tag":"button"`, `"label":"Submit form"`, `"disabled":true`} {
+ if !strings.Contains(report, want) {
+ t.Errorf("audit report JSON lost %s:\n%s", want, report)
+ }
+ }
+}
+
+// The SDK mirrors this struct by hand so the public surface never imports
+// internal packages, which means nothing but this guard keeps a field removed
+// from one side from surviving on the other.
+func TestInteractiveElementMatchesTheSDKMirror(t *testing.T) {
+ shape := func(rt reflect.Type) []string {
+ var out []string
+ for i := 0; i < rt.NumField(); i++ {
+ f := rt.Field(i)
+ out = append(out, f.Name+" "+f.Type.String()+" "+f.Tag.Get("json"))
+ }
+ return out
+ }
+
+ got := shape(reflect.TypeOf(InteractiveElement{}))
+ want := shape(reflect.TypeOf(pinchtabaudit.InteractiveElement{}))
+ if len(got) == 0 {
+ t.Fatal("InteractiveElement has no fields; the guard would pass vacuously")
+ }
+ if !reflect.DeepEqual(got, want) {
+ t.Errorf("InteractiveElement diverges from the SDK mirror\n internal: %v\n sdk: %v", got, want)
+ }
+}
diff --git a/pkg/pinchtabaudit/types.go b/pkg/pinchtabaudit/types.go
index 2de10f5d..b798cc1f 100644
--- a/pkg/pinchtabaudit/types.go
+++ b/pkg/pinchtabaudit/types.go
@@ -45,7 +45,6 @@ type InteractiveElement struct {
Tag string `json:"tag,omitempty"`
Label string `json:"label,omitempty"`
Disabled bool `json:"disabled,omitempty"`
- Visible bool `json:"visible,omitempty"`
}
// TimingMetrics holds browser-level performance timings in milliseconds.
diff --git a/tests/e2e/fixtures/audit-site/golden-report.json b/tests/e2e/fixtures/audit-site/golden-report.json
index abb81b2c..dd0985b0 100644
--- a/tests/e2e/fixtures/audit-site/golden-report.json
+++ b/tests/e2e/fixtures/audit-site/golden-report.json
@@ -14,63 +14,51 @@
"interactiveElements": [
{
"name": "Home",
- "role": "link",
- "visible": true
+ "role": "link"
},
{
"name": "Broken assets",
- "role": "link",
- "visible": true
+ "role": "link"
},
{
"name": "Console errors",
- "role": "link",
- "visible": true
+ "role": "link"
},
{
"name": "Accessibility issues",
- "role": "link",
- "visible": true
+ "role": "link"
},
{
"name": "Clean page",
- "role": "link",
- "visible": true
+ "role": "link"
},
{
"name": "Forms",
- "role": "link",
- "visible": true
+ "role": "link"
},
{
"name": "Cookie echo",
- "role": "link",
- "visible": true
+ "role": "link"
},
{
"name": "Product 1",
- "role": "link",
- "visible": true
+ "role": "link"
},
{
"name": "Product 2",
- "role": "link",
- "visible": true
+ "role": "link"
},
{
"name": "Product 3",
- "role": "link",
- "visible": true
+ "role": "link"
},
{
"name": "Product 4",
- "role": "link",
- "visible": true
+ "role": "link"
},
{
"name": "Product 5",
- "role": "link",
- "visible": true
+ "role": "link"
}
],
"networkRequests": [
@@ -118,8 +106,7 @@
"interactiveElements": [
{
"name": "Home",
- "role": "link",
- "visible": true
+ "role": "link"
}
],
"networkRequests": [
@@ -181,8 +168,7 @@
"interactiveElements": [
{
"name": "Home",
- "role": "link",
- "visible": true
+ "role": "link"
}
],
"networkRequests": [
@@ -206,21 +192,17 @@
"consoleLogs": [],
"interactiveElements": [
{
- "role": "textbox",
- "visible": true
+ "role": "textbox"
},
{
- "role": "link",
- "visible": true
+ "role": "link"
},
{
- "role": "button",
- "visible": true
+ "role": "button"
},
{
"name": "Home",
- "role": "link",
- "visible": true
+ "role": "link"
}
],
"networkRequests": [
@@ -251,18 +233,15 @@
"interactiveElements": [
{
"name": "Search",
- "role": "textbox",
- "visible": true
+ "role": "textbox"
},
{
"name": "Search",
- "role": "button",
- "visible": true
+ "role": "button"
},
{
"name": "Home",
- "role": "link",
- "visible": true
+ "role": "link"
}
],
"networkRequests": [
@@ -287,23 +266,19 @@
"interactiveElements": [
{
"name": "Username",
- "role": "textbox",
- "visible": true
+ "role": "textbox"
},
{
"name": "Password",
- "role": "textbox",
- "visible": true
+ "role": "textbox"
},
{
"name": "Sign in",
- "role": "button",
- "visible": true
+ "role": "button"
},
{
"name": "Home",
- "role": "link",
- "visible": true
+ "role": "link"
}
],
"networkRequests": [
@@ -341,8 +316,7 @@
"interactiveElements": [
{
"name": "Home",
- "role": "link",
- "visible": true
+ "role": "link"
}
],
"networkRequests": [
@@ -367,8 +341,7 @@
"interactiveElements": [
{
"name": "Home",
- "role": "link",
- "visible": true
+ "role": "link"
}
],
"networkRequests": [
@@ -393,8 +366,7 @@
"interactiveElements": [
{
"name": "Home",
- "role": "link",
- "visible": true
+ "role": "link"
}
],
"networkRequests": [
@@ -419,8 +391,7 @@
"interactiveElements": [
{
"name": "Home",
- "role": "link",
- "visible": true
+ "role": "link"
}
],
"networkRequests": [
@@ -445,8 +416,7 @@
"interactiveElements": [
{
"name": "Home",
- "role": "link",
- "visible": true
+ "role": "link"
}
],
"networkRequests": [
@@ -471,8 +441,7 @@
"interactiveElements": [
{
"name": "Home",
- "role": "link",
- "visible": true
+ "role": "link"
}
],
"networkRequests": [