Skip to content

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

feat: add public pinchtabaudit library client with enrich example

Luigi Agosti7b855ce104b7
diff --git a/.dockerignore b/.dockerignore
index 7fb19cdf..a7cc7284 100644
--- a/.dockerignore
+++ b/.dockerignore
@@ -24,8 +24,9 @@ tests/
.vscode/
*.swp
-# Docs (not needed in image)
+# Docs (not needed in image), except the library example built into runner-cli
docs/
+!docs/examples/
# Development
node_modules/
diff --git a/docs/examples/enrich/main.go b/docs/examples/enrich/main.go
new file mode 100644
index 00000000..1fd4f2af
--- /dev/null
+++ b/docs/examples/enrich/main.go
@@ -0,0 +1,49 @@
+// Command enrich demonstrates pinchtab library mode: enrich a single page
+// through a running pinchtab server and print its BrowserPageData as JSON.
+//
+// Usage:
+//
+// go run ./docs/examples/enrich --server http://localhost:9867 --token $PINCHTAB_TOKEN https://example.com
+package main
+
+import (
+ "context"
+ "encoding/json"
+ "flag"
+ "fmt"
+ "os"
+ "time"
+
+ "github.com/pinchtab/pinchtab/pkg/pinchtabaudit"
+)
+
+func main() {
+ server := flag.String("server", "http://localhost:9867", "pinchtab server base URL")
+ token := flag.String("token", os.Getenv("PINCHTAB_TOKEN"), "API token (defaults to $PINCHTAB_TOKEN)")
+ screenshot := flag.Bool("screenshot", false, "capture a screenshot (inflates output)")
+ flag.Parse()
+
+ if flag.NArg() != 1 {
+ fmt.Fprintln(os.Stderr, "usage: enrich [--server URL] [--token TOKEN] <page-url>")
+ os.Exit(2)
+ }
+
+ client := pinchtabaudit.New(*server, *token)
+ ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
+ defer cancel()
+
+ page, err := client.EnrichPage(ctx, flag.Arg(0), &pinchtabaudit.PageOptions{
+ Screenshot: pinchtabaudit.Bool(*screenshot),
+ })
+ if err != nil {
+ fmt.Fprintf(os.Stderr, "enrich: %v\n", err)
+ os.Exit(1)
+ }
+
+ out, err := json.MarshalIndent(page, "", " ")
+ if err != nil {
+ fmt.Fprintf(os.Stderr, "encode: %v\n", err)
+ os.Exit(1)
+ }
+ fmt.Println(string(out))
+}
diff --git a/pkg/pinchtabaudit/client.go b/pkg/pinchtabaudit/client.go
new file mode 100644
index 00000000..57b6bbd2
--- /dev/null
+++ b/pkg/pinchtabaudit/client.go
@@ -0,0 +1,131 @@
+// Package pinchtabaudit is the public Go client for pinchtab's audit API —
+// the spec's library mode. It talks to a running pinchtab server over HTTP
+// and exposes typed wrappers for single-page enrichment (POST /audit/page)
+// and multi-page audit runs (POST /audit), so Go programs can embed browser
+// enrichment without shelling out to the CLI.
+//
+// The exported types mirror the server's JSON contract and depend on no
+// pinchtab internal packages.
+package pinchtabaudit
+
+import (
+ "bytes"
+ "context"
+ "encoding/json"
+ "fmt"
+ "io"
+ "net/http"
+ "strings"
+ "time"
+)
+
+// DefaultTimeout bounds a whole enrichment call when the caller's context
+// carries no deadline. Multi-page runs can legitimately take minutes.
+const DefaultTimeout = 10 * time.Minute
+
+// Client is a typed client for a running pinchtab server.
+type Client struct {
+ baseURL string
+ token string
+ // HTTPClient may be replaced before first use; it defaults to a client
+ // with DefaultTimeout.
+ HTTPClient *http.Client
+}
+
+// New returns a Client for the pinchtab server at baseURL. token may be
+// empty when the server runs without authentication.
+func New(baseURL, token string) *Client {
+ return &Client{
+ baseURL: strings.TrimSuffix(baseURL, "/"),
+ token: token,
+ HTTPClient: &http.Client{Timeout: DefaultTimeout},
+ }
+}
+
+// EnrichPage audits a single URL with full browser enrichment and returns
+// its BrowserPageData. A page that fails to load is not an error: the
+// returned PageAudit carries the failure in its Error field.
+func (c *Client) EnrichPage(ctx context.Context, url string, opts *PageOptions) (*PageAudit, error) {
+ body := map[string]any{"url": url}
+ if opts != nil {
+ body["options"] = opts
+ }
+ var page PageAudit
+ if err := c.post(ctx, "/audit/page", body, &page); err != nil {
+ return nil, err
+ }
+ return &page, nil
+}
+
+// EnrichWithBrowser runs a multi-page audit over the given input — a URL
+// list, a sitemap, or seaportal results (routed via browserRecommended) —
+// and returns the versioned AuditReport.
+func (c *Client) EnrichWithBrowser(ctx context.Context, input AuditInput, opts *RunOptions) (*AuditReport, error) {
+ body := map[string]any{}
+ switch {
+ case len(input.URLs) > 0:
+ body["urls"] = input.URLs
+ case input.SitemapURL != "":
+ body["sitemapUrl"] = input.SitemapURL
+ case len(input.SeaportalResults) > 0:
+ body["seaportalResults"] = json.RawMessage(input.SeaportalResults)
+ default:
+ return nil, fmt.Errorf("pinchtabaudit: input needs urls, a sitemap URL, or seaportal results")
+ }
+ if opts != nil {
+ if opts.Concurrency > 0 {
+ body["concurrency"] = opts.Concurrency
+ }
+ if opts.SampleSize > 0 {
+ body["sampleSize"] = opts.SampleSize
+ }
+ if opts.EnrichAll {
+ body["enrichAll"] = true
+ }
+ if opts.Page != nil {
+ body["options"] = opts.Page
+ }
+ }
+ var report AuditReport
+ if err := c.post(ctx, "/audit", body, &report); err != nil {
+ return nil, err
+ }
+ return &report, nil
+}
+
+func (c *Client) post(ctx context.Context, path string, body, out any) error {
+ payload, err := json.Marshal(body)
+ if err != nil {
+ return fmt.Errorf("pinchtabaudit: encode request: %w", err)
+ }
+ req, err := http.NewRequestWithContext(ctx, http.MethodPost, c.baseURL+path, bytes.NewReader(payload))
+ if err != nil {
+ return fmt.Errorf("pinchtabaudit: build request: %w", err)
+ }
+ req.Header.Set("Content-Type", "application/json")
+ if c.token != "" {
+ req.Header.Set("Authorization", "Bearer "+c.token)
+ }
+
+ client := c.HTTPClient
+ if client == nil {
+ client = &http.Client{Timeout: DefaultTimeout}
+ }
+ resp, err := client.Do(req)
+ if err != nil {
+ return fmt.Errorf("pinchtabaudit: %s: %w", path, err)
+ }
+ defer func() { _ = resp.Body.Close() }()
+
+ data, err := io.ReadAll(resp.Body)
+ if err != nil {
+ return fmt.Errorf("pinchtabaudit: read response: %w", err)
+ }
+ if resp.StatusCode != http.StatusOK {
+ return fmt.Errorf("pinchtabaudit: %s: HTTP %d: %s", path, resp.StatusCode, strings.TrimSpace(string(data)))
+ }
+ if err := json.Unmarshal(data, out); err != nil {
+ return fmt.Errorf("pinchtabaudit: decode response: %w", err)
+ }
+ return nil
+}
diff --git a/pkg/pinchtabaudit/client_test.go b/pkg/pinchtabaudit/client_test.go
new file mode 100644
index 00000000..0f5eb3fa
--- /dev/null
+++ b/pkg/pinchtabaudit/client_test.go
@@ -0,0 +1,98 @@
+package pinchtabaudit
+
+import (
+ "context"
+ "encoding/json"
+ "net/http"
+ "net/http/httptest"
+ "strings"
+ "testing"
+)
+
+func TestEnrichPage(t *testing.T) {
+ srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ if r.URL.Path != "/audit/page" || r.Method != http.MethodPost {
+ t.Errorf("unexpected request %s %s", r.Method, r.URL.Path)
+ }
+ if got := r.Header.Get("Authorization"); got != "Bearer tok" {
+ t.Errorf("Authorization = %q", got)
+ }
+ var body map[string]any
+ _ = json.NewDecoder(r.Body).Decode(&body)
+ if body["url"] != "http://fixtures/clean.html" {
+ t.Errorf("body url = %v", body["url"])
+ }
+ opts, _ := body["options"].(map[string]any)
+ if opts["screenshot"] != false {
+ t.Errorf("options = %v", opts)
+ }
+ _, _ = w.Write([]byte(`{
+ "url": "http://fixtures/clean.html",
+ "title": "Clean",
+ "accessibilityScore": 100,
+ "timingMetrics": {"ttfbMs": 3.5, "loadMs": 20},
+ "interactiveElements": [{"ref": "e1", "role": "link", "name": "Home"}]
+ }`))
+ }))
+ defer srv.Close()
+
+ client := New(srv.URL, "tok")
+ page, err := client.EnrichPage(context.Background(), "http://fixtures/clean.html", &PageOptions{Screenshot: Bool(false)})
+ if err != nil {
+ t.Fatalf("EnrichPage: %v", err)
+ }
+ if page.Title != "Clean" || page.AccessibilityScore != 100 || page.TimingMetrics.Load != 20 {
+ t.Errorf("page = %+v", page)
+ }
+ if len(page.InteractiveElements) != 1 || page.InteractiveElements[0].Ref != "e1" {
+ t.Errorf("elements = %+v", page.InteractiveElements)
+ }
+}
+
+func TestEnrichWithBrowser(t *testing.T) {
+ srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ if r.URL.Path != "/audit" {
+ t.Errorf("path = %s", r.URL.Path)
+ }
+ var body map[string]any
+ _ = json.NewDecoder(r.Body).Decode(&body)
+ if body["sitemapUrl"] != "http://fixtures/sitemap.xml" || body["concurrency"] != float64(3) {
+ t.Errorf("body = %v", body)
+ }
+ _, _ = w.Write([]byte(`{
+ "schemaVersion": "1.0",
+ "generatedAt": "2026-07-04T12:00:00Z",
+ "pages": [{"url": "http://fixtures/a.html", "browser": {"timingMetrics": {}}}],
+ "summaryScore": 100
+ }`))
+ }))
+ defer srv.Close()
+
+ report, err := New(srv.URL, "").EnrichWithBrowser(context.Background(),
+ AuditInput{SitemapURL: "http://fixtures/sitemap.xml"},
+ &RunOptions{Concurrency: 3})
+ if err != nil {
+ t.Fatalf("EnrichWithBrowser: %v", err)
+ }
+ if report.SchemaVersion != "1.0" || len(report.Pages) != 1 || report.SummaryScore != 100 {
+ t.Errorf("report = %+v", report)
+ }
+}
+
+func TestEnrichWithBrowserRequiresInput(t *testing.T) {
+ if _, err := New("http://localhost:1", "").EnrichWithBrowser(context.Background(), AuditInput{}, nil); err == nil {
+ t.Error("empty input should error before any request")
+ }
+}
+
+func TestHTTPErrorsSurfaceBody(t *testing.T) {
+ srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ http.Error(w, `{"error":"urls required"}`, http.StatusBadRequest)
+ }))
+ defer srv.Close()
+
+ _, err := New(srv.URL, "").EnrichPage(context.Background(), "http://x/", nil)
+ if err == nil || !strings.Contains(err.Error(), "HTTP 400") || !strings.Contains(err.Error(), "urls required") {
+ t.Errorf("err = %v, want HTTP 400 with body", err)
+ }
+}
diff --git a/pkg/pinchtabaudit/example_test.go b/pkg/pinchtabaudit/example_test.go
new file mode 100644
index 00000000..4afca2ea
--- /dev/null
+++ b/pkg/pinchtabaudit/example_test.go
@@ -0,0 +1,41 @@
+package pinchtabaudit_test
+
+import (
+ "context"
+ "fmt"
+ "log"
+
+ "github.com/pinchtab/pinchtab/pkg/pinchtabaudit"
+)
+
+// Enrich a single page through a running pinchtab server and inspect the
+// browser-level data HTTP scraping cannot see.
+func ExampleClient_EnrichPage() {
+ client := pinchtabaudit.New("http://localhost:9867", "my-token")
+
+ page, err := client.EnrichPage(context.Background(), "https://example.com", &pinchtabaudit.PageOptions{
+ Screenshot: pinchtabaudit.Bool(false),
+ })
+ if err != nil {
+ log.Fatal(err)
+ }
+
+ fmt.Printf("accessibility %d/100, %d broken assets, load %.0f ms\n",
+ page.AccessibilityScore, len(page.BrokenAssets), page.TimingMetrics.Load)
+}
+
+// Run a whole-site audit from a sitemap — the library form of
+// `pinchtab audit --sitemap`.
+func ExampleClient_EnrichWithBrowser() {
+ client := pinchtabaudit.New("http://localhost:9867", "my-token")
+
+ report, err := client.EnrichWithBrowser(context.Background(),
+ pinchtabaudit.AuditInput{SitemapURL: "https://example.com/sitemap.xml"},
+ &pinchtabaudit.RunOptions{Concurrency: 3, SampleSize: 2},
+ )
+ if err != nil {
+ log.Fatal(err)
+ }
+
+ fmt.Printf("audited %d pages, summary score %d/100\n", len(report.Pages), report.SummaryScore)
+}
diff --git a/pkg/pinchtabaudit/types.go b/pkg/pinchtabaudit/types.go
new file mode 100644
index 00000000..2de10f5d
--- /dev/null
+++ b/pkg/pinchtabaudit/types.go
@@ -0,0 +1,184 @@
+package pinchtabaudit
+
+import "time"
+
+// The types in this file mirror the pinchtab audit API's JSON contract.
+// They are defined here rather than aliased so the public surface never
+// depends on pinchtab internal packages.
+
+// ConsoleLogEntry is a single console message captured during page load.
+type ConsoleLogEntry struct {
+ Timestamp time.Time `json:"timestamp"`
+ Level string `json:"level"`
+ Message string `json:"message"`
+ Source string `json:"source,omitempty"`
+}
+
+// NetworkRequest is a resource request observed while loading a page.
+type NetworkRequest struct {
+ URL string `json:"url"`
+ Method string `json:"method"`
+ Status int `json:"status,omitempty"`
+ StatusText string `json:"statusText,omitempty"`
+ ResourceType string `json:"resourceType,omitempty"`
+ MimeType string `json:"mimeType,omitempty"`
+ StartTime time.Time `json:"startTime"`
+ Duration float64 `json:"duration,omitempty"`
+ Size int64 `json:"size,omitempty"`
+ Failed bool `json:"failed,omitempty"`
+ Error string `json:"error,omitempty"`
+}
+
+// BrokenAsset is a page resource that failed to load.
+type BrokenAsset struct {
+ URL string `json:"url"`
+ ResourceType string `json:"resourceType,omitempty"`
+ Status int `json:"status,omitempty"`
+ Error string `json:"error,omitempty"`
+}
+
+// InteractiveElement is an actionable element discovered on the page.
+type InteractiveElement struct {
+ Ref string `json:"ref"`
+ Role string `json:"role"`
+ Name string `json:"name,omitempty"`
+ 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.
+type TimingMetrics struct {
+ TimeToFirstByte float64 `json:"ttfbMs,omitempty"`
+ DOMContentLoaded float64 `json:"domContentLoadedMs,omitempty"`
+ Load float64 `json:"loadMs,omitempty"`
+ FirstContentfulPaint float64 `json:"fcpMs,omitempty"`
+ LargestContentfulPaint float64 `json:"lcpMs,omitempty"`
+ CumulativeLayoutShift float64 `json:"cls,omitempty"`
+}
+
+// VisualDiffResult is the outcome of a compare-mode screenshot diff.
+type VisualDiffResult struct {
+ BaselinePath string `json:"baselinePath"`
+ CurrentPath string `json:"currentPath"`
+ DiffPath string `json:"diffPath,omitempty"`
+ DiffPixels int `json:"diffPixels"`
+ DiffRatio float64 `json:"diffRatio"`
+ Changed bool `json:"changed"`
+}
+
+// SecurityFinding is a rule-based security-surface issue.
+type SecurityFinding struct {
+ RuleID string `json:"ruleId"`
+ Severity string `json:"severity"`
+ Detail string `json:"detail"`
+ URL string `json:"url,omitempty"`
+}
+
+// A11yFinding is one accessibility rule violation aggregated for a page.
+type A11yFinding struct {
+ Rule string `json:"rule"`
+ Severity string `json:"severity"`
+ Count int `json:"count"`
+ Samples []string `json:"samples"`
+}
+
+// BrowserPageData is the browser-enriched data captured for a single page.
+type BrowserPageData struct {
+ ScreenshotPath string `json:"screenshotPath,omitempty"`
+ FullPageScreenshot bool `json:"fullPageScreenshot,omitempty"`
+ ConsoleLogs []ConsoleLogEntry `json:"consoleLogs,omitempty"`
+ NetworkRequests []NetworkRequest `json:"networkRequests,omitempty"`
+ BrokenAssets []BrokenAsset `json:"brokenAssets,omitempty"`
+ InteractiveElements []InteractiveElement `json:"interactiveElements,omitempty"`
+ AccessibilityScore int `json:"accessibilityScore,omitempty"`
+ VisualDiff *VisualDiffResult `json:"visualDiff,omitempty"`
+ TimingMetrics TimingMetrics `json:"timingMetrics"`
+}
+
+// PageAudit is the POST /audit/page response: one page's audit with the
+// BrowserPageData fields inlined.
+type PageAudit struct {
+ URL string `json:"url"`
+ Title string `json:"title,omitempty"`
+ Error string `json:"error,omitempty"`
+ Screenshot string `json:"screenshot,omitempty"`
+ A11yFindings []A11yFinding `json:"a11yFindings,omitempty"`
+ SecurityFindings []SecurityFinding `json:"securityFindings,omitempty"`
+ BrowserPageData
+}
+
+// PageResult is one page entry of an AuditReport.
+type PageResult struct {
+ URL string `json:"url"`
+ Title string `json:"title,omitempty"`
+ StatusCode int `json:"statusCode,omitempty"`
+ Error string `json:"error,omitempty"`
+ Screenshot string `json:"screenshot,omitempty"`
+ Seaportal map[string]any `json:"seaportal,omitempty"`
+ SecurityFindings []SecurityFinding `json:"securityFindings,omitempty"`
+ Browser BrowserPageData `json:"browser"`
+}
+
+// AuditInput describes where a run's pages come from. Exactly one source
+// should be set.
+type AuditInput struct {
+ // URLs is a direct list of page URLs to audit.
+ URLs []string `json:"urls,omitempty"`
+ // SitemapURL discovers pages from a sitemap (recursively).
+ SitemapURL string `json:"sitemapUrl,omitempty"`
+ // SeaportalResults is a raw seaportal results array (the interim
+ // seaportal-results/v0 format); pages route through browserRecommended.
+ SeaportalResults []byte `json:"seaportalResults,omitempty"`
+}
+
+// AuditOptions echoes the options a run was executed with.
+type AuditOptions struct {
+ SampleSize int `json:"sampleSize,omitempty"`
+ Screenshot bool `json:"screenshot,omitempty"`
+ NetworkMonitor bool `json:"networkMonitor,omitempty"`
+ VisualDiff bool `json:"visualDiff,omitempty"`
+ Concurrency int `json:"concurrency,omitempty"`
+ OutputDir string `json:"outputDir,omitempty"`
+}
+
+// AuditReport is the POST /audit response: the versioned site-level report.
+type AuditReport struct {
+ SchemaVersion string `json:"schemaVersion"`
+ GeneratedAt time.Time `json:"generatedAt"`
+ Input map[string]any `json:"input,omitempty"`
+ Options AuditOptions `json:"options"`
+ Pages []PageResult `json:"pages"`
+ SummaryScore int `json:"summaryScore"`
+ SecurityFindings []SecurityFinding `json:"securityFindings,omitempty"`
+ Recommendations []string `json:"recommendations,omitempty"`
+}
+
+// PageOptions toggles the per-page collectors. Nil fields keep the server
+// default (all collectors on); use Bool to set one explicitly.
+type PageOptions struct {
+ Screenshot *bool `json:"screenshot,omitempty"`
+ Network *bool `json:"network,omitempty"`
+ Console *bool `json:"console,omitempty"`
+ A11y *bool `json:"a11y,omitempty"`
+ Timing *bool `json:"timing,omitempty"`
+ Elements *bool `json:"elements,omitempty"`
+ Security *bool `json:"security,omitempty"`
+}
+
+// RunOptions configures a multi-page EnrichWithBrowser run.
+type RunOptions struct {
+ // Concurrency is the number of pages audited in parallel (server caps apply).
+ Concurrency int
+ // SampleSize caps pages per URL template group, 0 = no cap.
+ SampleSize int
+ // EnrichAll browser-enriches every seaportal page regardless of
+ // browserRecommended routing.
+ EnrichAll bool
+ // Page toggles the per-page collectors.
+ Page *PageOptions
+}
+
+// Bool returns a pointer to v, for PageOptions fields.
+func Bool(v bool) *bool { return &v }
diff --git a/tests/e2e/runner-cli/Dockerfile b/tests/e2e/runner-cli/Dockerfile
index 1a114c6c..49766b87 100644
--- a/tests/e2e/runner-cli/Dockerfile
+++ b/tests/e2e/runner-cli/Dockerfile
@@ -18,6 +18,9 @@ RUN go mod download
COPY . .
RUN CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o /out/pinchtab ./cmd/pinchtab
+# Library-mode example program, exercised by the library-mode smoke scenario
+RUN CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o /out/enrich-example ./docs/examples/enrich
+
# ── Runner image ──────────────────────────────────────────────────────────────
FROM alpine:3.23
@@ -33,9 +36,10 @@ RUN apk add --no-cache \
coreutils \
ca-certificates
-# Copy the freshly-built binary from the build stage
+# Copy the freshly-built binaries from the build stage
COPY --from=build /out/pinchtab /usr/local/bin/pinchtab
-RUN chmod +x /usr/local/bin/pinchtab
+COPY --from=build /out/enrich-example /usr/local/bin/enrich-example
+RUN chmod +x /usr/local/bin/pinchtab /usr/local/bin/enrich-example
# Sanity-check: bail early with a clear message if the binary is broken/missing
RUN pinchtab --version 2>/dev/null || { echo "ERROR: pinchtab binary not runnable after build"; exit 1; }
diff --git a/tests/e2e/scenarios/cli/library-mode-smoke.sh b/tests/e2e/scenarios/cli/library-mode-smoke.sh
new file mode 100755
index 00000000..b21b3cb7
--- /dev/null
+++ b/tests/e2e/scenarios/cli/library-mode-smoke.sh
@@ -0,0 +1,52 @@
+#!/bin/bash
+# library-mode-smoke.sh — pkg/pinchtabaudit library client end-to-end.
+#
+# The example program (docs/examples/enrich) is compiled into the runner-cli
+# image as `enrich-example`; this smoke drives it against the e2e service.
+
+GROUP_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+source "${GROUP_DIR}/../../helpers/cli.sh"
+
+# ─────────────────────────────────────────────────────────────────
+start_test "library example enriches a fixture page"
+
+if ! command -v enrich-example >/dev/null 2>&1; then
+ fail_assert "enrich-example binary present in runner image"
+ end_test
+ exit 0
+fi
+pass_assert "enrich-example binary present"
+
+OUT=$(enrich-example --server "$E2E_SERVER" --token "$E2E_SERVER_TOKEN" "http://fixtures/audit-site/clean.html" 2>/tmp/enrich-err)
+STATUS=$?
+if [ "$STATUS" -eq 0 ]; then
+ pass_assert "example exits 0"
+else
+ fail_assert "example exits 0 (got $STATUS, stderr: $(cat /tmp/enrich-err))"
+fi
+
+if echo "$OUT" | jq -e '.url == "http://fixtures/audit-site/clean.html"' >/dev/null 2>&1; then
+ pass_assert "output is valid JSON with the page url"
+else
+ fail_assert "output is valid JSON with the page url"
+fi
+
+if echo "$OUT" | jq -e '.accessibilityScore == 100' >/dev/null 2>&1; then
+ pass_assert "accessibilityScore present (100 for clean.html)"
+else
+ fail_assert "accessibilityScore present (got: $(echo "$OUT" | jq '.accessibilityScore'))"
+fi
+
+if echo "$OUT" | jq -e '.timingMetrics.loadMs > 0' >/dev/null 2>&1; then
+ pass_assert "timingMetrics.loadMs > 0"
+else
+ fail_assert "timingMetrics.loadMs > 0"
+fi
+
+if echo "$OUT" | jq -e '.interactiveElements | length >= 1' >/dev/null 2>&1; then
+ pass_assert "interactiveElements populated"
+else
+ fail_assert "interactiveElements populated"
+fi
+
+end_test
diff --git a/tests/e2e/scenarios/manifest.json b/tests/e2e/scenarios/manifest.json
index a07b75ff..86bc8a3e 100644
--- a/tests/e2e/scenarios/manifest.json
+++ b/tests/e2e/scenarios/manifest.json
@@ -1,145 +1,456 @@
{
"scenarios": {
"api/actions-basic.sh": {
- "tags": ["actions", "pr"]
+ "tags": [
+ "actions",
+ "pr"
+ ]
},
"api/actions-extended.sh": {
- "tags": ["actions", "mouse", "dialogs"]
+ "tags": [
+ "actions",
+ "mouse",
+ "dialogs"
+ ]
},
"api/browser-basic.sh": {
- "tags": ["browser", "snapshot", "find", "text", "pr"]
+ "tags": [
+ "browser",
+ "snapshot",
+ "find",
+ "text",
+ "pr"
+ ]
},
"api/browser-extended.sh": {
- "tags": ["browser", "cookies", "network", "wait"]
+ "tags": [
+ "browser",
+ "cookies",
+ "network",
+ "wait"
+ ]
},
"api/tabs-extended.sh": {
- "services": ["pinchtab", "pinchtab-secure", "fixtures"],
- "ready": ["E2E_SERVER", "E2E_SECURE_SERVER"],
- "tags": ["tabs", "secure", "handoff"]
+ "services": [
+ "pinchtab",
+ "pinchtab-secure",
+ "fixtures"
+ ],
+ "ready": [
+ "E2E_SERVER",
+ "E2E_SECURE_SERVER"
+ ],
+ "tags": [
+ "tabs",
+ "secure",
+ "handoff"
+ ]
},
"api/tabs-autoclose-smoke.sh": {
- "services": ["pinchtab", "pinchtab-autoclose", "fixtures"],
- "ready": ["E2E_SERVER", "E2E_AUTOCLOSE_SERVER"],
- "tags": ["tabs", "autoclose", "lifecycle", "smoke"]
+ "services": [
+ "pinchtab",
+ "pinchtab-autoclose",
+ "fixtures"
+ ],
+ "ready": [
+ "E2E_SERVER",
+ "E2E_AUTOCLOSE_SERVER"
+ ],
+ "tags": [
+ "tabs",
+ "autoclose",
+ "lifecycle",
+ "smoke"
+ ]
},
"api/auto-switch-smoke.sh": {
- "tags": ["tabs", "actions", "auto-switch", "smoke"]
+ "tags": [
+ "tabs",
+ "actions",
+ "auto-switch",
+ "smoke"
+ ]
},
"api/screencast-input-basic.sh": {
- "tags": ["actions", "screencast", "input", "coordinates", "multi-browser", "pr"]
+ "tags": [
+ "actions",
+ "screencast",
+ "input",
+ "coordinates",
+ "multi-browser",
+ "pr"
+ ]
},
"api/network-route-extended.sh": {
- "services": ["pinchtab", "pinchtab-full", "fixtures"],
- "ready": ["E2E_SERVER", "E2E_FULL_SERVER"],
- "tags": ["network", "route", "interception"]
+ "services": [
+ "pinchtab",
+ "pinchtab-full",
+ "fixtures"
+ ],
+ "ready": [
+ "E2E_SERVER",
+ "E2E_FULL_SERVER"
+ ],
+ "tags": [
+ "network",
+ "route",
+ "interception"
+ ]
},
"api/network-route-smoke.sh": {
- "services": ["pinchtab", "pinchtab-full", "fixtures"],
- "ready": ["E2E_SERVER", "E2E_FULL_SERVER"],
- "tags": ["network", "route", "interception", "smoke", "multi-browser"]
+ "services": [
+ "pinchtab",
+ "pinchtab-full",
+ "fixtures"
+ ],
+ "ready": [
+ "E2E_SERVER",
+ "E2E_FULL_SERVER"
+ ],
+ "tags": [
+ "network",
+ "route",
+ "interception",
+ "smoke",
+ "multi-browser"
+ ]
},
"api/network-retain-body.sh": {
- "services": ["pinchtab", "pinchtab-retain", "fixtures"],
- "ready": ["E2E_SERVER", "E2E_RETAIN_SERVER"],
- "tags": ["network", "retain", "body", "smoke"]
+ "services": [
+ "pinchtab",
+ "pinchtab-retain",
+ "fixtures"
+ ],
+ "ready": [
+ "E2E_SERVER",
+ "E2E_RETAIN_SERVER"
+ ],
+ "tags": [
+ "network",
+ "retain",
+ "body",
+ "smoke"
+ ]
},
"api/secrets-extended.sh": {
- "tags": ["actions", "secrets", "credentials"]
+ "tags": [
+ "actions",
+ "secrets",
+ "credentials"
+ ]
},
"cli/actions-basic.sh": {
- "tags": ["actions", "pr"]
+ "tags": [
+ "actions",
+ "pr"
+ ]
},
"cli/actions-extended.sh": {
- "tags": ["actions", "mouse", "keyboard", "wait"]
+ "tags": [
+ "actions",
+ "mouse",
+ "keyboard",
+ "wait"
+ ]
},
"cli/system-smoke.sh": {
- "tags": ["system", "lifecycle", "instance", "smoke"]
+ "tags": [
+ "system",
+ "lifecycle",
+ "instance",
+ "smoke"
+ ]
},
"cli/tabs-smoke.sh": {
- "tags": ["tabs", "eviction", "smoke"]
+ "tags": [
+ "tabs",
+ "eviction",
+ "smoke"
+ ]
},
"infra/auth-extended.sh": {
- "services": ["pinchtab", "pinchtab-full", "fixtures"],
- "ready": ["E2E_SERVER", "E2E_FULL_SERVER"],
- "tags": ["auth", "dashboard", "sessions"]
+ "services": [
+ "pinchtab",
+ "pinchtab-full",
+ "fixtures"
+ ],
+ "ready": [
+ "E2E_SERVER",
+ "E2E_FULL_SERVER"
+ ],
+ "tags": [
+ "auth",
+ "dashboard",
+ "sessions"
+ ]
},
"infra/autosolver-smoke.sh": {
- "services": ["pinchtab", "pinchtab-medium", "fixtures"],
- "ready": ["E2E_SERVER", "E2E_MEDIUM_SERVER"],
- "tags": ["autosolver", "medium", "smoke", "multi-browser"]
+ "services": [
+ "pinchtab",
+ "pinchtab-medium",
+ "fixtures"
+ ],
+ "ready": [
+ "E2E_SERVER",
+ "E2E_MEDIUM_SERVER"
+ ],
+ "tags": [
+ "autosolver",
+ "medium",
+ "smoke",
+ "multi-browser"
+ ]
},
"infra/dashboard-smoke.sh": {
- "services": ["pinchtab", "pinchtab-full", "fixtures"],
- "ready": ["E2E_SERVER", "E2E_FULL_SERVER"],
- "tags": ["dashboard", "screencast", "full", "smoke", "multi-browser"]
+ "services": [
+ "pinchtab",
+ "pinchtab-full",
+ "fixtures"
+ ],
+ "ready": [
+ "E2E_SERVER",
+ "E2E_FULL_SERVER"
+ ],
+ "tags": [
+ "dashboard",
+ "screencast",
+ "full",
+ "smoke",
+ "multi-browser"
+ ]
},
"infra/screencast-cloak-diag.sh": {
- "services": ["pinchtab", "pinchtab-full", "fixtures"],
- "ready": ["E2E_SERVER", "E2E_FULL_SERVER"],
- "tags": ["screencast", "cloak", "diagnostics", "full"]
+ "services": [
+ "pinchtab",
+ "pinchtab-full",
+ "fixtures"
+ ],
+ "ready": [
+ "E2E_SERVER",
+ "E2E_FULL_SERVER"
+ ],
+ "tags": [
+ "screencast",
+ "cloak",
+ "diagnostics",
+ "full"
+ ]
},
"infra/browser-routing-smoke.sh": {
- "services": ["pinchtab", "fixtures"],
- "ready": ["E2E_SERVER"],
- "tags": ["browser-routing", "smoke", "multi-browser"]
+ "services": [
+ "pinchtab",
+ "fixtures"
+ ],
+ "ready": [
+ "E2E_SERVER"
+ ],
+ "tags": [
+ "browser-routing",
+ "smoke",
+ "multi-browser"
+ ]
},
"infra/browser-routing-extended.sh": {
- "services": ["pinchtab", "pinchtab-secure", "pinchtab-ghostchrome", "fixtures"],
- "ready": ["E2E_SERVER", "E2E_SECURE_SERVER", "E2E_SERVER_GHOSTCHROME"],
- "tags": ["browser-routing", "ghost-chrome", "secure"]
+ "services": [
+ "pinchtab",
+ "pinchtab-secure",
+ "pinchtab-ghostchrome",
+ "fixtures"
+ ],
+ "ready": [
+ "E2E_SERVER",
+ "E2E_SECURE_SERVER",
+ "E2E_SERVER_GHOSTCHROME"
+ ],
+ "tags": [
+ "browser-routing",
+ "ghost-chrome",
+ "secure"
+ ]
},
"infra/idpi-extended.sh": {
- "services": ["pinchtab", "pinchtab-secure", "fixtures"],
- "ready": ["E2E_SERVER", "E2E_SECURE_SERVER"],
- "tags": ["idpi", "secure"]
+ "services": [
+ "pinchtab",
+ "pinchtab-secure",
+ "fixtures"
+ ],
+ "ready": [
+ "E2E_SERVER",
+ "E2E_SECURE_SERVER"
+ ],
+ "tags": [
+ "idpi",
+ "secure"
+ ]
},
"infra/orchestrator-extended.sh": {
- "services": ["pinchtab", "pinchtab-bridge", "fixtures"],
- "ready": ["E2E_SERVER", "E2E_BRIDGE_URL|60|E2E_BRIDGE_TOKEN"],
- "tags": ["orchestrator", "multiinstance", "bridge", "lifecycle"]
+ "services": [
+ "pinchtab",
+ "pinchtab-bridge",
+ "fixtures"
+ ],
+ "ready": [
+ "E2E_SERVER",
+ "E2E_BRIDGE_URL|60|E2E_BRIDGE_TOKEN"
+ ],
+ "tags": [
+ "orchestrator",
+ "multiinstance",
+ "bridge",
+ "lifecycle"
+ ]
},
"infra/orchestrator-smoke.sh": {
- "services": ["pinchtab", "fixtures"],
- "ready": ["E2E_SERVER"],
- "tags": ["orchestrator", "multiinstance", "topology", "cleanup", "lifecycle", "smoke"]
+ "services": [
+ "pinchtab",
+ "fixtures"
+ ],
+ "ready": [
+ "E2E_SERVER"
+ ],
+ "tags": [
+ "orchestrator",
+ "multiinstance",
+ "topology",
+ "cleanup",
+ "lifecycle",
+ "smoke"
+ ]
},
"infra/security-extended.sh": {
- "services": ["pinchtab", "pinchtab-secure", "fixtures"],
- "ready": ["E2E_SERVER", "E2E_SECURE_SERVER"],
- "tags": ["security", "secure", "multiinstance"]
+ "services": [
+ "pinchtab",
+ "pinchtab-secure",
+ "fixtures"
+ ],
+ "ready": [
+ "E2E_SERVER",
+ "E2E_SECURE_SERVER"
+ ],
+ "tags": [
+ "security",
+ "secure",
+ "multiinstance"
+ ]
},
"infra/security-smoke.sh": {
- "services": ["pinchtab", "pinchtab-secure", "fixtures"],
- "ready": ["E2E_SERVER", "E2E_SECURE_SERVER"],
- "tags": ["security", "secure", "multiinstance", "allowedDomains", "smoke"]
+ "services": [
+ "pinchtab",
+ "pinchtab-secure",
+ "fixtures"
+ ],
+ "ready": [
+ "E2E_SERVER",
+ "E2E_SECURE_SERVER"
+ ],
+ "tags": [
+ "security",
+ "secure",
+ "multiinstance",
+ "allowedDomains",
+ "smoke"
+ ]
},
"infra/stealth-extended.sh": {
- "services": ["pinchtab", "pinchtab-secure", "pinchtab-medium", "pinchtab-full", "fixtures"],
- "ready": ["E2E_SERVER", "E2E_SECURE_SERVER", "E2E_MEDIUM_SERVER", "E2E_FULL_SERVER"],
- "tags": ["stealth", "secure", "medium", "full"]
+ "services": [
+ "pinchtab",
+ "pinchtab-secure",
+ "pinchtab-medium",
+ "pinchtab-full",
+ "fixtures"
+ ],
+ "ready": [
+ "E2E_SERVER",
+ "E2E_SECURE_SERVER",
+ "E2E_MEDIUM_SERVER",
+ "E2E_FULL_SERVER"
+ ],
+ "tags": [
+ "stealth",
+ "secure",
+ "medium",
+ "full"
+ ]
},
"infra/system-extended.sh": {
- "services": ["pinchtab", "pinchtab-secure", "pinchtab-ghostchrome", "fixtures"],
- "ready": ["E2E_SERVER", "E2E_SECURE_SERVER", "E2E_SERVER_GHOSTCHROME"],
- "tags": ["system", "tasks", "idpi", "ghost-chrome", "secure"]
+ "services": [
+ "pinchtab",
+ "pinchtab-secure",
+ "pinchtab-ghostchrome",
+ "fixtures"
+ ],
+ "ready": [
+ "E2E_SERVER",
+ "E2E_SECURE_SERVER",
+ "E2E_SERVER_GHOSTCHROME"
+ ],
+ "tags": [
+ "system",
+ "tasks",
+ "idpi",
+ "ghost-chrome",
+ "secure"
+ ]
},
"api/recording-smoke.sh": {
- "tags": ["recording", "video", "smoke", "multi-browser"]
+ "tags": [
+ "recording",
+ "video",
+ "smoke",
+ "multi-browser"
+ ]
},
"api/browser-route-basic.sh": {
- "tags": ["browser", "route", "metadata", "provider", "pr"]
+ "tags": [
+ "browser",
+ "route",
+ "metadata",
+ "provider",
+ "pr"
+ ]
},
"api/browser-selection-basic.sh": {
- "tags": ["browser", "selection", "errors", "provider", "pr"]
+ "tags": [
+ "browser",
+ "selection",
+ "errors",
+ "provider",
+ "pr"
+ ]
},
"api/browser-activity-basic.sh": {
- "tags": ["browser", "activity", "metadata", "route", "pr"]
+ "tags": [
+ "browser",
+ "activity",
+ "metadata",
+ "route",
+ "pr"
+ ]
},
"infra/browser-instance-basic.sh": {
- "tags": ["browser", "instance", "launch", "provider", "pr"]
+ "tags": [
+ "browser",
+ "instance",
+ "launch",
+ "provider",
+ "pr"
+ ]
},
"infra/browser-config-basic.sh": {
- "tags": ["browser", "config", "dashboard", "proxy", "redaction", "pr"]
+ "tags": [
+ "browser",
+ "config",
+ "dashboard",
+ "proxy",
+ "redaction",
+ "pr"
+ ]
+ },
+ "cli/library-mode-smoke.sh": {
+ "tags": [
+ "library",
+ "smoke"
+ ]
}
}
}