High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.
feat: stealth level improvements with medium tier, E2E test reorg, and screencast fixes (#317)
luigiagentd0b5df68023f
diff --git a/.github/DEFINITION_OF_DONE.md b/.github/DEFINITION_OF_DONE.mdindex cf3aacb2..2b18d584 100644--- a/.github/DEFINITION_OF_DONE.md+++ b/.github/DEFINITION_OF_DONE.md@@ -20,7 +20,7 @@ These run automatically via `ci.yml`. If your PR fails them, fix and re-push.## Manual — Testing (Required)- [ ] **New/changed functionality has tests** — Same-package unit tests preferred-- [ ] **Docker E2E tests run locally** — If you modified handlers/bridge/tabs, run: `./dev e2e` (Docker curl E2E) and/or `./dev e2e cli` (Docker CLI E2E)+- [ ] **Docker E2E tests run locally** — If you modified handlers/bridge/tabs, run: `./dev e2e` and/or the narrower suite you changed, for example `./dev e2e api-fast`, `./dev e2e api-full`, or `./dev e2e cli-full`- [ ] **npm commands work** (if npm wrapper touched):- `npm pack` in `/npm/` produces valid tarball- `npm install -g pinchtab` (or from local tarball) succeedsdiff --git a/.github/workflows/e2e-recent.yml b/.github/workflows/e2e.ymlsimilarity index 58%rename from .github/workflows/e2e-recent.ymlrename to .github/workflows/e2e.ymlindex f169a2f7..5cf5359d 100644--- a/.github/workflows/e2e-recent.yml+++ b/.github/workflows/e2e.yml@@ -4,15 +4,6 @@ permissions:contents: readon:- push:- branches: [main]- paths-ignore:- - '**.md'- - 'docs/**'- - 'LICENSE'- - '.gitignore'- - 'skill/**'- - 'plugin/**'pull_request:branches: [main]paths-ignore:@@ -28,19 +19,7 @@ env:FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: truejobs:- recent:- if: github.event_name != 'workflow_dispatch' && (github.event_name != 'pull_request' || github.event.pull_request.draft == false)- uses: ./.github/workflows/reusable-e2e-suite.yml- with:- ref: ${{ github.sha }}- suite: recent- summary_title: E2E Recent Tests- timeout_minutes: 10- compose_file: tests/e2e/docker-compose.yml- dump_instance_inventory: true-api-fast:- needs: recentif: github.event_name != 'workflow_dispatch'uses: ./.github/workflows/reusable-e2e-suite.ymlwith:@@ -51,7 +30,6 @@ jobs:compose_file: tests/e2e/docker-compose.ymlcli-fast:- needs: recentif: github.event_name != 'workflow_dispatch'uses: ./.github/workflows/reusable-e2e-suite.ymlwith:@@ -59,7 +37,7 @@ jobs:suite: cli-fastsummary_title: E2E CLI Fast Teststimeout_minutes: 15- compose_file: tests/e2e/docker-compose-cli.yml+ compose_file: tests/e2e/docker-compose.ymlfull-api:if: github.event_name == 'workflow_dispatch'@@ -69,7 +47,7 @@ jobs:suite: full-apisummary_title: E2E Full API Teststimeout_minutes: 20- compose_file: tests/e2e/docker-compose.yml+ compose_file: tests/e2e/docker-compose-multi.ymlfull-cli:if: github.event_name == 'workflow_dispatch'@@ -79,14 +57,4 @@ jobs:suite: full-clisummary_title: E2E Full CLI Teststimeout_minutes: 20- compose_file: tests/e2e/docker-compose-cli.yml-- full-extended:- if: github.event_name == 'workflow_dispatch'- uses: ./.github/workflows/reusable-e2e-suite.yml- with:- ref: ${{ github.sha }}- suite: full-extended- summary_title: E2E Full Extended Tests- timeout_minutes: 20- compose_file: tests/e2e/docker-compose-orchestrator.yml+ compose_file: tests/e2e/docker-compose.ymldiff --git a/.github/workflows/prepare-release.yml b/.github/workflows/prepare-release.ymlindex a86effd5..eeba2cf5 100644--- a/.github/workflows/prepare-release.yml+++ b/.github/workflows/prepare-release.yml@@ -32,7 +32,7 @@ jobs:sha: ${{ steps.meta.outputs.sha }}ref: ${{ steps.meta.outputs.ref }}steps:- - uses: actions/checkout@v5+ - uses: actions/checkout@v6with:fetch-depth: 0ref: ${{ inputs.ref }}@@ -125,7 +125,7 @@ jobs:runs-on: ubuntu-latesttimeout-minutes: 20steps:- - uses: actions/checkout@v5+ - uses: actions/checkout@v6with:fetch-depth: 0ref: ${{ needs.validate.outputs.sha }}@@ -134,7 +134,7 @@ jobs:with:go-version: '1.26'- - uses: actions/setup-node@v5+ - uses: actions/setup-node@v6with:node-version: '22'@@ -191,7 +191,7 @@ jobs:permissions:contents: writesteps:- - uses: actions/checkout@v5+ - uses: actions/checkout@v6with:fetch-depth: 0ref: ${{ needs.validate.outputs.sha }}diff --git a/.github/workflows/publish-skill.yml b/.github/workflows/publish-skill.ymlindex fd44814c..711c034f 100644--- a/.github/workflows/publish-skill.yml+++ b/.github/workflows/publish-skill.yml@@ -26,9 +26,9 @@ jobs:name: Publish to ClawHubruns-on: ubuntu-lateststeps:- - uses: actions/checkout@v5+ - uses: actions/checkout@v6- - uses: actions/setup-node@v5+ - uses: actions/setup-node@v6with:node-version: '22'diff --git a/.github/workflows/release.yml b/.github/workflows/release.ymlindex 0b678219..e179189e 100644--- a/.github/workflows/release.yml+++ b/.github/workflows/release.yml@@ -22,7 +22,7 @@ jobs:permissions:contents: writesteps:- - uses: actions/checkout@v5+ - uses: actions/checkout@v6with:fetch-depth: 0ref: ${{ github.ref }}@@ -53,11 +53,11 @@ jobs:permissions:contents: readsteps:- - uses: actions/checkout@v5+ - uses: actions/checkout@v6with:ref: ${{ github.ref }}- - uses: actions/setup-node@v5+ - uses: actions/setup-node@v6with:node-version: '22'registry-url: 'https://registry.npmjs.org'@@ -105,7 +105,7 @@ jobs:contents: readpackages: writesteps:- - uses: actions/checkout@v5+ - uses: actions/checkout@v6with:ref: ${{ github.ref }}diff --git a/.github/workflows/reusable-dashboard.yml b/.github/workflows/reusable-dashboard.ymlindex f3dce955..580d9b3e 100644--- a/.github/workflows/reusable-dashboard.yml+++ b/.github/workflows/reusable-dashboard.yml@@ -22,7 +22,7 @@ jobs:name: Lint, Type Check & Testruns-on: ubuntu-lateststeps:- - uses: actions/checkout@v5+ - uses: actions/checkout@v6with:ref: ${{ inputs.ref }}@@ -65,7 +65,7 @@ jobs:runs-on: ubuntu-latestneeds: checksteps:- - uses: actions/checkout@v5+ - uses: actions/checkout@v6with:ref: ${{ inputs.ref }}@@ -94,7 +94,7 @@ jobs:run: bun run build- name: Upload build artifacts- uses: actions/upload-artifact@v4+ uses: actions/upload-artifact@v6with:name: dashboard-distpath: dashboard/dist/diff --git a/.github/workflows/reusable-docker-smoke.yml b/.github/workflows/reusable-docker-smoke.ymlindex 0144567e..347f90e7 100644--- a/.github/workflows/reusable-docker-smoke.yml+++ b/.github/workflows/reusable-docker-smoke.yml@@ -19,7 +19,7 @@ jobs:runs-on: ubuntu-latesttimeout-minutes: 20steps:- - uses: actions/checkout@v5+ - uses: actions/checkout@v6with:ref: ${{ inputs.ref }}diff --git a/.github/workflows/reusable-docs-verify.yml b/.github/workflows/reusable-docs-verify.ymlindex c5057d2e..5736ef81 100644--- a/.github/workflows/reusable-docs-verify.yml+++ b/.github/workflows/reusable-docs-verify.yml@@ -18,7 +18,7 @@ jobs:name: Validate Documentationruns-on: ubuntu-lateststeps:- - uses: actions/checkout@v5+ - uses: actions/checkout@v6with:ref: ${{ inputs.ref }}diff --git a/.github/workflows/reusable-e2e-suite.yml b/.github/workflows/reusable-e2e-suite.ymlindex 57d89033..918178bf 100644--- a/.github/workflows/reusable-e2e-suite.yml+++ b/.github/workflows/reusable-e2e-suite.yml@@ -37,7 +37,7 @@ jobs:timeout-minutes: ${{ inputs.timeout_minutes }}steps:- name: Checkout- uses: actions/checkout@v5+ uses: actions/checkout@v6with:ref: ${{ inputs.ref }}@@ -55,12 +55,19 @@ jobs:run: |set +emkdir -p tests/e2e/results+ rm -f tests/e2e/results/summary*.txt tests/e2e/results/report*.md e2e-output.log./dev e2e "${{ inputs.suite }}" 2>&1 | tee e2e-output.logEXIT_CODE=${PIPESTATUS[0]}- PASSED=$(grep -oP 'Passed:\s*\K\d+' e2e-output.log | awk '{s+=$1} END {print s+0}')- FAILED=$(grep -oP 'Failed:\s*\K\d+' e2e-output.log | awk '{s+=$1} END {print s+0}')+ SUMMARY_FILES=$(find tests/e2e/results -maxdepth 1 -type f -name 'summary*.txt' | sort || true)+ if [ -n "$SUMMARY_FILES" ]; then+ PASSED=$(awk -F= '/^passed=/{s+=$2} END {print s+0}' $SUMMARY_FILES)+ FAILED=$(awk -F= '/^failed=/{s+=$2} END {print s+0}' $SUMMARY_FILES)+ else+ PASSED=$(grep -oP 'Passed:\s*\K\d+' e2e-output.log | awk '{s+=$1} END {print s+0}')+ FAILED=$(grep -oP 'Failed:\s*\K\d+' e2e-output.log | awk '{s+=$1} END {print s+0}')+ fiFAILURES=$(grep -E '✗.*failed' e2e-output.log | sed 's/.*✗ /- /' | head -10 || true)echo "passed=$PASSED" >> "$GITHUB_OUTPUT"@@ -76,6 +83,17 @@ jobs:DOCKER_BUILDKIT: 1COMPOSE_DOCKER_CLI_BUILD: 1+ - name: Upload E2E artifacts+ if: always()+ uses: actions/upload-artifact@v6+ with:+ name: e2e-results-${{ inputs.suite }}+ path: |+ tests/e2e/results/+ e2e-output.log+ if-no-files-found: warn+ retention-days: 7+- name: Dump pinchtab logs on failureif: failure() && inputs.compose_file != ''run: |@@ -122,3 +140,5 @@ jobs:echo "${{ steps.e2e.outputs.failures }}" >> "$GITHUB_STEP_SUMMARY"echo '```' >> "$GITHUB_STEP_SUMMARY"fi+ echo "" >> "$GITHUB_STEP_SUMMARY"+ echo "Artifacts: \`e2e-results-${{ inputs.suite }}\`" >> "$GITHUB_STEP_SUMMARY"diff --git a/.github/workflows/reusable-go-verify.yml b/.github/workflows/reusable-go-verify.ymlindex aafc83bd..172c47de 100644--- a/.github/workflows/reusable-go-verify.yml+++ b/.github/workflows/reusable-go-verify.yml@@ -18,7 +18,7 @@ jobs:name: Build & Vetruns-on: ubuntu-lateststeps:- - uses: actions/checkout@v5+ - uses: actions/checkout@v6with:ref: ${{ inputs.ref }}@@ -59,7 +59,7 @@ jobs:name: Lintruns-on: ubuntu-lateststeps:- - uses: actions/checkout@v5+ - uses: actions/checkout@v6with:ref: ${{ inputs.ref }}@@ -80,7 +80,7 @@ jobs:./scripts/build-dashboard.sh- name: golangci-lint- uses: golangci/golangci-lint-action@v7+ uses: golangci/golangci-lint-action@v9with:version: v2.9.0@@ -88,7 +88,7 @@ jobs:name: Security Scanruns-on: ubuntu-lateststeps:- - uses: actions/checkout@v5+ - uses: actions/checkout@v6with:ref: ${{ inputs.ref }}diff --git a/.github/workflows/reusable-npm-verify.yml b/.github/workflows/reusable-npm-verify.ymlindex b30dca4d..7900049f 100644--- a/.github/workflows/reusable-npm-verify.yml+++ b/.github/workflows/reusable-npm-verify.yml@@ -18,11 +18,11 @@ jobs:name: Verify npm Packageruns-on: ubuntu-lateststeps:- - uses: actions/checkout@v5+ - uses: actions/checkout@v6with:ref: ${{ inputs.ref }}- - uses: actions/setup-node@v5+ - uses: actions/setup-node@v6with:node-version: '22'diff --git a/TESTING.md b/TESTING.mdindex 1874bdca..51a185e6 100644--- a/TESTING.md+++ b/TESTING.md@@ -8,14 +8,17 @@ The `dev` developer toolkit is the easiest way to run checks and tests:./dev # Interactive picker./dev test # All tests (unit + E2E)./dev test unit # Unit tests only-./dev e2e # Release meta-suite (full API + full CLI + full extended)-./dev e2e pr # PR meta-suite (recent + api-fast + cli-fast)-./dev e2e recent # Recent E2E coverage for fail-fast feedback-./dev e2e api-fast # PR-fast API suite-./dev e2e cli-fast # PR-fast CLI suite-./dev e2e full-api # Full API suite-./dev e2e full-cli # Full CLI suite-./dev e2e full-extended # Extended suite (recent + orchestrator)+./dev e2e # Release suite (api-full + cli-full)+./dev e2e pr # PR suite (api-fast + cli-fast)+./dev e2e api-fast # API fast, single-instance+./dev e2e cli-fast # CLI fast, single-instance+./dev e2e api-full # API full, multi-instance+./dev e2e cli-full # CLI full, single-instance++/bin/bash tests/e2e/run.sh api+/bin/bash tests/e2e/run.sh api all=true+/bin/bash tests/e2e/run.sh cli+/bin/bash tests/e2e/run.sh cli all=true./dev check # All checks (format, vet, build, lint)./dev check go # Go checks only./dev check security # Gosec security scan@@ -41,7 +44,6 @@ End-to-end tests launch a real pinchtab server with Chrome and run e2e-level tes```bash./dev e2e pr-./dev e2e recent./dev e2e api-fast./dev e2e cli-fast```@@ -49,33 +51,24 @@ End-to-end tests launch a real pinchtab server with Chrome and run e2e-level tesUse these on pull requests and during normal development:- `pr` runs the same E2E suite composition as the PR workflow-- `recent` is the fail-fast bucket for newly added coverage-- `api-fast` is the stable API smoke/regression set-- `cli-fast` is the stable CLI smoke/regression set+- `api-fast` runs the API `*-basic.sh` groups on the single-instance stack+- `cli-fast` runs the CLI `*-basic.sh` groups on the single-instance stack### Full API Suite```bash-./dev e2e full-api+./dev e2e api-full```-Runs 184 HTTP-level tests using curl against the server. Tests the REST API, navigation, snapshots, activity logging, and other HTTP endpoints.+Runs the grouped API `basic` and `full` scenarios on the multi-instance stack. `api-fast` is the `basic` layer only on the single-instance stack; `api-full` adds the extra and edge-case groups plus the multi-instance-only coverage.### Full CLI Suite```bash-./dev e2e full-cli+./dev e2e cli-full```-Runs CLI e2e tests. Tests the command-line interface directly, including activity queries.--### Full Extended Suite--```bash-./dev e2e full-extended-```--Runs the extended/manual coverage bucket: recent edge-case scenarios plus the orchestration-focused suite, including remote bridge attachment and multi-instance flows.+Runs the grouped CLI `basic` and `full` scenarios on the single-instance stack. `cli-fast` is the `basic` layer only; `cli-full` adds the extra and edge-case groups.### Release Meta-Suite@@ -83,7 +76,7 @@ Runs the extended/manual coverage bucket: recent edge-case scenarios plus the or./dev e2e```-Runs `full-api`, `full-cli`, and `full-extended` in sequence.+Runs `api-full` and `cli-full` in sequence.## Environment Variables@@ -106,88 +99,47 @@ Everything is cleaned up automatically when tests finish.## Test File Structure-E2E tests are organized by surface plus suite manifests:+E2E tests are organized by surface and feature group:-- **`tests/e2e/scenarios/*.sh`** — HTTP curl-based tests (184 tests)- - Test the REST API directly- - Use Docker Compose: `tests/e2e/docker-compose.yml`+- **`tests/e2e/scenarios-api/*.sh`** — grouped API entrypoints such as `tabs-basic.sh` and `tabs-full.sh`+ - `*-basic.sh` is the PR-fast happy-path layer+ - `*-full.sh` adds the extra and edge-case coverage for the same feature+ - Use Docker Compose: `tests/e2e/docker-compose.yml` for `api-fast`, `tests/e2e/docker-compose-multi.yml` for `api-full`-- **`tests/e2e/scenarios-orchestrator/*.sh`** — orchestration-heavy curl tests- - Test multi-instance flows and remote bridge attachment- - Use Docker Compose: `tests/e2e/docker-compose-orchestrator.yml`+- **`tests/e2e/scenarios-cli/*.sh`** — grouped CLI entrypoints such as `tabs-basic.sh` and `tabs-full.sh`+ - Follows the same `basic` vs `full` split as the API side+ - Use Docker Compose: `tests/e2e/docker-compose.yml` for both `cli-fast` and `cli-full`-- **`tests/e2e/scenarios-cli/*.sh`** — CLI e2e tests (42 tests)- - Test the command-line interface- - Use Docker Compose: `tests/e2e/docker-compose-cli.yml`+## E2E Results-- **`tests/e2e/scenarios-recent/*.sh`** — recent edge-case coverage for fail-fast CI+Each suite writes its own summary and markdown report under `tests/e2e/results/`:-- **`tests/e2e/suites/*.txt`** — curated suite manifests- - `api-fast.txt`- - `cli-fast.txt`+- `summary-api-fast.txt` / `report-api-fast.md`+- `summary-api-full.txt` / `report-api-full.md`+- `summary-cli-fast.txt` / `report-cli-fast.md`+- `summary-cli-full.txt` / `report-cli-full.md`-Each test is a standalone bash script that:-1. Starts the test server (or uses existing)-2. Runs curl or CLI commands-3. Asserts expected output or exit codes-4. Cleans up+The runner clears the target suite files before each run so stale results do not survive into the next suite.## Writing New E2E Tests-Create a new bash script in `tests/e2e/scenarios/` (for API tests), `tests/e2e/scenarios-cli/` (for CLI tests), or `tests/e2e/scenarios-recent/` (for fresh fail-fast coverage):+Add new coverage directly to a grouped entrypoint in `tests/e2e/scenarios-api/` or `tests/e2e/scenarios-cli/`. Keep `*-basic.sh` focused on the happy path and put the extra and edge-case coverage in the matching `*-full.sh`.-### Example: Simple Curl Test+### Example: Grouped API Entrypoint```bash#!/bin/bash-# tests/e2e/scenarios/test-my-feature.sh--set -e # Exit on error--# Source helpers-. "$(dirname "$0")/../helpers.sh"--# Test setup-SERVER_URL="http://localhost:9867"--# Start server if needed-start_test_server--# Run test-echo "Testing my feature..."-RESPONSE=$(curl -s "$SERVER_URL/health")--if [ "$(echo "$RESPONSE" | jq -r '.status')" != "ok" ]; then- echo "❌ Health check failed"- exit 1-fi--echo "✅ Test passed"-```--### Example: CLI Test--```bash-#!/bin/bash--# tests/e2e/scenarios-cli/test-my-cli.sh--set -e--# Source helpers-. "$(dirname "$0")/../helpers.sh"--# Test the CLI-echo "Testing pinchtab CLI..."-OUTPUT=$($PINCHTAB_BIN --version)+# tests/e2e/scenarios-api/tabs-basic.sh+SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"+source "${SCRIPT_DIR}/../helpers/api.sh"-if [[ ! "$OUTPUT" =~ pinchtab ]]; then- echo "❌ Version output incorrect"- exit 1-fi+start_test "tab-scoped snapshot"+# ...-echo "✅ CLI test passed"+start_test "tab focus"+# ...+end_test```## Coveragediff --git a/cmd/pinchtab/cmd_cli.go b/cmd/pinchtab/cmd_cli.goindex 4340bfa5..298e3a6e 100644--- a/cmd/pinchtab/cmd_cli.go+++ b/cmd/pinchtab/cmd_cli.go@@ -13,12 +13,20 @@ import ("github.com/spf13/cobra")+func normalizeRequiredURL(raw string) string {+ trimmed := strings.TrimSpace(raw)+ if trimmed == "" {+ cobra.CheckErr(fmt.Errorf("empty URL"))+ }+ return urlutil.Normalize(trimmed)+}+var quickCmd = &cobra.Command{Use: "quick <url>",Short: "Navigate + analyze page",Args: cobra.ExactArgs(1),Run: func(cmd *cobra.Command, args []string) {- args[0] = urlutil.Normalize(args[0])+ args[0] = normalizeRequiredURL(args[0])cfg := config.Load()runCLIWith(cfg, func(client *http.Client, base, token string) {browseractions.Quick(client, base, token, args)@@ -32,7 +40,7 @@ var navCmd = &cobra.Command{Short: "Navigate to URL",Args: cobra.ExactArgs(1),Run: func(cmd *cobra.Command, args []string) {- url := urlutil.Normalize(args[0])+ url := normalizeRequiredURL(args[0])cfg := config.Load()runCLIWith(cfg, func(client *http.Client, base, token string) {browseractions.Navigate(client, base, token, url, cmd)@@ -285,7 +293,7 @@ var downloadCmd = &cobra.Command{Short: "Download a file via browser session",Args: cobra.ExactArgs(1),Run: func(cmd *cobra.Command, args []string) {- args[0] = urlutil.Normalize(args[0])+ args[0] = normalizeRequiredURL(args[0])output, _ := cmd.Flags().GetString("output")cfg := config.Load()runCLIWith(cfg, func(client *http.Client, base, token string) {@@ -555,7 +563,7 @@ func init() {runCLIWith(cfg, func(client *http.Client, base, token string) {body := map[string]any{"action": "new"}if len(args) > 0 {- body["url"] = urlutil.Normalize(args[0])+ body["url"] = normalizeRequiredURL(args[0])}browseractions.TabNew(client, base, token, body)})@@ -744,7 +752,7 @@ func init() {Short: "Navigate an instance to a URL",Args: cobra.ExactArgs(2),Run: func(cmd *cobra.Command, args []string) {- args[1] = urlutil.Normalize(args[1])+ args[1] = normalizeRequiredURL(args[1])cfg := config.Load()runCLIWith(cfg, func(client *http.Client, base, token string) {browseractions.InstanceNavigate(client, base, token, args)diff --git a/cmd/pinchtab/cmd_cli_test.go b/cmd/pinchtab/cmd_cli_test.gonew file mode 100644index 00000000..8fa7d606--- /dev/null+++ b/cmd/pinchtab/cmd_cli_test.go@@ -0,0 +1,19 @@+package main++import "testing"++func TestNormalizeRequiredURL(t *testing.T) {+ t.Run("normalizes bare hostname", func(t *testing.T) {+ got := normalizeRequiredURL("pinchtab.com")+ if got != "https://pinchtab.com" {+ t.Fatalf("normalizeRequiredURL() = %q, want %q", got, "https://pinchtab.com")+ }+ })++ t.Run("trims whitespace", func(t *testing.T) {+ got := normalizeRequiredURL(" https://pinchtab.com ")+ if got != "https://pinchtab.com" {+ t.Fatalf("normalizeRequiredURL() = %q, want %q", got, "https://pinchtab.com")+ }+ })+}diff --git a/dashboard/src/components/screencast/ScreencastTile.test.tsx b/dashboard/src/components/screencast/ScreencastTile.test.tsxindex cff589ba..e6347eb1 100644--- a/dashboard/src/components/screencast/ScreencastTile.test.tsx+++ b/dashboard/src/components/screencast/ScreencastTile.test.tsx@@ -1,16 +1,26 @@-import { render, waitFor } from "@testing-library/react";+import {+ act,+ fireEvent,+ render,+ screen,+ waitFor,+} from "@testing-library/react";import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";+import * as api from "../../services/api";import ScreencastTile from "../screencast/ScreencastTile";+const webSocketInstances: Record<string, unknown>[] = [];const webSocketMock = vi.fn(function MockWebSocket(this: Record<string, unknown>,) {this.close = vi.fn();+ webSocketInstances.push(this);});describe("ScreencastTile", () => {beforeEach(() => {vi.clearAllMocks();+ webSocketInstances.length = 0;vi.stubGlobal("location",new URL("https://pinchtab.com/dashboard/profiles"),@@ -20,9 +30,20 @@ describe("ScreencastTile", () => {drawImage: vi.fn(),} as unknown as CanvasRenderingContext2D);vi.stubGlobal("WebSocket", webSocketMock);+ Object.defineProperty(URL, "createObjectURL", {+ configurable: true,+ writable: true,+ value: vi.fn(() => "blob:preview"),+ });+ Object.defineProperty(URL, "revokeObjectURL", {+ configurable: true,+ writable: true,+ value: vi.fn(),+ });});afterEach(() => {+ vi.useRealTimers();window.localStorage.clear();vi.unstubAllGlobals();vi.restoreAllMocks();@@ -44,4 +65,52 @@ describe("ScreencastTile", () => {"wss://pinchtab.com/instances/inst_123/proxy/screencast?tabId=tab_456&quality=30&maxWidth=800&fps=1&token=secret-token",);});++ it("shows a static preview when no screencast frame arrives", async () => {+ vi.useFakeTimers();+ vi.spyOn(api, "fetchTabScreenshot").mockResolvedValue(new Blob(["frame"]));++ render(+ <ScreencastTile+ instanceId="inst_123"+ tabId="tab_456"+ label="Example"+ url="https://pinchtab.com"+ />,+ );++ await act(async () => {+ await vi.advanceTimersByTimeAsync(1500);+ });++ expect(api.fetchTabScreenshot).toHaveBeenCalledWith("tab_456", "png");+ expect(screen.getByAltText("Tab preview")).toHaveAttribute(+ "src",+ "blob:preview",+ );+ });++ it("reconnects when retry is clicked after the socket closes", async () => {+ render(+ <ScreencastTile+ instanceId="inst_123"+ tabId="tab_456"+ label="Example"+ url="https://pinchtab.com"+ />,+ );++ await waitFor(() => expect(webSocketMock).toHaveBeenCalledTimes(1));++ const firstSocket = webSocketInstances[0] as {+ onclose?: (event: CloseEvent) => void;+ };+ await act(async () => {+ firstSocket.onclose?.({} as CloseEvent);+ });++ fireEvent.click(screen.getByRole("button", { name: "Retry connection" }));++ await waitFor(() => expect(webSocketMock).toHaveBeenCalledTimes(2));+ });});diff --git a/dashboard/src/components/screencast/ScreencastTile.tsx b/dashboard/src/components/screencast/ScreencastTile.tsxindex 9f0c0c17..ff2733cb 100644--- a/dashboard/src/components/screencast/ScreencastTile.tsx+++ b/dashboard/src/components/screencast/ScreencastTile.tsx@@ -1,4 +1,4 @@-import { useEffect, useRef, useState } from "react";+import { useCallback, useEffect, useRef, useState } from "react";import { addTokenToUrl } from "../../services/auth";import * as api from "../../services/api";@@ -33,12 +33,15 @@ export default function ScreencastTile({const [localFps, setLocalFps] = useState(fps);const [isCapturing, setIsCapturing] = useState(false);const [isPdfGenerating, setIsPdfGenerating] = useState(false);+ const [hasFrame, setHasFrame] = useState(false);const [fallbackUrl, setFallbackUrl] = useState<string | null>(null);+ const [retryKey, setRetryKey] = useState(0);// Reset local FPS when the tab changes to match the new tab's initial requestuseEffect(() => {setLocalFps(fps);setStatus("connecting");+ setHasFrame(false);setFallbackUrl(null);}, [tabId, fps]);@@ -93,15 +96,20 @@ export default function ScreencastTile({}};- const captureFallback = async () => {+ const captureFallback = useCallback(async () => {try {const blob = await api.fetchTabScreenshot(tabId, "png");- if (fallbackUrl) URL.revokeObjectURL(fallbackUrl);- setFallbackUrl(URL.createObjectURL(blob));+ const nextUrl = URL.createObjectURL(blob);+ setFallbackUrl((prev) => {+ if (prev) {+ URL.revokeObjectURL(prev);+ }+ return nextUrl;+ });} catch (e) {console.error("Fallback capture failed", e);}- };+ }, [tabId]);useEffect(() => {const canvas = canvasRef.current;@@ -125,49 +133,87 @@ export default function ScreencastTile({const socket = new WebSocket(wsUrl.toString());socket.binaryType = "arraybuffer";socketRef.current = socket;+ setStatus("connecting");+ setHasFrame(false);++ let disposed = false;+ let fallbackCaptured = false;let frameCount = 0;let lastFpsTime = Date.now();+ const fallbackTimer = window.setTimeout(() => {+ if (!disposed && !fallbackCaptured) {+ void captureFallback();+ }+ }, 1500);socket.onopen = () => {- setStatus("streaming");+ if (!disposed) {+ setStatus("connecting");+ }};socket.onmessage = (evt) => {+ if (disposed) return;+ fallbackCaptured = true;+ window.clearTimeout(fallbackTimer);+const blob = new Blob([evt.data], { type: "image/jpeg" });const imgUrl = URL.createObjectURL(blob);const img = new Image();img.onload = () => {+ if (disposed) {+ URL.revokeObjectURL(imgUrl);+ return;+ }canvas.width = img.width;canvas.height = img.height;ctx.drawImage(img, 0, 0);URL.revokeObjectURL(imgUrl);};img.src = imgUrl;+ setHasFrame(true);+ setStatus("streaming");frameCount++;const now = Date.now();if (now - lastFpsTime >= 1000) {setFpsDisplay(`${frameCount} fps`);- setSizeDisplay(`${(evt.data.byteLength / 1024).toFixed(0)} KB/frame`);+ const frameBytes =+ evt.data instanceof Blob ? evt.data.size : evt.data.byteLength;+ setSizeDisplay(`${(frameBytes / 1024).toFixed(0)} KB/frame`);frameCount = 0;lastFpsTime = now;}};socket.onerror = () => {- setStatus("error");+ if (!disposed) {+ setStatus("error");+ }};socket.onclose = () => {- setStatus("error");+ if (!disposed) {+ setStatus("error");+ }};return () => {+ disposed = true;+ window.clearTimeout(fallbackTimer);socket.close();socketRef.current = null;};- }, [instanceId, tabId, quality, maxWidth, localFps]);+ }, [+ instanceId,+ tabId,+ quality,+ maxWidth,+ localFps,+ retryKey,+ captureFallback,+ ]);const statusColor =status === "streaming"@@ -193,7 +239,7 @@ export default function ScreencastTile({)}{/* Canvas */}<div className="relative flex min-h-0 flex-1 items-center justify-center bg-black">- {status === "error" && fallbackUrl ? (+ {!hasFrame && fallbackUrl ? (<imgsrc={fallbackUrl}alt="Tab preview"@@ -223,7 +269,11 @@ export default function ScreencastTile({</button>)}<button- onClick={() => setStatus("connecting")}+ onClick={() => {+ setStatus("connecting");+ setHasFrame(false);+ setRetryKey((prev) => prev + 1);+ }}className="rounded bg-primary/30 px-3 py-1.5 font-medium text-white shadow-lg backdrop-blur-md transition-colors hover:bg-primary/40">Retry connectiondiff --git a/dashboard/src/generated/types.ts b/dashboard/src/generated/types.tsindex 2125d24b..ce8c425a 100644--- a/dashboard/src/generated/types.ts+++ b/dashboard/src/generated/types.ts@@ -122,7 +122,7 @@ export interface BrowserSettings {*/export interface Settings {screencast: ScreencastSettings;- stealth: string; // light/full+ stealth: string; // light/medium/fullbrowser: BrowserSettings;monitoring: MonitoringSettings;}diff --git a/dashboard/src/pages/SettingsPage.tsx b/dashboard/src/pages/SettingsPage.tsxindex aefae741..e387a367 100644--- a/dashboard/src/pages/SettingsPage.tsx+++ b/dashboard/src/pages/SettingsPage.tsx@@ -579,21 +579,99 @@ export default function SettingsPage() {</SettingRow><SettingRowlabel="Stealth level"- description="Fingerprint hardening profile for new instances."+ description="Bot detection evasion profile. Higher levels may affect error monitoring and certain browser features.">- <select- value={backendConfig.instanceDefaults.stealthLevel}- onChange={(e) =>- updateBackendSection("instanceDefaults", {- stealthLevel: e.target- .value as BackendConfig["instanceDefaults"]["stealthLevel"],- })- }- className={selectClass}- >- <option value="light">Light</option>- <option value="full">Full</option>- </select>+ <div className="space-y-2">+ <select+ value={backendConfig.instanceDefaults.stealthLevel}+ onChange={(e) =>+ updateBackendSection("instanceDefaults", {+ stealthLevel: e.target+ .value as BackendConfig["instanceDefaults"]["stealthLevel"],+ })+ }+ className={selectClass}+ >+ <option value="light">Light</option>+ <option value="medium">Medium</option>+ <option value="full">Full</option>+ </select>+ <div className="rounded-sm border border-border-subtle bg-black/10 px-3 py-2 text-xs leading-5 text-text-muted">+ {backendConfig.instanceDefaults.stealthLevel ===+ "light" && (+ <div className="space-y-2">+ <div>+ <strong className="text-text-secondary">+ Light:+ </strong>{" "}+ Safe baseline stealth. Hides navigator.webdriver,+ removes CDP markers, spoofs+ plugins/languages/hardware.+ </div>+ <div className="text-success/80">+ ✓ No functional side effects+ </div>+ <div className="text-success/80">+ ✓ No security implications — standard automation+ hiding only+ </div>+ </div>+ )}+ {backendConfig.instanceDefaults.stealthLevel ===+ "medium" && (+ <div className="space-y-2">+ <div>+ <strong className="text-warning">Medium:</strong>{" "}+ Adds Client Hints API, chrome.runtime.connect (for+ Cloudflare Turnstile), chrome.csi/loadTimes,+ enhanced permissions, video codec spoofing.+ </div>+ <div className="text-warning/80">+ ⚠ May interfere with error monitoring (Sentry,+ LogRocket) — Error.prepareStackTrace is blocked+ </div>+ <div className="text-warning/80">+ ⚠ Permissions API returns fake states — code+ relying on accurate permission checks may+ misbehave+ </div>+ <div className="text-warning/80">+ ⚠ chrome.runtime.connect returns dummy objects —+ real extension messaging won't work+ </div>+ </div>+ )}+ {backendConfig.instanceDefaults.stealthLevel ===+ "full" && (+ <div className="space-y-2">+ <div>+ <strong className="text-destructive">+ Full:+ </strong>{" "}+ Maximum stealth. Adds WebGL/canvas fingerprint+ noise, WebRTC IP leak prevention, AudioContext+ protection.+ </div>+ <div className="text-destructive/80">+ ⚠ WebRTC forced to relay mode — direct P2P+ connections disabled, video calls may fail+ </div>+ <div className="text-destructive/80">+ ⚠ Canvas operations have subtle pixel noise — may+ affect pixel-precise rendering or image comparison+ </div>+ <div className="text-destructive/80">+ ⚠ WebGL reports spoofed GPU — applications+ detecting GPU capabilities may behave unexpectedly+ </div>+ <div className="text-destructive/80">+ ⚠ AudioContext has frequency noise — may affect+ audio fingerprinting detection or processing apps+ </div>+ </div>+ )}+ </div>+ </div></SettingRow><SettingRowlabel="Tab eviction policy"diff --git a/dashboard/src/types/index.ts b/dashboard/src/types/index.tsindex 0b460017..2f25456f 100644--- a/dashboard/src/types/index.ts+++ b/dashboard/src/types/index.ts@@ -77,7 +77,7 @@ export interface BackendInstanceDefaultsConfig {maxParallelTabs: number;userAgent: string;noAnimations: boolean;- stealthLevel: "light" | "full";+ stealthLevel: "light" | "medium" | "full";tabEvictionPolicy: "reject" | "close_oldest" | "close_lru";}diff --git a/dev b/devindex 2b6c72aa..0d5c7e53 100755--- a/dev+++ b/dev@@ -23,16 +23,14 @@ COMMANDS=("check:🧪:All checks""test unit:🔬:Go unit tests""test dashboard:🔬:Dashboard unit tests"- "e2e:🐳:E2E release suites"+ "e2e:🐳:E2E suites"+ " pr:🐳:PR suite (api-fast + cli-fast)"+ " release:🐳:Release suite (api-full + cli-full)"" docker:🐳:Build local image and run Docker smoke test"- " pr:🐳:E2E PR suite"- " recent:🐳:E2E Recent tests"- " api-fast:🐳:E2E API fast tests"- " cli-fast:🐳:E2E CLI fast tests"- " full-api:🐳:E2E full API tests"- " full-cli:🐳:E2E full CLI tests"- " full-extended:🐳:E2E full extended tests"- " release:🐳:E2E release meta-suite"+ " api-fast:🐳:API fast (single-instance)"+ " cli-fast:🐳:CLI fast (single-instance)"+ " api-full:🐳:API full (multi-instance)"+ " cli-full:🐳:CLI full (single-instance)""doctor:🩺:Setup dev environment""check go:🧪:Go only""check dashboard:🧪:Dashboard only"diff --git a/docs/guides/contributing.md b/docs/guides/contributing.mdindex 45d98a0b..60f4f834 100644--- a/docs/guides/contributing.md+++ b/docs/guides/contributing.md@@ -240,6 +240,9 @@ go test ./... -v -coverprofile=coverage.outgo tool cover -html=coverage.out # View coverage./dev e2e # Run the default E2E release suite./dev e2e docker # Build the local image and run Docker smoke+./dev e2e pr # Run API fast + CLI fast+./dev e2e api-full # Run the multi-instance API suite+./dev e2e cli-full # Run the single-instance CLI full suite```### Developer Toolkit (`dev`)@@ -268,15 +271,13 @@ All dev scripts are accessible through `./dev`:| `test` | Run all tests || `test unit` | Unit tests only || `test dashboard` | Dashboard tests only |-| `e2e` | Run the default E2E release suite |+| `e2e` | Run the default E2E release suite (`api-full` + `cli-full`) || `e2e docker` | Build the local image and run the Docker smoke test |-| `e2e pr` | Run the PR E2E suite |-| `e2e recent` | Run the recent E2E suite |-| `e2e api-fast` | Run the fast API E2E suite |-| `e2e cli-fast` | Run the fast CLI E2E suite |-| `e2e full-api` | Run the full API E2E suite |-| `e2e full-cli` | Run the full CLI E2E suite |-| `e2e full-extended` | Run the extended E2E suite |+| `e2e pr` | Run the PR E2E suite (`api-fast` + `cli-fast`) |+| `e2e api-fast` | Run the fast API E2E suite on the single-instance stack |+| `e2e cli-fast` | Run the fast CLI E2E suite on the single-instance stack |+| `e2e api-full` | Run the full API E2E suite on the multi-instance stack |+| `e2e cli-full` | Run the full CLI E2E suite on the single-instance stack || `e2e release` | Run the release E2E meta-suite || `build` | Build the application || `dev` | Build and run the application |diff --git a/docs/reference/config.md b/docs/reference/config.mdindex e61819a1..e15f7c30 100644--- a/docs/reference/config.md+++ b/docs/reference/config.md@@ -351,7 +351,7 @@ Valid enum values:| Field | Values || --- | --- || `instanceDefaults.mode` | `headless`, `headed` |-| `instanceDefaults.stealthLevel` | `light`, `full` |+| `instanceDefaults.stealthLevel` | `light`, `medium`, `full` || `instanceDefaults.tabEvictionPolicy` | `reject`, `close_oldest`, `close_lru` (default) || `multiInstance.strategy` | `simple`, `explicit`, `simple-autorestart`, `always-on` (default) || `multiInstance.allocationPolicy` | `fcfs`, `round_robin`, `random` |diff --git a/internal/api/types/types.go b/internal/api/types/types.goindex ae4d7a18..23513877 100644--- a/internal/api/types/types.go+++ b/internal/api/types/types.go@@ -109,7 +109,7 @@ type BrowserSettings struct {// Settings contains all dashboard settings.type Settings struct {Screencast ScreencastSettings `json:"screencast"`- Stealth string `json:"stealth"` // light/full+ Stealth string `json:"stealth"` // light/medium/fullBrowser BrowserSettings `json:"browser"`Monitoring MonitoringSettings `json:"monitoring"`}diff --git a/internal/assets/stealth.js b/internal/assets/stealth.jsindex 8227b4de..d6d49398 100644--- a/internal/assets/stealth.js+++ b/internal/assets/stealth.js@@ -1,4 +1,16 @@+// ═══════════════════════════════════════════════════════════════════════════+// PINCHTAB STEALTH - Bot Detection Evasion+// ═══════════════════════════════════════════════════════════════════════════+//+// Stealth Levels:+// light - Safe, no functional impact. Basic automation hiding.+// medium - Standard stealth. May affect error monitoring and some APIs.+// full - Maximum stealth. May break WebRTC, canvas-dependent features.+//+// ═══════════════════════════════════════════════════════════════════════════+const sessionSeed = (typeof __pinchtab_seed !== 'undefined') ? __pinchtab_seed : 42;+const stealthLevel = (typeof __pinchtab_stealth_level !== 'undefined') ? __pinchtab_stealth_level : 'light';const seededRandom = (function() {const cache = {};@@ -13,51 +25,71 @@ const seededRandom = (function() {};})();-// Webdriver evasion - hide the property completely+// ═══════════════════════════════════════════════════════════════════════════+// LIGHT LEVEL - Safe, no functional impact+// ═══════════════════════════════════════════════════════════════════════════+// - Hides navigator.webdriver+// - Removes CDP markers (cdc_*, __webdriver, etc.)+// - Spoofs plugins array+// - Sets navigator.languages, platform, hardwareConcurrency, deviceMemory+// - Basic chrome.runtime object+// ═══════════════════════════════════════════════════════════════════════════++// CDP MARKER CLEANUP - Remove automation traces(function() {- const proto = Object.getPrototypeOf(navigator);-- // Delete from both instance and prototype- try { delete navigator.webdriver; } catch(e) {}- try { delete proto.webdriver; } catch(e) {}-- // If we can't delete, make it return undefined and be non-enumerable- // so 'webdriver' in navigator returns false- const desc = {- get: () => undefined,- configurable: false,- enumerable: false // Hide from 'in' operator and Object.keys- };+ const markers = [+ 'cdc_adoQpoasnfa76pfcZLmcfl_Array',+ 'cdc_adoQpoasnfa76pfcZLmcfl_Promise',+ 'cdc_adoQpoasnfa76pfcZLmcfl_Symbol'+ ];+ markers.forEach(m => { try { delete window[m]; } catch(e) {} });- // Only define if it still exists after deletion- if ('webdriver' in navigator) {- try { Object.defineProperty(navigator, 'webdriver', desc); } catch(e) {}- }- if ('webdriver' in proto) {- try { Object.defineProperty(proto, 'webdriver', desc); } catch(e) {}+ // Pattern-based cleanup+ const markerPatterns = [/^cdc_/, /^\$cdc_/, /^__webdriver/, /^__selenium/, /^__driver/];+ for (const prop of Object.getOwnPropertyNames(window)) {+ if (markerPatterns.some(p => p.test(prop))) {+ try { delete window[prop]; } catch(e) {}+ }}})();-delete window.cdc_adoQpoasnfa76pfcZLmcfl_Array;-delete window.cdc_adoQpoasnfa76pfcZLmcfl_Promise;-delete window.cdc_adoQpoasnfa76pfcZLmcfl_Symbol;+// WEBDRIVER EVASION - Hide the property+(function() {+ const realNavigator = window.navigator;+ const proxyNavigator = new Proxy(realNavigator, {+ get(target, prop) {+ if (prop === 'webdriver') return undefined;+ return Reflect.get(target, prop, target);+ },+ has(target, prop) {+ if (prop === 'webdriver') return false;+ return Reflect.has(target, prop);+ },+ getOwnPropertyDescriptor(target, prop) {+ if (prop === 'webdriver') return undefined;+ return Reflect.getOwnPropertyDescriptor(target, prop);+ }+ });++ try {+ Object.defineProperty(window, 'navigator', {+ get: () => proxyNavigator,+ configurable: true+ });+ } catch(e) {}++ const proto = Object.getPrototypeOf(realNavigator);+ try { delete realNavigator.webdriver; } catch(e) {}+ try { delete proto.webdriver; } catch(e) {}+})();+// BASIC CHROME OBJECTif (!window.chrome) { window.chrome = {}; }if (!window.chrome.runtime) {- window.chrome.runtime = {- onConnect: undefined,- onMessage: undefined- };+ window.chrome.runtime = { onConnect: undefined, onMessage: undefined };}-const originalQuery = window.navigator.permissions.query;-window.navigator.permissions.query = (parameters) => (- parameters.name === 'notifications' ?- Promise.resolve({ state: Notification.permission }) :- originalQuery(parameters)-);--// Create a proper PluginArray-like object that passes instanceof checks+// PLUGINS ARRAY - Proper PluginArray that passes instanceof checks(function() {const fakePlugins = [{ name: 'Chrome PDF Plugin', filename: 'internal-pdf-viewer', description: 'Portable Document Format', length: 1 },@@ -65,10 +97,7 @@ window.navigator.permissions.query = (parameters) => ({ name: 'Native Client', filename: 'internal-nacl-plugin', description: '', length: 1 }];- // Get the real PluginArray prototype from navigator.pluginsconst realPluginsProto = Object.getPrototypeOf(navigator.plugins);-- // Create array-like object with PluginArray prototypeconst pluginArray = Object.create(realPluginsProto, {length: { value: fakePlugins.length, writable: false, enumerable: true },item: { value: function(i) { return this[i] || null; }, writable: false },@@ -81,66 +110,307 @@ window.navigator.permissions.query = (parameters) => (refresh: { value: function() {}, writable: false }});- // Add indexed accessfakePlugins.forEach((p, i) => {- // Create Plugin-like objectconst plugin = Object.create(Plugin.prototype, {name: { value: p.name, writable: false, enumerable: true },filename: { value: p.filename, writable: false, enumerable: true },description: { value: p.description, writable: false, enumerable: true },length: { value: p.length, writable: false, enumerable: true },- item: { value: function(i) { return null; }, writable: false },- namedItem: { value: function(n) { return null; }, writable: false }+ item: { value: function() { return null; }, writable: false },+ namedItem: { value: function() { return null; }, writable: false }});Object.defineProperty(pluginArray, i, { value: plugin, writable: false, enumerable: true });Object.defineProperty(pluginArray, p.name, { value: plugin, writable: false, enumerable: false });});- Object.defineProperty(navigator, 'plugins', {- get: () => pluginArray,- configurable: true- });+ Object.defineProperty(navigator, 'plugins', { get: () => pluginArray, configurable: true });})();-Object.defineProperty(navigator, 'languages', {- get: () => ['en-US', 'en'],-});-+// NAVIGATOR PROPERTIES+Object.defineProperty(navigator, 'languages', { get: () => ['en-US', 'en'], configurable: true });-// Derive platform from user agent to avoid mismatch detection(function() {const ua = navigator.userAgent || '';- let platform = 'Win32'; // default- if (ua.includes('Macintosh') || ua.includes('Mac OS X')) {- platform = 'MacIntel';- } else if (ua.includes('Linux')) {- platform = ua.includes('x86_64') || ua.includes('amd64') ? 'Linux x86_64' : 'Linux';- } else if (ua.includes('Windows')) {- platform = ua.includes('Win64') || ua.includes('WOW64') ? 'Win32' : 'Win32';- }- Object.defineProperty(navigator, 'platform', {- get: () => platform,- configurable: true- });+ let platform = 'Win32';+ if (ua.includes('Macintosh') || ua.includes('Mac OS X')) platform = 'MacIntel';+ else if (ua.includes('Linux')) platform = ua.includes('x86_64') ? 'Linux x86_64' : 'Linux';+ Object.defineProperty(navigator, 'platform', { get: () => platform, configurable: true });})();+const hardwareCore = 2 + Math.floor(seededRandom(sessionSeed) * 6) * 2;+const deviceMem = [2, 4, 8, 16][Math.floor(seededRandom(sessionSeed * 2) * 4)];++Object.defineProperty(navigator, 'hardwareConcurrency', { get: () => hardwareCore, configurable: true });+Object.defineProperty(navigator, 'deviceMemory', { get: () => deviceMem, configurable: true });+Object.defineProperty(navigator.connection || {}, 'rtt', {- get: () => 100,+ get: () => 50 + Math.floor(seededRandom(sessionSeed * 3) * 100),+ configurable: true});-const stealthLevel = (typeof __pinchtab_stealth_level !== 'undefined') ? __pinchtab_stealth_level : 'light';+// TIMEZONE OVERRIDE+const __pinchtab_origGetTimezoneOffset = Date.prototype.getTimezoneOffset;+Object.defineProperty(Date.prototype, 'getTimezoneOffset', {+ value: function() { return window.__pinchtab_timezone || __pinchtab_origGetTimezoneOffset.call(this); },+ configurable: true+});++// BASIC PERMISSIONS (notifications only)+const originalQuery = navigator.permissions.query.bind(navigator.permissions);+navigator.permissions.query = (parameters) => (+ parameters.name === 'notifications' ?+ Promise.resolve({ state: Notification.permission === 'default' ? 'prompt' : Notification.permission, onchange: null }) :+ originalQuery(parameters)+);++// SCREEN DIMENSIONS - Headless often has weird/small values+(function() {+ const screenWidth = 1920;+ const screenHeight = 1080;+ const availHeight = 1055; // Account for taskbar++ Object.defineProperty(screen, 'width', { get: () => screenWidth, configurable: true });+ Object.defineProperty(screen, 'height', { get: () => screenHeight, configurable: true });+ Object.defineProperty(screen, 'availWidth', { get: () => screenWidth, configurable: true });+ Object.defineProperty(screen, 'availHeight', { get: () => availHeight, configurable: true });+ Object.defineProperty(screen, 'colorDepth', { get: () => 24, configurable: true });+ Object.defineProperty(screen, 'pixelDepth', { get: () => 24, configurable: true });+})();++// BATTERY API - Headless often lacks this+if (!navigator.getBattery) {+ navigator.getBattery = function() {+ return Promise.resolve({+ charging: true,+ chargingTime: 0,+ dischargingTime: Infinity,+ level: 1.0,+ addEventListener: function() {},+ removeEventListener: function() {}+ });+ };+}++// ═══════════════════════════════════════════════════════════════════════════+// MEDIUM LEVEL - Standard stealth (may affect error monitoring)+// ═══════════════════════════════════════════════════════════════════════════+// Adds:+// - navigator.userAgentData (Client Hints API)+// - chrome.runtime.connect/sendMessage (required by Cloudflare Turnstile)+// - chrome.csi, chrome.loadTimes, chrome.app+// - Error.prepareStackTrace protection+// - Enhanced permissions API+// - Video codec spoofing+// - maxTouchPoints+//+// ⚠️ May interfere with: Error monitoring (Sentry), extension messaging+// ═══════════════════════════════════════════════════════════════════════════++if (stealthLevel === 'medium' || stealthLevel === 'full') {++// ERROR.PREPARESTACKTRACE PROTECTION+// ⚠️ May interfere with error monitoring tools (Sentry, LogRocket, etc.)+(function() {+ const originalPrepareStackTrace = Error.prepareStackTrace;+ Object.defineProperty(Error, 'prepareStackTrace', {+ get() { return originalPrepareStackTrace; },+ set(fn) { /* block modifications to prevent CDP detection */ },+ configurable: true,+ enumerable: false+ });+})();++// ENHANCED CDP MARKER CLEANUP (includes puppeteer/playwright)+(function() {+ const patterns = [/^__puppeteer/, /^__playwright/, /^\$chrome_/];+ for (const prop of Object.getOwnPropertyNames(window)) {+ if (patterns.some(p => p.test(prop))) {+ try { delete window[prop]; } catch(e) {}+ }+ }+})();++// CHROME EXTENDED APIS+(function() {+ // chrome.runtime.connect - required by Cloudflare Turnstile+ // ⚠️ Returns dummy Port object - real extension messaging won't work+ if (!window.chrome.runtime.connect) {+ window.chrome.runtime.connect = function(extensionId, connectInfo) {+ return {+ name: connectInfo?.name || '',+ sender: undefined,+ onDisconnect: { addListener: function() {}, removeListener: function() {}, hasListener: function() { return false; } },+ onMessage: { addListener: function() {}, removeListener: function() {}, hasListener: function() { return false; } },+ postMessage: function() {},+ disconnect: function() {}+ };+ };+ }++ if (!window.chrome.runtime.sendMessage) {+ window.chrome.runtime.sendMessage = function(extensionId, message, options, callback) {+ if (typeof callback === 'function') setTimeout(callback, 0);+ };+ }++ window.chrome.runtime.onConnect = window.chrome.runtime.onConnect || { addListener: function() {}, removeListener: function() {}, hasListener: function() { return false; } };+ window.chrome.runtime.onMessage = window.chrome.runtime.onMessage || { addListener: function() {}, removeListener: function() {}, hasListener: function() { return false; } };++ // chrome.csi - Chrome Speed Index+ if (!window.chrome.csi) {+ window.chrome.csi = function() {+ const now = Date.now();+ return { startE: now - 500, onloadT: now - 100, pageT: now, tran: 15 };+ };+ }++ // chrome.loadTimes - deprecated but still checked+ if (!window.chrome.loadTimes) {+ window.chrome.loadTimes = function() {+ const now = Date.now() / 1000;+ return {+ requestTime: now - 0.5, startLoadTime: now - 0.4, commitLoadTime: now - 0.3,+ finishDocumentLoadTime: now - 0.1, finishLoadTime: now, firstPaintTime: now - 0.2,+ firstPaintAfterLoadTime: 0, navigationType: "Other", wasFetchedViaSpdy: false,+ wasNpnNegotiated: true, npnNegotiatedProtocol: "h2", wasAlternateProtocolAvailable: false, connectionInfo: "h2"+ };+ };+ }++ // chrome.app+ if (!window.chrome.app) {+ window.chrome.app = {+ isInstalled: false,+ InstallState: { DISABLED: 'disabled', INSTALLED: 'installed', NOT_INSTALLED: 'not_installed' },+ RunningState: { CANNOT_RUN: 'cannot_run', READY_TO_RUN: 'ready_to_run', RUNNING: 'running' },+ getDetails: function() { return null; },+ getIsInstalled: function() { return false; }+ };+ }+})();++// NAVIGATOR.USERAGENTDATA - Client Hints API (required by Turnstile/CF)+(function() {+ const ua = navigator.userAgent || '';+ const chromeMatch = ua.match(/Chrome\/(\d+)/);+ const chromeVersion = chromeMatch ? chromeMatch[1] : '129';++ let platform = 'Windows', platformVersion = '15.0.0';+ if (ua.includes('Macintosh') || ua.includes('Mac OS X')) { platform = 'macOS'; platformVersion = '14.0.0'; }+ else if (ua.includes('Linux')) { platform = 'Linux'; platformVersion = '6.5.0'; }++ const brands = [+ { brand: 'Chromium', version: chromeVersion },+ { brand: 'Google Chrome', version: chromeVersion },+ { brand: 'Not=A?Brand', version: '24' }+ ];++ const userAgentData = {+ brands: brands,+ mobile: false,+ platform: platform,+ getHighEntropyValues: async function(hints) {+ const values = { brands: brands, mobile: false, platform: platform };+ for (const hint of hints) {+ if (hint === 'platformVersion') values.platformVersion = platformVersion;+ else if (hint === 'architecture') values.architecture = 'x86';+ else if (hint === 'model') values.model = '';+ else if (hint === 'bitness') values.bitness = '64';+ else if (hint === 'uaFullVersion') values.uaFullVersion = chromeVersion + '.0.0.0';+ else if (hint === 'fullVersionList') values.fullVersionList = brands.map(b => ({ ...b, version: b.version + '.0.0.0' }));+ else if (hint === 'wow64') values.wow64 = false;+ }+ return values;+ },+ toJSON: function() { return { brands: this.brands, mobile: this.mobile, platform: this.platform }; }+ };++ Object.defineProperty(Navigator.prototype, 'userAgentData', { get: () => userAgentData, configurable: true, enumerable: true });+})();++// ENHANCED PERMISSIONS API+// ⚠️ Returns fake permission states - may affect permission-dependent logic+(function() {+ const origQuery = navigator.permissions.query.bind(navigator.permissions);+ navigator.permissions.query = async function(desc) {+ const handlers = {+ 'notifications': () => Notification.permission === 'default' ? 'prompt' : Notification.permission,+ 'geolocation': () => 'prompt',+ 'camera': () => 'prompt',+ 'microphone': () => 'prompt',+ 'background-sync': () => 'granted',+ 'accelerometer': () => 'granted',+ 'gyroscope': () => 'granted'+ };+ if (desc.name in handlers) return { state: handlers[desc.name](), onchange: null };+ return origQuery(desc);+ };+})();++// VIDEO CODEC SPOOFING+// ⚠️ Returns "probably" for common codecs - may affect codec selection logic+(function() {+ const originalCanPlayType = HTMLMediaElement.prototype.canPlayType;+ HTMLMediaElement.prototype.canPlayType = function(type) {+ if (type.includes('avc1') || type.includes('h264')) return 'probably';+ if (type.includes('mp4a.40') || type.includes('aac')) return 'probably';+ if (type === 'video/mp4' || type === 'audio/mp4') return 'probably';+ if (type.includes('vp8') || type.includes('vp9') || type.includes('opus')) return 'probably';+ if (type === 'video/webm' || type === 'audio/webm') return 'probably';+ return originalCanPlayType.apply(this, arguments);+ };+})();++// maxTouchPoints+Object.defineProperty(navigator, 'maxTouchPoints', { get: () => 0, configurable: true });++} // end medium level++// ═══════════════════════════════════════════════════════════════════════════+// FULL LEVEL - Maximum stealth (may break functionality)+// ═══════════════════════════════════════════════════════════════════════════+// Adds:+// - WebGL vendor/renderer spoofing+// - Canvas fingerprint noise+// - WebRTC IP leak prevention+// - AudioContext fingerprint protection+// - Font measurement noise+//+// ⚠️ May break: WebRTC video calls, canvas-dependent apps, audio processing+// ═══════════════════════════════════════════════════════════════════════════if (stealthLevel === 'full') {-const getParameter = WebGLRenderingContext.prototype.getParameter;-WebGLRenderingContext.prototype.getParameter = function(parameter) {- if (parameter === 37445) return 'Intel Inc.';- if (parameter === 37446) return 'Intel Iris OpenGL Engine';- return getParameter.apply(this, arguments);-};+// WebGL SPOOFING+// ⚠️ Changes reported GPU - may affect WebGL-dependent applications+(function() {+ const ua = navigator.userAgent || '';+ let vendor = 'Google Inc. (Intel)';+ let renderer = 'ANGLE (Intel, Intel(R) UHD Graphics 630 Direct3D11 vs_5_0 ps_5_0)';++ if (ua.includes('Macintosh') || ua.includes('Mac OS X')) {+ vendor = 'Google Inc. (Apple)';+ renderer = 'ANGLE (Apple, Apple M1, OpenGL 4.1)';+ } else if (ua.includes('Linux')) {+ vendor = 'Google Inc. (Intel)';+ renderer = 'ANGLE (Intel, Mesa Intel(R) UHD Graphics 630, OpenGL 4.6)';+ }++ const spoofWebGL = (proto) => {+ const getParameter = proto.getParameter;+ proto.getParameter = function(parameter) {+ if (parameter === 37445) return vendor; // UNMASKED_VENDOR+ if (parameter === 37446) return renderer; // UNMASKED_RENDERER+ return getParameter.apply(this, arguments);+ };+ };+ spoofWebGL(WebGLRenderingContext.prototype);+ if (typeof WebGL2RenderingContext !== 'undefined') spoofWebGL(WebGL2RenderingContext.prototype);+})();+// CANVAS FINGERPRINT NOISE+// ⚠️ Adds subtle pixel noise - may affect pixel-precise canvas operationsconst originalToDataURL = HTMLCanvasElement.prototype.toDataURL;-const originalToBlob = HTMLCanvasElement.prototype.toBlob;const originalGetImageData = CanvasRenderingContext2D.prototype.getImageData;HTMLCanvasElement.prototype.toDataURL = function(...args) {@@ -172,8 +442,7 @@ HTMLCanvasElement.prototype.toBlob = function(callback, type, quality) {let n = bstr.length;const u8arr = new Uint8Array(n);while(n--){ u8arr[n] = bstr.charCodeAt(n); }- const blob = new Blob([u8arr], {type: mime});- setTimeout(() => callback(blob), 5 + seededRandom(sessionSeed + 1000) * 10);+ setTimeout(() => callback(new Blob([u8arr], {type: mime})), 5 + seededRandom(sessionSeed + 1000) * 10);};CanvasRenderingContext2D.prototype.getImageData = function(...args) {@@ -181,12 +450,13 @@ CanvasRenderingContext2D.prototype.getImageData = function(...args) {const pixelCount = imageData.data.length / 4;const noisyPixels = Math.min(10, pixelCount * 0.0001);for (let i = 0; i < noisyPixels; i++) {- const pixelIndex = Math.floor(Math.random() * pixelCount) * 4;- imageData.data[pixelIndex] = Math.min(255, Math.max(0, imageData.data[pixelIndex] + (Math.random() > 0.5 ? 1 : -1)));+ const pixelIndex = Math.floor(seededRandom(sessionSeed + 2000 + i) * pixelCount) * 4;+ imageData.data[pixelIndex] = Math.min(255, Math.max(0, imageData.data[pixelIndex] + (seededRandom(sessionSeed + 3000 + i) > 0.5 ? 1 : -1)));}return imageData;};+// FONT MEASUREMENT NOISEconst originalMeasureText = CanvasRenderingContext2D.prototype.measureText;CanvasRenderingContext2D.prototype.measureText = function(text) {const metrics = originalMeasureText.apply(this, arguments);@@ -199,6 +469,8 @@ CanvasRenderingContext2D.prototype.measureText = function(text) {});};+// WEBRTC IP LEAK PREVENTION+// ⚠️ Forces relay mode - direct P2P connections won't workif (window.RTCPeerConnection) {const originalRTCPeerConnection = window.RTCPeerConnection;window.RTCPeerConnection = function(config, constraints) {@@ -208,23 +480,23 @@ if (window.RTCPeerConnection) {window.RTCPeerConnection.prototype = originalRTCPeerConnection.prototype;}+// AUDIOCONTEXT FINGERPRINT PROTECTION+// ⚠️ Adds subtle frequency noise - may affect audio processing applications+if (window.AudioContext || window.webkitAudioContext) {+ const AudioContextClass = window.AudioContext || window.webkitAudioContext;+ const originalCreateOscillator = AudioContextClass.prototype.createOscillator;++ AudioContextClass.prototype.createOscillator = function() {+ const oscillator = originalCreateOscillator.apply(this, arguments);+ const originalConnect = oscillator.connect.bind(oscillator);+ oscillator.connect = function(dest) {+ if (dest instanceof AnalyserNode) {+ oscillator.frequency.value += seededRandom(sessionSeed + 4000) * 0.0001;+ }+ return originalConnect(dest);+ };+ return oscillator;+ };}-const __pinchtab_origGetTimezoneOffset = Date.prototype.getTimezoneOffset;-Object.defineProperty(Date.prototype, 'getTimezoneOffset', {- value: function() {- return window.__pinchtab_timezone || __pinchtab_origGetTimezoneOffset.call(this);- }-});--const hardwareCore = 2 + Math.floor(seededRandom(sessionSeed) * 6) * 2;-const deviceMem = [2, 4, 8, 16][Math.floor(seededRandom(sessionSeed * 2) * 4)];--Object.defineProperty(navigator, 'hardwareConcurrency', {- get: () => hardwareCore,- configurable: true-});--Object.defineProperty(navigator, 'deviceMemory', {- get: () => deviceMem-});+} // end full leveldiff --git a/internal/config/validate.go b/internal/config/validate.goindex e141445b..993c6939 100644--- a/internal/config/validate.go+++ b/internal/config/validate.go@@ -92,7 +92,7 @@ func ValidateFileConfig(fc *FileConfig) []error {if !isValidStealthLevel(fc.InstanceDefaults.StealthLevel) {errs = append(errs, ValidationError{Field: "instanceDefaults.stealthLevel",- Message: fmt.Sprintf("invalid value %q (must be light or full)", fc.InstanceDefaults.StealthLevel),+ Message: fmt.Sprintf("invalid value %q (must be light, medium, or full)", fc.InstanceDefaults.StealthLevel),})}}@@ -228,7 +228,7 @@ func validateBind(bind string, field string) error {func isValidStealthLevel(level string) bool {switch level {- case "light", "full":+ case "light", "medium", "full":return truedefault:return false@@ -272,7 +272,7 @@ func isValidAttachScheme(scheme string) bool {}func ValidStealthLevels() []string {- return []string{"light", "full"}+ return []string{"light", "medium", "full"}}func ValidEvictionPolicies() []string {diff --git a/internal/config/validate_test.go b/internal/config/validate_test.goindex 9037c095..ab1f6fd3 100644--- a/internal/config/validate_test.go+++ b/internal/config/validate_test.go@@ -171,9 +171,9 @@ func TestValidateFileConfig_InvalidStealthLevel(t *testing.T) {wantErr bool}{{"light", false},+ {"medium", false},{"full", false},- {"", false}, // empty is ok- {"medium", true}, // removed, no longer valid+ {"", false}, // empty is ok{"none", true},{"max", true},{"LIGHT", true}, // case sensitivediff --git a/internal/dashboard/config_api.go b/internal/dashboard/config_api.goindex 931c4f74..4a5b4bc8 100644--- a/internal/dashboard/config_api.go+++ b/internal/dashboard/config_api.go@@ -220,7 +220,7 @@ func (c *ConfigAPI) currentConfig() (config.FileConfig, string, []string, error)}func (c *ConfigAPI) restartReasonsFor(next config.FileConfig) []string {- reasons := make([]string, 0, 4)+ reasons := make([]string, 0, 5)if c.boot.Server.Port != next.Server.Port || c.boot.Server.Bind != next.Server.Bind {reasons = append(reasons, "Server address")@@ -231,6 +231,9 @@ func (c *ConfigAPI) restartReasonsFor(next config.FileConfig) []string {if c.boot.MultiInstance.Strategy != next.MultiInstance.Strategy {reasons = append(reasons, "Routing strategy")}+ if c.boot.InstanceDefaults.StealthLevel != next.InstanceDefaults.StealthLevel {+ reasons = append(reasons, "Stealth level")+ }if !sameIntPtr(c.boot.MultiInstance.Restart.MaxRestarts, next.MultiInstance.Restart.MaxRestarts) ||!sameIntPtr(c.boot.MultiInstance.Restart.InitBackoffSec, next.MultiInstance.Restart.InitBackoffSec) ||!sameIntPtr(c.boot.MultiInstance.Restart.MaxBackoffSec, next.MultiInstance.Restart.MaxBackoffSec) ||diff --git a/internal/dashboard/config_api_test.go b/internal/dashboard/config_api_test.goindex 610fbb95..119926dd 100644--- a/internal/dashboard/config_api_test.go+++ b/internal/dashboard/config_api_test.go@@ -4,6 +4,7 @@ import ("encoding/json""os""path/filepath"+ "slices""testing""time"@@ -63,3 +64,17 @@ func TestNewConfigAPISnapshotsBootConfigFromFile(t *testing.T) {t.Fatalf("currentConfig() restartReasons = %v, want none", restartReasons)}}++func TestRestartReasonsIncludeStealthLevel(t *testing.T) {+ cfg := config.DefaultFileConfig()+ api := NewConfigAPI(config.Load(), nil, nil, nil, "test", time.Now())+ api.boot = cfg++ next := cfg+ next.InstanceDefaults.StealthLevel = "full"++ reasons := api.restartReasonsFor(next)+ if !slices.Contains(reasons, "Stealth level") {+ t.Fatalf("restartReasonsFor() = %v, want Stealth level", reasons)+ }+}diff --git a/internal/handlers/stealth_test.go b/internal/handlers/stealth_test.goindex 2374e70b..8f8f0629 100644--- a/internal/handlers/stealth_test.go+++ b/internal/handlers/stealth_test.go@@ -83,6 +83,9 @@ func TestStealthScript_Content(t *testing.T) {if !strings.Contains(assets.StealthScript, "navigator") || !strings.Contains(assets.StealthScript, "webdriver") {t.Error("stealth script missing webdriver protection")}+ if !strings.Contains(assets.StealthScript, "new Proxy") || !strings.Contains(assets.StealthScript, "Object.defineProperty(window, 'navigator'") {+ t.Error("stealth script missing navigator proxy protection")+ }}func TestStealthScript_Populated(t *testing.T) {diff --git a/scripts/check-dashboard.sh b/scripts/check-dashboard.shindex a6c20546..6243a2b3 100755--- a/scripts/check-dashboard.sh+++ b/scripts/check-dashboard.sh@@ -74,26 +74,24 @@ TYGO="${GOPATH:-$HOME/go}/bin/tygo"if [ -x "$TYGO" ] || command -v tygo &>/dev/null; thensection "Types (tygo)"TYGO_CMD="${TYGO:-tygo}"+ GENERATED_TYPES="src/generated/types.ts"if [ -x "$TYGO" ]; then TYGO_CMD="$TYGO"; fi+ BEFORE_FIX="$(mktemp)"+ cp "$GENERATED_TYPES" "$BEFORE_FIX"$TYGO_CMD generate 2>/dev/null- npx prettier --write src/generated/types.ts 2>/dev/null || true- if git diff --quiet -- src/generated/types.ts 2>/dev/null; then+ npx prettier --write "$GENERATED_TYPES" 2>/dev/null || true+ if cmp -s "$BEFORE_FIX" "$GENERATED_TYPES"; thenok "Types in sync"elsefail "Types out of sync" "Run: cd dashboard && tygo generate && npx prettier --write src/generated/types.ts"if confirm "Fix generated types now?"; then- $TYGO_CMD generate- npx prettier --write src/generated/types.ts- if git diff --quiet -- src/generated/types.ts 2>/dev/null; then- ok "Types fixed"- else- fail "Types still out of sync" "Review tygo output and rerun the check."- exit 1- fi+ ok "Types fixed"else+ rm -f "$BEFORE_FIX"exit 1fifi+ rm -f "$BEFORE_FIX"fisection "TypeScript"diff --git a/scripts/e2e.sh b/scripts/e2e.shindex 5696f09f..39531a83 100644--- a/scripts/e2e.sh+++ b/scripts/e2e.sh@@ -22,123 +22,168 @@ compose_down() {docker compose -f "${compose_file}" down -v 2>/dev/null || true}-run_recent() {- echo " ${ACCENT}${BOLD}🐳 E2E Recent tests (Docker)${NC}"- echo ""- set +e- docker compose -f tests/e2e/docker-compose.yml run --build --rm runner /scenarios-recent/run.sh- local recent_exit=$?- set -e- if [ "${recent_exit}" -ne 0 ]; then- echo -e "${ERROR} Recent tests failed. Showing pinchtab logs:${NC}"- docker compose -f tests/e2e/docker-compose.yml logs pinchtab | tail -n 50 || true+dump_compose_failure() {+ local compose_file="$1"+ shift+ local log_prefix="$1"+ shift+ local services=("$@")++ mkdir -p tests/e2e/results+ for service in "${services[@]}"; do+ docker compose -f "${compose_file}" logs "${service}" > "tests/e2e/results/${log_prefix}-${service}.log" 2>&1 || true+ done+}++show_suite_artifacts() {+ local summary_file="$1"+ local report_file="$2"+ local progress_file="$3"+ local log_prefix="$4"+ shift 4+ local services=("$@")+ local printed=0++ if [ -f "${summary_file}" ]; then+ echo ""+ echo " ${MUTED}Summary saved to: ${summary_file}${NC}"+ printed=1+ fi++ if [ -f "${report_file}" ]; then+ echo " ${MUTED}Report saved to: ${report_file}${NC}"+ printed=1+ fi++ if [ -f "${progress_file}" ]; then+ echo " ${MUTED}Progress saved to: ${progress_file}${NC}"+ printed=1+ fi++ for service in "${services[@]}"; do+ local service_log="tests/e2e/results/${log_prefix}-${service}.log"+ if [ -f "${service_log}" ]; then+ echo " ${MUTED}Logs saved to: ${service_log}${NC}"+ printed=1+ fi+ done++ if [ "${printed}" -eq 1 ]; then+ echo ""fi- compose_down tests/e2e/docker-compose.yml- return "${recent_exit}"+}++show_suite_summary() {+ local compose_file="$1"+ shift+ :+}++prepare_suite_results() {+ local summary_file="$1"+ local report_file="$2"+ local progress_file="$3"+ local log_prefix="$4"++ rm -f \+ "${summary_file}" \+ "${report_file}" \+ "${progress_file}" \+ tests/e2e/results/${log_prefix}-*.log \+ tests/e2e/results/summary.txt \+ tests/e2e/results/report.md}run_api_fast() {+ local compose_file="tests/e2e/docker-compose.yml"+ local summary_file="tests/e2e/results/summary-api-fast.txt"+ local report_file="tests/e2e/results/report-api-fast.md"+ local progress_file="tests/e2e/results/progress-api-fast.log"+ local log_prefix="logs-api-fast"echo " ${ACCENT}${BOLD}🐳 E2E API Fast tests (Docker)${NC}"echo ""+ prepare_suite_results "${summary_file}" "${report_file}" "${progress_file}" "${log_prefix}"set +e- docker compose -f tests/e2e/docker-compose.yml run --build --rm runner /scenarios/run-fast.sh+ docker compose -f "${compose_file}" run --build --rm runner-api /bin/bash /e2e/run.sh apilocal api_fast_exit=$?set -eif [ "${api_fast_exit}" -ne 0 ]; then- docker compose -f tests/e2e/docker-compose.yml logs pinchtab | tail -n 50 || true+ dump_compose_failure "${compose_file}" "${log_prefix}" runner-api pinchtab+ show_suite_artifacts "${summary_file}" "${report_file}" "${progress_file}" "${log_prefix}" runner-api pinchtabfi- compose_down tests/e2e/docker-compose.yml+ compose_down "${compose_file}"return "${api_fast_exit}"}run_full_api() {+ local compose_file="tests/e2e/docker-compose-multi.yml"+ local summary_file="tests/e2e/results/summary-api-full.txt"+ local report_file="tests/e2e/results/report-api-full.md"+ local progress_file="tests/e2e/results/progress-api-full.log"+ local log_prefix="logs-api-full"echo " ${ACCENT}${BOLD}🐳 E2E Full API tests (Docker)${NC}"echo ""+ prepare_suite_results "${summary_file}" "${report_file}" "${progress_file}" "${log_prefix}"set +e- docker compose -f tests/e2e/docker-compose.yml up --build --abort-on-container-exit+ docker compose -f "${compose_file}" up --build --abort-on-container-exit --exit-code-from runner-api runner-apilocal api_exit=$?set -eif [ "${api_exit}" -ne 0 ]; then- docker compose -f tests/e2e/docker-compose.yml logs pinchtab | tail -n 50 || true+ dump_compose_failure "${compose_file}" "${log_prefix}" runner-api pinchtab pinchtab-secure pinchtab-medium pinchtab-full pinchtab-lite pinchtab-bridge+ show_suite_artifacts "${summary_file}" "${report_file}" "${progress_file}" "${log_prefix}" runner-api pinchtab pinchtab-secure pinchtab-medium pinchtab-full pinchtab-lite pinchtab-bridgefi- compose_down tests/e2e/docker-compose.yml+ compose_down "${compose_file}"return "${api_exit}"}run_cli_fast() {+ local compose_file="tests/e2e/docker-compose.yml"+ local summary_file="tests/e2e/results/summary-cli-fast.txt"+ local report_file="tests/e2e/results/report-cli-fast.md"+ local progress_file="tests/e2e/results/progress-cli-fast.log"+ local log_prefix="logs-cli-fast"echo " ${ACCENT}${BOLD}🐳 E2E CLI Fast tests (Docker)${NC}"echo ""build_e2e_cli_binary+ prepare_suite_results "${summary_file}" "${report_file}" "${progress_file}" "${log_prefix}"set +e- docker compose -f tests/e2e/docker-compose-cli.yml run --build --rm runner /bin/bash /scenarios/run-fast.sh+ docker compose -f "${compose_file}" run --build --rm runner-cli /bin/bash /e2e/run.sh clilocal cli_fast_exit=$?set -eif [ "${cli_fast_exit}" -ne 0 ]; then- docker compose -f tests/e2e/docker-compose-cli.yml logs pinchtab | tail -n 50 || true+ dump_compose_failure "${compose_file}" "${log_prefix}" runner-cli pinchtab+ show_suite_artifacts "${summary_file}" "${report_file}" "${progress_file}" "${log_prefix}" runner-cli pinchtabfi- compose_down tests/e2e/docker-compose-cli.yml+ compose_down "${compose_file}"return "${cli_fast_exit}"}run_full_cli() {+ local compose_file="tests/e2e/docker-compose.yml"+ local summary_file="tests/e2e/results/summary-cli-full.txt"+ local report_file="tests/e2e/results/report-cli-full.md"+ local progress_file="tests/e2e/results/progress-cli-full.log"+ local log_prefix="logs-cli-full"echo " ${ACCENT}${BOLD}🐳 E2E Full CLI tests (Docker)${NC}"echo ""build_e2e_cli_binary+ prepare_suite_results "${summary_file}" "${report_file}" "${progress_file}" "${log_prefix}"set +e- docker compose -f tests/e2e/docker-compose-cli.yml up --build --abort-on-container-exit+ docker compose -f "${compose_file}" up --build --abort-on-container-exit --exit-code-from runner-cli runner-clilocal cli_exit=$?set -eif [ "${cli_exit}" -ne 0 ]; then- docker compose -f tests/e2e/docker-compose-cli.yml logs pinchtab | tail -n 50 || true+ dump_compose_failure "${compose_file}" "${log_prefix}" runner-cli pinchtab+ show_suite_artifacts "${summary_file}" "${report_file}" "${progress_file}" "${log_prefix}" runner-cli pinchtabfi- compose_down tests/e2e/docker-compose-cli.yml+ compose_down "${compose_file}"return "${cli_exit}"}-run_orchestrator() {- echo " ${ACCENT}${BOLD}🐳 E2E Orchestrator tests (Docker)${NC}"- echo ""- set +e- docker compose -f tests/e2e/docker-compose-orchestrator.yml run --build --rm runner- local orch_exit=$?- set -e- if [ "${orch_exit}" -ne 0 ]; then- docker compose -f tests/e2e/docker-compose-orchestrator.yml logs pinchtab | tail -n 50 || true- docker compose -f tests/e2e/docker-compose-orchestrator.yml logs pinchtab-bridge | tail -n 50 || true- fi- compose_down tests/e2e/docker-compose-orchestrator.yml- return "${orch_exit}"-}--run_full_extended() {- local recent_exit=0- local orch_exit=0-- run_recent || recent_exit=$?-- echo ""-- run_orchestrator || orch_exit=$?-- echo ""- if [ "${recent_exit}" -ne 0 ] || [ "${orch_exit}" -ne 0 ]; then- echo " ${ERROR}Extended E2E suites failed${NC}"- echo " ${MUTED}exit codes: recent=${recent_exit}, orchestrator=${orch_exit}${NC}"- return 1- fi- echo " ${SUCCESS}Extended E2E suites passed${NC}"- return 0-}-run_pr() {- local recent_exit=0local api_fast_exit=0local cli_fast_exit=0- run_recent || recent_exit=$?-- echo ""-run_api_fast || api_fast_exit=$?echo ""@@ -146,9 +191,9 @@ run_pr() {run_cli_fast || cli_fast_exit=$?echo ""- if [ "${recent_exit}" -ne 0 ] || [ "${api_fast_exit}" -ne 0 ] || [ "${cli_fast_exit}" -ne 0 ]; then+ if [ "${api_fast_exit}" -ne 0 ] || [ "${cli_fast_exit}" -ne 0 ]; thenecho " ${ERROR}PR E2E suites failed${NC}"- echo " ${MUTED}exit codes: recent=${recent_exit}, api-fast=${api_fast_exit}, cli-fast=${cli_fast_exit}${NC}"+ echo " ${MUTED}exit codes: api-fast=${api_fast_exit}, cli-fast=${cli_fast_exit}${NC}"return 1fiecho " ${SUCCESS}PR E2E suites passed${NC}"@@ -158,7 +203,6 @@ run_pr() {run_release() {local api_exit=0local cli_exit=0- local extended_exit=0run_full_api || api_exit=$?@@ -167,13 +211,9 @@ run_release() {run_full_cli || cli_exit=$?echo ""-- run_full_extended || extended_exit=$?-- echo ""- if [ "${api_exit}" -ne 0 ] || [ "${cli_exit}" -ne 0 ] || [ "${extended_exit}" -ne 0 ]; then+ if [ "${api_exit}" -ne 0 ] || [ "${cli_exit}" -ne 0 ]; thenecho " ${ERROR}Some E2E suites failed${NC}"- echo " ${MUTED}exit codes: full-api=${api_exit}, full-cli=${cli_exit}, full-extended=${extended_exit}${NC}"+ echo " ${MUTED}exit codes: api-full=${api_exit}, cli-full=${cli_exit}${NC}"return 1fiecho " ${SUCCESS}All E2E suites passed${NC}"@@ -188,33 +228,24 @@ case "${suite}" inpr)run_pr;;- recent)- run_recent- ;;api-fast)run_api_fast;;cli-fast)run_cli_fast;;- full-api|curl)+ api-full|full-api|curl)run_full_api;;- full-cli|cli)+ cli-full|full-cli|cli)run_full_cli;;- full-extended)- run_full_extended- ;;- orchestrator)- run_orchestrator- ;;release|all)run_release;;*)echo "Unknown E2E suite: ${suite}" >&2- echo "Available suites: pr, recent, api-fast, cli-fast, full-api, full-cli, full-extended, orchestrator, release" >&2+ echo "Available suites: pr, api-fast, cli-fast, api-full, cli-full, release" >&2exit 1;;esacdiff --git a/tests/e2e/README.md b/tests/e2e/README.mdindex 7c9ad6af..594cbbbd 100644--- a/tests/e2e/README.md+++ b/tests/e2e/README.md@@ -7,30 +7,37 @@ End-to-end tests for PinchTab that exercise the full stack including browser aut### With Docker (recommended)```bash-./dev e2e # Run the release meta-suite-./dev e2e pr # Run the PR meta-suite-./dev e2e recent # Run only recently added/changed scenarios (fast feedback)-./dev e2e api-fast # Run the stable PR-fast API suite-./dev e2e cli-fast # Run the stable PR-fast CLI suite-./dev e2e full-api # Run the full API suite-./dev e2e full-cli # Run the full CLI suite-./dev e2e full-extended # Run the manual/pre-release extended suite+./dev e2e # Run the release suite+./dev e2e pr # Run the PR suite+./dev e2e api-fast # Run API fast on the single-instance stack+./dev e2e cli-fast # Run CLI fast on the single-instance stack+./dev e2e api-full # Run API full on the multi-instance stack+./dev e2e cli-full # Run CLI full on the single-instance stack++# Manual grouped runners+/bin/bash tests/e2e/run.sh api+/bin/bash tests/e2e/run.sh api all=true+/bin/bash tests/e2e/run.sh cli+/bin/bash tests/e2e/run.sh cli all=true```Or directly:```bash-docker compose -f tests/e2e/docker-compose.yml up --build-docker compose -f tests/e2e/docker-compose-orchestrator.yml run --build --rm runner+docker compose -f tests/e2e/docker-compose.yml up --build runner-api+docker compose -f tests/e2e/docker-compose.yml up --build runner-cli+docker compose -f tests/e2e/docker-compose-multi.yml up --build runner-api```## Architecture```tests/e2e/-├── docker-compose.yml # Generic curl scenarios-├── docker-compose-orchestrator.yml # Orchestrator-specific services+├── docker-compose.yml # Single-instance stack for api-fast and cli suites+├── docker-compose-multi.yml # Multi-instance API full stack├── config/ # E2E-specific PinchTab configs│ ├── pinchtab.json+│ ├── pinchtab-medium-permissive.json+│ ├── pinchtab-full-permissive.json│ ├── pinchtab-secure.json│ └── pinchtab-bridge.json├── fixtures/ # Static HTML test pages@@ -38,60 +45,66 @@ tests/e2e/│ ├── form.html│ ├── table.html│ └── buttons.html-├── scenarios/ # Test scripts-│ ├── common.sh # Shared utilities-│ ├── run-all.sh # Generic curl scenarios-│ ├── run-fast.sh # API fast suite runner-│ ├── 01-health.sh-│ ├── 02-navigate.sh-│ ├── 03-snapshot.sh-│ ├── 04-tabs-api.sh # Regression test for #207-│ ├── 05-actions.sh-│ └── 06-screenshot-pdf.sh-├── scenarios-cli/ # CLI scenarios-│ ├── run-all.sh-│ ├── run-fast.sh # CLI fast suite runner-│ └── ...-├── scenarios-recent/ # Recent edge-case coverage-│ ├── run.sh-│ └── 41-extensions.sh-├── scenarios-orchestrator/ # Multi-instance and attach flows-│ ├── run-all.sh-│ ├── 01-attach-bridge.sh-│ └── 31-multi-instance.sh-├── suites/ # Curated PR-fast suite manifests-│ ├── api-fast.txt-│ └── cli-fast.txt-├── runner/ # Test runner container+├── helpers/ # Shared API/CLI E2E helpers+│ ├── api.sh+│ ├── api-http.sh+│ ├── api-assertions.sh+│ ├── api-actions.sh+│ ├── api-snapshot.sh+│ ├── cli.sh+│ └── base.sh+├── scenarios-api/ # Grouped API entrypoints+│ ├── browser-basic.sh+│ ├── browser-full.sh+│ ├── tabs-basic.sh+│ ├── tabs-full.sh+│ ├── orchestrator-full.sh+│ ├── stealth-basic.sh+│ └── stealth-full.sh+├── scenarios-cli/ # Grouped CLI entrypoints+│ ├── browser-basic.sh+│ ├── browser-full.sh+│ ├── tabs-basic.sh+│ └── tabs-full.sh+├── runner-api/ # API test runner container+│ └── Dockerfile+├── runner-cli/ # CLI test runner container│ └── Dockerfile└── results/ # Test output (gitignored)```-The Docker stack reuses the repository root `Dockerfile` and mounts explicit config files with `PINCHTAB_CONFIG` instead of maintaining separate e2e-only images.+The Docker stacks reuse the repository root `Dockerfile` and mount explicit config files with `PINCHTAB_CONFIG` instead of maintaining separate e2e-only images.++## Test Groups++The API and CLI suites are grouped by feature area:++- `browser-basic` / `browser-full`+- `tabs-basic` / `tabs-full`+- `actions-basic` / `actions-full`+- `files-basic` / `files-full`+- `security-basic`+- `orchestrator-full` on API+- `system-basic` / `system-full`+- `stealth-basic` / `stealth-full` on API-## Test Scenarios+The `basic` entrypoints are the PR-fast happy path. The `full` entrypoints add extra and edge-case coverage for the same feature. The top-level runner defaults to the basic layer; pass `all=true` to run both basic and full.-| Script | Tests |-|--------|-------|-| 01-health | Basic connectivity, health endpoint |-| 02-navigate | Navigation, tab creation, tab listing |-| 03-snapshot | A11y tree extraction, text content |-| 04-tabs-api | Tab-scoped APIs (regression #207) |-| 05-actions | Click, type, press, check, and uncheck actions |-| 06-screenshot-pdf | Screenshot and PDF export |-| 40-activity | Activity API capture and filtering |-| scenarios-orchestrator/01-attach-bridge | Orchestrator attaches to the dedicated `pinchtab-bridge` container and proxies tab traffic |-| scenarios-orchestrator/31-multi-instance | Launch/list/stop and aggregate orchestration behavior |+Compose usage:+- `docker-compose.yml` powers `api-fast`, `cli-fast`, and `cli-full`+- `docker-compose-multi.yml` powers `api-full`## Adding Tests-1. Create a new script in `scenarios/` following the naming pattern `NN-name.sh`-2. Source `common.sh` for utilities-3. Use the assertion helpers:+1. Add or update a grouped entrypoint such as `tabs-basic.sh` or `tabs-full.sh`+2. Source `../helpers/api.sh` or `../helpers/cli.sh`+3. Put the happy path in `*-basic.sh` and the extra/edge cases in `*-full.sh`+4. Use the assertion helpers:```bash#!/bin/bash-source "$(dirname "$0")/common.sh"+SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"+source "${SCRIPT_DIR}/../helpers/api.sh"start_test "My test name"@@ -112,8 +125,8 @@ end_test```The action scenarios already cover common interaction regressions against the bundled fixtures:-- `tests/e2e/scenarios/05-actions.sh` covers API actions including `check` and `uncheck`-- `tests/e2e/scenarios-cli/03-actions.sh` covers the matching CLI commands+- `tests/e2e/scenarios-api/actions-basic.sh` groups the API happy-path actions+- `tests/e2e/scenarios-cli/actions-basic.sh` groups the matching CLI commands## Adding Fixtures@@ -128,32 +141,39 @@ Add HTML files to `fixtures/` for testing specific scenarios:## CI IntegrationThe E2E tests run automatically:-- On PRs and pushes to `main`: `recent`, `api-fast`, and `cli-fast`-- Manually via workflow dispatch: `full-api`, `full-cli`, and `full-extended`+- On PRs and pushes to `main`: `api-fast` and `cli-fast`+- Manually via workflow dispatch: `api-full` and `cli-full`++## Result Files++Each suite writes its own result files in `tests/e2e/results/`:++- `summary-api-fast.txt` / `report-api-fast.md`+- `summary-api-full.txt` / `report-api-full.md`+- `summary-cli-fast.txt` / `report-cli-fast.md`+- `summary-cli-full.txt` / `report-cli-full.md`++The launcher deletes the target suite files before each run to avoid stale output.## Debugging### View container logs```bashdocker compose -f tests/e2e/docker-compose.yml logs pinchtab+docker compose -f tests/e2e/docker-compose-multi.yml logs pinchtab```### Interactive shell in runner```bash-docker compose -f tests/e2e/docker-compose.yml run runner bash+docker compose -f tests/e2e/docker-compose.yml run runner-api bash+docker compose -f tests/e2e/docker-compose.yml run runner-cli bash```### Run specific scenario```bash-docker compose -f tests/e2e/docker-compose.yml run runner /scenarios/04-tabs-api.sh-```--### Run orchestrator scenarios-```bash-docker compose -f tests/e2e/docker-compose-orchestrator.yml run --build --rm runner+docker compose -f tests/e2e/docker-compose.yml run runner-api /bin/bash /e2e/scenarios-api/tabs-basic.sh+docker compose -f tests/e2e/docker-compose-multi.yml run runner-api /bin/bash /e2e/scenarios-api/tabs-full.sh```-### Run remote bridge attach scenario-```bash-docker compose -f tests/e2e/docker-compose-orchestrator.yml run --build --rm runner /scenarios-orchestrator/01-attach-bridge.sh-```+### Orchestrator Coverage+`api-full` uses `docker-compose-multi.yml` and includes the multi-instance and remote-bridge orchestrator scenarios through `orchestrator-full.sh`.diff --git a/tests/e2e/config/pinchtab-full-permissive.json b/tests/e2e/config/pinchtab-full-permissive.jsonnew file mode 100644index 00000000..1481445c--- /dev/null+++ b/tests/e2e/config/pinchtab-full-permissive.json@@ -0,0 +1,66 @@+{+ "server": {+ "bind": "0.0.0.0",+ "port": "9999"+ },+ "browser": {+ "extraFlags": "--no-sandbox --disable-dev-shm-usage",+ "extensionPaths": [+ "/extensions/test-extension"+ ]+ },+ "instanceDefaults": {+ "maxTabs": 10,+ "stealthLevel": "full"+ },+ "multiInstance": {+ "strategy": "always-on",+ "allocationPolicy": "fcfs",+ "restart": {+ "maxRestarts": 20,+ "initBackoffSec": 2,+ "maxBackoffSec": 60,+ "stableAfterSec": 300+ }+ },+ "scheduler": {+ "enabled": true,+ "strategy": "fair-fifo",+ "maxQueueSize": 5,+ "maxPerAgent": 3,+ "maxInflight": 2,+ "workerCount": 2,+ "maxBatchSize": 5,+ "resultTTLSec": 120+ },+ "security": {+ "allowEvaluate": true,+ "allowDownload": true,+ "allowUpload": true,+ "attach": {+ "enabled": true,+ "allowHosts": [+ "127.0.0.1",+ "localhost",+ "::1",+ "pinchtab-bridge"+ ],+ "allowSchemes": [+ "ws",+ "wss",+ "http",+ "https"+ ]+ },+ "idpi": {+ "enabled": true,+ "scanContent": true,+ "allowedDomains": [+ "localhost",+ "127.0.0.1",+ "::1",+ "fixtures"+ ]+ }+ }+}diff --git a/tests/e2e/config/pinchtab-medium-permissive.json b/tests/e2e/config/pinchtab-medium-permissive.jsonnew file mode 100644index 00000000..13f2f7ce--- /dev/null+++ b/tests/e2e/config/pinchtab-medium-permissive.json@@ -0,0 +1,66 @@+{+ "server": {+ "bind": "0.0.0.0",+ "port": "9999"+ },+ "browser": {+ "extraFlags": "--no-sandbox --disable-dev-shm-usage",+ "extensionPaths": [+ "/extensions/test-extension"+ ]+ },+ "instanceDefaults": {+ "maxTabs": 10,+ "stealthLevel": "medium"+ },+ "multiInstance": {+ "strategy": "always-on",+ "allocationPolicy": "fcfs",+ "restart": {+ "maxRestarts": 20,+ "initBackoffSec": 2,+ "maxBackoffSec": 60,+ "stableAfterSec": 300+ }+ },+ "scheduler": {+ "enabled": true,+ "strategy": "fair-fifo",+ "maxQueueSize": 5,+ "maxPerAgent": 3,+ "maxInflight": 2,+ "workerCount": 2,+ "maxBatchSize": 5,+ "resultTTLSec": 120+ },+ "security": {+ "allowEvaluate": true,+ "allowDownload": true,+ "allowUpload": true,+ "attach": {+ "enabled": true,+ "allowHosts": [+ "127.0.0.1",+ "localhost",+ "::1",+ "pinchtab-bridge"+ ],+ "allowSchemes": [+ "ws",+ "wss",+ "http",+ "https"+ ]+ },+ "idpi": {+ "enabled": true,+ "scanContent": true,+ "allowedDomains": [+ "localhost",+ "127.0.0.1",+ "::1",+ "fixtures"+ ]+ }+ }+}diff --git a/tests/e2e/docker-compose-cli.yml b/tests/e2e/docker-compose-cli.ymldeleted file mode 100644index 87be5380..00000000--- a/tests/e2e/docker-compose-cli.yml+++ /dev/null@@ -1,47 +0,0 @@-services:- # Main pinchtab instance- pinchtab:- build:- context: ../..- dockerfile: Dockerfile- environment:- PINCHTAB_CONFIG: /config/pinchtab.json- volumes:- - ./config/pinchtab.json:/config/pinchtab.json:ro- - ./fixtures/test-extension:/extensions/test-extension:ro- ports:- - "9999:9999"- shm_size: '2gb'- healthcheck:- test: ["CMD-SHELL", "wget -q -O /dev/null http://localhost:9999/health"]- interval: 3s- timeout: 10s- retries: 20- start_period: 15s-- fixtures:- image: nginx:alpine- volumes:- - ./fixtures:/usr/share/nginx/html:ro- healthcheck:- test: ["CMD-SHELL", "wget -q -O /dev/null http://localhost:80/"]- interval: 2s- timeout: 5s- retries: 5-- runner:- build:- context: ./runner-cli- depends_on:- pinchtab:- condition: service_healthy- fixtures:- condition: service_healthy- environment:- - E2E_SERVER=http://pinchtab:9999- - FIXTURES_URL=http://fixtures:80- volumes:- - ./scenarios-cli:/scenarios:ro- - ./suites:/e2e-suites:ro- - ./results:/results- command: ["/scenarios/run-all.sh"]diff --git a/tests/e2e/docker-compose-multi.yml b/tests/e2e/docker-compose-multi.ymlnew file mode 100644index 00000000..b5aad009--- /dev/null+++ b/tests/e2e/docker-compose-multi.yml@@ -0,0 +1,155 @@+services:+ pinchtab:+ build:+ context: ../..+ dockerfile: Dockerfile+ environment:+ PINCHTAB_CONFIG: /config/pinchtab.json+ volumes:+ - ./config/pinchtab.json:/config/pinchtab.json:ro+ - ./fixtures/test-extension:/extensions/test-extension+ - ./fixtures/test-extension-api:/extensions/test-extension-api+ ports:+ - "9999:9999"+ shm_size: '2gb'+ healthcheck:+ test: ["CMD-SHELL", "wget -q -O /dev/null http://localhost:9999/health"]+ interval: 3s+ timeout: 10s+ retries: 20+ start_period: 15s++ pinchtab-secure:+ build:+ context: ../..+ dockerfile: Dockerfile+ environment:+ PINCHTAB_CONFIG: /config/pinchtab-secure.json+ volumes:+ - ./config/pinchtab-secure.json:/config/pinchtab-secure.json:ro+ ports:+ - "9998:9999"+ shm_size: '2gb'+ healthcheck:+ test: ["CMD-SHELL", "wget -q -O /dev/null http://localhost:9999/health"]+ interval: 3s+ timeout: 10s+ retries: 20+ start_period: 15s++ pinchtab-medium:+ build:+ context: ../..+ dockerfile: Dockerfile+ environment:+ PINCHTAB_CONFIG: /config/pinchtab-medium-permissive.json+ volumes:+ - ./config/pinchtab-medium-permissive.json:/config/pinchtab-medium-permissive.json:ro+ - ./fixtures/test-extension:/extensions/test-extension+ ports:+ - "9994:9999"+ shm_size: '2gb'+ healthcheck:+ test: ["CMD-SHELL", "wget -q -O /dev/null http://localhost:9999/health"]+ interval: 3s+ timeout: 10s+ retries: 20+ start_period: 15s++ pinchtab-full:+ build:+ context: ../..+ dockerfile: Dockerfile+ environment:+ PINCHTAB_CONFIG: /config/pinchtab-full-permissive.json+ volumes:+ - ./config/pinchtab-full-permissive.json:/config/pinchtab-full-permissive.json:ro+ - ./fixtures/test-extension:/extensions/test-extension+ ports:+ - "9995:9999"+ shm_size: '2gb'+ healthcheck:+ test: ["CMD-SHELL", "wget -q -O /dev/null http://localhost:9999/health"]+ interval: 3s+ timeout: 10s+ retries: 20+ start_period: 15s++ pinchtab-lite:+ build:+ context: ../..+ dockerfile: Dockerfile+ environment:+ PINCHTAB_CONFIG: /config/pinchtab-lite.json+ volumes:+ - ./config/pinchtab-lite.json:/config/pinchtab-lite.json:ro+ ports:+ - "9997:9999"+ command: ["/usr/local/bin/pinchtab", "bridge"]+ healthcheck:+ test: ["CMD-SHELL", "wget -q -O /dev/null http://localhost:9999/health"]+ interval: 3s+ timeout: 10s+ retries: 20+ start_period: 15s++ pinchtab-bridge:+ build:+ context: ../..+ dockerfile: Dockerfile+ environment:+ PINCHTAB_CONFIG: /config/pinchtab-bridge.json+ volumes:+ - ./config/pinchtab-bridge.json:/config/pinchtab-bridge.json:ro+ ports:+ - "9996:9999"+ command: ["/usr/local/bin/pinchtab", "bridge"]+ shm_size: '2gb'+ healthcheck:+ test: ["CMD-SHELL", "wget --header='Authorization: Bearer e2e-bridge-token' -q -O /dev/null http://localhost:9999/health"]+ interval: 3s+ timeout: 10s+ retries: 20+ start_period: 15s++ fixtures:+ image: nginx:alpine+ volumes:+ - ./fixtures:/usr/share/nginx/html:ro+ healthcheck:+ test: ["CMD-SHELL", "wget -q -O /dev/null http://localhost:80/"]+ interval: 2s+ timeout: 5s+ retries: 5++ runner-api:+ build:+ context: ./runner-api+ depends_on:+ pinchtab:+ condition: service_healthy+ pinchtab-secure:+ condition: service_healthy+ pinchtab-medium:+ condition: service_healthy+ pinchtab-full:+ condition: service_healthy+ pinchtab-lite:+ condition: service_healthy+ pinchtab-bridge:+ condition: service_healthy+ fixtures:+ condition: service_healthy+ environment:+ - E2E_SERVER=http://pinchtab:9999+ - E2E_SECURE_SERVER=http://pinchtab-secure:9999+ - E2E_MEDIUM_SERVER=http://pinchtab-medium:9999+ - E2E_FULL_SERVER=http://pinchtab-full:9999+ - E2E_LITE_SERVER=http://pinchtab-lite:9999+ - E2E_BRIDGE_URL=http://pinchtab-bridge:9999+ - E2E_BRIDGE_TOKEN=e2e-bridge-token+ - FIXTURES_URL=http://fixtures:80+ volumes:+ - ./:/e2e:ro+ - ./results:/results+ command: ["/bin/bash", "/e2e/run.sh", "api", "all=true"]diff --git a/tests/e2e/docker-compose-orchestrator.yml b/tests/e2e/docker-compose-orchestrator.ymldeleted file mode 100644index 40f2fcb7..00000000--- a/tests/e2e/docker-compose-orchestrator.yml+++ /dev/null@@ -1,70 +0,0 @@-services:- pinchtab:- build:- context: ../..- dockerfile: Dockerfile- environment:- PINCHTAB_CONFIG: /config/pinchtab.json- volumes:- - ./config/pinchtab.json:/config/pinchtab.json:ro- - ./fixtures/test-extension:/extensions/test-extension- - ./fixtures/test-extension-api:/extensions/test-extension-api- ports:- - "9999:9999"- shm_size: '2gb'- healthcheck:- test: ["CMD-SHELL", "wget -q -O /dev/null http://localhost:9999/health"]- interval: 3s- timeout: 10s- retries: 20- start_period: 15s-- pinchtab-bridge:- build:- context: ../..- dockerfile: Dockerfile- environment:- PINCHTAB_CONFIG: /config/pinchtab-bridge.json- volumes:- - ./config/pinchtab-bridge.json:/config/pinchtab-bridge.json:ro- ports:- - "9996:9999"- command: ["/usr/local/bin/pinchtab", "bridge"]- shm_size: '2gb'- healthcheck:- test: ["CMD-SHELL", "wget --header='Authorization: Bearer e2e-bridge-token' -q -O /dev/null http://localhost:9999/health"]- interval: 3s- timeout: 10s- retries: 20- start_period: 15s-- fixtures:- image: nginx:alpine- volumes:- - ./fixtures:/usr/share/nginx/html:ro- healthcheck:- test: ["CMD-SHELL", "wget -q -O /dev/null http://localhost:80/"]- interval: 2s- timeout: 5s- retries: 5-- runner:- build:- context: ./runner- depends_on:- pinchtab:- condition: service_healthy- pinchtab-bridge:- condition: service_healthy- fixtures:- condition: service_healthy- environment:- - E2E_SERVER=http://pinchtab:9999- - E2E_BRIDGE_URL=http://pinchtab-bridge:9999- - E2E_BRIDGE_TOKEN=e2e-bridge-token- - FIXTURES_URL=http://fixtures:80- volumes:- - ./scenarios:/scenarios:ro- - ./scenarios-orchestrator:/scenarios-orchestrator:ro- - ./results:/results- command: ["/scenarios-orchestrator/run-all.sh"]diff --git a/tests/e2e/docker-compose.yml b/tests/e2e/docker-compose.ymlindex cfa4a4c5..ff2ba579 100644--- a/tests/e2e/docker-compose.yml+++ b/tests/e2e/docker-compose.yml@@ -1,5 +1,4 @@services:- # Main instance: security features ENABLED (permissive)pinchtab:build:context: ../..@@ -8,11 +7,10 @@ services:PINCHTAB_CONFIG: /config/pinchtab.jsonvolumes:- ./config/pinchtab.json:/config/pinchtab.json:ro- - ./fixtures/test-extension:/extensions/test-extension- - ./fixtures/test-extension-api:/extensions/test-extension-api+ - ./fixtures/test-extension:/extensions/test-extension:ro+ - ./fixtures/test-extension-api:/extensions/test-extension-api:roports:- "9999:9999"- # Chrome needs more shared memory in Dockershm_size: '2gb'healthcheck:test: ["CMD-SHELL", "wget -q -O /dev/null http://localhost:9999/health"]@@ -21,44 +19,6 @@ services:retries: 20start_period: 15s- # Secure instance: security features DISABLED (restrictive)- pinchtab-secure:- build:- context: ../..- dockerfile: Dockerfile- environment:- PINCHTAB_CONFIG: /config/pinchtab-secure.json- volumes:- - ./config/pinchtab-secure.json:/config/pinchtab-secure.json:ro- ports:- - "9998:9999"- shm_size: '2gb'- healthcheck:- test: ["CMD-SHELL", "wget -q -O /dev/null http://localhost:9999/health"]- interval: 3s- timeout: 10s- retries: 20- start_period: 15s-- # Lite engine instance: no Chrome, DOM-only (bridge mode)- pinchtab-lite:- build:- context: ../..- dockerfile: Dockerfile- environment:- PINCHTAB_CONFIG: /config/pinchtab-lite.json- volumes:- - ./config/pinchtab-lite.json:/config/pinchtab-lite.json:ro- ports:- - "9997:9999"- command: ["/usr/local/bin/pinchtab", "bridge"]- healthcheck:- test: ["CMD-SHELL", "wget -q -O /dev/null http://localhost:9999/health"]- interval: 3s- timeout: 10s- retries: 20- start_period: 15s-fixtures:image: nginx:alpinevolumes:@@ -69,26 +29,34 @@ services:timeout: 5sretries: 5- runner:+ runner-api:build:- context: ./runner+ context: ./runner-apidepends_on:pinchtab:condition: service_healthy- pinchtab-secure:+ fixtures:condition: service_healthy- pinchtab-lite:+ environment:+ - E2E_SERVER=http://pinchtab:9999+ - FIXTURES_URL=http://fixtures:80+ volumes:+ - ./:/e2e:ro+ - ./results:/results+ command: ["/bin/bash", "/e2e/run.sh", "api"]++ runner-cli:+ build:+ context: ./runner-cli+ depends_on:+ pinchtab:condition: service_healthyfixtures:condition: service_healthyenvironment:- E2E_SERVER=http://pinchtab:9999- - E2E_SECURE_SERVER=http://pinchtab-secure:9999- - E2E_LITE_SERVER=http://pinchtab-lite:9999- FIXTURES_URL=http://fixtures:80volumes:- - ./scenarios:/scenarios:ro- - ./scenarios-recent:/scenarios-recent:ro- - ./suites:/e2e-suites:ro+ - ./:/e2e:ro- ./results:/results- command: ["/scenarios/run-all.sh"]+ command: ["/bin/bash", "/e2e/run.sh", "cli", "all=true"]diff --git a/tests/e2e/fixtures/bot-detect.html b/tests/e2e/fixtures/bot-detect.htmlindex c9a91fc7..8d554f1a 100644--- a/tests/e2e/fixtures/bot-detect.html+++ b/tests/e2e/fixtures/bot-detect.html@@ -109,6 +109,41 @@addResult('no_cdp_traces', !hasCDPTraces,hasCDPTraces ? 'CDP traces found!' : 'Clean');+ // Test: navigator.userAgentData exists (Client Hints API - required by Turnstile)+ const hasUserAgentData = !!(navigator.userAgentData && navigator.userAgentData.brands);+ addResult('useragentdata_exists', hasUserAgentData,+ hasUserAgentData ? `${navigator.userAgentData.brands.length} brands` : 'Missing');++ // Test: userAgentData.getHighEntropyValues exists+ const hasHighEntropy = !!(navigator.userAgentData && typeof navigator.userAgentData.getHighEntropyValues === 'function');+ addResult('useragentdata_highentropy', hasHighEntropy,+ hasHighEntropy ? 'Available' : 'Missing');++ // Test: chrome.runtime.connect exists (required by Cloudflare Turnstile)+ const hasChromeConnect = !!(window.chrome && window.chrome.runtime && typeof window.chrome.runtime.connect === 'function');+ addResult('chrome_runtime_connect', hasChromeConnect,+ hasChromeConnect ? 'Available' : 'Missing');++ // Test: chrome.csi exists (Chrome Speed Index - some sites check)+ const hasChromeCsi = !!(window.chrome && typeof window.chrome.csi === 'function');+ addResult('chrome_csi', hasChromeCsi,+ hasChromeCsi ? 'Available' : 'Missing');++ // Test: chrome.loadTimes exists (deprecated but still checked)+ const hasChromeLoadTimes = !!(window.chrome && typeof window.chrome.loadTimes === 'function');+ addResult('chrome_loadtimes', hasChromeLoadTimes,+ hasChromeLoadTimes ? 'Available' : 'Missing');++ // Test: No CDP markers in window object+ let cdpMarkerCount = 0;+ for (const prop of Object.getOwnPropertyNames(window)) {+ if (/^cdc_|^\$cdc_|^__webdriver|^__selenium|^__driver|^\$chrome_|^__puppeteer|^__playwright/.test(prop)) {+ cdpMarkerCount++;+ }+ }+ addResult('no_cdp_markers', cdpMarkerCount === 0,+ cdpMarkerCount === 0 ? 'Clean' : `${cdpMarkerCount} markers found`);+// ═══════════════════════════════════════════════════════════════════// WARNING TESTS - Nice to pass, but not always critical// ═══════════════════════════════════════════════════════════════════@@ -160,6 +195,11 @@addResult('screen_dimensions', screenOk,`${screen.width}x${screen.height} @ ${screen.colorDepth}bit`, 'warn');+ // Test: Battery API exists (headless often lacks this)+ const hasBatteryAPI = typeof navigator.getBattery === 'function';+ addResult('battery_api', hasBatteryAPI,+ hasBatteryAPI ? 'Available' : 'Missing', 'warn');+// Test: Notification permission queryable (not denied by default)let notifOk = true;try {@@ -178,6 +218,37 @@addResult('function_tostring', toStringOk,toStringOk ? 'Native' : 'Modified', 'warn');+ // Test: maxTouchPoints is 0 for desktop+ const touchPoints = navigator.maxTouchPoints;+ const touchOk = touchPoints === 0 || touchPoints > 0; // Either is fine, just should exist+ addResult('max_touch_points', touchOk, `${touchPoints}`, 'warn');++ // Test: Video codec support (H.264/VP9)+ let codecSupport = 'unknown';+ try {+ const video = document.createElement('video');+ const h264 = video.canPlayType('video/mp4; codecs="avc1.42E01E"');+ const vp9 = video.canPlayType('video/webm; codecs="vp9"');+ codecSupport = `H.264: ${h264}, VP9: ${vp9}`;+ } catch (e) { codecSupport = 'error'; }+ const codecsOk = codecSupport.includes('probably');+ addResult('video_codecs', codecsOk, codecSupport, 'warn');++ // Test: userAgentData platform matches navigator.platform+ let uaPlatformMatch = true;+ if (navigator.userAgentData) {+ const uadPlatform = navigator.userAgentData.platform;+ const navPlatform = navigator.platform;+ // Windows: userAgentData.platform = "Windows", navigator.platform = "Win32"+ // macOS: userAgentData.platform = "macOS", navigator.platform = "MacIntel"+ // Linux: userAgentData.platform = "Linux", navigator.platform = "Linux x86_64"+ if (uadPlatform === 'Windows' && !navPlatform.includes('Win')) uaPlatformMatch = false;+ if (uadPlatform === 'macOS' && navPlatform !== 'MacIntel') uaPlatformMatch = false;+ if (uadPlatform === 'Linux' && !navPlatform.includes('Linux')) uaPlatformMatch = false;+ }+ addResult('useragentdata_platform_match', uaPlatformMatch,+ navigator.userAgentData ? `${navigator.userAgentData.platform} / ${navigator.platform}` : 'N/A', 'warn');+// ═══════════════════════════════════════════════════════════════════// INFO - Just for debugging// ═══════════════════════════════════════════════════════════════════@@ -193,6 +264,12 @@addInfo('Cookies Enabled', navigator.cookieEnabled);addInfo('Do Not Track', navigator.doNotTrack);addInfo('WebGL Renderer', webglRenderer);+ addInfo('Max Touch Points', navigator.maxTouchPoints);+ addInfo('UserAgentData Platform', navigator.userAgentData?.platform || 'N/A');+ addInfo('UserAgentData Brands', navigator.userAgentData?.brands?.map(b => `${b.brand}/${b.version}`).join(', ') || 'N/A');+ addInfo('chrome.csi', typeof window.chrome?.csi === 'function' ? 'Present' : 'Missing');+ addInfo('chrome.loadTimes', typeof window.chrome?.loadTimes === 'function' ? 'Present' : 'Missing');+ addInfo('chrome.runtime.connect', typeof window.chrome?.runtime?.connect === 'function' ? 'Present' : 'Missing');// ═══════════════════════════════════════════════════════════════════// SCORINGdiff --git a/tests/e2e/scenarios/helpers/actions.sh b/tests/e2e/helpers/api-actions.shsimilarity index 96%rename from tests/e2e/scenarios/helpers/actions.shrename to tests/e2e/helpers/api-actions.shindex 7934e3de..f78b94df 100644--- a/tests/e2e/scenarios/helpers/actions.sh+++ b/tests/e2e/helpers/api-actions.sh@@ -1,5 +1,5 @@#!/bin/bash-# helpers/actions.sh — Action helpers (click, type, humanClick, humanType)+# api-actions.sh — Action helpers (click, type, humanClick, humanType)## Higher-level wrappers around pt_post /action for readable tests.diff --git a/tests/e2e/helpers/api-assertions.sh b/tests/e2e/helpers/api-assertions.shnew file mode 100644index 00000000..b7dccddb--- /dev/null+++ b/tests/e2e/helpers/api-assertions.sh@@ -0,0 +1,291 @@+#!/bin/bash+# Assertion helpers for API/curl E2E tests.++assert_json_eq() {+ local json="$1"+ local path="$2"+ local expected="$3"+ local desc="${4:-$path = $expected}"+ local actual+ actual=$(echo "$json" | jq -r "$path")++ if [ "$actual" = "$expected" ]; then+ echo -e " ${GREEN}✓${NC} $desc"+ ((ASSERTIONS_PASSED++)) || true+ else+ echo -e " ${RED}✗${NC} $desc (got: $actual)"+ ((ASSERTIONS_FAILED++)) || true+ fi+}++assert_json_value() {+ local json="$1"+ local path="$2"+ local expected="$3"+ local desc="${4:-$path = $expected}"+ assert_json_eq "$json" "$path" "$expected" "$desc"+}++assert_json_contains() {+ local json="$1"+ local path="$2"+ local needle="$3"+ local desc="${4:-$path contains '$needle'}"+ local actual+ actual=$(echo "$json" | jq -r "$path")++ if [[ "$actual" == *"$needle"* ]]; then+ echo -e " ${GREEN}✓${NC} $desc"+ ((ASSERTIONS_PASSED++)) || true+ else+ echo -e " ${RED}✗${NC} $desc (got: $actual)"+ ((ASSERTIONS_FAILED++)) || true+ fi+}++assert_json_length() {+ local json="$1"+ local path="$2"+ local expected="$3"+ local desc="${4:-$path length = $expected}"+ local actual+ actual=$(echo "$json" | jq "$path | length")++ if [ "$actual" -eq "$expected" ]; then+ echo -e " ${GREEN}✓${NC} $desc"+ ((ASSERTIONS_PASSED++)) || true+ else+ echo -e " ${RED}✗${NC} $desc (got: $actual)"+ ((ASSERTIONS_FAILED++)) || true+ fi+}++assert_json_length_gte() {+ local json="$1"+ local path="$2"+ local expected="$3"+ local desc="${4:-$path length >= $expected}"+ local actual+ actual=$(echo "$json" | jq "$path | length")++ if [ "$actual" -ge "$expected" ]; then+ echo -e " ${GREEN}✓${NC} $desc"+ ((ASSERTIONS_PASSED++)) || true+ else+ echo -e " ${RED}✗${NC} $desc (got: $actual)"+ ((ASSERTIONS_FAILED++)) || true+ fi+}++assert_json_exists() {+ local json="$1"+ local path="$2"+ local desc="${3:-$path exists}"++ if echo "$json" | jq -e "$path" >/dev/null 2>&1; then+ echo -e " ${GREEN}✓${NC} $desc"+ ((ASSERTIONS_PASSED++)) || true+ else+ echo -e " ${RED}✗${NC} $desc (field missing or null)"+ ((ASSERTIONS_FAILED++)) || true+ fi+}++assert_contains() {+ local haystack="$1"+ local needle="$2"+ local desc="${3:-contains '$needle'}"++ if echo "$haystack" | grep -q "$needle"; then+ echo -e " ${GREEN}✓${NC} $desc"+ ((ASSERTIONS_PASSED++)) || true+ else+ echo -e " ${RED}✗${NC} $desc (not found)"+ ((ASSERTIONS_FAILED++)) || true+ fi+}++assert_result_eq() {+ local path="$1"+ local expected="$2"+ local desc="${3:-$path = $expected}"+ assert_json_eq "$RESULT" "$path" "$expected" "$desc"+}++assert_result_exists() {+ local path="$1"+ local desc="${2:-$path exists}"+ assert_json_exists "$RESULT" "$path" "$desc"+}++assert_result_jq() {+ local expr="$1"+ local success_desc="$2"+ local fail_desc="${3:-$2}"+ shift 3+ assert_ref_json_jq "$expr" "$success_desc" "$fail_desc" "$@"+}++assert_result_has_tab_event() {+ local tab_id="$1"+ local path="$2"+ local success_desc="$3"+ local fail_desc="$4"+ assert_result_jq \+ '.events[] | select(.tabId == $tab and .path == $path)' \+ "$success_desc" \+ "$fail_desc" \+ --arg tab "$tab_id" \+ --arg path "$path"+}++assert_input_not_contains() {+ local selector="$1"+ local forbidden="$2"+ local desc="${3:-$selector should not contain '$forbidden'}"++ local json_body+ json_body=$(jq -n --arg sel "$selector" '{"expression": ("document.querySelector(\"" + $sel + "\")?.value || \"\"")}')+ pt_post /evaluate "$json_body"+ local value+ value=$(echo "$RESULT" | jq -r '.result // empty')++ if echo "$value" | grep -qi "$forbidden"; then+ echo -e " ${RED}✗${NC} $desc: found '$forbidden' in value '$value'"+ ((ASSERTIONS_FAILED++)) || true+ return 1+ fi++ echo -e " ${GREEN}✓${NC} $desc (value: '$value')"+ ((ASSERTIONS_PASSED++)) || true+ return 0+}++assert_http_error() {+ local expected_status="$1"+ local error_pattern="${2:-error}"+ local desc="${3:-HTTP $expected_status error}"+ local actual_status+ actual_status=$(echo "$RESULT" | jq -r '.status // empty')++ if [ "$actual_status" = "$expected_status" ] || grep -q "$error_pattern" <<< "$RESULT"; then+ echo -e " ${GREEN}✓${NC} $desc"+ ((ASSERTIONS_PASSED++)) || true+ else+ echo -e " ${YELLOW}~${NC} $desc (got: $actual_status)"+ ((ASSERTIONS_PASSED++)) || true+ fi+}++assert_contains_any() {+ local haystack="$1"+ local patterns="$2"+ local desc="${3:-contains expected pattern}"++ if echo "$haystack" | grep -qE "$patterns"; then+ echo -e " ${GREEN}✓${NC} $desc"+ ((ASSERTIONS_PASSED++)) || true+ else+ echo -e " ${YELLOW}~${NC} $desc (not found)"+ ((ASSERTIONS_PASSED++)) || true+ fi+}++assert_buttons_page() {+ local snap="$1"+ local expected_buttons=("Increment" "Decrement" "Reset")+ local found=0++ for btn in "${expected_buttons[@]}"; do+ if echo "$snap" | jq -e ".nodes[] | select(.name == \"$btn\")" > /dev/null 2>&1; then+ ((found++))+ fi+ done++ if [ "$found" -ge 3 ]; then+ echo -e " ${GREEN}✓${NC} buttons.html: found $found/3 expected buttons"+ ((ASSERTIONS_PASSED++)) || true+ else+ echo -e " ${RED}✗${NC} buttons.html: found only $found/3 expected buttons"+ ((ASSERTIONS_FAILED++)) || true+ fi+}++assert_form_page() {+ local snap="$1"+ local checks=0+ local textboxes+ textboxes=$(echo "$snap" | jq '[.nodes[] | select(.role == "textbox")] | length')+ [ "$textboxes" -ge 2 ] && ((checks++))+ echo "$snap" | jq -e '.nodes[] | select(.name == "Submit")' > /dev/null 2>&1 && ((checks++))+ echo "$snap" | jq -e '.nodes[] | select(.role == "combobox")' > /dev/null 2>&1 && ((checks++))++ if [ "$checks" -ge 3 ]; then+ echo -e " ${GREEN}✓${NC} form.html: found expected form elements"+ ((ASSERTIONS_PASSED++)) || true+ else+ echo -e " ${RED}✗${NC} form.html: missing expected form elements ($checks/3)"+ ((ASSERTIONS_FAILED++)) || true+ fi+}++assert_table_page() {+ local text="$1"+ local checks=0++ echo "$text" | grep -q "Alice Johnson" && ((checks++))+ echo "$text" | grep -q "[email protected]" && ((checks++))+ echo "$text" | grep -q "Active" && ((checks++))++ if [ "$checks" -ge 3 ]; then+ echo -e " ${GREEN}✓${NC} table.html: found expected table data"+ ((ASSERTIONS_PASSED++)) || true+ else+ echo -e " ${RED}✗${NC} table.html: missing expected data ($checks/3)"+ ((ASSERTIONS_FAILED++)) || true+ fi+}++assert_index_page() {+ local snap="$1"++ if echo "$snap" | jq -e '.title' | grep -q "E2E Test"; then+ echo -e " ${GREEN}✓${NC} index.html: correct title"+ ((ASSERTIONS_PASSED++)) || true+ else+ echo -e " ${RED}✗${NC} index.html: wrong title"+ ((ASSERTIONS_FAILED++)) || true+ fi+}++generate_markdown_report() {+ local total=$((TESTS_PASSED + TESTS_FAILED))+ local total_time=0++ echo "## 🦀 PinchTab E2E Test Report"+ echo ""+ if [ "$TESTS_FAILED" -eq 0 ]; then+ echo "**Status:** ✅ All tests passed"+ else+ echo "**Status:** ❌ ${TESTS_FAILED} test(s) failed"+ fi+ echo ""+ echo "| Test | Duration | Status |"+ echo "|------|----------|--------|"++ for result in "${TEST_RESULTS[@]}"; do+ IFS='|' read -r name duration status <<< "$result"+ local time_num=${duration%ms}+ ((total_time += time_num)) || true+ local icon="✅"+ [ "$status" = "failed" ] && icon="❌"+ local clean_name="${name#✅ }"+ clean_name="${clean_name#❌ }"+ echo "| ${clean_name} | ${duration} | ${icon} |"+ done++ echo ""+ echo "**Summary:** ${TESTS_PASSED}/${total} passed in ${total_time}ms"+ echo ""+ echo "<sub>Generated at $(date -u +%Y-%m-%dT%H:%M:%SZ)</sub>"+}diff --git a/tests/e2e/helpers/api-http.sh b/tests/e2e/helpers/api-http.shnew file mode 100644index 00000000..e6103f1c--- /dev/null+++ b/tests/e2e/helpers/api-http.sh@@ -0,0 +1,447 @@+#!/bin/bash+# HTTP/API helpers for curl-based E2E tests.++wait_for_orchestrator_instance_status() {+ local base_url="$1"+ local instance_id="$2"+ local wanted_status="${3:-running}"+ local timeout_sec="${4:-60}"+ local started_at+ started_at=$(date +%s)++ while true; do+ local now+ now=$(date +%s)+ if [ $((now - started_at)) -ge "$timeout_sec" ]; then+ echo -e " ${RED}✗${NC} instance ${instance_id} at ${base_url} did not reach ${wanted_status} within ${timeout_sec}s"+ return 1+ fi++ local inst_json+ inst_json=$(curl -sf "${base_url}/instances/${instance_id}" 2>/dev/null || true)+ if [ -n "$inst_json" ]; then+ local inst_status+ inst_status=$(echo "$inst_json" | jq -r '.status // empty' 2>/dev/null || true)+ if [ "$inst_status" = "$wanted_status" ]; then+ echo -e " ${GREEN}✓${NC} instance ${instance_id} is ${wanted_status}"+ return 0+ fi+ if [ "$inst_status" = "stopped" ] || [ "$inst_status" = "error" ]; then+ echo -e " ${RED}✗${NC} instance ${instance_id} reached terminal status ${inst_status} before ${wanted_status}"+ return 1+ fi+ fi++ sleep 1+ done+}++wait_for_instances_gone() {+ local base_url="$1"+ local timeout_sec="${2:-10}"+ shift 2+ local -a instance_ids=("$@")+ local started_at+ started_at=$(date +%s)++ while true; do+ local remaining=0+ for instance_id in "${instance_ids[@]}"; do+ local inst_json+ inst_json=$(curl -sf "${base_url}/instances/${instance_id}" 2>/dev/null || true)+ if [ -n "$inst_json" ]; then+ local inst_status+ inst_status=$(echo "$inst_json" | jq -r '.status // empty' 2>/dev/null || true)+ if [ "$inst_status" != "stopped" ] && [ "$inst_status" != "" ] && [ "$inst_status" != "null" ]; then+ ((remaining++)) || true+ fi+ fi+ done++ if [ "$remaining" -eq 0 ]; then+ return 0+ fi++ local now+ now=$(date +%s)+ if [ $((now - started_at)) -ge "$timeout_sec" ]; then+ return 1+ fi++ sleep 1+ done+}++wait_for_instances_running() {+ local base_url="$1"+ local timeout_sec="${2:-30}"+ shift 2+ local -a instance_ids=("$@")+ local started_at+ started_at=$(date +%s)++ while true; do+ local ready=0+ for instance_id in "${instance_ids[@]}"; do+ local inst_json+ inst_json=$(curl -sf "${base_url}/instances/${instance_id}" 2>/dev/null || true)+ if [ -n "$inst_json" ]; then+ local inst_status+ inst_status=$(echo "$inst_json" | jq -r '.status // empty' 2>/dev/null || true)+ if [ "$inst_status" = "running" ]; then+ ((ready++)) || true+ fi+ fi+ done++ if [ "$ready" -eq "${#instance_ids[@]}" ]; then+ return 0+ fi++ local now+ now=$(date +%s)+ if [ $((now - started_at)) -ge "$timeout_sec" ]; then+ return 1+ fi++ sleep 1+ done+}++RESULT=""+HTTP_STATUS=""++pinchtab() {+ local method="$1"+ local path="$2"+ shift 2++ echo -e "${BLUE}→ curl -X $method ${E2E_SERVER}$path $(printf "%q " "$@")${NC}" >&2++ local response+ response=$(curl -s -w "\n%{http_code}" \+ -X "$method" \+ "${E2E_SERVER}$path" \+ -H "Content-Type: application/json" \+ "$@")++ RESULT=$(echo "$response" | head -n -1)+ HTTP_STATUS=$(echo "$response" | tail -n 1)++ if [[ ! "$HTTP_STATUS" =~ ^2 ]]; then+ echo -e "${ERROR} HTTP $HTTP_STATUS: $RESULT${NC}" >&2+ fi+}++pt() { pinchtab "$@"; }++_echo_truncated() {+ if [ ${#RESULT} -gt 1000 ]; then+ echo "${RESULT:0:200}...[truncated ${#RESULT} chars]"+ else+ echo "$RESULT"+ fi+}++pt_get() { pinchtab GET "$1"; _echo_truncated; }++pt_post() {+ local path="$1"+ shift+ if [ "$1" = "-d" ]; then+ shift+ fi+ pinchtab POST "$path" -d "$1"+ _echo_truncated+}++pt_patch() {+ local path="$1"+ local body="$2"+ echo -e "${BLUE}→ curl -X PATCH ${E2E_SERVER}$path${NC}" >&2+ local response+ response=$(curl -s -w "\n%{http_code}" \+ -X PATCH \+ "${E2E_SERVER}$path" \+ -H "Content-Type: application/json" \+ -d "$body")+ RESULT=$(echo "$response" | head -n -1)+ HTTP_STATUS=$(echo "$response" | tail -n 1)+ _echo_truncated+}++pt_delete() {+ local path="$1"+ echo -e "${BLUE}→ curl -X DELETE ${E2E_SERVER}$path${NC}" >&2+ local response+ response=$(curl -s -w "\n%{http_code}" \+ -X DELETE \+ "${E2E_SERVER}$path")+ RESULT=$(echo "$response" | head -n -1)+ HTTP_STATUS=$(echo "$response" | tail -n 1)+ _echo_truncated+}++pt_post_raw() {+ local path="$1"+ local body="$2"+ echo -e "${BLUE}→ curl -X POST ${E2E_SERVER}$path -d '$body'${NC}" >&2+ local response+ response=$(curl -s -w "\n%{http_code}" \+ -X POST \+ "${E2E_SERVER}$path" \+ -H "Content-Type: application/json" \+ -d "$body")+ RESULT=$(echo "$response" | head -n -1)+ HTTP_STATUS=$(echo "$response" | tail -n 1)+ _echo_truncated+}++assert_url_accessible() {+ local url="$1"+ local label="${2:-$url}"++ if curl -sf "$url" >/dev/null 2>&1; then+ echo -e " ${GREEN}✓${NC} GET $label"+ ((ASSERTIONS_PASSED++)) || true+ else+ echo -e " ${RED}✗${NC} GET $label (not accessible)"+ ((ASSERTIONS_FAILED++)) || true+ fi+}++assert_fixtures_accessible() {+ assert_url_accessible "${FIXTURES_URL}/" "fixtures/"+ assert_url_accessible "${FIXTURES_URL}/form.html" "fixtures/form.html"+ assert_url_accessible "${FIXTURES_URL}/table.html" "fixtures/table.html"+ assert_url_accessible "${FIXTURES_URL}/buttons.html" "fixtures/buttons.html"+}++assert_ok() {+ local label="${1:-request}"++ if [ "$HTTP_STATUS" = "200" ] || [ "$HTTP_STATUS" = "201" ]; then+ echo -e " ${GREEN}✓${NC} $label → $HTTP_STATUS"+ ((ASSERTIONS_PASSED++)) || true+ else+ echo -e " ${RED}✗${NC} $label failed (status: $HTTP_STATUS)"+ ((ASSERTIONS_FAILED++)) || true+ fi+}++assert_http_status() {+ local expected="$1"+ local label="${2:-request}"++ if [ "$HTTP_STATUS" = "$expected" ]; then+ echo -e " ${GREEN}✓${NC} $label → $HTTP_STATUS"+ ((ASSERTIONS_PASSED++)) || true+ else+ echo -e " ${RED}✗${NC} $label: expected $expected, got $HTTP_STATUS"+ ((ASSERTIONS_FAILED++)) || true+ fi+}++assert_not_ok() {+ local label="${1:-request}"++ if [ "$HTTP_STATUS" != "200" ] && [ "$HTTP_STATUS" != "201" ]; then+ echo -e " ${GREEN}✓${NC} $label → $HTTP_STATUS (error expected)"+ ((ASSERTIONS_PASSED++)) || true+ else+ echo -e " ${RED}✗${NC} $label: expected error, got $HTTP_STATUS"+ ((ASSERTIONS_FAILED++)) || true+ fi+}++click_button() {+ local name="$1"+ local ref+ ref=$(echo "$RESULT" | jq -r "[.nodes[] | select(.name == \"$name\") | .ref] | first // empty")++ if [ -n "$ref" ] && [ "$ref" != "null" ]; then+ pt_post /action "{\"kind\":\"click\",\"ref\":\"${ref}\"}" >/dev/null+ echo -e " ${GREEN}✓${NC} clicked '$name' (ref: $ref)"+ ((ASSERTIONS_PASSED++)) || true+ else+ echo -e " ${RED}✗${NC} button '$name' not found"+ ((ASSERTIONS_FAILED++)) || true+ fi+}++type_into() {+ local name="$1"+ local text="$2"+ local ref+ ref=$(echo "$RESULT" | jq -r "[.nodes[] | select(.name == \"$name\") | .ref] | first // empty")++ if [ -z "$ref" ] || [ "$ref" = "null" ]; then+ ref=$(echo "$RESULT" | jq -r '[.nodes[] | select(.role == "textbox") | .ref] | first // empty')+ fi++ if [ -n "$ref" ] && [ "$ref" != "null" ]; then+ pt_post /action "{\"kind\":\"type\",\"ref\":\"${ref}\",\"text\":\"${text}\"}" >/dev/null+ echo -e " ${GREEN}✓${NC} typed '$text' into '$name' (ref: $ref)"+ ((ASSERTIONS_PASSED++)) || true+ else+ echo -e " ${RED}✗${NC} input '$name' not found"+ ((ASSERTIONS_FAILED++)) || true+ fi+}++press_key() {+ local key="$1"+ pt_post /action -d "{\"kind\":\"press\",\"key\":\"${key}\"}" >/dev/null+ echo -e " ${GREEN}✓${NC} pressed '$key'"+ ((ASSERTIONS_PASSED++)) || true+}++get_tab_count() {+ curl -s "${E2E_SERVER}/tabs" | jq '.tabs | length'+}++get_tab_id() {+ echo "$RESULT" | jq -r '.tabId'+}++assert_tab_id() {+ local desc="${1:-tabId returned}"+ TAB_ID=$(echo "$RESULT" | jq -r '.tabId')+ if [ -n "$TAB_ID" ] && [ "$TAB_ID" != "null" ]; then+ echo -e " ${GREEN}✓${NC} $desc: ${TAB_ID:0:12}..."+ ((ASSERTIONS_PASSED++)) || true+ else+ echo -e " ${RED}✗${NC} no tabId in response"+ ((ASSERTIONS_FAILED++)) || true+ fi+}++assert_instance_list_contains() {+ local instance_id="$1"+ local present_msg="$2"+ local missing_msg="$3"+ local found+ found=$(echo "$RESULT" | jq -r ".[] | select(.id == \"$instance_id\") | .id")+ if [ "$found" = "$instance_id" ]; then+ echo -e " ${GREEN}✓${NC} $present_msg"+ ((ASSERTIONS_PASSED++)) || true+ else+ echo -e " ${RED}✗${NC} $missing_msg"+ ((ASSERTIONS_FAILED++)) || true+ fi+}++assert_instance_list_absent() {+ local instance_id="$1"+ local absent_msg="$2"+ local present_msg="$3"+ local found+ found=$(echo "$RESULT" | jq -r ".[] | select(.id == \"$instance_id\") | .id")+ if [ -z "$found" ] || [ "$found" = "null" ]; then+ echo -e " ${GREEN}✓${NC} $absent_msg"+ ((ASSERTIONS_PASSED++)) || true+ else+ echo -e " ${RED}✗${NC} $present_msg"+ ((ASSERTIONS_FAILED++)) || true+ fi+}++assert_instance_id_prefix() {+ local instance_id="$1"+ if echo "$instance_id" | grep -q "^inst_"; then+ echo -e " ${GREEN}✓${NC} instance ID has inst_ prefix: $instance_id"+ ((ASSERTIONS_PASSED++)) || true+ else+ echo -e " ${RED}✗${NC} bad ID format: $instance_id"+ ((ASSERTIONS_FAILED++)) || true+ fi+}++get_first_tab() {+ echo "$RESULT" | jq -r '.tabs[0].id'+}++show_tab() {+ local label="$1"+ local id="$2"+ echo -e " ${MUTED}$label: ${id:0:12}...${NC}"+}++assert_tab_count() {+ local expected="$1"+ local actual+ actual=$(get_tab_count)++ if [ "$actual" -eq "$expected" ]; then+ echo -e " ${GREEN}✓${NC} tab count = $actual"+ ((ASSERTIONS_PASSED++)) || true+ else+ echo -e " ${RED}✗${NC} tab count: expected $expected, got $actual"+ ((ASSERTIONS_FAILED++)) || true+ fi+}++assert_tab_count_gte() {+ local min="$1"+ local actual+ actual=$(get_tab_count)++ if [ "$actual" -ge "$min" ]; then+ echo -e " ${GREEN}✓${NC} tab count $actual >= $min"+ ((ASSERTIONS_PASSED++)) || true+ else+ echo -e " ${RED}✗${NC} tab count: expected >= $min, got $actual"+ ((ASSERTIONS_FAILED++)) || true+ fi+}++assert_tab_closed() {+ local before="$1"+ local actual+ actual=$(get_tab_count)++ if [ "$actual" -lt "$before" ]; then+ echo -e " ${GREEN}✓${NC} tab closed (before: $before, after: $actual)"+ ((ASSERTIONS_PASSED++)) || true+ else+ echo -e " ${RED}✗${NC} tab not closed (before: $before, after: $actual)"+ ((ASSERTIONS_FAILED++)) || true+ fi+}++assert_eval_poll() {+ local expr="$1"+ local expected="$2"+ local desc="${3:-eval poll}"+ local attempts="${4:-5}"+ local delay="${5:-0.4}"+ local tab_id="${6:-}"++ local ok=false+ local actual=""+ for i in $(seq 1 "$attempts"); do+ local json_body+ if [ -n "$tab_id" ]; then+ json_body=$(jq -n --arg expr "$expr" --arg tabId "$tab_id" '{"expression": $expr, "tabId": $tabId}')+ else+ json_body=$(jq -n --arg expr "$expr" '{"expression": $expr}')+ fi+ pt_post /evaluate "$json_body"+ actual=$(echo "$RESULT" | jq -r '.result // empty' 2>/dev/null)+ if [ "$actual" = "$expected" ]; then+ ok=true+ break+ fi+ sleep "$delay"+ done++ if [ "$ok" = "true" ]; then+ echo -e " ${GREEN}✓${NC} $desc"+ ((ASSERTIONS_PASSED++)) || true+ return 0+ fi++ echo -e " ${RED}✗${NC} $desc (got: $actual, expected: $expected)"+ ((ASSERTIONS_FAILED++)) || true+ return 1+}diff --git a/tests/e2e/scenarios/helpers/snapshot.sh b/tests/e2e/helpers/api-snapshot.shsimilarity index 97%rename from tests/e2e/scenarios/helpers/snapshot.shrename to tests/e2e/helpers/api-snapshot.shindex 2e49e606..fa2cc297 100644--- a/tests/e2e/scenarios/helpers/snapshot.sh+++ b/tests/e2e/helpers/api-snapshot.sh@@ -1,5 +1,5 @@#!/bin/bash-# helpers/snapshot.sh — Snapshot ref helpers+# api-snapshot.sh — Snapshot ref helpers## Provides functions to find and interact with elements from snapshot results.# All functions operate on $RESULT (set by pt_get /snapshot).diff --git a/tests/e2e/helpers/api.sh b/tests/e2e/helpers/api.shnew file mode 100644index 00000000..60e0c9c8--- /dev/null+++ b/tests/e2e/helpers/api.sh@@ -0,0 +1,13 @@+#!/bin/bash+# Common API/curl E2E entrypoint.++HELPERS_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"+source "${HELPERS_DIR}/base.sh"++E2E_SUMMARY_TITLE="E2E Test Summary"+E2E_SUMMARY_FILE="summary.txt"+E2E_GENERATE_MARKDOWN_REPORT=1+E2E_REF_JSON_VAR="RESULT"++source "${HELPERS_DIR}/api-assertions.sh"+source "${HELPERS_DIR}/api-http.sh"diff --git a/tests/e2e/helpers/base.sh b/tests/e2e/helpers/base.shnew file mode 100644index 00000000..1b3754ba--- /dev/null+++ b/tests/e2e/helpers/base.sh@@ -0,0 +1,221 @@+#!/bin/bash+# Shared utilities for E2E bash suites.++set -uo pipefail++RED='\033[0;31m'+ERROR="${RED}"+GREEN='\033[0;32m'+YELLOW='\033[0;33m'+BLUE='\033[0;34m'+MUTED='\033[0;90m'+BOLD='\033[1m'+NC='\033[0m'++E2E_SERVER="${E2E_SERVER:-http://localhost:9999}"+E2E_SECURE_SERVER="${E2E_SECURE_SERVER:-http://localhost:9998}"+E2E_MEDIUM_SERVER="${E2E_MEDIUM_SERVER:-}"+E2E_FULL_SERVER="${E2E_FULL_SERVER:-}"+E2E_BRIDGE_URL="${E2E_BRIDGE_URL:-}"+E2E_BRIDGE_TOKEN="${E2E_BRIDGE_TOKEN:-}"+FIXTURES_URL="${FIXTURES_URL:-http://localhost:8080}"+RESULTS_DIR="${RESULTS_DIR:-/results}"++CURRENT_TEST="${CURRENT_TEST:-}"+TESTS_PASSED="${TESTS_PASSED:-0}"+TESTS_FAILED="${TESTS_FAILED:-0}"+ASSERTIONS_PASSED="${ASSERTIONS_PASSED:-0}"+ASSERTIONS_FAILED="${ASSERTIONS_FAILED:-0}"+TEST_START_TIME="${TEST_START_TIME:-0}"+TEST_START_NS="${TEST_START_NS:-0}"+if [ -z "${TEST_RESULTS_INIT:-}" ]; then+ TEST_RESULTS=()+ TEST_RESULTS_INIT=1+fi++get_time_ms() {+ if [ -f /proc/uptime ]; then+ awk '{printf "%.0f", $1 * 1000}' /proc/uptime+ elif command -v gdate &>/dev/null; then+ gdate +%s%3N+ elif command -v perl &>/dev/null; then+ perl -MTime::HiRes=time -e 'printf "%.0f", time * 1000'+ else+ echo $(($(date +%s) * 1000))+ fi+}++wait_for_instance_ready() {+ local base_url="$1"+ local timeout_sec="${2:-60}"+ local token="${3:-}"+ local started_at+ started_at=$(date +%s)++ while true; do+ local now+ now=$(date +%s)+ if [ $((now - started_at)) -ge "$timeout_sec" ]; then+ echo -e " ${RED}✗${NC} instance at ${base_url} did not reach running within ${timeout_sec}s"+ return 1+ fi++ local health_json+ if [ -n "$token" ]; then+ health_json=$(curl -sf -H "Authorization: Bearer ${token}" "${base_url}/health" 2>/dev/null || true)+ else+ health_json=$(curl -sf "${base_url}/health" 2>/dev/null || true)+ fi+ if [ -n "$health_json" ]; then+ local inst_status+ inst_status=$(echo "$health_json" | jq -r '.defaultInstance.status // .status // empty' 2>/dev/null || true)+ if [ "$inst_status" = "running" ] || [ "$inst_status" = "ok" ]; then+ echo -e " ${GREEN}✓${NC} instance ready at ${base_url}"+ return 0+ fi+ fi++ sleep 1+ done+}++start_test() {+ CURRENT_TEST="$1"+ TEST_START_TIME=$(get_time_ms)+ echo -e "${BLUE}▶ ${CURRENT_TEST}${NC}"+}++end_test() {+ local end_time+ end_time=$(get_time_ms)+ local duration=$((end_time - TEST_START_TIME))++ if [ "$ASSERTIONS_FAILED" -eq 0 ]; then+ echo -e "${GREEN}✓ ${CURRENT_TEST} passed${NC} ${MUTED}(${duration}ms)${NC}\n"+ TEST_RESULTS+=("✅ ${CURRENT_TEST}|${duration}ms|passed")+ ((TESTS_PASSED++)) || true+ else+ echo -e "${RED}✗ ${CURRENT_TEST} failed${NC} ${MUTED}(${duration}ms)${NC}\n"+ TEST_RESULTS+=("❌ ${CURRENT_TEST}|${duration}ms|failed")+ ((TESTS_FAILED++)) || true+ fi+ ASSERTIONS_PASSED=0+ ASSERTIONS_FAILED=0+}++_e2e_default_ref_json() {+ local ref_var="${E2E_REF_JSON_VAR:-RESULT}"+ printf '%s' "${!ref_var-}"+}++find_ref_by_role() {+ local role="$1"+ local json="${2:-$(_e2e_default_ref_json)}"+ echo "$json" | jq -r "[.nodes[] | select(.role == \"$role\") | .ref] | first // empty"+}++find_ref_by_name() {+ local name="$1"+ local json="${2:-$(_e2e_default_ref_json)}"+ echo "$json" | jq -r "[.nodes[] | select(.name == \"$name\") | .ref] | first // empty"+}++assert_ref_found() {+ local ref="$1"+ local desc="${2:-ref}"+ if [ -n "$ref" ] && [ "$ref" != "null" ]; then+ echo -e " ${GREEN}✓${NC} found $desc: $ref"+ ((ASSERTIONS_PASSED++)) || true+ return 0+ fi++ echo -e " ${YELLOW}⚠${NC} could not find $desc, skipping"+ ((ASSERTIONS_PASSED++)) || true+ return 1+}++assert_json_jq() {+ local json="$1"+ local expr="$2"+ local success_desc="$3"+ local fail_desc="${4:-$3}"+ shift 4+ local -a jq_args=("$@")++ if echo "$json" | jq -e "${jq_args[@]}" "$expr" >/dev/null 2>&1; then+ echo -e " ${GREEN}✓${NC} $success_desc"+ ((ASSERTIONS_PASSED++)) || true+ else+ echo -e " ${RED}✗${NC} $fail_desc"+ ((ASSERTIONS_FAILED++)) || true+ fi+}++assert_ref_json_jq() {+ local expr="$1"+ local success_desc="$2"+ local fail_desc="${3:-$2}"+ shift 3+ assert_json_jq "$(_e2e_default_ref_json)" "$expr" "$success_desc" "$fail_desc" "$@"+}++print_summary() {+ local total=$((TESTS_PASSED + TESTS_FAILED))+ local total_time=0+ local title="${E2E_SUMMARY_TITLE:-E2E Test Summary}"+ local summary_file="${E2E_SUMMARY_FILE:-summary.txt}"+ local report_file="${E2E_REPORT_FILE:-report.md}"++ local name_width=40+ for result in "${TEST_RESULTS[@]}"; do+ IFS='|' read -r name _ _ <<< "$result"+ local len=${#name}+ [ "$len" -gt "$name_width" ] && name_width=$len+ done+ ((name_width += 2)) || true+ local line_width=$((name_width + 24))+ local separator+ separator=$(printf '─%.0s' $(seq 1 $line_width))++ echo ""+ echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"+ echo -e "${BLUE}${title}${NC}"+ echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"+ echo ""+ printf " %-${name_width}s %10s %10s\n" "Test" "Duration" "Status"+ echo " ${separator}"++ for result in "${TEST_RESULTS[@]}"; do+ IFS='|' read -r name duration status <<< "$result"+ local time_num=${duration%ms}+ ((total_time += time_num)) || true+ if [ "$status" = "passed" ]; then+ printf " %-${name_width}s %10s ${GREEN}%10s${NC}\n" "$name" "$duration" "✓"+ else+ printf " %-${name_width}s %10s ${RED}%10s${NC}\n" "$name" "$duration" "✗"+ fi+ done++ echo " ${separator}"+ printf " %-${name_width}s %10s\n" "Total" "${total_time}ms"+ echo ""+ echo -e " ${GREEN}Passed:${NC} ${TESTS_PASSED}/${total}"+ echo -e " ${RED}Failed:${NC} ${TESTS_FAILED}/${total}"+ echo ""+ echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"++ if [ -d "${RESULTS_DIR:-}" ]; then+ echo "passed=$TESTS_PASSED" > "${RESULTS_DIR}/${summary_file}"+ echo "failed=$TESTS_FAILED" >> "${RESULTS_DIR}/${summary_file}"+ echo "total_time=${total_time}ms" >> "${RESULTS_DIR}/${summary_file}"+ echo "timestamp=$(date -u +%Y-%m-%dT%H:%M:%SZ)" >> "${RESULTS_DIR}/${summary_file}"++ if [ "${E2E_GENERATE_MARKDOWN_REPORT:-0}" = "1" ] && declare -F generate_markdown_report >/dev/null 2>&1; then+ generate_markdown_report > "${RESULTS_DIR}/${report_file}"+ fi+ fi++ if [ "$TESTS_FAILED" -gt 0 ]; then+ exit 1+ fi+}diff --git a/tests/e2e/helpers/cli.sh b/tests/e2e/helpers/cli.shnew file mode 100644index 00000000..abcad9f8--- /dev/null+++ b/tests/e2e/helpers/cli.sh@@ -0,0 +1,237 @@+#!/bin/bash+# Common CLI E2E entrypoint.++HELPERS_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"+source "${HELPERS_DIR}/base.sh"++E2E_SUMMARY_TITLE="CLI E2E Test Summary"+E2E_SUMMARY_FILE="summary.txt"+E2E_REF_JSON_VAR="PT_OUT"++pt() {+ local tmpout+ tmpout=$(mktemp)+ local tmperr+ tmperr=$(mktemp)++ echo -e " ${BLUE}→ pinchtab --server $E2E_SERVER $@${NC}"++ set +e+ pinchtab --server "$E2E_SERVER" "$@" > "$tmpout" 2> "$tmperr"+ PT_CODE=$?+ set -e++ PT_OUT=$(cat "$tmpout")+ PT_ERR=$(cat "$tmperr")+ rm -f "$tmpout" "$tmperr"++ if [ -n "$PT_OUT" ]; then+ echo "$PT_OUT" | head -5+ fi+}++pt_ok() {+ pt "$@"+ if [ "$PT_CODE" -eq 0 ]; then+ echo -e " ${GREEN}✓${NC} exit 0"+ ((ASSERTIONS_PASSED++)) || true+ else+ echo -e " ${RED}✗${NC} expected exit 0, got $PT_CODE"+ echo -e " ${RED}stderr: $PT_ERR${NC}"+ ((ASSERTIONS_FAILED++)) || true+ fi+}++pt_fail() {+ pt "$@"+ if [ "$PT_CODE" -ne 0 ]; then+ echo -e " ${GREEN}✓${NC} exit $PT_CODE (expected failure)"+ ((ASSERTIONS_PASSED++)) || true+ else+ echo -e " ${RED}✗${NC} expected non-zero exit, got 0"+ ((ASSERTIONS_FAILED++)) || true+ fi+}++assert_output_contains() {+ local expected="$1"+ local desc="${2:-output contains '$expected'}"++ if echo "$PT_OUT" | grep -q "$expected"; then+ echo -e " ${GREEN}✓${NC} $desc"+ ((ASSERTIONS_PASSED++)) || true+ else+ echo -e " ${RED}✗${NC} $desc"+ echo -e " ${RED} output was: $PT_OUT${NC}"+ ((ASSERTIONS_FAILED++)) || true+ fi+}++assert_exit_code() {+ local expected="$1"+ local desc="${2:-exit code is $expected}"+ if [ "$PT_CODE" -eq "$expected" ]; then+ echo -e " ${GREEN}✓${NC} $desc (exit $PT_CODE)"+ ((ASSERTIONS_PASSED++)) || true+ else+ echo -e " ${RED}✗${NC} $desc (expected $expected, got $PT_CODE)"+ ((ASSERTIONS_FAILED++)) || true+ fi+}++assert_exit_code_lte() {+ local max="$1"+ local desc="${2:-exit code <= $max}"+ if [ "$PT_CODE" -le "$max" ]; then+ echo -e " ${GREEN}✓${NC} $desc (exit $PT_CODE)"+ ((ASSERTIONS_PASSED++)) || true+ else+ echo -e " ${RED}✗${NC} $desc (got $PT_CODE)"+ ((ASSERTIONS_FAILED++)) || true+ fi+}++assert_json_field_contains() {+ local path="$1"+ local needle="$2"+ local desc="${3:-$path contains '$needle'}"+ local actual+ actual=$(echo "$PT_OUT" | jq -r "$path" 2>/dev/null)+ if [[ "$actual" == *"$needle"* ]]; then+ echo -e " ${GREEN}✓${NC} $desc"+ ((ASSERTIONS_PASSED++)) || true+ else+ echo -e " ${RED}✗${NC} $desc (got '$actual')"+ ((ASSERTIONS_FAILED++)) || true+ fi+}++assert_file_exists() {+ local path="$1"+ local desc="${2:-file exists: $path}"+ if [ -f "$path" ]; then+ echo -e " ${GREEN}✓${NC} $desc"+ ((ASSERTIONS_PASSED++)) || true+ else+ echo -e " ${RED}✗${NC} $desc (not found)"+ ((ASSERTIONS_FAILED++)) || true+ fi+}++config_version_of() {+ local path="$1"+ jq -r '.configVersion // "none"' "$path"+}++assert_config_version() {+ local path="$1"+ local expected="$2"+ local success_desc="${3:-configVersion is $expected}"+ local actual+ actual=$(config_version_of "$path")++ if [ "$actual" = "$expected" ]; then+ echo -e " ${GREEN}✓${NC} $success_desc"+ ((ASSERTIONS_PASSED++)) || true+ else+ echo -e " ${RED}✗${NC} expected configVersion $expected, got $actual"+ ((ASSERTIONS_FAILED++)) || true+ fi+}++assert_config_version_one_of() {+ local path="$1"+ shift+ local actual+ actual=$(config_version_of "$path")++ while [ "$#" -gt 1 ]; do+ local expected="$1"+ local success_desc="$2"+ shift 2+ if [ "$actual" = "$expected" ]; then+ echo -e " ${GREEN}✓${NC} $success_desc"+ ((ASSERTIONS_PASSED++)) || true+ return 0+ fi+ done++ echo -e " ${RED}✗${NC} unexpected configVersion: $actual"+ ((ASSERTIONS_FAILED++)) || true+ return 1+}++assert_output_not_contains() {+ local forbidden="$1"+ local desc="${2:-output does not contain '$forbidden'}"++ if echo "$PT_OUT" | grep -q "$forbidden"; then+ echo -e " ${RED}✗${NC} $desc"+ echo -e " ${RED} output was: $PT_OUT${NC}"+ ((ASSERTIONS_FAILED++)) || true+ else+ echo -e " ${GREEN}✓${NC} $desc"+ ((ASSERTIONS_PASSED++)) || true+ fi+}++assert_output_json() {+ local desc="${1:-output is valid JSON}"++ if echo "$PT_OUT" | jq . >/dev/null 2>&1; then+ echo -e " ${GREEN}✓${NC} $desc"+ ((ASSERTIONS_PASSED++)) || true+ else+ echo -e " ${RED}✗${NC} $desc"+ echo -e " ${RED} output was: $PT_OUT${NC}"+ ((ASSERTIONS_FAILED++)) || true+ fi+}++assert_json_field() {+ local path="$1"+ local expected="$2"+ local desc="${3:-$path equals '$expected'}"+ local actual+ actual=$(echo "$PT_OUT" | jq -r "$path" 2>/dev/null)++ if [ "$actual" = "$expected" ]; then+ echo -e " ${GREEN}✓${NC} $desc"+ ((ASSERTIONS_PASSED++)) || true+ else+ echo -e " ${RED}✗${NC} $desc (got '$actual')"+ ((ASSERTIONS_FAILED++)) || true+ fi+}++assert_output_jq() {+ local expr="$1"+ local success_desc="$2"+ local fail_desc="${3:-$2}"+ shift 3+ assert_ref_json_jq "$expr" "$success_desc" "$fail_desc" "$@"+}++assert_output_has_tab_event() {+ local tab_id="$1"+ local path="$2"+ local success_desc="$3"+ local fail_desc="$4"+ assert_output_jq \+ '.events[] | select(.tabId == $tab and .path == $path)' \+ "$success_desc" \+ "$fail_desc" \+ --arg tab "$tab_id" \+ --arg path "$path"+}++assert_output_all_events_for_tab() {+ local tab_id="$1"+ local success_desc="$2"+ local fail_desc="$3"+ assert_output_jq \+ 'all(.events[]?; .tabId == $tab)' \+ "$success_desc" \+ "$fail_desc" \+ --arg tab "$tab_id"+}diff --git a/tests/e2e/run.sh b/tests/e2e/run.shnew file mode 100644index 00000000..aeaf17e6--- /dev/null+++ b/tests/e2e/run.sh@@ -0,0 +1,188 @@+#!/bin/bash+# run.sh - Run grouped E2E scenarios for a suite directory.++set -uo pipefail++ROOT_DIR="$(cd "$(dirname "$0")" && pwd)"+SUITE="${1:-api}"+shift || true++case "$SUITE" in+ api|scenarios-api|scenarios)+ source "${ROOT_DIR}/helpers/api.sh"+ GROUP_DIR="${ROOT_DIR}/scenarios-api"+ SUITE_KIND="api"+ RUN_ALL=false+ SUITE_TITLE_BASIC="PinchTab E2E API Fast Suite"+ SUITE_TITLE_ALL="PinchTab E2E Test Suite"+ SUMMARY_FILE_BASIC="summary-api-fast.txt"+ SUMMARY_FILE_ALL="summary-api-full.txt"+ REPORT_FILE_BASIC="report-api-fast.md"+ REPORT_FILE_ALL="report-api-full.md"+ PROGRESS_FILE_BASIC="progress-api-fast.log"+ PROGRESS_FILE_ALL="progress-api-full.log"+ ;;+ cli|scenarios-cli)+ source "${ROOT_DIR}/helpers/cli.sh"+ GROUP_DIR="${ROOT_DIR}/scenarios-cli"+ SUITE_KIND="cli"+ RUN_ALL=false+ SUITE_TITLE_BASIC=" PinchTab CLI Fast E2E Suite"+ SUITE_TITLE_ALL=" PinchTab CLI E2E Tests"+ SUMMARY_FILE_BASIC="summary-cli-fast.txt"+ SUMMARY_FILE_ALL="summary-cli-full.txt"+ REPORT_FILE_BASIC="report-cli-fast.md"+ REPORT_FILE_ALL="report-cli-full.md"+ PROGRESS_FILE_BASIC="progress-cli-fast.log"+ PROGRESS_FILE_ALL="progress-cli-full.log"+ ;;+ *)+ echo "unknown suite: $SUITE" >&2+ echo "usage: /bin/bash tests/e2e/run.sh api|cli [all=true|all=false]" >&2+ exit 1+ ;;+esac++for arg in "$@"; do+ case "$arg" in+ all=true)+ RUN_ALL=true+ ;;+ all=false)+ RUN_ALL=false+ ;;+ *)+ echo "unknown argument: $arg" >&2+ echo "usage: /bin/bash tests/e2e/run.sh api|cli [all=true|all=false]" >&2+ exit 1+ ;;+ esac+done++SCENARIO_GROUPS=()+for basic_path in "${GROUP_DIR}"/*-basic.sh; do+ if [ ! -f "${basic_path}" ]; then+ echo "no basic group entries found in: ${GROUP_DIR}" >&2+ exit 1+ fi++ feature=$(basename "${basic_path}" -basic.sh)+ basic_script="${feature}-basic.sh"+ SCENARIO_GROUPS+=("${basic_script}")++ if [ "$RUN_ALL" = "true" ]; then+ full_script="${feature}-full.sh"+ full_path="${GROUP_DIR}/${full_script}"+ if [ -f "${full_path}" ]; then+ SCENARIO_GROUPS+=("${full_script}")+ fi+ fi+done++if [ "$RUN_ALL" = "true" ]; then+ for full_path in "${GROUP_DIR}"/*-full.sh; do+ if [ ! -f "${full_path}" ]; then+ echo "no full group entries found in: ${GROUP_DIR}" >&2+ exit 1+ fi++ full_script=$(basename "${full_path}")+ case " ${SCENARIO_GROUPS[*]} " in+ *" ${full_script} "*) ;;+ *) SCENARIO_GROUPS+=("${full_script}") ;;+ esac+ done+fi++if [ "$RUN_ALL" = "true" ]; then+ SUITE_TITLE="$SUITE_TITLE_ALL"+ SUMMARY_FILE="$SUMMARY_FILE_ALL"+ REPORT_FILE="$REPORT_FILE_ALL"+ PROGRESS_FILE="$PROGRESS_FILE_ALL"+else+ SUITE_TITLE="$SUITE_TITLE_BASIC"+ SUMMARY_FILE="$SUMMARY_FILE_BASIC"+ REPORT_FILE="$REPORT_FILE_BASIC"+ PROGRESS_FILE="$PROGRESS_FILE_BASIC"+fi++export E2E_SUMMARY_TITLE="$SUITE_TITLE"+export E2E_SUMMARY_FILE="$SUMMARY_FILE"+export E2E_REPORT_FILE="$REPORT_FILE"+export E2E_PROGRESS_FILE="$PROGRESS_FILE"+export E2E_GENERATE_MARKDOWN_REPORT=1++if [ "$SUITE_KIND" = "api" ]; then+ echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"+ echo -e "${BLUE}${SUITE_TITLE}${NC}"+ echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"+ echo "E2E_SERVER: ${E2E_SERVER}"+ echo "FIXTURES_URL: ${FIXTURES_URL}"+ echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"+ echo ""++ echo "Waiting for instances to become ready..."+ wait_for_instance_ready "${E2E_SERVER}"+ if [ "$RUN_ALL" = "true" ]; then+ wait_for_instance_ready "${E2E_SECURE_SERVER}"+ if [ -n "${E2E_MEDIUM_SERVER:-}" ]; then+ wait_for_instance_ready "${E2E_MEDIUM_SERVER}"+ fi+ if [ -n "${E2E_FULL_SERVER:-}" ]; then+ wait_for_instance_ready "${E2E_FULL_SERVER}"+ fi+ if [ -n "${E2E_LITE_SERVER:-}" ]; then+ wait_for_instance_ready "${E2E_LITE_SERVER}"+ fi+ if [ -n "${E2E_BRIDGE_URL:-}" ]; then+ wait_for_instance_ready "${E2E_BRIDGE_URL}" 60 "${E2E_BRIDGE_TOKEN:-}"+ fi+ fi+ echo ""+else+ echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"+ echo "${SUITE_TITLE}"+ echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"+ echo ""+ echo " Server: $E2E_SERVER"+ echo " Fixtures: $FIXTURES_URL"+ echo ""++ wait_for_instance_ready "$E2E_SERVER"++ if ! command -v pinchtab &> /dev/null; then+ echo "ERROR: pinchtab CLI not found in PATH"+ exit 1+ fi++ echo ""+ if [ "$RUN_ALL" = "true" ]; then+ echo "Running CLI tests..."+ else+ echo "Running CLI fast tests..."+ fi+ echo ""+fi++for script_name in "${SCENARIO_GROUPS[@]}"; do+ script_path="${GROUP_DIR}/${script_name}"+ if [ ! -f "${script_path}" ]; then+ echo "group entry not found: ${script_path}" >&2+ exit 1+ fi++ if [ -d "${RESULTS_DIR:-}" ] && [ -n "${E2E_PROGRESS_FILE:-}" ]; then+ printf '%s RUNNING %s\n' "$(date -u +%Y-%m-%dT%H:%M:%SZ)" "${script_name}" >> "${RESULTS_DIR}/${E2E_PROGRESS_FILE}"+ fi++ echo -e "${YELLOW}Running: ${script_name}${NC}"+ echo ""+ source "${script_path}"+ echo ""++ if [ -d "${RESULTS_DIR:-}" ] && [ -n "${E2E_PROGRESS_FILE:-}" ]; then+ printf '%s DONE %s\n' "$(date -u +%Y-%m-%dT%H:%M:%SZ)" "${script_name}" >> "${RESULTS_DIR}/${E2E_PROGRESS_FILE}"+ fi+done++print_summarydiff --git a/tests/e2e/runner/Dockerfile b/tests/e2e/runner-api/Dockerfilesimilarity index 53%rename from tests/e2e/runner/Dockerfilerename to tests/e2e/runner-api/Dockerfileindex dac0c7bd..34a38a15 100644--- a/tests/e2e/runner/Dockerfile+++ b/tests/e2e/runner-api/Dockerfile@@ -5,6 +5,6 @@ RUN apk add --no-cache \curl \jq-WORKDIR /scenarios+WORKDIR /e2e-ENTRYPOINT ["/bin/bash"]+CMD ["/bin/bash", "/e2e/run.sh", "api", "all=true"]diff --git a/tests/e2e/runner-cli/Dockerfile b/tests/e2e/runner-cli/Dockerfileindex aa7a374f..fcb37bda 100644--- a/tests/e2e/runner-cli/Dockerfile+++ b/tests/e2e/runner-cli/Dockerfile@@ -17,7 +17,7 @@ RUN chmod +x /usr/local/bin/pinchtab# Create results directoryRUN mkdir -p /results-WORKDIR /scenarios+WORKDIR /e2e# Default command runs all tests-CMD ["/scenarios/run-all.sh"]+CMD ["/bin/bash", "/e2e/run.sh", "cli", "all=true"]diff --git a/tests/e2e/scenarios/05-actions.sh b/tests/e2e/scenarios-api/actions-basic.shold mode 100755new mode 100644similarity index 97%rename from tests/e2e/scenarios/05-actions.shrename to tests/e2e/scenarios-api/actions-basic.shindex c0c623c4..127bdd30--- a/tests/e2e/scenarios/05-actions.sh+++ b/tests/e2e/scenarios-api/actions-basic.sh@@ -1,7 +1,8 @@#!/bin/bash-# 05-actions.sh — Browser actions (click, type, press)+# actions-basic.sh — API happy-path action scenarios.-source "$(dirname "$0")/common.sh"+GROUP_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"+source "${GROUP_DIR}/../helpers/api.sh"# ─────────────────────────────────────────────────────────────────start_test "pinchtab click <button>"diff --git a/tests/e2e/scenarios-api/actions-full.sh b/tests/e2e/scenarios-api/actions-full.shnew file mode 100644index 00000000..3808fdc8--- /dev/null+++ b/tests/e2e/scenarios-api/actions-full.sh@@ -0,0 +1,248 @@+#!/bin/bash+# actions-full.sh — API advanced action scenarios.++GROUP_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"+source "${GROUP_DIR}/../helpers/api.sh"+source "${GROUP_DIR}/../helpers/api-snapshot.sh"+source "${GROUP_DIR}/../helpers/api-actions.sh"++# ─────────────────────────────────────────────────────────────────+start_test "HTTP: dblclick by ref"++pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/buttons.html\"}"+sleep 1++pt_get /snapshot+REF=$(echo "$RESULT" | jq -r '[.nodes[] | select(.name == "Increment")][0].ref // empty')++pt_post /action -d "{\"kind\":\"dblclick\",\"ref\":\"$REF\"}"+assert_ok "dblclick by ref"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "HTTP: dblclick by CSS selector"++pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/buttons.html\"}"+sleep 1++pt_post /action -d "{\"kind\":\"dblclick\",\"selector\":\"#increment\"}"+assert_ok "dblclick by selector"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "HTTP: dblclick by coordinates"++pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/buttons.html\"}"+sleep 1++pt_post /action -d "{\"kind\":\"dblclick\",\"x\":100,\"y\":100,\"hasXY\":true}"+assert_ok "dblclick by coordinates"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "CLI: pinchtab dblclick <ref>"++pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/buttons.html\"}"+sleep 1++pt_get /snapshot+REF=$(echo "$RESULT" | jq -r '[.nodes[] | select(.name == "Increment")][0].ref // empty')++run_cli dblclick "$REF"+assert_ok "CLI dblclick by ref"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "CLI: pinchtab dblclick --css <selector>"++pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/buttons.html\"}"+sleep 1++run_cli dblclick --css "#increment"+assert_ok "CLI dblclick by selector"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "CLI: pinchtab dblclick --tab <id>"++pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/buttons.html\",\"newTab\":true}"+assert_ok "navigate for new tab"+TAB_ID=$(echo "$RESULT" | jq -r '.tabId')++pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/buttons.html\"}"+sleep 1++pt_get /snapshot+REF=$(echo "$RESULT" | jq -r '[.nodes[] | select(.name == "Increment")][0].ref // empty')++run_cli dblclick "$REF" --tab "$TAB_ID"+assert_ok "CLI dblclick with --tab flag"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "HTTP: dblclick validation - missing ref/selector/coordinates"++pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/buttons.html\"}"++pt_post /action -d "{\"kind\":\"dblclick\"}"+assert_error "dblclick without parameters should fail"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "humanClick: click input by ref"++navigate_fixture "human-type.html"+fresh_snapshot++require_ref "textbox" "Email" EMAIL_REF && \+ action_human_click "$EMAIL_REF"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "humanType: type into input by ref"++fresh_snapshot+require_ref "textbox" "Email" EMAIL_REF && {+ action_human_type "$EMAIL_REF" "[email protected]"++ fresh_snapshot+ assert_value "textbox" "Email" "[email protected]"+}++end_test++# ─────────────────────────────────────────────────────────────────+start_test "humanType: type into second input by ref"++fresh_snapshot+require_ref "textbox" "Name" NAME_REF && {+ action_human_type "$NAME_REF" "John Doe"++ fresh_snapshot+ assert_value "textbox" "Name" "John Doe"+}++end_test++# ─────────────────────────────────────────────────────────────────+start_test "humanType: type with CSS selector"++action_human_type_selector "#name" " Jr."++end_test++# Regression test for GitHub issue #236: press action was typing key names+# as literal text instead of dispatching keyboard events.++# Use permissive instance (needs evaluate enabled)+E2E_SERVER="http://pinchtab:9999"++# ─────────────────────────────────────────────────────────────────+start_test "press Enter: does not type 'Enter' as text"++pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/form.html\"}"+sleep 1++pt_post /action -d '{"kind":"type","selector":"#username","text":"testuser"}'+assert_ok "type into username"++pt_post /action -d '{"kind":"press","key":"Enter"}'+assert_ok "press Enter"++assert_input_not_contains "#username" "Enter" "Enter key should dispatch event, not type text (bug #236)"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "press Tab: does not type 'Tab' as text"++pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/form.html\"}"+sleep 1++pt_post /action -d '{"kind":"click","selector":"#username"}'+pt_post /action -d '{"kind":"type","selector":"#username","text":"hello"}'+assert_ok "type hello"++pt_post /action -d '{"kind":"press","key":"Tab"}'+assert_ok "press Tab"++assert_input_not_contains "#username" "Tab" "Tab key should dispatch event, not type text (bug #236)"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "press Escape: does not type 'Escape' as text"++pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/form.html\"}"+sleep 1++pt_post /action -d '{"kind":"type","selector":"#username","text":"world"}'+assert_ok "type world"++pt_post /action -d '{"kind":"press","key":"Escape"}'+assert_ok "press Escape"++assert_input_not_contains "#username" "Escape" "Escape key should dispatch event, not type text (bug #236)"++end_test++# Migrated from: tests/integration/actions_test.go (error cases)++pt_post /navigate "{\"url\":\"${FIXTURES_URL}/buttons.html\"}"+assert_ok "navigate"++# ─────────────────────────────────────────────────────────────────+start_test "action: unknown kind → error"++pt_post /action '{"kind":"explode","ref":"e0"}'+assert_not_ok "rejects unknown kind"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "action: missing kind → error"++pt_post /action '{"ref":"e0"}'+assert_http_status "400" "rejects missing kind"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "action: ref not found → error"++pt_post /action '{"kind":"click","ref":"e999"}'+assert_not_ok "rejects missing ref"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "action: batch operations"++pt_post /actions '{"actions":[{"kind":"click","ref":"e4"},{"kind":"click","ref":"e5"}]}'+assert_ok "batch actions"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "action: empty batch → error"++pt_post /actions '{"actions":[]}'+assert_not_ok "rejects empty batch"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "action: nonexistent tabId → error"++pt_post /action '{"kind":"click","ref":"e0","tabId":"nonexistent_xyz_999"}'+assert_not_ok "rejects bad tab"++end_testdiff --git a/tests/e2e/scenarios-api/browser-basic.sh b/tests/e2e/scenarios-api/browser-basic.shnew file mode 100644index 00000000..5cddc92a--- /dev/null+++ b/tests/e2e/scenarios-api/browser-basic.sh@@ -0,0 +1,628 @@+#!/bin/bash+# browser-basic.sh — API happy-path browser scenarios.++GROUP_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"+source "${GROUP_DIR}/../helpers/api.sh"++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab health"++pt_get /health+assert_json_eq "$RESULT" '.status' 'ok'++end_test++# ─────────────────────────────────────────────────────────────────+start_test "fixtures server"++assert_fixtures_accessible++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab nav <url>"++pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/\"}"+assert_json_contains "$RESULT" '.title' 'E2E Test'+assert_json_contains "$RESULT" '.url' 'fixtures'++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab nav (multiple pages)"++pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/form.html\"}"+assert_json_contains "$RESULT" '.title' 'Form'++pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/table.html\"}"+assert_json_contains "$RESULT" '.title' 'Table'++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab tabs"++assert_tab_count_gte 2++end_test++# ─────────────────────────────────────────────────────────────────+start_test "navigate: blockImages flag"++pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/index.html\",\"blockImages\":true}"+assert_ok "navigate with blockImages"+assert_json_contains "$RESULT" '.url' 'index.html'++end_test++# ─────────────────────────────────────────────────────────────────+start_test "navigate: blockAds flag"++pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/index.html\",\"blockAds\":true}"+assert_ok "navigate with blockAds"+assert_json_contains "$RESULT" '.url' 'index.html'++end_test++# ─────────────────────────────────────────────────────────────────+start_test "navigate: timeout parameter"++pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/index.html\",\"timeout\":30000}"+assert_ok "navigate with custom timeout"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "navigate: waitSelector parameter"++pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/buttons.html\",\"waitSelector\":\"button\"}"+assert_ok "navigate with waitSelector"+assert_json_contains "$RESULT" '.title' 'Button'++end_test++# ─────────────────────────────────────────────────────────────────+start_test "navigate: missing URL → error"++pt_post /navigate '{}'+assert_not_ok "rejects missing URL"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "navigate: bad JSON → 400"++pt_post_raw /navigate '{broken'+assert_not_ok "rejects bad JSON"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab snap"++pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/\"}"++pt_get /snapshot+assert_index_page "$RESULT"+assert_json_length_gte "$RESULT" '.nodes' 1++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab snap (buttons.html)"++pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/buttons.html\"}"+sleep 1++pt_get /snapshot+assert_buttons_page "$RESULT"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab snap (form.html)"++pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/form.html\"}"+sleep 1++pt_get /snapshot+assert_form_page "$RESULT"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab text (table.html)"++pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/table.html\"}"+sleep 1++TEXT_RESULT=$(curl -s "${E2E_SERVER}/text" | jq -r '.text')+assert_table_page "$TEXT_RESULT"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "snapshot: diff mode"++pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/buttons.html\"}"+sleep 1++pt_get /snapshot+assert_ok "initial snapshot"+INITIAL_COUNT=$(echo "$RESULT" | jq '.nodes | length')++pt_get "/snapshot?diff=true"+assert_ok "diff snapshot"+DIFF_COUNT=$(echo "$RESULT" | jq '.nodes | length')++if [ "$DIFF_COUNT" -le "$INITIAL_COUNT" ]; then+ echo -e " ${GREEN}✓${NC} diff has <= nodes than full ($DIFF_COUNT <= $INITIAL_COUNT)"+ ((ASSERTIONS_PASSED++)) || true+else+ echo -e " ${RED}✗${NC} diff has more nodes than full ($DIFF_COUNT > $INITIAL_COUNT)"+ ((ASSERTIONS_FAILED++)) || true+fi++end_test++# ─────────────────────────────────────────────────────────────────+start_test "snapshot: maxTokens truncation"++pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/buttons.html\"}"+sleep 1++pt_get /snapshot+FULL_COUNT=$(echo "$RESULT" | jq '.nodes | length')++pt_get "/snapshot?maxTokens=50"+assert_ok "snapshot with maxTokens"+LIMITED_COUNT=$(echo "$RESULT" | jq '.nodes | length')++if [ "$LIMITED_COUNT" -le "$FULL_COUNT" ]; then+ echo -e " ${GREEN}✓${NC} maxTokens limited nodes ($LIMITED_COUNT <= $FULL_COUNT)"+ ((ASSERTIONS_PASSED++)) || true+else+ echo -e " ${RED}✗${NC} maxTokens did not limit ($LIMITED_COUNT > $FULL_COUNT)"+ ((ASSERTIONS_FAILED++)) || true+fi++end_test++# ─────────────────────────────────────────────────────────────────+start_test "snapshot: depth parameter"++pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/buttons.html\"}"+sleep 1++pt_get /snapshot+FULL_COUNT=$(echo "$RESULT" | jq '.nodes | length')++pt_get "/snapshot?depth=1"+assert_ok "snapshot with depth=1"+SHALLOW_COUNT=$(echo "$RESULT" | jq '.nodes | length')++if [ "$SHALLOW_COUNT" -le "$FULL_COUNT" ]; then+ echo -e " ${GREEN}✓${NC} depth=1 limited tree ($SHALLOW_COUNT <= $FULL_COUNT)"+ ((ASSERTIONS_PASSED++)) || true+else+ echo -e " ${RED}✗${NC} depth=1 did not limit ($SHALLOW_COUNT > $FULL_COUNT)"+ ((ASSERTIONS_FAILED++)) || true+fi++end_test++# ─────────────────────────────────────────────────────────────────+start_test "snapshot: format=text"++pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/index.html\"}"+pt_get "/snapshot?format=text"+assert_ok "get text format"++if echo "$RESULT" | head -c1 | grep -q '{'; then+ echo -e " ${RED}✗${NC} got JSON instead of text"+ ((ASSERTIONS_FAILED++)) || true+else+ echo -e " ${GREEN}✓${NC} format is text, not JSON"+ ((ASSERTIONS_PASSED++)) || true+fi++end_test++# ─────────────────────────────────────────────────────────────────+start_test "snapshot: nonexistent tabId → error"++pt_get "/snapshot?tabId=nonexistent_xyz_999"+assert_not_ok "rejects bad tab"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "snapshot: ref stability after action"++pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/form.html\"}"+pt_get /snapshot+REFS_BEFORE=$(echo "$RESULT" | jq '[.nodes[].ref] | sort')++pt_post /action '{"kind":"press","key":"Escape"}'+pt_get /snapshot+REFS_AFTER=$(echo "$RESULT" | jq '[.nodes[].ref] | sort')++if [ "$REFS_BEFORE" = "$REFS_AFTER" ]; then+ echo -e " ${GREEN}✓${NC} refs stable after action"+ ((ASSERTIONS_PASSED++)) || true+else+ echo -e " ${YELLOW}⚠${NC} refs changed (may be expected if DOM changed)"+ ((ASSERTIONS_PASSED++)) || true+fi++end_test++# ─────────────────────────────────────────────────────────────────+start_test "snapshot: format=yaml"++pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/index.html\"}"+pt_get "/snapshot?format=yaml"+assert_ok "get yaml format"++if echo "$RESULT" | grep -q "role:\|name:\|ref:"; then+ echo -e " ${GREEN}✓${NC} looks like YAML"+ ((ASSERTIONS_PASSED++)) || true+else+ echo -e " ${YELLOW}⚠${NC} may not be YAML format"+ ((ASSERTIONS_PASSED++)) || true+fi++end_test++# ─────────────────────────────────────────────────────────────────+start_test "snapshot: output=file"++pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/index.html\"}"+pt_get "/snapshot?output=file"+assert_ok "snapshot output=file"+assert_json_exists "$RESULT" '.path' "has file path"++end_test+# ─────────────────────────────────────────────────────────────────+start_test "snapshot: multi-tab content isolation with tabId"++pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/index.html\"}"+assert_ok "navigate to index"+TAB_A=$(echo "$RESULT" | jq -r '.tabId')++pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/form.html\"}"+assert_ok "navigate to form"+TAB_B=$(echo "$RESULT" | jq -r '.tabId')++pt_get "/snapshot?tabId=${TAB_A}"+assert_ok "snapshot tab A"+assert_json_contains "$RESULT" '.url' "index.html" "tab A has index.html URL"++pt_get "/snapshot?tabId=${TAB_B}"+assert_ok "snapshot tab B"+assert_json_contains "$RESULT" '.url' "form.html" "tab B has form.html URL"++pt_get "/text?tabId=${TAB_A}&format=text"+assert_ok "text tab A"+assert_contains "$RESULT" "test fixtures" "tab A text matches index.html"++pt_get "/text?tabId=${TAB_B}&format=text"+assert_ok "text tab B"+assert_contains "$RESULT" "Form Test" "tab B text matches form.html"++end_test++pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/find.html\"}"+sleep 1++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab find (login button)"++pt_post /find -d '{"query":"login button"}'+assert_ok "find login"+assert_result_exists ".best_ref" "has best_ref"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab find (email input)"++pt_post /find -d '{"query":"email input field"}'+assert_ok "find email"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab find (delete button)"++pt_post /find -d '{"query":"delete account button","threshold":0.2}'+assert_ok "find delete"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab find (search)"++pt_post /find -d '{"query":"search input","topK":5}'+assert_ok "find search"+assert_json_length_gte "$RESULT" ".matches" 1 "has matches"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab find --tab <id>"++pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/find.html\",\"newTab\":true}"+assert_ok "navigate for find"+TAB_ID=$(echo "$RESULT" | jq -r '.tabId')+sleep 1++pt_post "/tabs/${TAB_ID}/find" -d '{"query":"sign up link"}'+assert_ok "tab find"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab find (explain mode)"++pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/find.html\"}"+sleep 1++pt_post /find -d '{"query":"login button","explain":true}'+assert_ok "find with explain"++FIRST_EXPLAIN=$(echo "$RESULT" | jq '.matches[0].explain // empty')+if [ -n "$FIRST_EXPLAIN" ] && [ "$FIRST_EXPLAIN" != "null" ]; then+ echo -e " ${GREEN}✓${NC} explain field present in matches"+ ((ASSERTIONS_PASSED++)) || true+else+ echo -e " ${YELLOW}~${NC} explain field not in response (may need embedding model)"+ ((ASSERTIONS_PASSED++)) || true+fi++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab find (weight overrides)"++pt_post /find -d '{"query":"login button","lexicalWeight":1.0,"embeddingWeight":0.0}'+assert_ok "find with lexical-only weights"+assert_json_length_gte "$RESULT" ".matches" 1 "has matches with custom weights"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab find (low confidence → empty best_ref)"++pt_post /find -d '{"query":"xyzzy_nonexistent_element_12345","threshold":0.99}'+assert_ok "find with high threshold"++BEST_REF=$(echo "$RESULT" | jq -r '.best_ref // empty')+if [ -z "$BEST_REF" ] || [ "$BEST_REF" = "" ] || [ "$BEST_REF" = "null" ]; then+ echo -e " ${GREEN}✓${NC} best_ref empty for low-confidence query"+ ((ASSERTIONS_PASSED++)) || true+else+ echo -e " ${YELLOW}~${NC} best_ref returned: $BEST_REF (threshold may be met)"+ ((ASSERTIONS_PASSED++)) || true+fi++end_test++pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/evaluate.html\"}"+sleep 1++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab evaluate (simple expression)"++pt_post /evaluate -d '{"expression":"1 + 1"}'+assert_ok "evaluate simple"+assert_result_eq ".result" "2" "1+1=2"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab evaluate (DOM query)"++pt_post /evaluate -d '{"expression":"document.title"}'+assert_ok "evaluate DOM"+assert_result_eq ".result" "Evaluate Test Page" "got title"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab evaluate (call function)"++pt_post /evaluate -d '{"expression":"window.calculate.add(5, 3)"}'+assert_ok "evaluate function"+assert_result_eq ".result" "8" "5+3=8"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab evaluate (get object)"++pt_post /evaluate -d '{"expression":"JSON.stringify(window.testData)"}'+assert_ok "evaluate object"+assert_json_contains "$RESULT" ".result" "PinchTab" "has testData"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab evaluate (modify DOM)"++pt_post /evaluate -d '{"expression":"document.getElementById(\"counter\").textContent = \"42\"; 42"}'+assert_ok "evaluate modify DOM"++pt_post /evaluate -d '{"expression":"document.getElementById(\"counter\").textContent"}'+assert_result_eq ".result" "42" "counter=42"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab evaluate --tab <id>"++pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/evaluate.html\",\"newTab\":true}"+assert_ok "navigate for evaluate"+TAB_ID=$(echo "$RESULT" | jq -r '.tabId')+sleep 1++pt_post "/tabs/${TAB_ID}/evaluate" -d '{"expression":"1 + 2 + 3"}'+assert_ok "tab evaluate"+assert_result_eq ".result" "6" "1+2+3=6"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "evaluate: missing expression → error"++pt_post /evaluate '{}'+assert_not_ok "rejects missing expression"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "evaluate: bad JSON → 400"++pt_post_raw /evaluate '{broken'+assert_not_ok "rejects bad JSON"++end_test++start_test "text extraction: GET /text extracts readable content"++pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/index.html\"}"+pt_get /text+assert_ok "get text"++assert_contains "$RESULT" "E2E Test\|Buttons\|Search\|Customize" "text contains page content"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "text extraction: GET /tabs/{id}/text extracts per-tab content"++pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/buttons.html\"}"+TAB_ID=$(get_tab_id)++pt_get "/tabs/${TAB_ID}/text"+assert_ok "get tab text"++assert_contains "$RESULT" "Click me\|Button" "text includes button labels"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "text extraction: text differs between tabs"++pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/form.html\"}"+TAB_ID2=$(get_tab_id)++pt_get "/tabs/${TAB_ID2}/text"+FORM_TEXT="$RESULT"++assert_contains "$FORM_TEXT" "Name\|Email\|Submit\|Form" "text includes form labels"++end_test++# ─────────────────────────────────────────────────────────────────+# ─────────────────────────────────────────────────────────────────+start_test "text extraction: raw mode"++pt_post /navigate "{\"url\":\"${FIXTURES_URL}/index.html\"}"+assert_ok "navigate"++pt_get "/text?mode=raw"+assert_ok "get text raw"+assert_contains "$RESULT" "E2E Test\|Welcome\|index" "raw text has content"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "text extraction: nonexistent tab → error"++pt_get "/text?tabId=nonexistent_xyz_999"+assert_not_ok "rejects bad tab"++end_test++# ─────────────────────────────────────────────────────────────────+# ─────────────────────────────────────────────────────────────────+start_test "text extraction: maxChars truncation"++pt_post /navigate "{\"url\":\"${FIXTURES_URL}/index.html\"}"+assert_ok "navigate"++pt_get "/text?maxChars=50"+assert_ok "get text with maxChars=50"++TEXT_LEN=$(echo "$RESULT" | jq -r '.text' | wc -c)+if [ "$TEXT_LEN" -le 55 ]; then # small buffer for json encoding+ echo -e " ${GREEN}✓${NC} text truncated to ~50 chars (got $TEXT_LEN)"+ ((ASSERTIONS_PASSED++)) || true+else+ echo -e " ${RED}✗${NC} text not truncated (got $TEXT_LEN chars)"+ ((ASSERTIONS_FAILED++)) || true+fi++end_test++# ─────────────────────────────────────────────────────────────────+start_test "text extraction: format=text returns plain text"++pt_post /navigate "{\"url\":\"${FIXTURES_URL}/index.html\"}"+assert_ok "navigate"++# format=text should return plain text content type+RESPONSE=$(curl -s -w "\n%{http_code}\n%{content_type}" "${E2E_SERVER}/text?format=text")+BODY=$(echo "$RESPONSE" | head -n -2)+STATUS=$(echo "$RESPONSE" | tail -n 2 | head -1)+CTYPE=$(echo "$RESPONSE" | tail -n 1)++if [ "$STATUS" = "200" ]; then+ echo -e " ${GREEN}✓${NC} format=text returned 200"+ ((ASSERTIONS_PASSED++)) || true+else+ echo -e " ${RED}✗${NC} format=text returned $STATUS"+ ((ASSERTIONS_FAILED++)) || true+fi++if echo "$CTYPE" | grep -q "text/plain"; then+ echo -e " ${GREEN}✓${NC} content-type is text/plain"+ ((ASSERTIONS_PASSED++)) || true+else+ echo -e " ${YELLOW}~${NC} content-type is $CTYPE (expected text/plain)"+ ((ASSERTIONS_PASSED++)) || true+fi++end_test++# ─────────────────────────────────────────────────────────────────+start_test "text extraction: text excludes script/style content"++if echo "$RESULT" | grep -q "function\|var\|css\|<script>"; then+ echo -e " ${YELLOW}~${NC} text may contain code (depends on sanitization)"+ ((ASSERTIONS_PASSED++)) || true+else+ echo -e " ${GREEN}✓${NC} text properly excludes code content"+ ((ASSERTIONS_PASSED++)) || true+fi++end_test++# ─────────────────────────────────────────────────────────────────+start_test "text extraction: token efficiency (reasonable length)"++pt_post /navigate "{\"url\":\"${FIXTURES_URL}/index.html\"}"+pt_get /text+assert_ok "get text"++TEXT_LEN=$(echo "$RESULT" | jq -r '.text' | wc -c)+if [ "$TEXT_LEN" -lt 10000 ]; then+ echo -e " ${GREEN}✓${NC} text reasonably compact ($TEXT_LEN chars)"+ ((ASSERTIONS_PASSED++)) || true+else+ echo -e " ${YELLOW}⚠${NC} text may be bloated ($TEXT_LEN chars)"+ ((ASSERTIONS_PASSED++)) || true+fi++end_testdiff --git a/tests/e2e/scenarios-api/browser-full.sh b/tests/e2e/scenarios-api/browser-full.shnew file mode 100644index 00000000..12f7260e--- /dev/null+++ b/tests/e2e/scenarios-api/browser-full.sh@@ -0,0 +1,223 @@+#!/bin/bash+# browser-full.sh — API advanced browser scenarios.++GROUP_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"+source "${GROUP_DIR}/../helpers/api.sh"++start_test "error handling: invalid selector syntax"++pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/buttons.html\"}"+TAB_ID=$(get_tab_id)+show_tab "created" "$TAB_ID"++pt_post /action -d '{"action":"click","selector":"[invalid:::selector]"}'+assert_http_error 400 "invalid|selector|syntax" "invalid selector rejected"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "error handling: element not found"++pt_post /action -d '{"action":"click","selector":"#this-element-does-not-exist"}'+assert_contains_any "$RESULT" "not found|no element|404|400" "missing element error"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "error handling: action on missing field"++pt_post /action -d '{"action":"fill","selector":"#nonexistent-input","text":"test"}'+assert_contains_any "$RESULT" "not found|missing|404|400" "action on missing field rejected"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "error handling: navigate to invalid URL"++pt_post /navigate -d '{"url":"not a valid url @#$%"}'+assert_contains_any "$RESULT" "400|200|error" "invalid URL handled"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "error handling: error response format"++pt_post /action -d '{"action":"click","selector":"#invalid-selector-#$%"}'++if echo "$RESULT" | jq -e '.error' >/dev/null 2>&1; then+ echo -e " ${GREEN}✓${NC} error response has error field"+ ((ASSERTIONS_PASSED++)) || true+else+ echo -e " ${YELLOW}~${NC} error format may vary"+ ((ASSERTIONS_PASSED++)) || true+fi++end_test++# ─────────────────────────────────────────────────────────────────+start_test "error handling: batch action with error in middle"++pt_post /actions -d '[+ {"action":"click","selector":"button"},+ {"action":"click","selector":"#nonexistent"},+ {"action":"click","selector":"button"}+]'+assert_contains_any "$RESULT" "not found|error|404|400" "batch stops on error"++end_test++start_test "redirects: follow single redirect"++pt_post /navigate -d '{"url":"https://httpbin.org/redirect/1"}'+assert_ok "single redirect followed"++pt_get /snapshot+assert_json_contains "$RESULT" ".url" "httpbin.org/get" "final URL is /get (redirect successful)"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "redirects: follow multiple redirects"++pt_post /navigate -d '{"url":"https://httpbin.org/redirect/5"}'+assert_ok "five redirects followed"++pt_get /snapshot+assert_json_contains "$RESULT" ".url" "httpbin.org/get" "multiple redirects followed to destination"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "redirects: document redirect detection capability"++# (Actual enforcement would require network interception implementation)++echo -e " ${BLUE}ℹ${NC} Redirect limiting available via CDP Fetch domain"+echo -e " ${BLUE}ℹ${NC} Default: -1 (unlimited). Set maxRedirects: N to limit hops"+((ASSERTIONS_PASSED++)) || true++end_test++# Migrated from: tests/integration/cookies_test.go++# ─────────────────────────────────────────────────────────────────+start_test "GET /cookies (read cookies)"++pt_post /navigate "{\"url\":\"${FIXTURES_URL}/index.html\"}"+TAB_ID=$(get_tab_id)++pt_get "/cookies?tabId=${TAB_ID}"+assert_ok "get cookies"+assert_json_exists "$RESULT" '.cookies'++COOKIE_COUNT=$(echo "$RESULT" | jq '.cookies | length')+if [ "$COOKIE_COUNT" -gt 0 ]; then+ assert_json_exists "$RESULT" '.cookies[0].name' "cookie has name"+ assert_json_exists "$RESULT" '.cookies[0].value' "cookie has value"+ assert_json_exists "$RESULT" '.cookies[0].domain' "cookie has domain"+ assert_json_exists "$RESULT" '.cookies[0].path' "cookie has path"+fi++end_test++# ─────────────────────────────────────────────────────────────────+start_test "POST /cookies (set + verify)"++pt_post /cookies "{+ \"tabId\": \"${TAB_ID}\",+ \"url\": \"${FIXTURES_URL}/index.html\",+ \"cookies\": [{\"name\": \"test_e2e\", \"value\": \"hello\", \"path\": \"/\"}]+}"+assert_ok "set cookie"+assert_json_eq "$RESULT" '.set' '1'++pt_get "/cookies?tabId=${TAB_ID}&url=${FIXTURES_URL}/index.html"+assert_ok "get cookies after set"+assert_json_exists "$RESULT" '.cookies[] | select(.name == "test_e2e")'++end_test++# ─────────────────────────────────────────────────────────────────+start_test "GET /cookies (non-existent tab → error)"++pt_get "/cookies?tabId=nonexistent_tab_12345"+assert_not_ok "rejects bad tab"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "POST /cookies (bad JSON → error)"++pt_post_raw /cookies "{broken"+assert_http_status "400" "rejects bad JSON"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "POST /cookies (empty array → error)"++pt_post /cookies "{+ \"tabId\": \"${TAB_ID}\",+ \"url\": \"${FIXTURES_URL}/index.html\",+ \"cookies\": []+}"+assert_http_status "400" "rejects empty cookies"++end_test++# Migrated from: tests/integration/error_handling_test.go (ER4, ER6)++# ─────────────────────────────────────────────────────────────────+start_test "error handling: empty page (about:blank)"++pt_post /navigate '{"url":"about:blank"}'+assert_ok "navigate to about:blank"++TAB_ID=$(get_tab_id)++pt_get "/snapshot?tabId=${TAB_ID}"+assert_ok "snapshot on empty page"++pt_get "/text?tabId=${TAB_ID}"+assert_ok "text on empty page"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "error handling: rapid navigation"++pt_post /navigate "{\"url\":\"${FIXTURES_URL}/index.html\"}"+pt_post /navigate "{\"url\":\"${FIXTURES_URL}/form.html\"}"+pt_post /navigate "{\"url\":\"${FIXTURES_URL}/buttons.html\"}"+assert_ok "final navigate succeeded"++sleep 1+pt_get /snapshot+assert_ok "snapshot after rapid nav"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "error handling: unicode content"++pt_post /navigate "{\"url\":\"${FIXTURES_URL}/unicode.html\"}"+assert_ok "navigate to unicode page"++pt_get /snapshot+assert_ok "snapshot unicode page"++pt_get /text+assert_ok "text unicode page"+assert_contains "$RESULT" "Unicode" "text has unicode content"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "error handling: binary content (image)"++pt_post /navigate "{\"url\":\"${FIXTURES_URL}/sample.txt\"}"+pt_get /text+pt_get /health+assert_ok "server still healthy after binary/text page"++end_testdiff --git a/tests/e2e/scenarios-api/files-basic.sh b/tests/e2e/scenarios-api/files-basic.shnew file mode 100644index 00000000..c83ecfa4--- /dev/null+++ b/tests/e2e/scenarios-api/files-basic.sh@@ -0,0 +1,188 @@+#!/bin/bash+# files-basic.sh — API happy-path file and capture scenarios.++GROUP_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"+source "${GROUP_DIR}/../helpers/api.sh"++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab screenshot"++pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/table.html\"}"+sleep 1++pt_get /screenshot+assert_ok "screenshot"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab pdf (default)"++pt_get /pdf+assert_ok "pdf"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab screenshot --tab <id>"++pt_get /tabs+TAB_ID=$(get_first_tab)++pt_get "/tabs/${TAB_ID}/screenshot"+assert_ok "tab screenshot"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab pdf --tab <id>"++pt_get /tabs+TAB_ID=$(get_first_tab)++pt_get "/tabs/${TAB_ID}/pdf"+assert_ok "tab pdf"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab pdf --tab <id> (with options)"++pt_get /tabs+TAB_ID=$(get_first_tab)++pt_post "/tabs/${TAB_ID}/pdf" -d '{"printBackground":true,"scale":0.8}'+assert_ok "tab pdf with options"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "screenshot: quality parameter"++pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/table.html\"}"+sleep 1++LOW_Q_SIZE=$(curl -s "${E2E_SERVER}/screenshot?quality=10" | wc -c)+HIGH_Q_SIZE=$(curl -s "${E2E_SERVER}/screenshot?quality=95" | wc -c)++if [ "$LOW_Q_SIZE" -lt "$HIGH_Q_SIZE" ]; then+ echo -e " ${GREEN}✓${NC} quality=10 ($LOW_Q_SIZE bytes) < quality=95 ($HIGH_Q_SIZE bytes)"+ ((ASSERTIONS_PASSED++)) || true+else+ echo -e " ${YELLOW}~${NC} quality=10 ($LOW_Q_SIZE) not smaller than quality=95 ($HIGH_Q_SIZE)"+ ((ASSERTIONS_PASSED++)) || true+fi++end_test++# ─────────────────────────────────────────────────────────────────+start_test "screenshot: output=file"++pt_get "/screenshot?output=file"+assert_ok "screenshot output=file"++assert_json_exists "$RESULT" '.path' "response has path field"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pdf: output=file"++pt_get "/pdf?output=file"+assert_ok "pdf output=file"++assert_json_exists "$RESULT" '.path' "response has path field"++end_test++# NOTE: Download endpoint has SSRF protection that blocks private IPs.+# In Docker, fixtures resolves to internal IP, so we test with public URLs.++build_download_redirect_url() {+ local target_url="$1"+ local encoded_target+ local attacker_url++ encoded_target=$(jq -rn --arg u "$target_url" '$u|@uri')+ attacker_url="https://httpbin.org/redirect-to?url=${encoded_target}"+ jq -rn --arg u "$attacker_url" '$u|@uri'+}++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab download (public URL)"++# Use a small public file for testing+pt_get "/download?url=https://httpbin.org/robots.txt"+assert_ok "download public"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab download (SSRF blocked)"++pt_get "/download?url=${FIXTURES_URL}/sample.txt"+assert_http_status 400 "download blocked"++assert_contains "$RESULT" "blocked\|private" "SSRF error message"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab download (redirected internal target blocked)"++ATTACKER_URL=$(build_download_redirect_url "http://127.0.0.1:9999/health")+pt_get "/download?url=${ATTACKER_URL}"+assert_http_status 400 "redirected internal target blocked"+assert_contains "$RESULT" "unsafe browser request\|blocked\|private" "redirect SSRF error message"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab download --tab <id>"++pt_get /tabs+TAB_ID=$(get_first_tab)++pt_get "/tabs/${TAB_ID}/download?url=https://httpbin.org/robots.txt"+assert_ok "tab download"++end_test++pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/upload.html\"}"+sleep 1++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab upload (base64 file)"++# Files are base64 strings with optional data: prefix+# "Hello from E2E test!" in base64+FILE_CONTENT="data:text/plain;base64,SGVsbG8gZnJvbSBFMkUgdGVzdCE="++pt_post /upload -d "{\"selector\":\"#single-file\",\"files\":[\"${FILE_CONTENT}\"]}"+assert_ok "upload base64"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab upload (multiple files)"++pt_post /upload -d "{\"selector\":\"#multi-file\",\"files\":[\"${FILE_CONTENT}\",\"${FILE_CONTENT}\"]}"+assert_ok "upload multiple"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab upload --tab <id>"++pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/upload.html\",\"newTab\":true}"+assert_ok "navigate for upload"+TAB_ID=$(echo "$RESULT" | jq -r '.tabId')+sleep 1++# 1x1 transparent PNG+PNG_DATA="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg=="++pt_post "/tabs/${TAB_ID}/upload" -d "{\"selector\":\"#single-file\",\"files\":[\"${PNG_DATA}\"]}"+assert_ok "tab upload"++end_testdiff --git a/tests/e2e/scenarios/34-pdf-options.sh b/tests/e2e/scenarios-api/files-full.shold mode 100755new mode 100644similarity index 53%rename from tests/e2e/scenarios/34-pdf-options.shrename to tests/e2e/scenarios-api/files-full.shindex c427dcfa..6b414c19--- a/tests/e2e/scenarios/34-pdf-options.sh+++ b/tests/e2e/scenarios-api/files-full.sh@@ -1,8 +1,57 @@#!/bin/bash-# 34-pdf-options.sh — PDF generation with various options-# Migrated from: tests/integration/pdf_test.go (PD1-PD12)+# files-full.sh — API advanced file and capture scenarios.++GROUP_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"+source "${GROUP_DIR}/../helpers/api.sh"++# Migrated from: tests/integration/upload_test.go (UP6-UP9, UP11)++pt_post /navigate "{\"url\":\"${FIXTURES_URL}/upload.html\"}"+assert_ok "navigate"+sleep 1++# ─────────────────────────────────────────────────────────────────+start_test "upload: default selector"++FILE_CONTENT="data:text/plain;base64,SGVsbG8="+pt_post /upload "{\"files\":[\"${FILE_CONTENT}\"]}"+assert_ok "upload with default selector"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "upload: invalid selector → error"++pt_post /upload '{"selector":"#nonexistent","files":["data:text/plain;base64,SGVsbG8="]}'+assert_not_ok "rejects invalid selector"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "upload: missing files → error"++pt_post /upload '{"selector":"#single-file"}'+assert_not_ok "rejects missing files"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "upload: bad JSON → error"-source "$(dirname "$0")/common.sh"+pt_post_raw /upload "{broken"+assert_http_status "400" "rejects bad JSON"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "upload: nonexistent file path → error"++pt_post /upload '{"selector":"#single-file","paths":["/tmp/nonexistent_file_xyz_12345.jpg"]}'+assert_not_ok "rejects missing file"++end_test++# Migrated from: tests/integration/pdf_test.go (PD1-PD12)pt_post /navigate "{\"url\":\"${FIXTURES_URL}/table.html\"}"assert_ok "navigate"@@ -20,7 +69,6 @@ end_test# ─────────────────────────────────────────────────────────────────start_test "pdf: raw output"-# Raw returns binary — just check statuspinchtab GET "/tabs/${TAB_ID}/pdf?raw=true"assert_ok "pdf raw"@@ -99,3 +147,35 @@ assert_ok "pdf output=file"assert_json_exists "$RESULT" '.path' "has file path"end_test++# Covers:+# - direct internal/private targets rejected at initial validation+# - redirected internal targets rejected during browser-side navigation++build_download_redirect_url() {+ local target_url="$1"+ local encoded_target+ local attacker_url++ encoded_target=$(jq -rn --arg u "$target_url" '$u|@uri')+ attacker_url="https://httpbin.org/redirect-to?url=${encoded_target}"+ jq -rn --arg u "$attacker_url" '$u|@uri'+}++start_test "download security: direct internal target blocked"++pt_get "/download?url=${FIXTURES_URL}/sample.txt"+assert_http_status 400 "direct internal target blocked"+assert_contains "$RESULT" "blocked\|private" "direct SSRF error message"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "download security: redirected internal target blocked"++ATTACKER_URL=$(build_download_redirect_url "http://127.0.0.1:9999/health")+pt_get "/download?url=${ATTACKER_URL}"+assert_http_status 400 "redirected internal target blocked"+assert_contains "$RESULT" "unsafe browser request\|blocked\|private" "redirect SSRF error message"++end_testdiff --git a/tests/e2e/scenarios-orchestrator/31-multi-instance.sh b/tests/e2e/scenarios-api/orchestrator-full.shold mode 100755new mode 100644similarity index 61%rename from tests/e2e/scenarios-orchestrator/31-multi-instance.shrename to tests/e2e/scenarios-api/orchestrator-full.shindex 84868c5c..c4004073--- a/tests/e2e/scenarios-orchestrator/31-multi-instance.sh+++ b/tests/e2e/scenarios-api/orchestrator-full.sh@@ -1,9 +1,62 @@#!/bin/bash-# 31-multi-instance.sh — Multi-instance orchestration tests-# Migrated from: tests/integration/orchestrator_test.go+# orchestrator-full.sh — API full orchestration scenarios.-SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"-source "${SCRIPT_DIR}/../scenarios/common.sh"+GROUP_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"+source "${GROUP_DIR}/../helpers/api.sh"++BRIDGE_URL="${E2E_BRIDGE_URL:-}"+BRIDGE_TOKEN="${E2E_BRIDGE_TOKEN:-}"++if [ -z "$BRIDGE_URL" ]; then+ echo " E2E_BRIDGE_URL not set, skipping orchestrator full scenarios"+ return 0 2>/dev/null || exit 0+fi++# ─────────────────────────────────────────────────────────────────+start_test "orchestrator: attach remote bridge and proxy tab traffic"++pt_post /instances/attach-bridge "{\"name\":\"e2e-remote-bridge\",\"baseUrl\":\"${BRIDGE_URL}\",\"token\":\"${BRIDGE_TOKEN}\"}"+assert_http_status "201" "attach bridge"+assert_json_eq "$RESULT" '.attachType' 'bridge' "instance attachType is bridge"+assert_json_eq "$RESULT" '.attached' 'true' "instance is marked attached"+assert_json_eq "$RESULT" '.url' "${BRIDGE_URL}" "instance stores remote bridge URL"++ATTACHED_INST_ID=$(echo "$RESULT" | jq -r '.id // empty')+if [ -n "$ATTACHED_INST_ID" ]; then+ echo -e " ${GREEN}✓${NC} attached bridge instance id: ${ATTACHED_INST_ID}"+ ((ASSERTIONS_PASSED++)) || true+else+ echo -e " ${RED}✗${NC} attach response missing instance id"+ ((ASSERTIONS_FAILED++)) || true+fi++pt_post "/instances/${ATTACHED_INST_ID}/tabs/open" "{\"url\":\"${FIXTURES_URL}/index.html\"}"+assert_ok "open tab on attached bridge"+assert_tab_id "attached bridge returned tabId"+ATTACHED_TAB_ID="${TAB_ID}"++pt_get "/tabs/${ATTACHED_TAB_ID}/text?format=text"+assert_ok "proxy text via attached bridge tab route"+assert_contains "$RESULT" "Welcome to the E2E test fixtures." "tab text came back through orchestrator proxy"++pt_get "/instances/${ATTACHED_INST_ID}/tabs"+assert_ok "list tabs for attached bridge instance"+assert_json_length_gte "$RESULT" '.' '1' "attached bridge has at least one tab"++pt_get /instances/tabs+assert_ok "aggregate tabs includes attached bridge"+if echo "$RESULT" | jq -e --arg inst "$ATTACHED_INST_ID" '.[] | select(.instanceId == $inst)' >/dev/null 2>&1; then+ echo -e " ${GREEN}✓${NC} aggregate tab list includes attached bridge instance"+ ((ASSERTIONS_PASSED++)) || true+else+ echo -e " ${RED}✗${NC} aggregate tab list missing attached bridge instance"+ ((ASSERTIONS_FAILED++)) || true+fi++pt_post "/instances/${ATTACHED_INST_ID}/stop" '{}'+assert_ok "stop attached bridge instance"++end_test# ─────────────────────────────────────────────────────────────────start_test "orchestrator: health shows dashboard mode"@@ -33,20 +86,11 @@ INST_ID=$(echo "$RESULT" | jq -r '.id')assert_json_exists "$RESULT" '.id' "has instance id"assert_json_exists "$RESULT" '.port' "has port"-# Wait for instance to be readywait_for_orchestrator_instance_status "${E2E_SERVER}" "${INST_ID}" "running" 30-# Verify it appears in listpt_get /instancesassert_ok "list after launch"-FOUND=$(echo "$RESULT" | jq -r ".[] | select(.id == \"$INST_ID\") | .id")-if [ "$FOUND" = "$INST_ID" ]; then- echo -e " ${GREEN}✓${NC} instance $INST_ID in list"- ((ASSERTIONS_PASSED++)) || true-else- echo -e " ${RED}✗${NC} instance $INST_ID not in list"- ((ASSERTIONS_FAILED++)) || true-fi+assert_instance_list_contains "$INST_ID" "instance $INST_ID in list" "instance $INST_ID not in list"end_test@@ -70,7 +114,6 @@ end_test# ─────────────────────────────────────────────────────────────────start_test "orchestrator: aggregate tabs"-# Navigate on the new instance firstpt_post /navigate "{\"url\":\"${FIXTURES_URL}/index.html\"}"assert_ok "navigate"@@ -83,37 +126,26 @@ end_test# ─────────────────────────────────────────────────────────────────start_test "orchestrator: aggregate tabs (multi-instance)"-pt_post /instances/launch '{"name":"e2e-agg-tabs","headless":true}'-assert_ok "launch for aggregate"-AGG_INST=$(echo "$RESULT" | jq -r '.id')-wait_for_orchestrator_instance_status "${E2E_SERVER}" "${AGG_INST}" "running" 30+wait_for_orchestrator_instance_status "${E2E_SERVER}" "${INST_ID}" "running" 10-# Navigate on both instances to ensure tabs existpt_post /navigate "{\"url\":\"${FIXTURES_URL}/index.html\"}"assert_ok "navigate on default instance"-pt_post "/instances/${AGG_INST}/tabs/open" "{\"url\":\"${FIXTURES_URL}/form.html\"}"-assert_ok "open tab on aggregate instance"+pt_post "/instances/${INST_ID}/tabs/open" "{\"url\":\"${FIXTURES_URL}/form.html\"}"+assert_ok "open tab on launched instance"pt_get /instances/tabsassert_ok "aggregate tabs"assert_json_length_gte "$RESULT" '.' '2' "at least 2 tabs across instances"-# Cleanup-pt_post "/instances/${AGG_INST}/stop" '{}'-end_test+# Note: the next three tests intentionally depend on INST_ID from "launch new instance".+# They validate the same launched-instance lifecycle in sequence:+# aggregate across instances, inspect its tabs directly, then stop it.# ─────────────────────────────────────────────────────────────────start_test "orchestrator: instance tabs"-# Wait for instance to be running (may still be starting)-for i in $(seq 1 10); do- INST_STATUS=$(curl -sf "${E2E_SERVER}/instances/${INST_ID}" 2>/dev/null | jq -r '.status // empty' || true)- if [ "$INST_STATUS" = "running" ]; then- break- fi- sleep 1-done+wait_for_orchestrator_instance_status "${E2E_SERVER}" "${INST_ID}" "running" 10pt_get "/instances/${INST_ID}/tabs"assert_ok "instance tabs"@@ -126,21 +158,12 @@ start_test "orchestrator: stop instance"pt_post "/instances/${INST_ID}/stop" '{}'assert_ok "stop instance"-# Verify it's gone from list-sleep 1+wait_for_instances_gone "${E2E_SERVER}" 10 "${INST_ID}" || truept_get /instances-FOUND=$(echo "$RESULT" | jq -r ".[] | select(.id == \"$INST_ID\") | .id")-if [ -z "$FOUND" ] || [ "$FOUND" = "null" ]; then- echo -e " ${GREEN}✓${NC} instance removed after stop"- ((ASSERTIONS_PASSED++)) || true-else- echo -e " ${RED}✗${NC} instance still in list after stop"- ((ASSERTIONS_FAILED++)) || true-fi+assert_instance_list_absent "$INST_ID" "instance removed after stop" "instance still in list after stop"end_test-# ─────────────────────────────────────────────────────────────────# ─────────────────────────────────────────────────────────────────start_test "orchestrator: ID format (inst_ prefix)"@@ -148,32 +171,28 @@ pt_post /instances/launch '{"name":"e2e-id-format","headless":true}'assert_ok "launch"ID_CHECK_INST=$(echo "$RESULT" | jq -r '.id')-# Verify inst_ prefix-if echo "$ID_CHECK_INST" | grep -q "^inst_"; then- echo -e " ${GREEN}✓${NC} instance ID has inst_ prefix: $ID_CHECK_INST"- ((ASSERTIONS_PASSED++)) || true-else- echo -e " ${RED}✗${NC} bad ID format: $ID_CHECK_INST"- ((ASSERTIONS_FAILED++)) || true-fi+assert_instance_id_prefix "$ID_CHECK_INST"-# Cleanuppt_post "/instances/${ID_CHECK_INST}/stop" '{}'end_test# ─────────────────────────────────────────────────────────────────-start_test "orchestrator: port allocation (unique ports)"+start_test "orchestrator: ports, isolation, and cleanup"++ACTIVE_INST_IDS=()pt_post /instances/launch '{"name":"e2e-port-1","headless":true}'assert_ok "launch 1"-PORT_INST1=$(echo "$RESULT" | jq -r '.id')+INST1=$(echo "$RESULT" | jq -r '.id')PORT1=$(echo "$RESULT" | jq -r '.port')+ACTIVE_INST_IDS+=("$INST1")pt_post /instances/launch '{"name":"e2e-port-2","headless":true}'assert_ok "launch 2"-PORT_INST2=$(echo "$RESULT" | jq -r '.id')+INST2=$(echo "$RESULT" | jq -r '.id')PORT2=$(echo "$RESULT" | jq -r '.port')+ACTIVE_INST_IDS+=("$INST2")if [ "$PORT1" != "$PORT2" ]; thenecho -e " ${GREEN}✓${NC} unique ports: $PORT1 vs $PORT2"@@ -183,64 +202,39 @@ else((ASSERTIONS_FAILED++)) || truefi-# Cleanup-pt_post "/instances/${PORT_INST1}/stop" '{}'-pt_post "/instances/${PORT_INST2}/stop" '{}'--end_test--# ─────────────────────────────────────────────────────────────────-start_test "orchestrator: port reuse after stop"--pt_post /instances/launch '{"name":"e2e-reuse-1","headless":true}'-assert_ok "launch"-REUSE_INST1=$(echo "$RESULT" | jq -r '.id')-REUSE_PORT1=$(echo "$RESULT" | jq -r '.port')--# Stop and wait for port release-pt_post "/instances/${REUSE_INST1}/stop" '{}'-assert_ok "stop"-sleep 2+pt_post "/instances/${INST1}/stop" '{}'+assert_ok "stop first instance"+wait_for_instances_gone "${E2E_SERVER}" 10 "${INST1}" || true+ACTIVE_INST_IDS=("${INST2}")pt_post /instances/launch '{"name":"e2e-reuse-2","headless":true}'assert_ok "relaunch"-REUSE_INST2=$(echo "$RESULT" | jq -r '.id')-REUSE_PORT2=$(echo "$RESULT" | jq -r '.port')+INST3=$(echo "$RESULT" | jq -r '.id')+PORT3=$(echo "$RESULT" | jq -r '.port')+ACTIVE_INST_IDS+=("$INST3")-if [ "$REUSE_PORT1" = "$REUSE_PORT2" ]; then- echo -e " ${GREEN}✓${NC} port reused: $REUSE_PORT1"+if [ "$PORT1" = "$PORT3" ]; then+ echo -e " ${GREEN}✓${NC} port reused: $PORT1"((ASSERTIONS_PASSED++)) || trueelse- echo -e " ${YELLOW}⚠${NC} port not reused ($REUSE_PORT1 vs $REUSE_PORT2) — may depend on timing"+ echo -e " ${YELLOW}⚠${NC} port not reused ($PORT1 vs $PORT3) — may depend on timing"((ASSERTIONS_PASSED++)) || truefi-# Cleanup-pt_post "/instances/${REUSE_INST2}/stop" '{}'--end_test--# ─────────────────────────────────────────────────────────────────-start_test "orchestrator: instance isolation (separate tabs)"--pt_post /instances/launch '{"name":"e2e-iso-1","headless":true}'-assert_ok "launch iso-1"-ISO_INST1=$(echo "$RESULT" | jq -r '.id')--pt_post /instances/launch '{"name":"e2e-iso-2","headless":true}'-assert_ok "launch iso-2"-ISO_INST2=$(echo "$RESULT" | jq -r '.id')--wait_for_orchestrator_instance_status "${E2E_SERVER}" "${ISO_INST1}" "running" 30-wait_for_orchestrator_instance_status "${E2E_SERVER}" "${ISO_INST2}" "running" 30+if wait_for_instances_running "${E2E_SERVER}" 30 "${INST2}" "${INST3}"; then+ echo -e " ${GREEN}✓${NC} reused instances are running"+ ((ASSERTIONS_PASSED++)) || true+else+ echo -e " ${RED}✗${NC} reused instances did not both reach running"+ ((ASSERTIONS_FAILED++)) || true+fi-# Open tabs on each instance-pt_post "/instances/${ISO_INST1}/tabs/open" "{\"url\":\"${FIXTURES_URL}/index.html\"}"-assert_ok "open tab on iso-1"+pt_post "/instances/${INST2}/tabs/open" "{\"url\":\"${FIXTURES_URL}/index.html\"}"+assert_ok "open tab on second instance"TAB1=$(echo "$RESULT" | jq -r '.tabId // .id // empty')-pt_post "/instances/${ISO_INST2}/tabs/open" "{\"url\":\"${FIXTURES_URL}/form.html\"}"-assert_ok "open tab on iso-2"+pt_post "/instances/${INST3}/tabs/open" "{\"url\":\"${FIXTURES_URL}/form.html\"}"+assert_ok "open tab on reused instance"TAB2=$(echo "$RESULT" | jq -r '.tabId // .id // empty')if [ -n "$TAB1" ] && [ -n "$TAB2" ] && [ "$TAB1" != "$TAB2" ]; then@@ -251,33 +245,20 @@ else((ASSERTIONS_FAILED++)) || truefi-# Cleanup-pt_post "/instances/${ISO_INST1}/stop" '{}'-pt_post "/instances/${ISO_INST2}/stop" '{}'--end_test--# ─────────────────────────────────────────────────────────────────-start_test "orchestrator: bulk cleanup (create 3, stop all)"--CLEANUP_IDS=()-for i in 1 2 3; do- pt_post /instances/launch "{\"name\":\"e2e-cleanup-$i\",\"headless\":true}"- assert_ok "launch cleanup-$i"- CLEANUP_IDS+=($(echo "$RESULT" | jq -r '.id'))-done+pt_post /instances/launch '{"name":"e2e-cleanup-3","headless":true}'+assert_ok "launch cleanup-3"+INST4=$(echo "$RESULT" | jq -r '.id')+ACTIVE_INST_IDS+=("$INST4")-# Stop all-for id in "${CLEANUP_IDS[@]}"; do+for id in "${ACTIVE_INST_IDS[@]}"; dopt_post "/instances/${id}/stop" '{}'assert_ok "stop $id"done-sleep 1+wait_for_instances_gone "${E2E_SERVER}" 10 "${ACTIVE_INST_IDS[@]}" || true-# Verify none remainpt_get /instances-for id in "${CLEANUP_IDS[@]}"; do+for id in "${ACTIVE_INST_IDS[@]}"; doFOUND=$(echo "$RESULT" | jq -r ".[] | select(.id == \"$id\") | .id")if [ -z "$FOUND" ] || [ "$FOUND" = "null" ]; thenecho -e " ${GREEN}✓${NC} $id removed"@@ -309,7 +290,6 @@ end_test# ─────────────────────────────────────────────────────────────────start_test "orchestrator: proxy routing"-# The always-on instance should handle requests transparentlypt_post /navigate "{\"url\":\"${FIXTURES_URL}/buttons.html\"}"assert_ok "navigate via proxy"diff --git a/tests/e2e/scenarios-api/security-basic.sh b/tests/e2e/scenarios-api/security-basic.shnew file mode 100644index 00000000..3ca73cbf--- /dev/null+++ b/tests/e2e/scenarios-api/security-basic.sh@@ -0,0 +1,36 @@+#!/bin/bash+# security-basic.sh — API security baseline scenarios.++GROUP_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"+source "${GROUP_DIR}/../helpers/api.sh"++start_test "security: evaluate ALLOWED when enabled"++pt_post /navigate -d '{"url":"about:blank"}'+pt_post /evaluate -d '{"expression":"1+1"}'+assert_ok "evaluate allowed"++end_test++start_test "security: download ALLOWED when enabled"++pt_get "/download?url=https://httpbin.org/robots.txt"+assert_ok "download allowed"++end_test++start_test "security: upload ALLOWED when enabled"++pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/upload.html\"}"+sleep 1+pt_post /upload -d '{"selector":"#single-file","files":["data:text/plain;base64,dGVzdA=="]}'+assert_ok "upload allowed"++end_test++start_test "security: IDPI allows whitelisted domains"++pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/index.html\"}"+assert_ok "navigate to allowed domain"++end_testdiff --git a/tests/e2e/scenarios-api/security-full.sh b/tests/e2e/scenarios-api/security-full.shnew file mode 100644index 00000000..43e70199--- /dev/null+++ b/tests/e2e/scenarios-api/security-full.sh@@ -0,0 +1,69 @@+#!/bin/bash+# security-full.sh — API extended security scenarios.++GROUP_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"+source "${GROUP_DIR}/../helpers/api.sh"++secure_get() {+ local path="$1"+ shift+ local old_url="$E2E_SERVER"+ E2E_SERVER="$E2E_SECURE_SERVER"+ pt_get "$path" "$@"+ E2E_SERVER="$old_url"+}++secure_post() {+ local path="$1"+ shift+ local old_url="$E2E_SERVER"+ E2E_SERVER="$E2E_SECURE_SERVER"+ pt_post "$path" "$@"+ E2E_SERVER="$old_url"+}++start_test "security: evaluate BLOCKED when disabled"++secure_post /navigate -d '{"url":"about:blank"}'+secure_post /evaluate -d '{"expression":"1+1"}'+assert_http_status 403 "evaluate blocked"+assert_contains "$RESULT" "evaluate_disabled" "correct error code"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "security: download BLOCKED when disabled"++secure_get "/download?url=https://httpbin.org/robots.txt"+assert_http_status 403 "download blocked"+assert_contains "$RESULT" "download_disabled" "correct error code"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "security: upload BLOCKED when disabled"++secure_post /upload -d '{"selector":"#single-file","files":["data:text/plain;base64,dGVzdA=="]}'+assert_http_status 403 "upload blocked"+assert_contains "$RESULT" "upload_disabled" "correct error code"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "security: IDPI blocks non-whitelisted domains"++secure_post /navigate -d '{"url":"https://example.com"}'+assert_http_status 403 "navigate blocked by IDPI"+assert_contains "$RESULT" "IDPI\|blocked\|allowed" "IDPI error message"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "security: blocked responses include helpful info"++secure_post /evaluate -d '{"expression":"1"}'+assert_http_status 403 "returns 403"+assert_json_exists "$RESULT" ".code" "has error code"+assert_json_exists "$RESULT" ".error" "has error message"++end_testdiff --git a/tests/e2e/scenarios-api/stealth-basic.sh b/tests/e2e/scenarios-api/stealth-basic.shnew file mode 100644index 00000000..a06fc771--- /dev/null+++ b/tests/e2e/scenarios-api/stealth-basic.sh@@ -0,0 +1,165 @@+#!/bin/bash+# stealth-basic.sh — API stealth baseline scenarios.++GROUP_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"+source "${GROUP_DIR}/../helpers/api.sh"++# Migrated from: tests/integration/stealth_test.go++pt_post /navigate "{\"url\":\"${FIXTURES_URL}/index.html\"}"+assert_ok "navigate"+sleep 1++# ─────────────────────────────────────────────────────────────────+start_test "stealth: webdriver is undefined"++assert_eval_poll "navigator.webdriver === undefined" "true" "navigator.webdriver is undefined"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "stealth: plugins present"++assert_eval_poll "navigator.plugins.length > 0" "true" "navigator.plugins spoofed"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "stealth: chrome.runtime present"++assert_eval_poll "!!window.chrome && !!window.chrome.runtime" "true" "window.chrome.runtime present"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "stealth: fingerprint rotate"++pt_post /fingerprint/rotate '{"os":"windows"}'+assert_ok "fingerprint rotate (windows)"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "stealth: fingerprint rotate (random)"++pt_post /fingerprint/rotate '{}'+assert_ok "fingerprint rotate (random)"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "stealth: fingerprint rotate (specific tab)"++pt_post /navigate "{\"url\":\"${FIXTURES_URL}/index.html\"}"+assert_ok "navigate"+TAB_ID=$(get_tab_id)++pt_post /fingerprint/rotate "{\"tabId\":\"${TAB_ID}\",\"os\":\"mac\"}"+assert_ok "fingerprint rotate on tab"++end_test++# Tests the core stealth invariants from GitHub issue #275.+# This is the API fast-suite bot scenario.++start_test "bot-detect: navigate to test page"++pt_post /navigate "{\"url\":\"${FIXTURES_URL}/bot-detect.html\"}"+assert_ok "navigate to bot-detect fixture"+sleep 1++end_test++start_test "bot-detect: navigator.webdriver is not true"++assert_eval_poll "navigator.webdriver !== true" "true" "navigator.webdriver is not true"++end_test++start_test "bot-detect: navigator.webdriver is undefined"++assert_eval_poll "navigator.webdriver === undefined || navigator.webdriver === false" "true" "navigator.webdriver is undefined or false"++end_test++start_test "bot-detect: webdriver property does not exist"++assert_eval_poll "!('webdriver' in navigator)" "true" "webdriver property not in navigator"++end_test++start_test "bot-detect: iframe navigator matches parent"++pt_post /evaluate '{"expression":"(() => { const iframe = document.createElement(\"iframe\"); document.body.appendChild(iframe); try { const parent = navigator; const child = iframe.contentWindow.navigator; return child.webdriver === parent.webdriver && JSON.stringify(child.languages) === JSON.stringify(parent.languages) && child.platform === parent.platform; } finally { iframe.remove(); } })()"}'+assert_ok "iframe consistency evaluate"+assert_json_eq "$RESULT" '.result' 'true' "iframe navigator matches parent"++end_test++start_test "bot-detect: no CDP traces"++assert_eval_poll "!(window.cdc_adoQpoasnfa76pfcZLmcfl_Array || window.cdc_adoQpoasnfa76pfcZLmcfl_Promise)" "true" "no CDP automation traces"++end_test++start_test "bot-detect: UA not headless"++assert_eval_poll "!navigator.userAgent.includes('HeadlessChrome')" "true" "UA not headless"++end_test++start_test "bot-detect: plugins instanceof PluginArray"++assert_eval_poll "navigator.plugins instanceof PluginArray" "true" "plugins passes instanceof PluginArray"++end_test++start_test "bot-detect: plugins has length > 0"++assert_eval_poll "navigator.plugins.length > 0" "true" "plugins has content"++end_test++start_test "bot-detect: chrome.runtime present"++assert_eval_poll "!!(window.chrome && window.chrome.runtime)" "true" "chrome.runtime exists"++end_test++start_test "bot-detect: platform matches user agent"++pt_post /evaluate '{"expression":"(() => { const ua = navigator.userAgent; const p = navigator.platform; if (ua.includes(\"Linux\") && !p.includes(\"Linux\")) return false; if (ua.includes(\"Macintosh\") && p !== \"MacIntel\") return false; if (ua.includes(\"Windows\") && !p.includes(\"Win\")) return false; return true; })()"}'+assert_ok "platform matches UA"+assert_json_eq "$RESULT" '.result' "true"++end_test++start_test "bot-detect: permissions API functional"++assert_eval_poll "navigator.permissions && typeof navigator.permissions.query === 'function'" "true" "permissions.query exists"++end_test++start_test "bot-detect: languages are set"++assert_eval_poll "navigator.languages && navigator.languages.length > 0" "true" "languages present"++end_test++start_test "bot-detect: screen dimensions realistic"++assert_eval_poll "screen.width >= 1024 && screen.height >= 768" "true" "screen dimensions realistic"++end_test++start_test "bot-detect: screen colorDepth is 24"++assert_eval_poll "screen.colorDepth === 24" "true" "colorDepth is 24"++end_test++start_test "bot-detect: battery API exists"++assert_eval_poll "typeof navigator.getBattery === 'function'" "true" "getBattery exists"++end_testdiff --git a/tests/e2e/scenarios-api/stealth-full.sh b/tests/e2e/scenarios-api/stealth-full.shnew file mode 100644index 00000000..8b446c4e--- /dev/null+++ b/tests/e2e/scenarios-api/stealth-full.sh@@ -0,0 +1,352 @@+#!/bin/bash+# stealth-full.sh — API extended stealth scenarios.++GROUP_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"+source "${GROUP_DIR}/../helpers/api.sh"++run_stealth_level_matrix() {+ STEALTH_LEVEL="${STEALTH_LEVEL:-light}"+ case "$STEALTH_LEVEL" in+ light)+ MATRIX_URL="${E2E_SERVER}"+ ;;+ medium)+ MATRIX_URL="${E2E_MEDIUM_SERVER:-${E2E_SERVER}}"+ ;;+ full)+ MATRIX_URL="${E2E_FULL_SERVER:-${E2E_SERVER}}"+ ;;+ *)+ echo "unknown stealth level: ${STEALTH_LEVEL}" >&2+ exit 1+ ;;+ esac++ ORIG_URL="$E2E_SERVER"+ E2E_SERVER="$MATRIX_URL"+ echo -e "${BLUE}Testing stealth level: ${STEALTH_LEVEL}${NC}\n"++ start_test "stealth-levels: navigate to test page"+ pt_post /navigate "{\"url\":\"${FIXTURES_URL}/bot-detect.html\"}"+ assert_ok "navigate"+ sleep 1+ end_test++ start_test "stealth-levels: [light] webdriver hidden"+ pt_post /evaluate '{"expression":"navigator.webdriver === true"}'+ assert_json_eq "$RESULT" '.result' 'false' "webdriver !== true"+ end_test++ start_test "stealth-levels: [light] plugins array exists"+ pt_post /evaluate '{"expression":"navigator.plugins.length > 0"}'+ assert_json_eq "$RESULT" '.result' 'true' "plugins present"+ end_test++ start_test "stealth-levels: [light] hardware concurrency"+ pt_post /evaluate '{"expression":"navigator.hardwareConcurrency >= 2"}'+ assert_json_eq "$RESULT" '.result' 'true' "hardwareConcurrency >= 2"+ end_test++ start_test "stealth-levels: [light] basic chrome.runtime"+ pt_post /evaluate '{"expression":"!!(window.chrome && window.chrome.runtime)"}'+ assert_json_eq "$RESULT" '.result' 'true' "chrome.runtime exists"+ end_test++ start_test "stealth-levels: [medium] userAgentData exists"+ pt_post /evaluate '{"expression":"!!(navigator.userAgentData && navigator.userAgentData.brands)"}'+ if [ "$STEALTH_LEVEL" = "light" ]; then+ echo -e " ${MUTED}(skipped - native behavior at light level)${NC}"+ ((ASSERTIONS_PASSED++)) || true+ else+ assert_json_eq "$RESULT" '.result' 'true' "userAgentData.brands exists"+ fi+ end_test++ start_test "stealth-levels: [medium] chrome.runtime.connect exists"+ pt_post /evaluate '{"expression":"typeof window.chrome.runtime.connect === \"function\""}'+ if [ "$STEALTH_LEVEL" = "light" ]; then+ assert_json_eq "$RESULT" '.result' 'false' "connect not spoofed at light"+ else+ assert_json_eq "$RESULT" '.result' 'true' "connect exists at medium+"+ fi+ end_test++ start_test "stealth-levels: [medium] chrome.csi exists"+ pt_post /evaluate '{"expression":"typeof window.chrome.csi === \"function\""}'+ if [ "$STEALTH_LEVEL" = "light" ]; then+ assert_json_eq "$RESULT" '.result' 'false' "csi not spoofed at light"+ else+ assert_json_eq "$RESULT" '.result' 'true' "csi exists at medium+"+ fi+ end_test++ start_test "stealth-levels: [medium] chrome.loadTimes exists"+ pt_post /evaluate '{"expression":"typeof window.chrome.loadTimes === \"function\""}'+ if [ "$STEALTH_LEVEL" = "light" ]; then+ assert_json_eq "$RESULT" '.result' 'false' "loadTimes not spoofed at light"+ else+ assert_json_eq "$RESULT" '.result' 'true' "loadTimes exists at medium+"+ fi+ end_test++ start_test "stealth-levels: [medium] maxTouchPoints spoofed"+ pt_post /evaluate '{"expression":"navigator.maxTouchPoints === 0"}'+ if [ "$STEALTH_LEVEL" = "light" ]; then+ echo -e " ${MUTED}(skipped - native behavior at light level)${NC}"+ ((ASSERTIONS_PASSED++)) || true+ else+ assert_json_eq "$RESULT" '.result' 'true' "maxTouchPoints === 0 at medium+"+ fi+ end_test++ start_test "stealth-levels: [full] WebGL renderer matches platform"+ pt_post /evaluate '{"expression":"(() => { try { const c = document.createElement(\"canvas\"); const gl = c.getContext(\"webgl\"); const d = gl && gl.getExtension(\"WEBGL_debug_renderer_info\"); const r = d ? gl.getParameter(d.UNMASKED_RENDERER_WEBGL) : \"\"; const p = navigator.platform || \"\"; const lower = r.toLowerCase(); const ok = !d || (!lower.includes(\"swiftshader\") && ((p === \"MacIntel\" && !lower.includes(\"direct3d\")) || (p.includes(\"Linux\") && !lower.includes(\"direct3d\")) || (p.includes(\"Win\") && lower.includes(\"direct3d\")))); return JSON.stringify({available: !!d, renderer: r, platform: p, ok}); } catch(e) { return JSON.stringify({available:false, renderer:\"\", platform:navigator.platform || \"\", ok:false}); } })()"}'+ if [ "$STEALTH_LEVEL" = "full" ]; then+ webgl_json=$(echo "$RESULT" | jq -r '.result // "{}"')+ webgl_available=$(echo "$webgl_json" | jq -r '.available // false')+ webgl_ok=$(echo "$webgl_json" | jq -r '.ok // false')+ webgl_renderer=$(echo "$webgl_json" | jq -r '.renderer // ""')+ webgl_platform=$(echo "$webgl_json" | jq -r '.platform // ""')+ if [ "$webgl_available" = "true" ]; then+ if [ "$webgl_ok" = "true" ]; then+ echo -e " ${GREEN}✓${NC} WebGL renderer matches platform (${webgl_platform})"+ ((ASSERTIONS_PASSED++)) || true+ else+ echo -e " ${RED}✗${NC} WebGL renderer mismatches platform ${webgl_platform}: ${webgl_renderer}"+ ((ASSERTIONS_FAILED++)) || true+ fi+ else+ echo -e " ${MUTED}(skipped - WEBGL_debug_renderer_info unavailable)${NC}"+ ((ASSERTIONS_PASSED++)) || true+ fi+ else+ echo -e " ${MUTED}(skipped - native WebGL at ${STEALTH_LEVEL} level)${NC}"+ ((ASSERTIONS_PASSED++)) || true+ fi+ end_test++ start_test "stealth-levels: [full] canvas toDataURL modified"+ pt_post /evaluate '{"expression":"typeof HTMLCanvasElement.prototype.toDataURL === \"function\""}'+ assert_json_eq "$RESULT" '.result' 'true' "toDataURL exists"+ end_test++ start_test "stealth-levels: comprehensive score at ${STEALTH_LEVEL} level"+ pt_post /evaluate '{"expression":"JSON.stringify(window.__botDetectScore || {})"}'+ score_json=$(echo "$RESULT" | jq -r '.result // "{}"')+ critical_passed=$(echo "$score_json" | jq -r '.critical // 0')+ critical_total=$(echo "$score_json" | jq -r '.criticalTotal // 0')++ echo -e " ${MUTED}Critical tests: ${critical_passed}/${critical_total}${NC}"++ case "$STEALTH_LEVEL" in+ light)+ [ "$critical_passed" -ge 6 ] && ((ASSERTIONS_PASSED++)) || ((ASSERTIONS_FAILED++))+ ;;+ medium)+ [ "$critical_passed" -ge 10 ] && ((ASSERTIONS_PASSED++)) || ((ASSERTIONS_FAILED++))+ ;;+ full)+ [ "$critical_passed" -ge 12 ] && ((ASSERTIONS_PASSED++)) || ((ASSERTIONS_FAILED++))+ ;;+ esac++ echo -e " ${GREEN}✓${NC} score meets ${STEALTH_LEVEL} level expectations"+ end_test++ E2E_SERVER="$ORIG_URL"+}++if [ "${STEALTH_MATRIX:-0}" = "1" ]; then+ run_stealth_level_matrix+ if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then+ print_summary+ fi+ exit 0+fi++# Adds the heavier heuristics and secure-instance smoke checks on top of the+# baseline coverage in 45-bot-detection.sh.++start_test "bot-detect-full: navigate to test page"++pt_post /navigate "{\"url\":\"${FIXTURES_URL}/bot-detect.html\"}"+assert_ok "navigate"+sleep 1 # Allow stealth.js injection++end_test++# Note: SwiftShader check moved to full stealth instance section below.+# Light/medium levels don't spoof WebGL, so SwiftShader is expected in headless.++start_test "bot-detect-full: outer window dimensions exist"++pt_post /evaluate '{"expression":"window.outerWidth > 0 && window.outerHeight > 0"}'+assert_json_eq "$RESULT" '.result' 'true' "outerWidth/outerHeight > 0"++end_test++start_test "bot-detect-full: hardware concurrency reasonable"++pt_post /evaluate '{"expression":"navigator.hardwareConcurrency >= 2"}'+assert_json_eq "$RESULT" '.result' 'true' "hardwareConcurrency >= 2"++end_test++start_test "bot-detect-full: device memory exists"++pt_post /evaluate '{"expression":"navigator.deviceMemory > 0"}'+assert_json_eq "$RESULT" '.result' 'true' "deviceMemory > 0"++end_test++start_test "bot-detect-full: comprehensive score check"++pt_post /evaluate '{"expression":"JSON.stringify(window.__botDetectScore || {})"}'+score_json=$(echo "$RESULT" | jq -r '.result // "{}"')++pt_post /evaluate '{"expression":"window.__pinchtab_stealth_level || \"light\""}'+stealth_level=$(echo "$RESULT" | jq -r '.result // "light"')++critical_passed=$(echo "$score_json" | jq -r '.critical // 0')+critical_total=$(echo "$score_json" | jq -r '.criticalTotal // 0')++case "$stealth_level" in+ medium|full)+ min_critical="$critical_total"+ ;;+ *)+ # Light intentionally skips connect/csi/loadTimes spoofing.+ min_critical=$((critical_total - 3))+ ;;+esac++echo -e " ${MUTED}Score: critical ${critical_passed}/${critical_total} (${stealth_level})${NC}"++if [ "$critical_passed" -ge "$min_critical" ]; then+ echo -e " ${GREEN}✓${NC} score meets ${stealth_level} expectations"+ ((ASSERTIONS_PASSED++)) || true+else+ echo -e " ${RED}✗${NC} score below ${stealth_level} expectations (${critical_passed}/${critical_total}, need ${min_critical})"+ ((ASSERTIONS_FAILED++)) || true+fi++end_test++FULL_URL="${E2E_FULL_SERVER:-}"+if [ -n "$FULL_URL" ]; then+ echo ""+ echo -e "${BLUE}Testing FULL stealth mode (permissive instance)${NC}"++ ORIG_URL="$E2E_SERVER"+ E2E_SERVER="$FULL_URL"++ start_test "bot-detect-full: can navigate with permissive full stealth"++ pt_post /navigate "{\"url\":\"${FIXTURES_URL}/bot-detect.html\"}"+ assert_ok "navigate to bot-detect fixture (permissive full stealth)"+ sleep 1++ end_test++ start_test "bot-detect-full: permissive full legacy shims are present"++ pt_post /evaluate '{"expression":"typeof window.chrome.csi === \"function\""}'+ assert_json_eq "$RESULT" '.result' 'true' "chrome.csi exists"++ pt_post /evaluate '{"expression":"typeof window.chrome.loadTimes === \"function\""}'+ assert_json_eq "$RESULT" '.result' 'true' "chrome.loadTimes exists"++ end_test++ start_test "bot-detect-full: WebGL not SwiftShader (full stealth spoofs GPU)"++ pt_post /evaluate '{"expression":"(() => { try { const c = document.createElement(\"canvas\"); const gl = c.getContext(\"webgl\"); const d = gl.getExtension(\"WEBGL_debug_renderer_info\"); return gl.getParameter(d.UNMASKED_RENDERER_WEBGL).toLowerCase().includes(\"swiftshader\"); } catch(e) { return false; } })()"}'+ assert_json_eq "$RESULT" '.result' 'false' "WebGL renderer not SwiftShader"++ end_test++ start_test "bot-detect-full: WebGL renderer matches platform when observable"++ pt_post /evaluate '{"expression":"(() => { try { const c = document.createElement(\"canvas\"); const gl = c.getContext(\"webgl\"); const d = gl && gl.getExtension(\"WEBGL_debug_renderer_info\"); const r = d ? gl.getParameter(d.UNMASKED_RENDERER_WEBGL) : \"\"; const p = navigator.platform || \"\"; const lower = r.toLowerCase(); const ok = !d || (!lower.includes(\"swiftshader\") && ((p === \"MacIntel\" && !lower.includes(\"direct3d\")) || (p.includes(\"Linux\") && !lower.includes(\"direct3d\")) || (p.includes(\"Win\") && lower.includes(\"direct3d\")))); return JSON.stringify({available: !!d, renderer: r, platform: p, ok}); } catch(e) { return JSON.stringify({available:false, renderer:\"\", platform:navigator.platform || \"\", ok:false}); } })()"}'+ webgl_json=$(echo "$RESULT" | jq -r '.result // "{}"')+ webgl_available=$(echo "$webgl_json" | jq -r '.available // false')+ webgl_ok=$(echo "$webgl_json" | jq -r '.ok // false')+ webgl_renderer=$(echo "$webgl_json" | jq -r '.renderer // ""')+ webgl_platform=$(echo "$webgl_json" | jq -r '.platform // ""')+ if [ "$webgl_available" = "true" ]; then+ if [ "$webgl_ok" = "true" ]; then+ echo -e " ${GREEN}✓${NC} WebGL renderer matches platform (${webgl_platform})"+ ((ASSERTIONS_PASSED++)) || true+ else+ echo -e " ${RED}✗${NC} WebGL renderer mismatches platform ${webgl_platform}: ${webgl_renderer}"+ ((ASSERTIONS_FAILED++)) || true+ fi+ else+ echo -e " ${MUTED}(skipped - WEBGL_debug_renderer_info unavailable)${NC}"+ ((ASSERTIONS_PASSED++)) || true+ fi++ end_test++ start_test "bot-detect-full: permissive full score check"++ pt_post /evaluate '{"expression":"JSON.stringify(window.__botDetectScore || {})"}'+ score_json=$(echo "$RESULT" | jq -r '.result // "{}"')+ critical_passed=$(echo "$score_json" | jq -r '.critical // 0')+ critical_total=$(echo "$score_json" | jq -r '.criticalTotal // 0')++ echo -e " ${MUTED}Score: critical ${critical_passed}/${critical_total} (full)${NC}"++ if [ "$critical_passed" -ge "$critical_total" ]; then+ echo -e " ${GREEN}✓${NC} score meets full expectations"+ ((ASSERTIONS_PASSED++)) || true+ else+ echo -e " ${RED}✗${NC} score below full expectations (${critical_passed}/${critical_total})"+ ((ASSERTIONS_FAILED++)) || true+ fi++ end_test++ E2E_SERVER="$ORIG_URL"+fi++echo ""+echo -e "${BLUE}Testing FULL stealth mode (restrictive instance)${NC}"+echo -e "${YELLOW}Note: evaluate disabled on restrictive instance, testing navigation only${NC}"++ORIG_URL="$E2E_SERVER"+E2E_SERVER="$E2E_SECURE_SERVER"++start_test "bot-detect-full: can navigate with full stealth"++pt_post /navigate "{\"url\":\"${FIXTURES_URL}/bot-detect.html\"}"+assert_ok "navigate to bot-detect fixture (full stealth)"++TAB_ID=$(echo "$RESULT" | jq -r '.tabId // empty')+if [ -n "$TAB_ID" ]; then+ echo -e " ${GREEN}✓${NC} Got tabId: $TAB_ID"+ ((ASSERTIONS_PASSED++)) || true+else+ echo -e " ${RED}✗${NC} No tabId in response"+ ((ASSERTIONS_FAILED++)) || true+fi++end_test++start_test "bot-detect-full: page title loaded correctly"++TITLE=$(echo "$RESULT" | jq -r '.title // empty')+if [ "$TITLE" = "Bot Detection Tests" ]; then+ echo -e " ${GREEN}✓${NC} Page title: $TITLE"+ ((ASSERTIONS_PASSED++)) || true+else+ echo -e " ${YELLOW}⚠${NC} Unexpected title: $TITLE"+fi++end_test++E2E_SERVER="$ORIG_URL"++if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then+ print_summary+fidiff --git a/tests/e2e/scenarios-api/system-basic.sh b/tests/e2e/scenarios-api/system-basic.shnew file mode 100644index 00000000..ff1a7b33--- /dev/null+++ b/tests/e2e/scenarios-api/system-basic.sh@@ -0,0 +1,268 @@+#!/bin/bash+# system-basic.sh — API config and observability happy-path scenarios.++GROUP_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"+source "${GROUP_DIR}/../helpers/api.sh"++# CF7: Chrome version in user agent++start_test "config: Chrome version in user agent"++pt_post /navigate '{"url":"about:blank"}'+assert_ok "navigate"+TAB_ID=$(echo "$RESULT" | jq -r '.tabId')++pt_post /evaluate "{\"tabId\":\"$TAB_ID\",\"expression\":\"navigator.userAgent\"}"+assert_ok "evaluate UA"+UA=$(echo "$RESULT" | jq -r '.result')++if echo "$UA" | grep -qE '(Headless)?Chrome/[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+'; then+ CHROME_VERSION=$(echo "$UA" | grep -oE '(Headless)?Chrome/[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+')+ echo -e " ${GREEN}✓${NC} UA contains Chrome version: $CHROME_VERSION"+ ((ASSERTIONS_PASSED++)) || true+else+ echo -e " ${RED}✗${NC} UA missing Chrome version: $UA"+ ((ASSERTIONS_FAILED++)) || true+fi++pt_post /tab "{\"tabId\":\"$TAB_ID\",\"action\":\"close\"}" >/dev/null 2>&1++end_test++# CF8: Fingerprint rotation preserves Chrome version++start_test "config: fingerprint rotation preserves Chrome version"++pt_post /navigate "{\"url\":\"${FIXTURES_URL}/index.html\"}"+assert_ok "navigate"+TAB_ID=$(echo "$RESULT" | jq -r '.tabId')++pt_post /evaluate "{\"tabId\":\"$TAB_ID\",\"expression\":\"navigator.userAgent\"}"+assert_ok "initial UA"+INITIAL_UA=$(echo "$RESULT" | jq -r '.result')+INITIAL_VERSION=$(echo "$INITIAL_UA" | grep -oE 'Chrome/[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+' | head -1)++if [ -z "$INITIAL_VERSION" ]; then+ echo -e " ${RED}✗${NC} initial UA missing Chrome version"+ ((ASSERTIONS_FAILED++)) || true+else+ echo -e " ${GREEN}✓${NC} initial version: $INITIAL_VERSION"+ ((ASSERTIONS_PASSED++)) || true+fi++pt_post /fingerprint/rotate "{\"os\":\"mac\",\"tabId\":\"$TAB_ID\"}"+assert_ok "fingerprint rotate"++pt_post /evaluate "{\"tabId\":\"$TAB_ID\",\"expression\":\"navigator.userAgent\"}"+assert_ok "rotated UA"+ROTATED_UA=$(echo "$RESULT" | jq -r '.result')+ROTATED_VERSION=$(echo "$ROTATED_UA" | grep -oE 'Chrome/[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+' | head -1)++if [ "$INITIAL_VERSION" = "$ROTATED_VERSION" ]; then+ echo -e " ${GREEN}✓${NC} Chrome version preserved after rotation: $ROTATED_VERSION"+ ((ASSERTIONS_PASSED++)) || true+else+ echo -e " ${RED}✗${NC} Chrome version changed: $INITIAL_VERSION → $ROTATED_VERSION"+ ((ASSERTIONS_FAILED++)) || true+fi++pt_post /tab "{\"tabId\":\"$TAB_ID\",\"action\":\"close\"}" >/dev/null 2>&1++end_test++# CF1: Config file loading (server started successfully)++start_test "config: server loads config file and starts"++pt_post /navigate "{\"url\":\"${FIXTURES_URL}/index.html\"}"+assert_ok "navigate"+TAB_ID=$(echo "$RESULT" | jq -r '.tabId')++pt_post /evaluate "{\"tabId\":\"$TAB_ID\",\"expression\":\"document.title\"}"+assert_ok "evaluate"+assert_json_exists "$RESULT" ".result" "got title result"++pt_post /tab "{\"tabId\":\"$TAB_ID\",\"action\":\"close\"}" >/dev/null 2>&1++end_test++# CF2: Config file port is used (server runs on port from config)++start_test "config: server uses port from config file"++# The server is running on port 9999 from config file.+# Verifies config is loaded correctly.+pt_post /navigate "{\"url\":\"${FIXTURES_URL}/index.html\"}"+assert_ok "navigate (proves env port override works)"++TAB_ID=$(echo "$RESULT" | jq -r '.tabId')+pt_post /evaluate "{\"tabId\":\"$TAB_ID\",\"expression\":\"window.location.href\"}"+assert_ok "evaluate"+assert_json_exists "$RESULT" ".result" "got location result"++pt_post /tab "{\"tabId\":\"$TAB_ID\",\"action\":\"close\"}" >/dev/null 2>&1++end_test++# ─────────────────────────────────────────────────────────────────+start_test "GET /api/activity — records tab-scoped requests"++pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/buttons.html\"}"+TAB_ID=$(get_tab_id)++pt_get "/tabs/${TAB_ID}/snapshot"+assert_ok "tab snapshot succeeded"++pt_post "/tabs/${TAB_ID}/action" -d '{"kind":"click","selector":"#increment"}'+assert_http_status "200" "click action succeeded"++pt_get "/api/activity?tabId=${TAB_ID}&limit=100&ageSec=300"+assert_ok "activity query"+assert_json_exists "$RESULT" '.events' "events array present"+assert_result_has_tab_event \+ "$TAB_ID" \+ "/tabs/${TAB_ID}/snapshot" \+ "tab snapshot event recorded" \+ "missing tab snapshot event for tab ${TAB_ID}"+assert_result_has_tab_event \+ "$TAB_ID" \+ "/tabs/${TAB_ID}/action" \+ "tab action event recorded" \+ "missing tab action event for tab ${TAB_ID}"++end_test++# Test: Browser extension loading+# Verifies that extension paths reach Chrome startup reliably in CI.++ORCH_URL=$E2E_SERVER+ORIG_URL=$E2E_SERVER++assert_instance_logs_poll() {+ local inst_id="$1"+ local needle="$2"+ local desc="$3"+ local attempts="${4:-15}"+ local delay="${5:-1}"++ local i+ for i in $(seq 1 "$attempts"); do+ E2E_SERVER=$ORCH_URL pt_get "/instances/${inst_id}/logs" >/dev/null+ if [[ "$HTTP_STATUS" =~ ^2 ]] && echo "$RESULT" | grep -Fq "$needle"; then+ echo -e " ${GREEN}✓${NC} $desc"+ ((ASSERTIONS_PASSED++)) || true+ return 0+ fi+ sleep "$delay"+ done++ echo -e " ${RED}✗${NC} $desc (missing: $needle)"+ ((ASSERTIONS_FAILED++)) || true+ return 1+}++print_extension_hints() {+ local inst_id="${1:-}"+ echo ""+ echo " ${YELLOW}${BOLD}🔍 Troubleshooting Extension Failure:${NC}"+ echo " - Check if /extensions/test-extension exists and is readable in the pinchtab container."+ echo " - Check Manifest V3 host_permissions matches: [\"*://*/*\"]"+ if [ -n "$inst_id" ]; then+ E2E_SERVER=$ORCH_URL pt_get "/instances/${inst_id}/logs" >/dev/null+ echo " - Recent instance log tail:"+ printf '%s\n' "$RESULT" | tail -n 12 | sed 's/^/ /'+ fi+ echo ""+}++# --- T1: Default instance loads configured extension path ---+start_test "Extension config: default instance loads configured extension path"++pt_get /health+assert_ok "health"+DEFAULT_INST_ID=$(echo "$RESULT" | jq -r '.defaultInstance.id // empty')+if [ -n "$DEFAULT_INST_ID" ] && [ "$DEFAULT_INST_ID" != "null" ]; then+ echo -e " ${GREEN}✓${NC} default instance present: ${DEFAULT_INST_ID}"+ ((ASSERTIONS_PASSED++)) || true+else+ echo -e " ${RED}✗${NC} default instance present"+ ((ASSERTIONS_FAILED++)) || true+fi++pt_post /navigate "{\"url\":\"${FIXTURES_URL}/index.html\"}"+assert_ok "navigate"++DEFAULT_LOG_PASS=1+if [ -n "$DEFAULT_INST_ID" ] && [ "$DEFAULT_INST_ID" != "null" ]; then+ assert_instance_logs_poll \+ "$DEFAULT_INST_ID" \+ "loading extensions paths=/extensions/test-extension" \+ "default instance logs configured extension path"+ DEFAULT_LOG_PASS=$?++ assert_instance_logs_poll \+ "$DEFAULT_INST_ID" \+ "chrome initialized successfully" \+ "default instance chrome initialized"+fi++if [ $DEFAULT_LOG_PASS -ne 0 ]; then+ print_extension_hints "$DEFAULT_INST_ID"+ # Debug: dump full instance logs for analysis+ echo " ${YELLOW}📋 Full instance logs:${NC}"+ E2E_SERVER=$ORCH_URL pt_get "/instances/${DEFAULT_INST_ID}/logs" >/dev/null+ printf '%s\n' "$RESULT" | head -30 | sed 's/^/ /'+fi++end_test++# --- T2: Instance start with extension via API ---+start_test "Extension config: instance start accepts extensionPaths"++pt_post /instances/start '{"extensionPaths":["/extensions/test-extension"]}'+assert_ok "instance start with extension"+INST_ID=$(echo "$RESULT" | jq -r '.id')+INST_PORT=$(echo "$RESULT" | jq -r '.port')+E2E_SERVER="http://pinchtab:${INST_PORT}"+wait_for_instance_ready "${E2E_SERVER}"+E2E_SERVER=$ORIG_URL++assert_instance_logs_poll \+ "$INST_ID" \+ "loading extensions paths=/extensions/test-extension" \+ "API-started instance logs extension path"++end_test++# --- T3: Global + API injected extensions (Additive) ---+start_test "Additive extensions: global + API paths merged"++pt_post /instances/start '{"extensionPaths":["/extensions/test-extension-api"]}'+assert_ok "instance start"+INST_ID=$(echo "$RESULT" | jq -r '.id')+INST_PORT=$(echo "$RESULT" | jq -r '.port')++E2E_SERVER="http://pinchtab:${INST_PORT}"++wait_for_instance_ready "${E2E_SERVER}"++pt_post /navigate "{\"url\":\"${FIXTURES_URL}/index.html\"}"+assert_ok "navigate"+assert_instance_logs_poll \+ "$INST_ID" \+ "loading extensions paths=/extensions/test-extension,/extensions/test-extension-api" \+ "child instance logs merged extension paths"+MERGE_PASS=$?++assert_instance_logs_poll \+ "$INST_ID" \+ "chrome initialized successfully" \+ "child instance chrome initialized"++if [ $MERGE_PASS -ne 0 ]; then+ print_extension_hints "$INST_ID"+fi++E2E_SERVER=$ORIG_URL++end_testdiff --git a/tests/e2e/scenarios-api/system-full.sh b/tests/e2e/scenarios-api/system-full.shnew file mode 100644index 00000000..1df7d2f2--- /dev/null+++ b/tests/e2e/scenarios-api/system-full.sh@@ -0,0 +1,682 @@+#!/bin/bash+# system-full.sh — API advanced config and platform scenarios.++GROUP_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"+source "${GROUP_DIR}/../helpers/api.sh"++# Migrated from: tests/integration/metrics_test.go++# ─────────────────────────────────────────────────────────────────+start_test "GET /instances/metrics"++pt_post /navigate "{\"url\":\"${FIXTURES_URL}/index.html\"}"+assert_ok "navigate"++pt_get "/instances/metrics"+assert_ok "get instance metrics"+assert_json_exists "$RESULT" '.[0].instanceId'+assert_json_exists "$RESULT" '.[0].jsHeapUsedMB'++end_test++# ─────────────────────────────────────────────────────────────────+start_test "GET /tabs/{id}/metrics"++pt_post /navigate "{\"url\":\"${FIXTURES_URL}/form.html\"}"+assert_ok "navigate"+TAB_ID=$(get_tab_id)++pt_get "/tabs/${TAB_ID}/metrics"+assert_ok "get tab metrics"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "GET /tabs/{invalid}/metrics → 404"++pt_get "/tabs/invalid_tab_id/metrics"+assert_http_status "404" "unknown tab metrics return 404"+assert_contains "$RESULT" "not found" "unknown tab metrics reports not found"++end_test++# Migrated from: tests/integration/profile_rename_test.go + security_profiles_test.go++# ─────────────────────────────────────────────────────────────────+start_test "profile: create + rename + verify"++pt_post /profiles/create '{"name":"e2e-rename-test"}'+assert_ok "create profile"+ORIG_ID=$(echo "$RESULT" | jq -r '.id')++pt_patch "/profiles/${ORIG_ID}" '{"name":"e2e-rename-test-renamed"}'+assert_ok "rename profile"+NEW_ID=$(echo "$RESULT" | jq -r '.id')+assert_json_eq "$RESULT" '.name' 'e2e-rename-test-renamed'++pt_get "/profiles/${NEW_ID}"+assert_ok "get by new ID"++pt_get "/profiles/${ORIG_ID}"+assert_not_ok "old ID returns error"++pt_delete "/profiles/${NEW_ID}"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "profile: PATCH requires ID (not name)"++pt_post /profiles/create '{"name":"e2e-patch-by-name"}'+assert_ok "create"+PATCH_ID=$(echo "$RESULT" | jq -r '.id')++pt_patch "/profiles/e2e-patch-by-name" '{"name":"new-name"}'+assert_http_status "404" "PATCH by name rejected"++pt_delete "/profiles/${PATCH_ID}"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "profile: DELETE requires ID (not name)"++pt_post /profiles/create '{"name":"e2e-delete-by-name"}'+assert_ok "create"+DEL_ID=$(echo "$RESULT" | jq -r '.id')++pt_delete "/profiles/e2e-delete-by-name"+assert_http_status "404" "DELETE by name rejected"++pt_delete "/profiles/${DEL_ID}"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "profile: rename conflict → 409"++pt_post /profiles/create '{"name":"e2e-conflict-a"}'+assert_ok "create A"+ID_A=$(echo "$RESULT" | jq -r '.id')++pt_post /profiles/create '{"name":"e2e-conflict-b"}'+assert_ok "create B"+ID_B=$(echo "$RESULT" | jq -r '.id')++pt_patch "/profiles/${ID_A}" '{"name":"e2e-conflict-b"}'+assert_http_status "409" "conflict on duplicate name"++pt_delete "/profiles/${ID_A}"+pt_delete "/profiles/${ID_B}"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "profile: path traversal rejected"++pt_post /profiles/create '{"name":"e2e-traversal"}'+assert_ok "create"+TRAV_ID=$(echo "$RESULT" | jq -r '.id')++pt_patch "/profiles/${TRAV_ID}" '{"name":"../etc/passwd"}'+assert_not_ok "rejects path traversal"++pt_patch "/profiles/${TRAV_ID}" '{"name":"foo/../../../bar"}'+assert_not_ok "rejects nested traversal"++pt_delete "/profiles/${TRAV_ID}"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "profile: empty name rejected"++pt_post /profiles/create '{"name":""}'+assert_not_ok "rejects empty name"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "profile: path separator rejected"++pt_post /profiles/create '{"name":"profile/subdir"}'+assert_not_ok "rejects forward slash"++pt_post /profiles/create '{"name":"dir\\myprofile"}'+assert_not_ok "rejects backslash"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "profile: valid names accepted"++for NAME in "e2e-valid-1" "e2e_valid_2" "e2eVALID3"; do+ pt_post /profiles/create "{\"name\":\"${NAME}\"}"+ assert_ok "create $NAME"+ VALID_ID=$(echo "$RESULT" | jq -r '.id')+ pt_delete "/profiles/${VALID_ID}"+done++end_test++# ─────────────────────────────────────────────────────────────────+start_test "profile reset"++pt_post /profiles -d '{"name":"reset-test-profile"}'+assert_ok "create profile for reset"+PROFILE_ID=$(echo "$RESULT" | jq -r '.id')++pt_post "/profiles/${PROFILE_ID}/reset" ""+assert_ok "reset profile"++pt_delete "/profiles/${PROFILE_ID}"++end_test++# Tests content-based IDPI scanning:+# - E2E_SERVER (main): IDPI enabled, scanContent=true (default), warn mode+# - E2E_SECURE_SERVER (secure): IDPI enabled, strictMode=true++# ─────────────────────────────────────────────────────────────────+# ─────────────────────────────────────────────────────────────────++# Usage: TAB_ID=$(idpi_setup <base_url> <page_url>)+idpi_setup() {+ local base_url="$1" page_url="$2"+ local old_url="$E2E_SERVER"+ E2E_SERVER="$base_url"+ pt_post /navigate "{\"url\":\"$page_url\"}" >/dev/null+ E2E_SERVER="$old_url"+ sleep 1+ echo "$RESULT" | jq -r '.tabId'+}++idpi_cleanup() {+ local base_url="$1" tab_id="$2"+ curl -sf -X POST "${base_url}/tab" \+ -H "Content-Type: application/json" \+ -d "{\"tabId\":\"$tab_id\",\"action\":\"close\"}" >/dev/null 2>&1 || true+}++# Usage: idpi_request POST <base_url> <path> <body> <header_name>+# idpi_request GET <base_url> <path> "" <header_name>+# Sets: RESULT, HTTP_STATUS, HDR_VALUE+idpi_request() {+ local method="$1" base_url="$2" path="$3" body="$4" header_name="$5"+ echo -e "${BLUE}→ curl -X $method ${base_url}${path}${NC}" >&2+ local tmpheaders=$(mktemp)+ local curl_args=(-s -w "\n%{http_code}" -X "$method" "${base_url}${path}" -H "Content-Type: application/json" -D "$tmpheaders")+ [ -n "$body" ] && curl_args+=(-d "$body")+ local response+ response=$(curl "${curl_args[@]}")+ RESULT=$(echo "$response" | head -n -1)+ HTTP_STATUS=$(echo "$response" | tail -n 1)+ HDR_VALUE=$(grep -i "^${header_name}:" "$tmpheaders" | sed 's/^[^:]*: *//' | tr -d '\r' | head -1)+ rm -f "$tmpheaders"+}++assert_header_present() {+ local desc="$1"+ if [ -n "$HDR_VALUE" ]; then+ echo -e " ${GREEN}✓${NC} $desc: $HDR_VALUE"+ ((ASSERTIONS_PASSED++)) || true+ else+ echo -e " ${RED}✗${NC} $desc (header missing)"+ ((ASSERTIONS_FAILED++)) || true+ fi+}++assert_header_absent() {+ local desc="$1"+ if [ -z "$HDR_VALUE" ]; then+ echo -e " ${GREEN}✓${NC} $desc"+ ((ASSERTIONS_PASSED++)) || true+ else+ echo -e " ${RED}✗${NC} $desc (unexpected: $HDR_VALUE)"+ ((ASSERTIONS_FAILED++)) || true+ fi+}++FIND_BODY='{"query":"continue button","threshold":0.1,"topK":5}'+FIND_CLEAN='{"query":"safe action button","threshold":0.1,"topK":5}'++# /find — WARN MODE (main instance)++start_test "idpi: /find clean page — no warning (warn mode)"+TAB_ID=$(idpi_setup "$E2E_SERVER" "${FIXTURES_URL}/idpi-clean.html")+idpi_request POST "$E2E_SERVER" "/tabs/${TAB_ID}/find" "$FIND_CLEAN" "X-IDPI-Warning"+assert_ok "/find clean page"+assert_header_absent "no X-IDPI-Warning on clean page"+idpi_cleanup "$E2E_SERVER" "$TAB_ID"+end_test++# ─────────────────────────────────────────────────────────────────+start_test "idpi: /find injection page — warns (warn mode)"+TAB_ID=$(idpi_setup "$E2E_SERVER" "${FIXTURES_URL}/idpi-inject.html")+idpi_request POST "$E2E_SERVER" "/tabs/${TAB_ID}/find" "$FIND_BODY" "X-IDPI-Warning"+assert_ok "/find injection (warn mode returns 200)"+assert_header_present "X-IDPI-Warning header present"+assert_json_exists "$RESULT" ".idpiWarning" "idpiWarning field in body"+idpi_cleanup "$E2E_SERVER" "$TAB_ID"+end_test++# ─────────────────────────────────────────────────────────────────+start_test "idpi: POST /find injection — warns (warn mode)"+TAB_ID=$(idpi_setup "$E2E_SERVER" "${FIXTURES_URL}/idpi-inject.html")+idpi_request POST "$E2E_SERVER" "/find" "{\"query\":\"malicious paragraph\",\"tabId\":\"$TAB_ID\",\"threshold\":0.1}" "X-IDPI-Warning"+assert_ok "POST /find (warn mode)"+assert_header_present "X-IDPI-Warning on POST /find"+idpi_cleanup "$E2E_SERVER" "$TAB_ID"+end_test++# /find — STRICT MODE (secure instance)++start_test "idpi: /find clean page — allowed (strict mode)"+TAB_ID=$(idpi_setup "$E2E_SECURE_SERVER" "${FIXTURES_URL}/idpi-clean.html")+idpi_request POST "$E2E_SECURE_SERVER" "/tabs/${TAB_ID}/find" "$FIND_CLEAN" "X-IDPI-Warning"+assert_ok "/find clean page (strict mode)"+idpi_cleanup "$E2E_SECURE_SERVER" "$TAB_ID"+end_test++# ─────────────────────────────────────────────────────────────────+start_test "idpi: /find injection page — blocked (strict mode)"+TAB_ID=$(idpi_setup "$E2E_SECURE_SERVER" "${FIXTURES_URL}/idpi-inject.html")+idpi_request POST "$E2E_SECURE_SERVER" "/tabs/${TAB_ID}/find" "$FIND_BODY" "X-IDPI-Warning"+assert_http_status 403 "/find blocked in strict mode"+assert_contains "$RESULT" "idpi" "403 body mentions IDPI"+idpi_cleanup "$E2E_SECURE_SERVER" "$TAB_ID"+end_test++# /pdf — WARN MODE (main instance)++start_test "idpi: /pdf clean page — no warning (warn mode)"+TAB_ID=$(idpi_setup "$E2E_SERVER" "${FIXTURES_URL}/idpi-clean.html")+idpi_request GET "$E2E_SERVER" "/tabs/${TAB_ID}/pdf" "" "X-IDPI-Warning"+assert_ok "/pdf clean page"+assert_header_absent "no X-IDPI-Warning on clean PDF"+idpi_cleanup "$E2E_SERVER" "$TAB_ID"+end_test++# ─────────────────────────────────────────────────────────────────+start_test "idpi: /pdf injection page — warns (warn mode)"+TAB_ID=$(idpi_setup "$E2E_SERVER" "${FIXTURES_URL}/idpi-inject.html")+idpi_request GET "$E2E_SERVER" "/tabs/${TAB_ID}/pdf" "" "X-IDPI-Warning"+assert_ok "/pdf injection (warn mode returns 200)"+assert_header_present "X-IDPI-Warning on injection PDF"+idpi_cleanup "$E2E_SERVER" "$TAB_ID"+end_test++# /pdf — STRICT MODE (secure instance)++start_test "idpi: /pdf clean page — allowed (strict mode)"+TAB_ID=$(idpi_setup "$E2E_SECURE_SERVER" "${FIXTURES_URL}/idpi-clean.html")+idpi_request GET "$E2E_SECURE_SERVER" "/tabs/${TAB_ID}/pdf" "" "X-IDPI-Warning"+assert_ok "/pdf clean page (strict mode)"+idpi_cleanup "$E2E_SECURE_SERVER" "$TAB_ID"+end_test++# ─────────────────────────────────────────────────────────────────+start_test "idpi: /pdf injection page — blocked (strict mode)"+TAB_ID=$(idpi_setup "$E2E_SECURE_SERVER" "${FIXTURES_URL}/idpi-inject.html")+idpi_request GET "$E2E_SECURE_SERVER" "/tabs/${TAB_ID}/pdf" "" "X-IDPI-Warning"+assert_http_status 403 "/pdf blocked in strict mode"+assert_contains "$RESULT" "idpi" "403 body mentions IDPI"+idpi_cleanup "$E2E_SECURE_SERVER" "$TAB_ID"+end_test++start_test "idpi: multiple injection phrases — single warning header"+TAB_ID=$(idpi_setup "$E2E_SERVER" "${FIXTURES_URL}/idpi-inject.html")+tmpheaders=$(mktemp)+curl -s -X POST "${E2E_SERVER}/tabs/${TAB_ID}/find" \+ -H "Content-Type: application/json" \+ -D "$tmpheaders" \+ -d "$FIND_BODY" >/dev/null+HDR_COUNT=$(grep -ci "^X-IDPI-Warning:" "$tmpheaders" 2>/dev/null || echo "0")+rm -f "$tmpheaders"+if [ "$HDR_COUNT" -eq 1 ]; then+ echo -e " ${GREEN}✓${NC} exactly one X-IDPI-Warning header"+ ((ASSERTIONS_PASSED++)) || true+else+ echo -e " ${RED}✗${NC} expected 1 X-IDPI-Warning, got $HDR_COUNT"+ ((ASSERTIONS_FAILED++)) || true+fi+idpi_cleanup "$E2E_SERVER" "$TAB_ID"+end_test++# ─────────────────────────────────────────────────────────────────+start_test "idpi: /pdf?raw=true blocked in strict mode"+TAB_ID=$(idpi_setup "$E2E_SECURE_SERVER" "${FIXTURES_URL}/idpi-inject.html")+idpi_request GET "$E2E_SECURE_SERVER" "/tabs/${TAB_ID}/pdf?raw=true" "" "X-IDPI-Warning"+assert_http_status 403 "raw PDF blocked in strict mode"+idpi_cleanup "$E2E_SECURE_SERVER" "$TAB_ID"+end_test++AGENT="test-agent-$$"++pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/index.html\"}"+TAB_ID=$(echo "$RESULT" | jq -r '.tabId')++# ─────────────────────────────────────────────────────────────────+start_test "POST /tasks — submit task"++pt_post /tasks -d "{\"agentId\":\"${AGENT}\",\"action\":\"snapshot\",\"tabId\":\"${TAB_ID}\"}"+assert_http_status "202" "task accepted"+TASK_ID=$(echo "$RESULT" | jq -r '.taskId')+assert_json_eq "$RESULT" ".state" "queued" "initial state is queued"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "GET /tasks/{id} — get task"++sleep 2+pt_get "/tasks/${TASK_ID}"+assert_ok "get task by id"+assert_json_eq "$RESULT" ".taskId" "$TASK_ID" "correct task id"+assert_json_eq "$RESULT" ".agentId" "$AGENT" "correct agent id"+assert_json_eq "$RESULT" ".action" "snapshot" "correct action"+STATE=$(echo "$RESULT" | jq -r '.state')+if [ "$STATE" = "completed" ] || [ "$STATE" = "running" ] || [ "$STATE" = "failed" ]; then+ echo -e " ${GREEN}✓${NC} task reached terminal/active state: $STATE"+ ((ASSERTIONS_PASSED++)) || true+else+ echo -e " ${RED}✗${NC} unexpected state: $STATE"+ ((ASSERTIONS_FAILED++)) || true+fi++end_test++# ─────────────────────────────────────────────────────────────────+start_test "GET /tasks — list tasks"++pt_get "/tasks?agentId=${AGENT}"+assert_ok "list tasks"+COUNT=$(echo "$RESULT" | jq '.count')+if [ "$COUNT" -ge 1 ]; then+ echo -e " ${GREEN}✓${NC} found $COUNT tasks for agent"+ ((ASSERTIONS_PASSED++)) || true+else+ echo -e " ${RED}✗${NC} expected at least 1 task, got $COUNT"+ ((ASSERTIONS_FAILED++)) || true+fi++end_test++# ─────────────────────────────────────────────────────────────────+start_test "GET /tasks — filter by state"++pt_get "/tasks?state=completed,failed"+assert_ok "list terminal tasks"+assert_json_exists "$RESULT" '.tasks' "tasks array present in response"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "POST /tasks/{id}/cancel — cancel queued task"++pt_post /tasks -d "{\"agentId\":\"${AGENT}\",\"action\":\"snapshot\",\"tabId\":\"${TAB_ID}\"}"+assert_http_status "202" "task accepted for cancel test"+CANCEL_ID=$(echo "$RESULT" | jq -r '.taskId')++pt_post "/tasks/${CANCEL_ID}/cancel" ""+if [ "$HTTP_STATUS" = "200" ]; then+ assert_json_eq "$RESULT" ".status" "cancelled" "task cancelled"+elif [ "$HTTP_STATUS" = "409" ]; then+ echo -e " ${GREEN}✓${NC} task already terminal (409 conflict, acceptable)"+ ((ASSERTIONS_PASSED++)) || true+else+ echo -e " ${RED}✗${NC} unexpected status: $HTTP_STATUS"+ ((ASSERTIONS_FAILED++)) || true+fi++end_test++# ─────────────────────────────────────────────────────────────────+start_test "POST /tasks/{id}/cancel — cancel nonexistent → 404"++pt_post "/tasks/tsk_nonexistent/cancel" ""+assert_http_status "404" "cancel nonexistent task"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "GET /scheduler/stats"++pt_get /scheduler/stats+assert_ok "stats endpoint"+assert_json_exists "$RESULT" '.queue' "has queue stats"+assert_json_exists "$RESULT" '.metrics' "has metrics"+assert_json_eq "$RESULT" ".config.strategy" "fair-fifo" "strategy is fair-fifo"+assert_json_eq "$RESULT" ".config.maxQueueSize" "5" "maxQueueSize matches config"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "POST /tasks/batch — submit 3 tasks"++pt_post /tasks/batch -d "{\"agentId\":\"${AGENT}\",\"tasks\":[{\"action\":\"snapshot\",\"tabId\":\"${TAB_ID}\"},{\"action\":\"text\",\"tabId\":\"${TAB_ID}\"},{\"action\":\"screenshot\",\"tabId\":\"${TAB_ID}\"}]}"+assert_http_status "202" "batch accepted"+SUBMITTED=$(echo "$RESULT" | jq '.submitted')+if [ "$SUBMITTED" = "3" ]; then+ echo -e " ${GREEN}✓${NC} all 3 tasks submitted"+ ((ASSERTIONS_PASSED++)) || true+else+ echo -e " ${RED}✗${NC} expected 3 submitted, got $SUBMITTED"+ ((ASSERTIONS_FAILED++)) || true+fi++end_test++# ─────────────────────────────────────────────────────────────────+start_test "POST /tasks/batch — validation: empty tasks"++pt_post /tasks/batch -d '{"agentId":"test","tasks":[]}'+assert_http_status "400" "empty batch rejected"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "POST /tasks/batch — validation: missing agentId"++pt_post /tasks/batch -d '{"tasks":[{"action":"snapshot"}]}'+assert_http_status "400" "missing agentId rejected"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "POST /tasks — deadline in the past → 400"++pt_post /tasks -d "{\"agentId\":\"${AGENT}\",\"action\":\"snapshot\",\"tabId\":\"${TAB_ID}\",\"deadline\":\"2020-01-01T00:00:00Z\"}"+assert_http_status "400" "past deadline rejected"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "POST /tasks — 429 queue full"++# maxPerAgent is 3, submit rapidly for a fresh agent+FLOOD_AGENT="flood-agent-$$"+for i in $(seq 1 4); do+ pt_post /tasks -d "{\"agentId\":\"${FLOOD_AGENT}\",\"action\":\"snapshot\",\"tabId\":\"${TAB_ID}\"}"+done+if [ "$HTTP_STATUS" = "429" ]; then+ echo -e " ${GREEN}✓${NC} queue full for agent (HTTP 429)"+ ((ASSERTIONS_PASSED++)) || true+elif [ "$HTTP_STATUS" = "202" ]; then+ echo -e " ${GREEN}✓${NC} task accepted (tasks completed before limit hit)"+ ((ASSERTIONS_PASSED++)) || true+else+ echo -e " ${RED}✗${NC} unexpected status: $HTTP_STATUS (expected 429 or 202)"+ ((ASSERTIONS_FAILED++)) || true+fi++end_test++# ─────────────────────────────────────────────────────────────────+start_test "GET /tasks/{id} — nonexistent → 404"++pt_get /tasks/tsk_doesnotexist+assert_http_status "404" "nonexistent task"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "POST /tasks — missing agentId → 400"++pt_post /tasks -d '{"action":"snapshot"}'+assert_http_status "400" "missing agentId rejected"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "POST /tasks — missing action → 400"++pt_post /tasks -d "{\"agentId\":\"validation-agent-$$\"}"+assert_http_status "400" "missing action rejected"++end_test++# Test: Lite engine (no Chrome, DOM-only)++LITE_URL="${E2E_LITE_SERVER:-}"+if [ -z "$LITE_URL" ]; then+ echo " ⚠️ E2E_LITE_SERVER not set, skipping lite engine tests"+ return 0 2>/dev/null || exit 0+fi++lite() {+ local method="$1"+ local path="$2"+ shift 2+ echo -e "${BLUE}→ curl -X $method ${LITE_URL}$path $(printf "%q " "$@")${NC}" >&2+ local response+ response=$(curl -s -w "\n%{http_code}" \+ -X "$method" \+ "${LITE_URL}${path}" \+ -H "Content-Type: application/json" \+ "$@")+ HTTP_STATUS=$(echo "$response" | tail -1)+ RESULT=$(echo "$response" | sed '$d')+ _echo_truncated+}++lite_get() { lite GET "$1"; }+lite_post() { lite POST "$1" -d "$2"; }++# --- T1: Health check ---+start_test "Lite engine: health check"+lite_get /health+assert_ok "lite health"+end_test++# --- T2: Navigate returns tab ID ---+start_test "Lite engine: navigate returns tabId"+lite_post /navigate "{\"url\":\"${FIXTURES_URL}/index.html\"}"+assert_ok "lite navigate"+TAB_ID=$(echo "$RESULT" | jq -r '.tabId // empty')+if [ -n "$TAB_ID" ]; then+ echo -e " ${GREEN}✓${NC} navigate returned tabId=$TAB_ID"+ ((ASSERTIONS_PASSED++)) || true+else+ echo -e " ${RED}✗${NC} navigate missing tabId"+ ((ASSERTIONS_FAILED++)) || true+fi+end_test++# --- T3: Snapshot returns nodes ---+start_test "Lite engine: snapshot returns DOM nodes"+lite_get "/snapshot?tabId=${TAB_ID}"+assert_ok "lite snapshot"+NODE_COUNT=$(echo "$RESULT" | jq '.nodes | length' 2>/dev/null || echo 0)+if [ "$NODE_COUNT" -gt 0 ]; then+ echo -e " ${GREEN}✓${NC} snapshot returned $NODE_COUNT nodes"+ ((ASSERTIONS_PASSED++)) || true+else+ echo -e " ${RED}✗${NC} snapshot returned 0 nodes"+ ((ASSERTIONS_FAILED++)) || true+fi+end_test++# --- T4: Text extraction ---+start_test "Lite engine: text extraction"+lite_get "/text?tabId=${TAB_ID}&format=text"+assert_ok "lite text"+assert_contains "$RESULT" "E2E" "text contains page content"+end_test++# --- T5: Interactive filter ---+start_test "Lite engine: interactive filter"+lite_get "/snapshot?tabId=${TAB_ID}&filter=interactive"+assert_ok "lite snapshot interactive"+end_test++# --- T6: Click action routes through lite ---+start_test "Lite engine: click action"++lite_post /navigate "{\"url\":\"${FIXTURES_URL}/lite-test.html\"}"+assert_ok "navigate to lite test page"+ACTION_TAB=$(echo "$RESULT" | jq -r '.tabId // empty')++lite_get "/snapshot?tabId=${ACTION_TAB}&filter=interactive"+BUTTON_REF=$(echo "$RESULT" | jq -r '[.nodes[] | select(.role == "button")] | first // empty | .ref // empty')++if [ -n "$BUTTON_REF" ]; then+ lite_post /action "{\"tabId\":\"${ACTION_TAB}\",\"kind\":\"click\",\"ref\":\"${BUTTON_REF}\"}"+ assert_ok "lite click"+else+ echo -e " ${RED}✗${NC} no button found for click test"+ ((ASSERTIONS_FAILED++)) || true+fi+end_test++# --- T7: Type action routes through lite ---+start_test "Lite engine: type action"++TYPE_TAB="${ACTION_TAB}"++lite_get "/snapshot?tabId=${TYPE_TAB}&filter=interactive"+INPUT_REF=$(echo "$RESULT" | jq -r '[.nodes[] | select(.role == "textbox")] | first // empty | .ref // empty')++if [ -n "$INPUT_REF" ]; then+ lite_post /action "{\"tabId\":\"${TYPE_TAB}\",\"kind\":\"type\",\"ref\":\"${INPUT_REF}\",\"text\":\"hello\"}"+ assert_ok "lite type"+else+ echo -e " ${RED}✗${NC} no textbox found on form.html"+ ((ASSERTIONS_FAILED++)) || true+fi+end_test++# --- T8: Unsupported action returns 501 ---+start_test "Lite engine: unsupported action returns 501"+lite_post /action "{\"tabId\":\"${TYPE_TAB}\",\"kind\":\"press\",\"ref\":\"e0\",\"key\":\"Enter\"}"+assert_http_status 501 "press returns 501 in lite mode"+end_test++# --- T9: Multi-tab isolation ---+start_test "Lite engine: multi-tab isolation"++lite_post /navigate "{\"url\":\"${FIXTURES_URL}/index.html\"}"+assert_ok "navigate page 1"+TAB_A=$(echo "$RESULT" | jq -r '.tabId // empty')++lite_post /navigate "{\"url\":\"${FIXTURES_URL}/form.html\"}"+assert_ok "navigate page 2"+TAB_B=$(echo "$RESULT" | jq -r '.tabId // empty')++if [ "$TAB_A" != "$TAB_B" ]; then+ echo -e " ${GREEN}✓${NC} different tab IDs: $TAB_A vs $TAB_B"+ ((ASSERTIONS_PASSED++)) || true+else+ echo -e " ${RED}✗${NC} tabs should have different IDs"+ ((ASSERTIONS_FAILED++)) || true+fi++lite_get "/text?tabId=${TAB_A}&format=text"+assert_ok "text for tab A"+assert_contains "$RESULT" "E2E Test Suite" "tab A returns index.html content"++lite_get "/text?tabId=${TAB_B}&format=text"+assert_ok "text for tab B"+assert_contains "$RESULT" "Form" "tab B returns form.html content"++end_testdiff --git a/tests/e2e/scenarios-api/tabs-basic.sh b/tests/e2e/scenarios-api/tabs-basic.shnew file mode 100644index 00000000..f0cd4ab0--- /dev/null+++ b/tests/e2e/scenarios-api/tabs-basic.sh@@ -0,0 +1,207 @@+#!/bin/bash+# tabs-basic.sh — API happy-path tab scenarios.++GROUP_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"+source "${GROUP_DIR}/../helpers/api.sh"++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab snap --tab <id> (regression #207)"++pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/index.html\"}"+TAB_ID=$(get_tab_id)+show_tab "created" "$TAB_ID"++pt_get "/tabs/${TAB_ID}/snapshot"+assert_ok "tab snapshot"+assert_json_contains "$RESULT" '.title' 'E2E Test'++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab text/screenshot --tab <id>"++pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/form.html\"}"+TAB_ID=$(get_tab_id)++pt_get "/tabs/${TAB_ID}/text"+assert_ok "tab text"++pt_get "/tabs/${TAB_ID}/screenshot"+assert_ok "tab screenshot"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab tab close"++pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/buttons.html\"}"+TAB_ID=$(get_tab_id)+AFTER_CREATE=$(get_tab_count)++pt_post "/tabs/${TAB_ID}/close" -d '{}'+assert_ok "tab close"++sleep 1+assert_tab_closed "$AFTER_CREATE"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "Focus tab by ID"++pt_post /navigate "{\"url\":\"${FIXTURES_URL}/index.html\"}"+assert_ok "navigate to index.html"+TAB_ID_A=$(echo "$RESULT" | jq -r '.tabId // empty')+assert_tab_id "tab A"+show_tab "TAB_ID_A" "$TAB_ID_A"++pt_post /navigate "{\"url\":\"${FIXTURES_URL}/form.html\"}"+assert_ok "navigate to form.html"+TAB_ID_B=$(echo "$RESULT" | jq -r '.tabId // empty')+assert_tab_id "tab B"+show_tab "TAB_ID_B" "$TAB_ID_B"++pt_post /tab "{\"action\":\"focus\",\"tabId\":\"${TAB_ID_A}\"}"+assert_ok "focus on tab A"+assert_json_contains "$RESULT" ".focused" "true" "response contains focused=true"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "Focus tab switches active tab"++pt_get "/snapshot?tabId=${TAB_ID_A}"+assert_ok "snapshot of tab A"+assert_result_exists ".title" "snapshot has title"++pt_get "/text?tabId=${TAB_ID_A}&format=text"+assert_ok "text of tab A"+assert_contains "$RESULT" "E2E" "tab A contains E2E Test Suite content"++pt_post /tab "{\"action\":\"focus\",\"tabId\":\"${TAB_ID_B}\"}"+assert_ok "focus on tab B"++pt_get "/text?tabId=${TAB_ID_B}&format=text"+assert_ok "text of tab B"+assert_contains "$RESULT" "Form" "tab B contains Form content"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "Focus missing tabId returns 400"++pt_post /tab "{\"action\":\"focus\"}"+assert_http_status 400 "missing tabId returns 400"+assert_json_contains "$RESULT" ".error" "tabId" "error message mentions tabId"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "Focus nonexistent tab returns 404"++pt_post /tab "{\"action\":\"focus\",\"tabId\":\"nonexistent-tab-id-12345\"}"+assert_http_status 404 "nonexistent tabId returns 404"+assert_json_contains "$RESULT" ".error" "not found" "error message indicates tab not found"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "Focus invalid action returns 400"++pt_post /tab "{\"action\":\"invalid\",\"tabId\":\"${TAB_ID_A}\"}"+assert_http_status 400 "invalid action returns 400"+assert_json_contains "$RESULT" ".error" "action" "error message mentions action"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "Navigate back to previous page"++pt_post /navigate "{\"url\":\"${FIXTURES_URL}/index.html\"}"+assert_ok "navigate to index.html"+TAB_ID=$(echo "$RESULT" | jq -r '.tabId // empty')+assert_tab_id "get tab ID"+show_tab "TAB_ID" "$TAB_ID"+URL_A=$(echo "$RESULT" | jq -r '.url // empty')+echo -e " ${MUTED}URL_A: $URL_A${NC}"++pt_post /navigate "{\"url\":\"${FIXTURES_URL}/form.html\",\"tabId\":\"${TAB_ID}\"}"+assert_ok "navigate to form.html"+URL_B=$(echo "$RESULT" | jq -r '.url // empty')+echo -e " ${MUTED}URL_B: $URL_B${NC}"++pt_post "/back?tabId=${TAB_ID}" ''+assert_ok "POST /back"+RESULT_URL=$(echo "$RESULT" | jq -r '.url // empty')+assert_json_contains "$RESULT" ".url" "index.html" "back returned to index.html"+assert_json_contains "$RESULT" ".tabId" "$TAB_ID" "back response contains tabId"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "Navigate forward after back"++pt_post "/forward?tabId=${TAB_ID}" ''+assert_ok "POST /forward"+RESULT_URL=$(echo "$RESULT" | jq -r '.url // empty')+assert_json_contains "$RESULT" ".url" "form.html" "forward returned to form.html"+assert_json_contains "$RESULT" ".tabId" "$TAB_ID" "forward response contains tabId"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "Reload page stays on same URL"++pt_post "/reload?tabId=${TAB_ID}" ''+assert_ok "POST /reload"+RESULT_URL=$(echo "$RESULT" | jq -r '.url // empty')+assert_json_contains "$RESULT" ".url" "form.html" "reload stayed on form.html"+assert_json_contains "$RESULT" ".tabId" "$TAB_ID" "reload response contains tabId"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "Back with tabId parameter"++pt_post /navigate "{\"url\":\"${FIXTURES_URL}/index.html\",\"tabId\":\"${TAB_ID}\"}"+assert_ok "navigate to index.html with tabId"++pt_post /navigate "{\"url\":\"${FIXTURES_URL}/form.html\",\"tabId\":\"${TAB_ID}\"}"+assert_ok "navigate to form.html with tabId"++pt_post "/back?tabId=${TAB_ID}" ''+assert_ok "POST /back?tabId=<id>"+assert_json_contains "$RESULT" ".url" "index.html" "back with tabId returned to index.html"+assert_json_contains "$RESULT" ".tabId" "$TAB_ID" "back with tabId response contains correct tabId"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "Tab-scoped back using path parameter"++pt_post /navigate "{\"url\":\"${FIXTURES_URL}/form.html\",\"tabId\":\"${TAB_ID}\"}"+assert_ok "navigate to form.html"++pt_post "/tabs/${TAB_ID}/back" ''+assert_ok "POST /tabs/{id}/back"+assert_json_contains "$RESULT" ".url" "index.html" "path-scoped back returned to index.html"+assert_json_contains "$RESULT" ".tabId" "$TAB_ID" "path-scoped back response contains correct tabId"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "Back with no history stays on same page"++pt_post /navigate "{\"url\":\"${FIXTURES_URL}/buttons.html\"}"+assert_ok "navigate to buttons.html"+NEW_TAB_ID=$(echo "$RESULT" | jq -r '.tabId // empty')+URL_SINGLE=$(echo "$RESULT" | jq -r '.url // empty')+show_tab "NEW_TAB_ID" "$NEW_TAB_ID"++pt_post "/back?tabId=${NEW_TAB_ID}" ''+assert_ok "POST /back with no history (should stay on same page)"+RESULT_URL=$(echo "$RESULT" | jq -r '.url // empty')+assert_json_contains "$RESULT" ".url" "buttons.html" "back with no history stayed on same page"+assert_json_contains "$RESULT" ".tabId" "$NEW_TAB_ID" "back with no history response contains correct tabId"++end_testdiff --git a/tests/e2e/scenarios-api/tabs-full.sh b/tests/e2e/scenarios-api/tabs-full.shnew file mode 100644index 00000000..f9e39a9a--- /dev/null+++ b/tests/e2e/scenarios-api/tabs-full.sh@@ -0,0 +1,251 @@+#!/bin/bash+# tabs-full.sh — API advanced tab scenarios.++GROUP_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"+source "${GROUP_DIR}/../helpers/api.sh"++start_test "tab-specific upload: POST /tabs/{id}/upload"++pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/upload.html\"}"+TAB_ID=$(get_tab_id)+show_tab "created" "$TAB_ID"++pt_post "/tabs/${TAB_ID}/upload" -d '{"selector":"#single-file","files":["data:text/plain;base64,dGVzdCBmaWxl"]}'+assert_ok "upload to tab"+assert_json_exists "$RESULT" ".files" "upload response has files count"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "tab-specific upload: multiple files"++pt_post "/tabs/${TAB_ID}/upload" -d '{"selector":"#multi-file","files":["data:text/plain;base64,ZmlsZTE=","data:text/plain;base64,ZmlsZTI="]}'+assert_ok "upload multiple files"+assert_json_contains "$RESULT" ".files" "2" "uploaded 2 files"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "tab-specific download: GET /tabs/{id}/download"++pt_post /navigate -d '{"url":"https://httpbin.org/robots.txt"}'+TAB_ID2=$(get_tab_id)+show_tab "created" "$TAB_ID2"++pt_get "/tabs/${TAB_ID2}/download?url=https://httpbin.org/json"+assert_ok "download from tab"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "tab-specific download: verify content returned"++if [ -n "$RESULT" ]; then+ echo -e " ${GREEN}✓${NC} download returned content"+ ((ASSERTIONS_PASSED++)) || true+else+ echo -e " ${RED}✗${NC} download returned empty content"+ ((ASSERTIONS_FAILED++)) || true+fi++end_test++# The secure pinchtab instance is configured with maxTabs=2 and close_lru.+# Tests that opening a 3rd managed tab evicts the least recently used one.+# Note: Chrome keeps an initial about:blank target that is unmanaged.+# Eviction is based on managed tab count, not Chrome target count.++ORIG_URL="$E2E_SERVER"+E2E_SERVER="$E2E_SECURE_SERVER"++# ─────────────────────────────────────────────────────────────────+start_test "LRU eviction: open 2 tabs (at limit)"++pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/index.html\"}"+TAB1=$(echo "$RESULT" | jq -r '.tabId')+assert_ok "open tab 1 (index)"+echo -e " ${MUTED}tab1: ${TAB1:0:12}...${NC}"++sleep 1++pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/form.html\"}"+TAB2=$(echo "$RESULT" | jq -r '.tabId')+assert_ok "open tab 2 (form)"+echo -e " ${MUTED}tab2: ${TAB2:0:12}...${NC}"++pt_get "/tabs/$TAB1/snapshot" > /dev/null+assert_ok "tab1 accessible"+pt_get "/tabs/$TAB2/snapshot" > /dev/null+assert_ok "tab2 accessible"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "LRU eviction: 3rd tab evicts least recently used"++sleep 1+pt_get "/tabs/$TAB2/snapshot" > /dev/null+sleep 1++pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/buttons.html\"}"+TAB3=$(echo "$RESULT" | jq -r '.tabId')+assert_ok "open tab 3 (triggers eviction)"+echo -e " ${MUTED}tab3: ${TAB3:0:12}...${NC}"++pt_get "/tabs/$TAB1/snapshot"+assert_http_error 404 "tab1 evicted (LRU)"++pt_get "/tabs/$TAB2/snapshot" > /dev/null+assert_ok "tab2 survived (recently used)"++pt_get "/tabs/$TAB3/snapshot" > /dev/null+assert_ok "tab3 accessible"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "LRU eviction: continuous eviction works"++sleep 1+pt_get "/tabs/$TAB3/snapshot" > /dev/null+sleep 1++pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/table.html\"}"+TAB4=$(echo "$RESULT" | jq -r '.tabId')+assert_ok "open tab 4 (triggers second eviction)"++pt_get "/tabs/$TAB2/snapshot"+assert_http_error 404 "tab2 evicted (LRU)"++pt_get "/tabs/$TAB3/snapshot" > /dev/null+assert_ok "tab3 survived"+pt_get "/tabs/$TAB4/snapshot" > /dev/null+assert_ok "tab4 accessible"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "tabs: list returns array"++pt_get /tabs+assert_ok "list tabs"+assert_json_exists "$RESULT" '.tabs'+assert_json_length_gte "$RESULT" '.tabs' '1' "at least 1 tab"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "tabs: new + close roundtrip"++pt_post /tab "{\"action\":\"new\",\"url\":\"${FIXTURES_URL}/index.html\"}"+assert_ok "new tab"+NEW_TAB=$(echo "$RESULT" | jq -r '.tabId')++pt_post /tab "{\"action\":\"close\",\"tabId\":\"${NEW_TAB}\"}"+assert_ok "close tab"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "tabs: close without tabId → 400"++pt_post /tab '{"action":"close"}'+assert_http_status "400" "rejects close without tabId"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "tabs: bad action → 400"++pt_post /tab '{"action":"explode"}'+assert_http_status "400" "rejects bad action"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "tabs: new tab returns tabId"++pt_post /tab '{"action":"new","url":"about:blank"}'+assert_ok "new tab"+assert_tab_id "new tab returns tabId"++pt_post /tab "{\"action\":\"close\",\"tabId\":\"${TAB_ID}\"}"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "tabs: nonexistent tab → 404"++FAKE_TAB="A25658CE1BA82659EBE9C93C46CEE63A"++pt_post "/tabs/${FAKE_TAB}/navigate" "{\"url\":\"${FIXTURES_URL}/index.html\"}"+assert_http_status "404" "navigate on fake tab"++pt_get "/tabs/${FAKE_TAB}/snapshot"+assert_http_status "404" "snapshot on fake tab"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "tab lock: lock and unlock"++pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/index.html\"}"+TAB_ID=$(get_tab_id)++pt_post /tab/lock -d "{\"tabId\":\"${TAB_ID}\",\"owner\":\"test-agent\"}"+assert_ok "lock tab"+assert_json_eq "$RESULT" '.locked' 'true' "tab is locked"+assert_json_eq "$RESULT" '.owner' 'test-agent' "owner matches"++pt_post /tab/unlock -d "{\"tabId\":\"${TAB_ID}\",\"owner\":\"test-agent\"}"+assert_ok "unlock tab"+assert_json_eq "$RESULT" '.unlocked' 'true' "tab is unlocked"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "tab lock: wrong owner cannot unlock"++pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/index.html\"}"+TAB_ID=$(get_tab_id)++pt_post /tab/lock -d "{\"tabId\":\"${TAB_ID}\",\"owner\":\"agent-a\"}"+assert_ok "lock tab"++pt_post /tab/unlock -d "{\"tabId\":\"${TAB_ID}\",\"owner\":\"agent-b\"}"+assert_not_ok "wrong owner rejected"++pt_post /tab/unlock -d "{\"tabId\":\"${TAB_ID}\",\"owner\":\"agent-a\"}"++end_test++E2E_SERVER="$ORIG_URL"++# ─────────────────────────────────────────────────────────────────+start_test "tab lock: lock with timeoutSec"++pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/index.html\"}"+TAB_ID=$(get_tab_id)++pt_post /tab/lock -d "{\"tabId\":\"${TAB_ID}\",\"owner\":\"test-ttl\",\"timeoutSec\":60}"+assert_ok "lock with timeout"+assert_json_exists "$RESULT" '.expiresAt' "has expiration time"++pt_post /tab/unlock -d "{\"tabId\":\"${TAB_ID}\",\"owner\":\"test-ttl\"}"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "tab lock: path-based lock (POST /tabs/{id}/lock)"++pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/index.html\"}"+TAB_ID=$(get_tab_id)++pt_post "/tabs/${TAB_ID}/lock" -d "{\"owner\":\"path-agent\"}"+assert_ok "path-based lock"+assert_json_eq "$RESULT" '.locked' 'true'++pt_post "/tabs/${TAB_ID}/unlock" -d "{\"owner\":\"path-agent\"}"+assert_ok "path-based unlock"++end_testdiff --git a/tests/e2e/scenarios-cli/01-nav.sh b/tests/e2e/scenarios-cli/01-nav.shdeleted file mode 100755index e7d488ea..00000000--- a/tests/e2e/scenarios-cli/01-nav.sh+++ /dev/null@@ -1,49 +0,0 @@-#!/bin/bash-# 01-nav.sh — CLI nav commands--source "$(dirname "$0")/common.sh"--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab nav <url>"--pt_ok nav "${FIXTURES_URL}/index.html"-assert_output_json-assert_output_contains "tabId" "returns tab ID"-assert_output_contains "title" "returns page title"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab nav (empty URL)"--# Empty URL should fail (only truly invalid case with URL normalization)-pt_fail nav ""--end_test--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab nav (bare hostname normalizes to https)"--# Bare hostnames are now normalized to https:// - Chrome shows error page but nav succeeds-pt nav "not-a-valid-url"-if echo "$PT_OUT" | grep -q "chrome-error"; then- echo -e " ${GREEN}✓${NC} Normalized to https://not-a-valid-url (Chrome error page)"- ((ASSERTIONS_PASSED++)) || true-else- echo -e " ${YELLOW}⚠${NC} Unexpected result: $PT_OUT"-fi--end_test--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab nav --tab <tabId> <url>"--# First navigate to get a tab-pt_ok nav "${FIXTURES_URL}/index.html"-TAB_ID=$(echo "$PT_OUT" | jq -r '.tabId')--# Navigate same tab using --tab flag-pt_ok nav "${FIXTURES_URL}/form.html" --tab "$TAB_ID"-assert_output_contains "form.html" "navigated to form.html"--end_testdiff --git a/tests/e2e/scenarios-cli/02-snap.sh b/tests/e2e/scenarios-cli/02-snap.shdeleted file mode 100755index 3f935981..00000000--- a/tests/e2e/scenarios-cli/02-snap.sh+++ /dev/null@@ -1,14 +0,0 @@-#!/bin/bash-# 02-snap.sh — CLI snapshot command--source "$(dirname "$0")/common.sh"--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab snap"--pt_ok nav "${FIXTURES_URL}/index.html"-pt_ok snap-assert_output_json-assert_output_contains "nodes" "returns snapshot nodes"--end_testdiff --git a/tests/e2e/scenarios-cli/04-tabs.sh b/tests/e2e/scenarios-cli/04-tabs.shdeleted file mode 100755index 1ca842bf..00000000--- a/tests/e2e/scenarios-cli/04-tabs.sh+++ /dev/null@@ -1,30 +0,0 @@-#!/bin/bash-# 04-tabs.sh — CLI tab management commands--source "$(dirname "$0")/common.sh"--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab tab (list)"--# Create a tab first-pt_ok nav "${FIXTURES_URL}/index.html"--pt_ok tab-assert_output_json-assert_output_contains "tabs" "returns tabs array"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab tab close <id>"--pt_ok nav "${FIXTURES_URL}/form.html"-TAB_ID=$(echo "$PT_OUT" | jq -r '.tabId')--pt_ok tab close "$TAB_ID"--# Verify tab is gone-pt_ok tab-assert_output_not_contains "$TAB_ID" "tab was closed"--end_testdiff --git a/tests/e2e/scenarios-cli/05-eval.sh b/tests/e2e/scenarios-cli/05-eval.shdeleted file mode 100755index cfc9a52b..00000000--- a/tests/e2e/scenarios-cli/05-eval.sh+++ /dev/null@@ -1,43 +0,0 @@-#!/bin/bash-# 05-eval.sh — CLI evaluate command--source "$(dirname "$0")/common.sh"--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab eval <expression>"--pt_ok nav "${FIXTURES_URL}/index.html"-pt_ok eval "1 + 1"-assert_output_contains "2" "evaluates simple expression"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab eval (DOM query)"--pt_ok nav "${FIXTURES_URL}/form.html"-pt_ok eval "document.title"-assert_output_contains "Form" "returns page title"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab eval (JSON result)"--pt_ok eval 'JSON.stringify({a: 1, b: 2})'-# Output is {"result": "{\"a\":1,\"b\":2}"} - escaped JSON-assert_output_contains 'a' "returns JSON object"-assert_output_contains 'b' "contains both keys"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab eval --tab <tabId> <expression>"--pt_ok nav "${FIXTURES_URL}/buttons.html"-TAB_ID=$(echo "$PT_OUT" | jq -r '.tabId')--pt_ok eval "document.title" --tab "$TAB_ID"-assert_output_contains "Button" "evaluates in correct tab"--end_testdiff --git a/tests/e2e/scenarios-cli/06-text.sh b/tests/e2e/scenarios-cli/06-text.shdeleted file mode 100755index 4e82bef1..00000000--- a/tests/e2e/scenarios-cli/06-text.sh+++ /dev/null@@ -1,22 +0,0 @@-#!/bin/bash-# 06-text.sh — CLI text extraction command--source "$(dirname "$0")/common.sh"--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab text"--pt_ok nav "${FIXTURES_URL}/index.html"-pt_ok text-assert_output_json-assert_output_contains "text" "returns text field"--end_test--# ─────────────────────────────────────────────────────────────────-# SKIP: text --raw outputs JSON instead of plain text-# Bug: CLI sets mode=raw but not format=text-# See: ~/dev/tmp/text-raw-bug.md-# start_test "pinchtab text --raw"-# pt_ok text --raw-# end_testdiff --git a/tests/e2e/scenarios-cli/07-screenshot.sh b/tests/e2e/scenarios-cli/07-screenshot.shdeleted file mode 100755index 80469f5d..00000000--- a/tests/e2e/scenarios-cli/07-screenshot.sh+++ /dev/null@@ -1,17 +0,0 @@-#!/bin/bash-# 07-screenshot.sh — CLI screenshot command--source "$(dirname "$0")/common.sh"--start_test "pinchtab screenshot"-pt_ok nav "${FIXTURES_URL}/index.html"-pt_ok screenshot -o /tmp/e2e-screenshot-test.jpg-if [ -f /tmp/e2e-screenshot-test.jpg ]; then- echo -e " ${GREEN}✓${NC} screenshot file created"- ((ASSERTIONS_PASSED++)) || true- rm -f /tmp/e2e-screenshot-test.jpg-else- echo -e " ${RED}✗${NC} screenshot file not created"- ((ASSERTIONS_FAILED++)) || true-fi-end_testdiff --git a/tests/e2e/scenarios-cli/08-scroll.sh b/tests/e2e/scenarios-cli/08-scroll.shdeleted file mode 100755index 808f3d54..00000000--- a/tests/e2e/scenarios-cli/08-scroll.sh+++ /dev/null@@ -1,26 +0,0 @@-#!/bin/bash-# 08-scroll.sh — CLI scroll command--source "$(dirname "$0")/common.sh"--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab scroll <pixels>"--pt_ok nav "${FIXTURES_URL}/table.html"--# Scroll down by pixels-pt_ok scroll 100-assert_output_contains "scrolled" "confirms scroll action"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab scroll down/up"--pt_ok scroll down-assert_output_contains "scrolled" "scroll down succeeded"--pt_ok scroll up-assert_output_contains "scrolled" "scroll up succeeded"--end_testdiff --git a/tests/e2e/scenarios-cli/09-health.sh b/tests/e2e/scenarios-cli/09-health.shdeleted file mode 100755index 17b92330..00000000--- a/tests/e2e/scenarios-cli/09-health.sh+++ /dev/null@@ -1,33 +0,0 @@-#!/bin/bash-# 09-health.sh — CLI health and status commands--source "$(dirname "$0")/common.sh"--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab health"--pt_ok health-assert_output_json-assert_output_contains "status" "returns status field"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab instances"--pt_ok instances-assert_output_json-# Output is an array like [{id:..., status:...}], check for instance properties-assert_output_contains "id" "returns instance id"-assert_output_contains "status" "returns instance status"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab profiles"--pt_ok profiles-# Output is array, might be truncated in PT_OUT but command succeeds-# Just verify exit code was 0--end_testdiff --git a/tests/e2e/scenarios-cli/10-quick.sh b/tests/e2e/scenarios-cli/10-quick.shdeleted file mode 100755index 8b232a62..00000000--- a/tests/e2e/scenarios-cli/10-quick.sh+++ /dev/null@@ -1,14 +0,0 @@-#!/bin/bash-# 10-quick.sh — CLI quick command (nav + snap combined)--source "$(dirname "$0")/common.sh"--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab quick <url>"--pt_ok quick "${FIXTURES_URL}/form.html"-# Quick command navigates and returns snapshot-assert_output_contains "nodes" "returns snapshot nodes"-assert_output_contains "form.html" "navigated to correct page"--end_testdiff --git a/tests/e2e/scenarios-cli/11-select.sh b/tests/e2e/scenarios-cli/11-select.shdeleted file mode 100755index cbb890e3..00000000--- a/tests/e2e/scenarios-cli/11-select.sh+++ /dev/null@@ -1,14 +0,0 @@-#!/bin/bash-# 11-select.sh — CLI select command (dropdown)--source "$(dirname "$0")/common.sh"--start_test "pinchtab select"-pt_ok nav "${FIXTURES_URL}/form.html"-# Get a ref for a select element from snapshot-pt_ok snap --interactive-# Try select - may fail if no dropdown on form.html, but command should not crash-pt select e0 "option1" 2>/dev/null-echo -e " ${GREEN}✓${NC} select command executed"-((ASSERTIONS_PASSED++)) || true-end_testdiff --git a/tests/e2e/scenarios-cli/12-type-ref.sh b/tests/e2e/scenarios-cli/12-type-ref.shdeleted file mode 100755index f203348b..00000000--- a/tests/e2e/scenarios-cli/12-type-ref.sh+++ /dev/null@@ -1,32 +0,0 @@-#!/bin/bash-# 12-type-ref.sh — CLI type and click with element refs--source "$(dirname "$0")/common.sh"--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab type <ref> <text>"--pt_ok nav "${FIXTURES_URL}/form.html"-pt_ok snap--USERNAME_REF=$(find_ref_by_name "Username:" "$PT_OUT")-if assert_ref_found "$USERNAME_REF" "username input ref"; then- pt_ok type "$USERNAME_REF" "typed-via-ref"- assert_output_contains "typed" "confirms text was typed"-fi--end_test--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab click <ref>"--pt_ok nav "${FIXTURES_URL}/buttons.html"-pt_ok snap--BUTTON_REF=$(find_ref_by_role "button" "$PT_OUT")-if assert_ref_found "$BUTTON_REF" "button ref"; then- pt_ok click "$BUTTON_REF"- assert_output_contains "clicked" "confirms click by ref"-fi--end_testdiff --git a/tests/e2e/scenarios-cli/13-pdf.sh b/tests/e2e/scenarios-cli/13-pdf.shdeleted file mode 100755index cc384587..00000000--- a/tests/e2e/scenarios-cli/13-pdf.sh+++ /dev/null@@ -1,17 +0,0 @@-#!/bin/bash-# 13-pdf.sh — CLI PDF export command--source "$(dirname "$0")/common.sh"--start_test "pinchtab pdf"-pt_ok nav "${FIXTURES_URL}/index.html"-pt_ok pdf -o /tmp/e2e-pdf-test.pdf-if [ -f /tmp/e2e-pdf-test.pdf ]; then- echo -e " ${GREEN}✓${NC} PDF file created"- ((ASSERTIONS_PASSED++)) || true- rm -f /tmp/e2e-pdf-test.pdf-else- echo -e " ${RED}✗${NC} PDF file not created"- ((ASSERTIONS_FAILED++)) || true-fi-end_testdiff --git a/tests/e2e/scenarios-cli/14-tabs-new.sh b/tests/e2e/scenarios-cli/14-tabs-new.shdeleted file mode 100755index 6e8b61d2..00000000--- a/tests/e2e/scenarios-cli/14-tabs-new.sh+++ /dev/null@@ -1,25 +0,0 @@-#!/bin/bash-# 14-tabs-new.sh — CLI tabs new command--source "$(dirname "$0")/common.sh"--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab tab new <url>"--pt_ok tab new "${FIXTURES_URL}/buttons.html"-assert_output_json-assert_output_contains "tabId" "returns new tab ID"--# Save the tab ID for cleanup-NEW_TAB_ID=$(echo "$PT_OUT" | jq -r '.tabId')--# Verify it appears in tabs list-pt_ok tab-assert_output_contains "$NEW_TAB_ID" "new tab appears in list"--# Cleanup-if [ -n "$NEW_TAB_ID" ] && [ "$NEW_TAB_ID" != "null" ]; then- pt tabs close "$NEW_TAB_ID" > /dev/null 2>&1 || true-fi--end_testdiff --git a/tests/e2e/scenarios-cli/15-instance.sh b/tests/e2e/scenarios-cli/15-instance.shdeleted file mode 100755index 9546c612..00000000--- a/tests/e2e/scenarios-cli/15-instance.sh+++ /dev/null@@ -1,26 +0,0 @@-#!/bin/bash-# 15-instance.sh — CLI instance management commands--source "$(dirname "$0")/common.sh"--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab instance logs"--# Get default instance ID from health-pt_ok health-INSTANCE_ID=$(echo "$PT_OUT" | jq -r '.defaultInstance.id // empty')--if [ -n "$INSTANCE_ID" ]; then- pt_ok instance logs "$INSTANCE_ID"- # Logs command succeeds - output might be empty- echo -e " ${GREEN}✓${NC} instance logs succeeded"- ((ASSERTIONS_PASSED++)) || true-else- echo -e " ${YELLOW}⚠${NC} No instance ID found, skipping logs test"- ((ASSERTIONS_PASSED++)) || true-fi--end_test--# Note: instance start is implicitly tested (server is running)-# instance stop is tested in 99-instance-stop.shdiff --git a/tests/e2e/scenarios-cli/16-meta.sh b/tests/e2e/scenarios-cli/16-meta.shdeleted file mode 100755index 723fcc89..00000000--- a/tests/e2e/scenarios-cli/16-meta.sh+++ /dev/null@@ -1,29 +0,0 @@-#!/bin/bash-# 16-meta.sh — CLI meta commands (version, help)--source "$(dirname "$0")/common.sh"--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab --version"--pt_ok --version-assert_output_contains "pinchtab" "outputs version string"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab help"--pt_ok help-assert_output_contains "pinchtab" "outputs help text"-assert_output_contains "nav" "mentions nav command"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab --help"--pt_ok --help-assert_output_contains "pinchtab" "outputs help text"--end_testdiff --git a/tests/e2e/scenarios-cli/16-nav-history.sh b/tests/e2e/scenarios-cli/16-nav-history.shdeleted file mode 100755index b81da89d..00000000--- a/tests/e2e/scenarios-cli/16-nav-history.sh+++ /dev/null@@ -1,54 +0,0 @@-#!/bin/bash-# 16-nav-history.sh — CLI navigation history commands (back, forward, reload)--source "$(dirname "$0")/common.sh"--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab back (no history)"--pt_ok back-assert_output_json "back returns JSON"-assert_output_contains "tabId" "response contains tabId"-assert_output_contains "url" "response contains url"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab back (navigate two pages then back)"--# Navigate to page A-pt_ok nav "${FIXTURES_URL}/index.html"-TAB_ID=$(echo "$PT_OUT" | jq -r '.tabId')-URL_A=$(echo "$PT_OUT" | jq -r '.url')--# Navigate to page B-pt_ok nav "${FIXTURES_URL}/form.html" --tab "$TAB_ID"-URL_B=$(echo "$PT_OUT" | jq -r '.url')--# Go back to page A-pt_ok back --tab "$TAB_ID"-assert_output_json "back returns JSON"-assert_output_contains "index.html" "back returned to index.html"-assert_output_contains "$TAB_ID" "back response contains correct tabId"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab forward"--pt_ok forward --tab "$TAB_ID"-assert_output_json "forward returns JSON"-assert_output_contains "form.html" "forward returned to form.html"-assert_output_contains "$TAB_ID" "forward response contains correct tabId"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab reload"--pt_ok reload --tab "$TAB_ID"-assert_output_json "reload returns JSON"-assert_output_contains "form.html" "reload kept same page"-assert_output_contains "$TAB_ID" "reload response contains correct tabId"--end_testdiff --git a/tests/e2e/scenarios-cli/17-tabs-ops.sh b/tests/e2e/scenarios-cli/17-tabs-ops.shdeleted file mode 100755index 79607346..00000000--- a/tests/e2e/scenarios-cli/17-tabs-ops.sh+++ /dev/null@@ -1,16 +0,0 @@-#!/bin/bash-# 17-tabs-ops.sh — Tab-specific operations--source "$(dirname "$0")/common.sh"--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab tab (list)"--pt_ok nav "${FIXTURES_URL}/form.html"-pt_ok tab-assert_output_json--end_test--# SKIP: tabs snapshot/screenshot/eval/cookies/text per-tab operations-# not yet available in cobra refactordiff --git a/tests/e2e/scenarios-cli/20-auto-https.sh b/tests/e2e/scenarios-cli/20-auto-https.shdeleted file mode 100755index ac21f9f2..00000000--- a/tests/e2e/scenarios-cli/20-auto-https.sh+++ /dev/null@@ -1,68 +0,0 @@-#!/bin/bash-# 20-auto-https.sh — Test auto-https prefix for CLI URL arguments-# Verifies that CLI commands automatically prepend https:// to URLs without protocol--source "$(dirname "$0")/common.sh"--# ─────────────────────────────────────────────────────────────────-start_test "auto-https: goto without protocol adds https://"--# Navigate to fixture hostname without protocol-# Since fixtures are HTTP-only, https:// navigation will land on error page-pt goto "fixtures:80/index.html"--# Chrome shows error page for failed https:// - check URL or title indicates error-if echo "$PT_OUT" | grep -qiE "chrome-error|err_|error|refused|failed|ssl"; then- echo -e " ${GREEN}✓${NC} CLI added https:// prefix (Chrome shows error page)"- ((ASSERTIONS_PASSED++)) || true-elif [ "$PT_CODE" -ne 0 ]; then- echo -e " ${GREEN}✓${NC} CLI added https:// prefix (navigation failed as expected)"- ((ASSERTIONS_PASSED++)) || true-else- # Check if the URL in response starts with https://- if echo "$PT_OUT" | grep -q '"url".*https://'; then- echo -e " ${GREEN}✓${NC} CLI added https:// prefix (URL in response shows https)"- ((ASSERTIONS_PASSED++)) || true- else- echo -e " ${RED}✗${NC} Expected https:// URL or error, got: $PT_OUT"- ((ASSERTIONS_FAILED++)) || true- fi-fi--end_test--# ─────────────────────────────────────────────────────────────────-start_test "auto-https: explicit http:// is preserved"--# Navigate with explicit http:// - should work and URL should be http://-pt_ok goto "http://fixtures:80/index.html"--if echo "$PT_OUT" | grep -q '"url".*http://'; then- echo -e " ${GREEN}✓${NC} Response URL is http://"- ((ASSERTIONS_PASSED++)) || true-else- echo -e " ${RED}✗${NC} Expected http:// in URL"- ((ASSERTIONS_FAILED++)) || true-fi--end_test--# ─────────────────────────────────────────────────────────────────-start_test "auto-https: explicit https:// is preserved"--# Navigate with explicit https:// to http-only fixture-pt goto "https://fixtures:80/index.html"--# Should show error page or fail (fixture doesn't support HTTPS)-if echo "$PT_OUT" | grep -qiE "chrome-error|err_|error|refused|failed"; then- echo -e " ${GREEN}✓${NC} Explicit https:// preserved (Chrome shows error)"- ((ASSERTIONS_PASSED++)) || true-elif echo "$PT_OUT" | grep -q '"url".*https://'; then- echo -e " ${GREEN}✓${NC} Explicit https:// preserved (URL shows https)"- ((ASSERTIONS_PASSED++)) || true-else- echo -e " ${RED}✗${NC} Expected https:// URL or error, got: $PT_OUT"- ((ASSERTIONS_FAILED++)) || true-fi--end_testdiff --git a/tests/e2e/scenarios-cli/20-download.sh b/tests/e2e/scenarios-cli/20-download.shdeleted file mode 100755index 4af65a75..00000000--- a/tests/e2e/scenarios-cli/20-download.sh+++ /dev/null@@ -1,35 +0,0 @@-#!/bin/bash-# 20-download.sh — CLI download command--source "$(dirname "$0")/common.sh"--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab download (rejects private IP)"--# The download endpoint blocks private/internal IPs (SSRF protection)-pt_fail download "${FIXTURES_URL}/index.html"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab download (public URL)"--pt_ok download "https://httpbin.org/robots.txt"-assert_output_contains "data" "response contains download data"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab download (save to file)"--pt_ok download "https://httpbin.org/robots.txt" -o /tmp/e2e-download-test.txt-if [ -f /tmp/e2e-download-test.txt ]; then- echo -e " ${GREEN}✓${NC} file saved"- ((ASSERTIONS_PASSED++)) || true-else- echo -e " ${RED}✗${NC} file not saved"- ((ASSERTIONS_FAILED++)) || true-fi-rm -f /tmp/e2e-download-test.txt--end_testdiff --git a/tests/e2e/scenarios-cli/21-upload.sh b/tests/e2e/scenarios-cli/21-upload.shdeleted file mode 100755index d023a5d7..00000000--- a/tests/e2e/scenarios-cli/21-upload.sh+++ /dev/null@@ -1,16 +0,0 @@-#!/bin/bash-# 21-upload.sh — CLI upload command--source "$(dirname "$0")/common.sh"--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab upload (basic)"--pt_ok nav "${FIXTURES_URL}/upload.html"--echo "test content" > /tmp/e2e-upload-test.txt-pt_ok upload /tmp/e2e-upload-test.txt --selector "#single-file"-assert_output_contains "ok" "upload succeeded"-rm -f /tmp/e2e-upload-test.txt--end_testdiff --git a/tests/e2e/scenarios-cli/22-tabs-errors.sh b/tests/e2e/scenarios-cli/22-tabs-errors.shdeleted file mode 100755index 33bd44f0..00000000--- a/tests/e2e/scenarios-cli/22-tabs-errors.sh+++ /dev/null@@ -1,43 +0,0 @@-#!/bin/bash-# 22-tabs-errors.sh — Tab error handling via CLI--source "$(dirname "$0")/common.sh"--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab tab returns valid JSON array"--pt_ok tab-assert_output_json "tabs output is valid JSON"-assert_output_contains "tabs" "response contains tabs field"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab tab new + close roundtrip"--# Use nav to create a tab in the existing instance (returns tabId reliably)-pt_ok nav "${FIXTURES_URL}/index.html"-assert_output_json-TAB_ID=$(echo "$PT_OUT" | jq -r '.tabId')--pt_ok tab close "$TAB_ID"--# Verify tab is gone-pt_ok tab-assert_output_not_contains "$TAB_ID" "closed tab no longer in list"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab tab close with no args → error"--pt_fail tab close--end_test--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab tab close nonexistent → error"--pt_fail tab close "nonexistent_tab_id_12345"--end_testdiff --git a/tests/e2e/scenarios-cli/23-redirects.sh b/tests/e2e/scenarios-cli/23-redirects.shdeleted file mode 100755index 37f79dde..00000000--- a/tests/e2e/scenarios-cli/23-redirects.sh+++ /dev/null@@ -1,22 +0,0 @@-#!/bin/bash-# 23-redirects.sh — Redirect following via CLI--source "$(dirname "$0")/common.sh"--# ─────────────────────────────────────────────────────────────────-start_test "redirects: follow single redirect"--pt_ok nav "https://httpbin.org/redirect/1"-pt_ok snap-assert_json_field_contains ".url" "httpbin.org/get" "landed on /get after redirect"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "redirects: follow multiple redirects"--pt_ok nav "https://httpbin.org/redirect/3"-pt_ok snap-assert_json_field_contains ".url" "httpbin.org/get" "multiple redirects followed to /get"--end_testdiff --git a/tests/e2e/scenarios-cli/24-tab-eviction.sh b/tests/e2e/scenarios-cli/24-tab-eviction.shdeleted file mode 100755index 446e9883..00000000--- a/tests/e2e/scenarios-cli/24-tab-eviction.sh+++ /dev/null@@ -1,41 +0,0 @@-#!/bin/bash-# 24-tab-eviction.sh — LRU tab eviction via CLI-#-# The default test instance has maxTabs=10.--source "$(dirname "$0")/common.sh"--MAX_TABS=10--# ─────────────────────────────────────────────────────────────────-start_test "tab eviction: open tabs up to limit"--TAB_IDS=()-for i in $(seq 1 $MAX_TABS); do- pt_ok nav "${FIXTURES_URL}/index.html?t=$i"- TAB_IDS+=($(echo "$PT_OUT" | jq -r '.tabId'))-done--pt_ok tab-TAB_COUNT=$(echo "$PT_OUT" | jq '.tabs | length')-if [ "$TAB_COUNT" -ge "$MAX_TABS" ]; then- echo -e " ${GREEN}✓${NC} $TAB_COUNT tabs open (>= $MAX_TABS)"- ((ASSERTIONS_PASSED++)) || true-else- echo -e " ${RED}✗${NC} expected >= $MAX_TABS tabs, got $TAB_COUNT"- ((ASSERTIONS_FAILED++)) || true-fi--end_test--# ─────────────────────────────────────────────────────────────────-start_test "tab eviction: new tab evicts oldest"--FIRST_TAB="${TAB_IDS[0]}"-sleep 1-pt_ok nav "${FIXTURES_URL}/index.html?t=overflow"--pt_ok tab-assert_output_not_contains "$FIRST_TAB" "oldest tab evicted (LRU)"--end_testdiff --git a/tests/e2e/scenarios-cli/25-find.sh b/tests/e2e/scenarios-cli/25-find.shdeleted file mode 100755index e7ad3d60..00000000--- a/tests/e2e/scenarios-cli/25-find.sh+++ /dev/null@@ -1,37 +0,0 @@-#!/bin/bash-# 25-find.sh — CLI find command--source "$(dirname "$0")/common.sh"--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab find (basic)"--pt_ok nav "${FIXTURES_URL}/form.html"-pt_ok find "username"-assert_output_contains "ref" "has ref in output"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab find --ref-only"--pt_ok find "username" --ref-only-# Output should be just a ref like "e5"-assert_output_contains "e" "outputs ref"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab find --explain"--pt_ok find "submit" --explain--end_test--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab find (no match)"--pt find "xyznonexistent99999"-# May succeed with low score or fail - just verify it doesn't crash--end_testdiff --git a/tests/e2e/scenarios-cli/27-screenshot-flags.sh b/tests/e2e/scenarios-cli/27-screenshot-flags.shdeleted file mode 100755index 385437c8..00000000--- a/tests/e2e/scenarios-cli/27-screenshot-flags.sh+++ /dev/null@@ -1,29 +0,0 @@-#!/bin/bash-# 27-screenshot-flags.sh — CLI screenshot flags--source "$(dirname "$0")/common.sh"--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab screenshot -o custom.jpg"--pt_ok nav "${FIXTURES_URL}/index.html"-pt_ok screenshot -o /tmp/e2e-custom-screenshot.jpg--if [ -f /tmp/e2e-custom-screenshot.jpg ]; then- echo -e " ${GREEN}✓${NC} file created"- ((ASSERTIONS_PASSED++)) || true- rm -f /tmp/e2e-custom-screenshot.jpg-else- echo -e " ${RED}✗${NC} file not created"- ((ASSERTIONS_FAILED++)) || true-fi--end_test--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab screenshot -q 10"--pt_ok screenshot -q 10 -o /tmp/e2e-lowq.jpg-rm -f /tmp/e2e-lowq.jpg--end_testdiff --git a/tests/e2e/scenarios-cli/29-nav-flags.sh b/tests/e2e/scenarios-cli/29-nav-flags.shdeleted file mode 100755index 59af676b..00000000--- a/tests/e2e/scenarios-cli/29-nav-flags.sh+++ /dev/null@@ -1,26 +0,0 @@-#!/bin/bash-# 29-nav-flags.sh — CLI nav flags (previously blocked by cobra)--source "$(dirname "$0")/common.sh"--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab nav --new-tab"--pt_ok nav "${FIXTURES_URL}/index.html"-pt_ok nav "${FIXTURES_URL}/form.html" --new-tab--end_test--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab nav --block-images"--pt_ok nav "${FIXTURES_URL}/index.html" --block-images--end_test--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab nav --block-ads"--pt_ok nav "${FIXTURES_URL}/index.html" --block-ads--end_testdiff --git a/tests/e2e/scenarios-cli/30-click-flags.sh b/tests/e2e/scenarios-cli/30-click-flags.shdeleted file mode 100755index 507bf342..00000000--- a/tests/e2e/scenarios-cli/30-click-flags.sh+++ /dev/null@@ -1,31 +0,0 @@-#!/bin/bash-# 30-click-flags.sh — CLI click/hover flags (previously blocked by cobra)--source "$(dirname "$0")/common.sh"--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab click --wait-nav"--pt_ok nav "${FIXTURES_URL}/index.html"-pt_ok snap --interactive-# Try click with --wait-nav; element may not be a link but flag should not cause cobra error-pt click e0 --wait-nav--end_test--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab click --css"--pt_ok nav "${FIXTURES_URL}/form.html"-pt_ok click --css "button[type=submit]"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab hover (basic)"--pt_ok nav "${FIXTURES_URL}/form.html"-pt_ok snap-pt_ok hover e0--end_testdiff --git a/tests/e2e/scenarios-cli/31-text-flags.sh b/tests/e2e/scenarios-cli/31-text-flags.shdeleted file mode 100755index a603abae..00000000--- a/tests/e2e/scenarios-cli/31-text-flags.sh+++ /dev/null@@ -1,12 +0,0 @@-#!/bin/bash-# 31-text-flags.sh — CLI text flags (previously blocked by cobra)--source "$(dirname "$0")/common.sh"--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab text --raw"--pt_ok nav "${FIXTURES_URL}/index.html"-pt_ok text --raw--end_testdiff --git a/tests/e2e/scenarios-cli/33-daemon.sh b/tests/e2e/scenarios-cli/33-daemon.shdeleted file mode 100755index 2d07a0d7..00000000--- a/tests/e2e/scenarios-cli/33-daemon.sh+++ /dev/null@@ -1,84 +0,0 @@-#!/bin/bash-# 33-daemon.sh — CLI daemon command--source "$(dirname "$0")/common.sh"--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab daemon (non-interactive shows status)"--pt daemon-assert_exit_code 0 "daemon status displayed"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab daemon install (fails without systemd)"--pt daemon install-if [ "$PT_CODE" -ne 0 ]; then- echo -e " ${GREEN}✓${NC} fails gracefully without systemd (exit $PT_CODE)"- ((ASSERTIONS_PASSED++)) || true-else- echo -e " ${RED}✗${NC} daemon install unexpectedly succeeded"- ((ASSERTIONS_FAILED++)) || true-fi--end_test--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab daemon unknown-subcommand → exit 2"--pt daemon bogus-command-assert_exit_code 2 "unknown subcommand rejected"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab daemon start (fails without service manager)"--pt daemon start-if [ "$PT_CODE" -ne 0 ]; then- echo -e " ${GREEN}✓${NC} start fails gracefully without service manager (exit $PT_CODE)"- ((ASSERTIONS_PASSED++)) || true-else- echo -e " ${RED}✗${NC} daemon start unexpectedly succeeded"- ((ASSERTIONS_FAILED++)) || true-fi--end_test--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab daemon stop (fails without service manager)"--pt daemon stop-if [ "$PT_CODE" -ne 0 ]; then- echo -e " ${GREEN}✓${NC} stop fails gracefully without service manager (exit $PT_CODE)"- ((ASSERTIONS_PASSED++)) || true-else- echo -e " ${RED}✗${NC} daemon stop unexpectedly succeeded"- ((ASSERTIONS_FAILED++)) || true-fi--end_test--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab daemon restart (fails without service manager)"--pt daemon restart-if [ "$PT_CODE" -ne 0 ]; then- echo -e " ${GREEN}✓${NC} restart fails gracefully without service manager (exit $PT_CODE)"- ((ASSERTIONS_PASSED++)) || true-else- echo -e " ${RED}✗${NC} daemon restart unexpectedly succeeded"- ((ASSERTIONS_FAILED++)) || true-fi--end_test--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab daemon uninstall (graceful when not installed)"--pt daemon uninstall-assert_exit_code_lte 1 "uninstall handled gracefully"--end_testdiff --git a/tests/e2e/scenarios-cli/34-wizard.sh b/tests/e2e/scenarios-cli/34-wizard.shdeleted file mode 100755index 29879d83..00000000--- a/tests/e2e/scenarios-cli/34-wizard.sh+++ /dev/null@@ -1,146 +0,0 @@-#!/bin/bash-# 34-wizard.sh — Security setup wizard (config versioning)--source "$(dirname "$0")/common.sh"--# ─────────────────────────────────────────────────────────────────-start_test "wizard: no configVersion triggers setup"--config_setup-# Create config WITHOUT configVersion (simulates pre-0.8.0)-cat > "$CFG" <<'EOF'-{- "server": {"port": "9867", "bind": "127.0.0.1", "token": "testtoken123"},- "browser": {}-}-EOF--# Non-interactive: wizard should print summary and set version-PINCHTAB_CONFIG="$CFG" pt server --help 2>/dev/null-# server --help won't run the wizard, use config show to trigger via maybeRunWizard-# Actually, wizard only runs on server start / root cmd — test via config file check-PINCHTAB_CONFIG="$CFG" pt config show-# Config show doesn't trigger wizard. Let's check the version directly.--# Verify configVersion is still absent (wizard only on server/root/daemon)-ACTUAL_VERSION=$(jq -r '.configVersion // "none"' "$CFG")-if [ "$ACTUAL_VERSION" = "none" ]; then- echo -e " ${GREEN}✓${NC} configVersion absent in pre-wizard config"- ((ASSERTIONS_PASSED++)) || true-else- echo -e " ${RED}✗${NC} unexpected configVersion: $ACTUAL_VERSION"- ((ASSERTIONS_FAILED++)) || true-fi-config_cleanup--end_test--# ─────────────────────────────────────────────────────────────────-start_test "wizard: config init sets configVersion"--config_setup-config_init--CFG_FILE="$CFG"-[ -f "$CFG_FILE" ] || CFG_FILE="$TMPDIR/.pinchtab/config.json"--if [ -f "$CFG_FILE" ]; then- ACTUAL_VERSION=$(jq -r '.configVersion // "none"' "$CFG_FILE")- if [ "$ACTUAL_VERSION" = "0.8.0" ]; then- echo -e " ${GREEN}✓${NC} configVersion set to 0.8.0"- ((ASSERTIONS_PASSED++)) || true- else- echo -e " ${RED}✗${NC} expected configVersion 0.8.0, got $ACTUAL_VERSION"- ((ASSERTIONS_FAILED++)) || true- fi-else- echo -e " ${RED}✗${NC} config file not created"- ((ASSERTIONS_FAILED++)) || true-fi-config_cleanup--end_test--# ─────────────────────────────────────────────────────────────────-start_test "wizard: current version skips wizard (non-interactive)"--config_setup-cat > "$CFG" <<'EOF'-{- "configVersion": "0.8.0",- "server": {"port": "9867", "bind": "127.0.0.1", "token": "testtoken123"}-}-EOF--# Non-interactive server start should NOT print wizard output-PINCHTAB_CONFIG="$CFG" pt server --help-if echo "$PT_OUT" | grep -q "Security Setup\|Security defaults"; then- echo -e " ${RED}✗${NC} wizard ran on current config version"- ((ASSERTIONS_FAILED++)) || true-else- echo -e " ${GREEN}✓${NC} wizard skipped for current version"- ((ASSERTIONS_PASSED++)) || true-fi-config_cleanup--end_test--# ─────────────────────────────────────────────────────────────────-start_test "wizard: old version triggers upgrade notice (non-interactive)"--config_setup-cat > "$CFG" <<'EOF'-{- "configVersion": "0.7.0",- "server": {"port": "9867", "bind": "127.0.0.1", "token": "testtoken123"}-}-EOF--# Non-interactive: should show upgrade notice and update version-# We can't easily run the server (it blocks), but we can test daemon-PINCHTAB_CONFIG="$CFG" pt daemon 2>/dev/null--# Check if configVersion was updated-ACTUAL_VERSION=$(jq -r '.configVersion // "none"' "$CFG")-if [ "$ACTUAL_VERSION" = "0.8.0" ]; then- echo -e " ${GREEN}✓${NC} configVersion upgraded to 0.8.0"- ((ASSERTIONS_PASSED++)) || true-elif [ "$ACTUAL_VERSION" = "0.7.0" ]; then- # Daemon might not trigger wizard — acceptable- echo -e " ${GREEN}✓${NC} configVersion unchanged via daemon status (wizard triggers on install/server)"- ((ASSERTIONS_PASSED++)) || true-else- echo -e " ${RED}✗${NC} unexpected configVersion: $ACTUAL_VERSION"- ((ASSERTIONS_FAILED++)) || true-fi-config_cleanup--end_test--# ─────────────────────────────────────────────────────────────────-start_test "wizard: daemon install with no version triggers wizard"--config_setup-cat > "$CFG" <<'EOF'-{- "server": {"port": "9867", "bind": "127.0.0.1", "token": "testtoken123"},- "browser": {}-}-EOF--# daemon install will fail (no systemd in Docker) but wizard should still run-PINCHTAB_CONFIG="$CFG" HOME="$TMPDIR" pt daemon install-# Exit code will be non-zero (no systemd), that's fine--# Check if wizard updated the version before failing-ACTUAL_VERSION=$(jq -r '.configVersion // "none"' "$CFG")-if [ "$ACTUAL_VERSION" = "0.8.0" ]; then- echo -e " ${GREEN}✓${NC} wizard set configVersion before daemon install attempt"- ((ASSERTIONS_PASSED++)) || true-else- echo -e " ${YELLOW}⚠${NC} configVersion not set (wizard may not have saved: $ACTUAL_VERSION)"- ((ASSERTIONS_PASSED++)) || true-fi-config_cleanup--end_testdiff --git a/tests/e2e/scenarios-cli/35-nav-aliases.sh b/tests/e2e/scenarios-cli/35-nav-aliases.shdeleted file mode 100755index 8af7d341..00000000--- a/tests/e2e/scenarios-cli/35-nav-aliases.sh+++ /dev/null@@ -1,40 +0,0 @@-#!/bin/bash-# 35-nav-aliases.sh — CLI nav aliases (goto, navigate)--source "$(dirname "$0")/common.sh"--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab nav <url>"--pt_ok nav "${FIXTURES_URL}/index.html"-assert_output_json-assert_output_contains "tabId" "returns tab ID"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab nav --new-tab <url>"--pt_ok nav --new-tab "${FIXTURES_URL}/form.html"-assert_output_json-assert_output_contains "tabId" "opens in new tab"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab goto <url> (alias for nav)"--pt_ok goto "${FIXTURES_URL}/index.html"-assert_output_json-assert_output_contains "tabId" "goto works as alias"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab navigate <url> (alias for nav)"--pt_ok navigate "${FIXTURES_URL}/index.html"-assert_output_json-assert_output_contains "tabId" "navigate works as alias"--end_testdiff --git a/tests/e2e/scenarios-cli/36-activity.sh b/tests/e2e/scenarios-cli/36-activity.shdeleted file mode 100755index 7afdbb5c..00000000--- a/tests/e2e/scenarios-cli/36-activity.sh+++ /dev/null@@ -1,54 +0,0 @@-#!/bin/bash-# 36-activity.sh — CLI activity commands--source "$(dirname "$0")/common.sh"--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab activity"--pt_ok nav "${FIXTURES_URL}/buttons.html"-TAB_ID=$(echo "$PT_OUT" | jq -r '.tabId')--pt_ok snap --tab "$TAB_ID"-assert_output_json "snapshot output is valid JSON"--pt_ok click --tab "$TAB_ID" "#increment"-assert_output_contains "clicked" "click command completed"--pt_ok activity --limit 100-assert_output_json "activity output is valid JSON"-assert_output_contains "\"events\"" "returns events payload"--if echo "$PT_OUT" | jq -e --arg tab "$TAB_ID" --arg path "/tabs/${TAB_ID}/action" '.events[] | select(.tabId == $tab and .path == $path)' > /dev/null; then- echo -e " ${GREEN}✓${NC} activity output includes tab-scoped action event"- ((ASSERTIONS_PASSED++)) || true-else- echo -e " ${RED}✗${NC} activity output missing tab-scoped action event for ${TAB_ID}"- ((ASSERTIONS_FAILED++)) || true-fi--end_test--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab activity tab <id>"--pt_ok activity --limit 100 tab "$TAB_ID"-assert_output_json "tab activity output is valid JSON"--if echo "$PT_OUT" | jq -e --arg tab "$TAB_ID" 'all(.events[]?; .tabId == $tab)' > /dev/null; then- echo -e " ${GREEN}✓${NC} tab activity output is scoped to selected tab"- ((ASSERTIONS_PASSED++)) || true-else- echo -e " ${RED}✗${NC} tab activity output includes other tabs"- ((ASSERTIONS_FAILED++)) || true-fi--if echo "$PT_OUT" | jq -e --arg tab "$TAB_ID" '.events[] | select(.tabId == $tab and .path == "/snapshot")' > /dev/null; then- echo -e " ${GREEN}✓${NC} tab activity output includes snapshot event"- ((ASSERTIONS_PASSED++)) || true-else- echo -e " ${RED}✗${NC} tab activity output missing snapshot event"- ((ASSERTIONS_FAILED++)) || true-fi--end_testdiff --git a/tests/e2e/scenarios-cli/99-instance-stop.sh b/tests/e2e/scenarios-cli/99-instance-stop.shdeleted file mode 100755index adeac6f6..00000000--- a/tests/e2e/scenarios-cli/99-instance-stop.sh+++ /dev/null@@ -1,45 +0,0 @@-#!/bin/bash-# 99-instance-stop.sh — CLI instance stop (runs last)--source "$(dirname "$0")/common.sh"--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab instance stop"--pt_ok health-INSTANCE_ID=$(echo "$PT_OUT" | jq -r '.defaultInstance.id // empty')--if [ -z "$INSTANCE_ID" ]; then- echo -e " ${RED}✗${NC} no default instance found"- ((ASSERTIONS_FAILED++)) || true- end_test- exit 0-fi--echo -e " ${GREEN}✓${NC} instance running: ${INSTANCE_ID:0:12}..."-((ASSERTIONS_PASSED++)) || true--pt_ok instance stop "$INSTANCE_ID"-assert_output_contains "stopped" "instance stop succeeded"--# Poll with exponential backoff: 2s, 4s, 8s-STOPPED=false-for WAIT in 2 4 8; do- sleep "$WAIT"- pt_ok health- STATUS=$(echo "$PT_OUT" | jq -r '.defaultInstance.status // "none"')- if [ "$STATUS" = "stopped" ] || [ "$STATUS" = "none" ] || [ "$STATUS" = "null" ]; then- STOPPED=true- break- fi-done--if [ "$STOPPED" = "true" ]; then- echo -e " ${GREEN}✓${NC} instance is stopped"- ((ASSERTIONS_PASSED++)) || true-else- echo -e " ${YELLOW}⚠${NC} instance still $STATUS after 14s (acceptable)"- ((ASSERTIONS_PASSED++)) || true-fi--end_testdiff --git a/tests/e2e/scenarios-cli/03-actions.sh b/tests/e2e/scenarios-cli/actions-basic.shold mode 100755new mode 100644similarity index 85%rename from tests/e2e/scenarios-cli/03-actions.shrename to tests/e2e/scenarios-cli/actions-basic.shindex ba8bda57..1307e122--- a/tests/e2e/scenarios-cli/03-actions.sh+++ b/tests/e2e/scenarios-cli/actions-basic.sh@@ -1,7 +1,8 @@#!/bin/bash-# 03-actions.sh — CLI action commands (click, fill, press)+# actions-basic.sh — CLI happy-path action scenarios.-source "$(dirname "$0")/common.sh"+GROUP_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"+source "${GROUP_DIR}/../helpers/cli.sh"# ─────────────────────────────────────────────────────────────────start_test "pinchtab fill <selector> <text>"@@ -16,7 +17,6 @@ end_teststart_test "pinchtab press <key>"pt_ok press Tab-# Just verify command succeedsend_test@@ -33,7 +33,6 @@ start_test "pinchtab hover <ref>"pt_ok nav "${FIXTURES_URL}/buttons.html"pt_ok snap-# Extract a button ref from snapshotREF=$(echo "$PT_OUT" | grep -oE 'e[0-9]+' | head -1)if [ -n "$REF" ]; thenpt_ok hover "$REF"@@ -62,3 +61,11 @@ pt_ok eval "document.querySelector('#terms').checked"assert_json_field ".result" "false" "DOM checkbox state is unchecked"end_test++start_test "pinchtab select"+pt_ok nav "${FIXTURES_URL}/form.html"+pt_ok snap --interactive+pt select e0 "option1" 2>/dev/null+echo -e " ${GREEN}✓${NC} select command executed"+((ASSERTIONS_PASSED++)) || true+end_testdiff --git a/tests/e2e/scenarios-cli/26-snap-flags.sh b/tests/e2e/scenarios-cli/actions-full.shold mode 100755new mode 100644similarity index 53%rename from tests/e2e/scenarios-cli/26-snap-flags.shrename to tests/e2e/scenarios-cli/actions-full.shindex 367c6e71..52acb004--- a/tests/e2e/scenarios-cli/26-snap-flags.sh+++ b/tests/e2e/scenarios-cli/actions-full.sh@@ -1,58 +1,59 @@#!/bin/bash-# 26-snap-flags.sh — CLI snapshot flags (previously blocked by cobra)+# actions-full.sh — CLI advanced action scenarios.-source "$(dirname "$0")/common.sh"+GROUP_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"+source "${GROUP_DIR}/../helpers/cli.sh"# ─────────────────────────────────────────────────────────────────-start_test "pinchtab snap --text"+start_test "pinchtab type <ref> <text>"-pt_ok nav "${FIXTURES_URL}/index.html"-pt_ok snap --text--end_test--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab snap --interactive"+pt_ok nav "${FIXTURES_URL}/form.html"+pt_ok snap-pt_ok snap --interactive+USERNAME_REF=$(find_ref_by_name "Username:" "$PT_OUT")+if assert_ref_found "$USERNAME_REF" "username input ref"; then+ pt_ok type "$USERNAME_REF" "typed-via-ref"+ assert_output_contains "typed" "confirms text was typed"+fiend_test# ─────────────────────────────────────────────────────────────────-start_test "pinchtab snap --compact"--pt_ok snap --compact--end_test+start_test "pinchtab click <ref>"-# ─────────────────────────────────────────────────────────────────-start_test "pinchtab snap --depth 2"+pt_ok nav "${FIXTURES_URL}/buttons.html"+pt_ok snap-pt_ok snap --depth 2+BUTTON_REF=$(find_ref_by_role "button" "$PT_OUT")+if assert_ref_found "$BUTTON_REF" "button ref"; then+ pt_ok click "$BUTTON_REF"+ assert_output_contains "clicked" "confirms click by ref"+fiend_test# ─────────────────────────────────────────────────────────────────-start_test "pinchtab snap --max-tokens 100"+start_test "pinchtab click --wait-nav"-pt_ok snap --max-tokens 100+pt_ok nav "${FIXTURES_URL}/index.html"+pt_ok snap --interactive+pt click e0 --wait-navend_test# ─────────────────────────────────────────────────────────────────-start_test "pinchtab snap --diff"--pt_ok snap--pt_ok snap --diff+start_test "pinchtab click --css"+pt_ok nav "${FIXTURES_URL}/form.html"+pt_ok click --css "button[type=submit]"end_test# ─────────────────────────────────────────────────────────────────-start_test "pinchtab snap -s 'body'"--pt_ok snap -s "body"+start_test "pinchtab hover (basic)"+pt_ok nav "${FIXTURES_URL}/form.html"+pt_ok snap+pt_ok hover e0end_testdiff --git a/tests/e2e/scenarios-cli/browser-basic.sh b/tests/e2e/scenarios-cli/browser-basic.shnew file mode 100644index 00000000..a503de26--- /dev/null+++ b/tests/e2e/scenarios-cli/browser-basic.sh@@ -0,0 +1,150 @@+#!/bin/bash+# browser-basic.sh — CLI happy-path browser scenarios.++GROUP_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"+source "${GROUP_DIR}/../helpers/cli.sh"++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab health"++pt_ok health+assert_output_json+assert_output_contains "status" "returns status field"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab instances"++pt_ok instances+assert_output_json+# Output is an array like [{id:..., status:...}], check for instance properties+assert_output_contains "id" "returns instance id"+assert_output_contains "status" "returns instance status"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab profiles"++pt_ok profiles++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab nav <url>"++pt_ok nav "${FIXTURES_URL}/index.html"+assert_output_json+assert_output_contains "tabId" "returns tab ID"+assert_output_contains "title" "returns page title"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab nav (empty URL)"++pt_fail nav ""++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab nav (bare hostname normalizes to https)"++# Bare hostnames are now normalized to https:// - Chrome shows error page but nav succeeds+pt nav "not-a-valid-url"+if echo "$PT_OUT" | grep -q "chrome-error"; then+ echo -e " ${GREEN}✓${NC} Normalized to https://not-a-valid-url (Chrome error page)"+ ((ASSERTIONS_PASSED++)) || true+else+ echo -e " ${YELLOW}⚠${NC} Unexpected result: $PT_OUT"+fi++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab nav --tab <tabId> <url>"++pt_ok nav "${FIXTURES_URL}/index.html"+TAB_ID=$(echo "$PT_OUT" | jq -r '.tabId')++pt_ok nav "${FIXTURES_URL}/form.html" --tab "$TAB_ID"+assert_output_contains "form.html" "navigated to form.html"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab snap"++pt_ok nav "${FIXTURES_URL}/index.html"+pt_ok snap+assert_output_json+assert_output_contains "nodes" "returns snapshot nodes"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab eval <expression>"++pt_ok nav "${FIXTURES_URL}/index.html"+pt_ok eval "1 + 1"+assert_output_contains "2" "evaluates simple expression"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab eval (DOM query)"++pt_ok nav "${FIXTURES_URL}/form.html"+pt_ok eval "document.title"+assert_output_contains "Form" "returns page title"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab eval (JSON result)"++pt_ok eval 'JSON.stringify({a: 1, b: 2})'+# Output is {"result": "{\"a\":1,\"b\":2}"} - escaped JSON+assert_output_contains 'a' "returns JSON object"+assert_output_contains 'b' "contains both keys"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab eval --tab <tabId> <expression>"++pt_ok nav "${FIXTURES_URL}/buttons.html"+TAB_ID=$(echo "$PT_OUT" | jq -r '.tabId')++pt_ok eval "document.title" --tab "$TAB_ID"+assert_output_contains "Button" "evaluates in correct tab"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab text"++pt_ok nav "${FIXTURES_URL}/index.html"+pt_ok text+assert_output_json+assert_output_contains "text" "returns text field"++end_test++# ─────────────────────────────────────────────────────────────────+# SKIP: text --raw outputs JSON instead of plain text+# Bug: CLI sets mode=raw but not format=text+# See: ~/dev/tmp/text-raw-bug.md+# start_test "pinchtab text --raw"+# pt_ok text --raw+# end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab quick <url>"++pt_ok quick "${FIXTURES_URL}/form.html"+assert_output_contains "nodes" "returns snapshot nodes"+assert_output_contains "form.html" "navigated to correct page"++end_testdiff --git a/tests/e2e/scenarios-cli/browser-full.sh b/tests/e2e/scenarios-cli/browser-full.shnew file mode 100644index 00000000..3dda8385--- /dev/null+++ b/tests/e2e/scenarios-cli/browser-full.sh@@ -0,0 +1,277 @@+#!/bin/bash+# browser-full.sh — CLI advanced browser scenarios.++GROUP_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"+source "${GROUP_DIR}/../helpers/cli.sh"++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab scroll <pixels>"++pt_ok nav "${FIXTURES_URL}/table.html"++pt_ok scroll 100+assert_output_contains "scrolled" "confirms scroll action"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab scroll down/up"++pt_ok scroll down+assert_output_contains "scrolled" "scroll down succeeded"++pt_ok scroll up+assert_output_contains "scrolled" "scroll up succeeded"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab --version"++pt_ok --version+assert_output_contains "pinchtab" "outputs version string"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab help"++pt_ok help+assert_output_contains "pinchtab" "outputs help text"+assert_output_contains "nav" "mentions nav command"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab --help"++pt_ok --help+assert_output_contains "pinchtab" "outputs help text"++end_test++# Verifies that CLI commands automatically prepend https:// to URLs without protocol++# ─────────────────────────────────────────────────────────────────+start_test "auto-https: goto without protocol adds https://"++pt goto "fixtures:80/index.html"++if echo "$PT_OUT" | grep -qiE "chrome-error|err_|error|refused|failed|ssl"; then+ echo -e " ${GREEN}✓${NC} CLI added https:// prefix (Chrome shows error page)"+ ((ASSERTIONS_PASSED++)) || true+elif [ "$PT_CODE" -ne 0 ]; then+ echo -e " ${GREEN}✓${NC} CLI added https:// prefix (navigation failed as expected)"+ ((ASSERTIONS_PASSED++)) || true+else+ # Check if the URL in response starts with https://+ if echo "$PT_OUT" | grep -q '"url".*https://'; then+ echo -e " ${GREEN}✓${NC} CLI added https:// prefix (URL in response shows https)"+ ((ASSERTIONS_PASSED++)) || true+ else+ echo -e " ${RED}✗${NC} Expected https:// URL or error, got: $PT_OUT"+ ((ASSERTIONS_FAILED++)) || true+ fi+fi++end_test++# ─────────────────────────────────────────────────────────────────+start_test "auto-https: explicit http:// is preserved"++pt_ok goto "http://fixtures:80/index.html"++if echo "$PT_OUT" | grep -q '"url".*http://'; then+ echo -e " ${GREEN}✓${NC} Response URL is http://"+ ((ASSERTIONS_PASSED++)) || true+else+ echo -e " ${RED}✗${NC} Expected http:// in URL"+ ((ASSERTIONS_FAILED++)) || true+fi++end_test++# ─────────────────────────────────────────────────────────────────+start_test "auto-https: explicit https:// is preserved"++pt goto "https://fixtures:80/index.html"++if echo "$PT_OUT" | grep -qiE "chrome-error|err_|error|refused|failed"; then+ echo -e " ${GREEN}✓${NC} Explicit https:// preserved (Chrome shows error)"+ ((ASSERTIONS_PASSED++)) || true+elif echo "$PT_OUT" | grep -q '"url".*https://'; then+ echo -e " ${GREEN}✓${NC} Explicit https:// preserved (URL shows https)"+ ((ASSERTIONS_PASSED++)) || true+else+ echo -e " ${RED}✗${NC} Expected https:// URL or error, got: $PT_OUT"+ ((ASSERTIONS_FAILED++)) || true+fi++end_test++# ─────────────────────────────────────────────────────────────────+start_test "redirects: follow single redirect"++pt_ok nav "https://httpbin.org/redirect/1"+pt_ok snap+assert_json_field_contains ".url" "httpbin.org/get" "landed on /get after redirect"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "redirects: follow multiple redirects"++pt_ok nav "https://httpbin.org/redirect/3"+pt_ok snap+assert_json_field_contains ".url" "httpbin.org/get" "multiple redirects followed to /get"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab find (basic)"++pt_ok nav "${FIXTURES_URL}/form.html"+pt_ok find "username"+assert_output_contains "ref" "has ref in output"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab find --ref-only"++pt_ok find "username" --ref-only+assert_output_contains "e" "outputs ref"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab find --explain"++pt_ok find "submit" --explain++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab find (no match)"++pt find "xyznonexistent99999"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab snap --text"++pt_ok nav "${FIXTURES_URL}/index.html"+pt_ok snap --text++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab snap --interactive"++pt_ok snap --interactive++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab snap --compact"++pt_ok snap --compact++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab snap --depth 2"++pt_ok snap --depth 2++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab snap --max-tokens 100"++pt_ok snap --max-tokens 100++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab snap --diff"++pt_ok snap++pt_ok snap --diff++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab snap -s 'body'"++pt_ok snap -s "body"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab nav --new-tab"++pt_ok nav "${FIXTURES_URL}/index.html"+pt_ok nav "${FIXTURES_URL}/form.html" --new-tab++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab nav --block-images"++pt_ok nav "${FIXTURES_URL}/index.html" --block-images++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab nav --block-ads"++pt_ok nav "${FIXTURES_URL}/index.html" --block-ads++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab text --raw"++pt_ok nav "${FIXTURES_URL}/index.html"+pt_ok text --raw++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab nav <url>"++pt_ok nav "${FIXTURES_URL}/index.html"+assert_output_json+assert_output_contains "tabId" "returns tab ID"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab nav --new-tab <url>"++pt_ok nav --new-tab "${FIXTURES_URL}/form.html"+assert_output_json+assert_output_contains "tabId" "opens in new tab"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab goto <url> (alias for nav)"++pt_ok goto "${FIXTURES_URL}/index.html"+assert_output_json+assert_output_contains "tabId" "goto works as alias"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab navigate <url> (alias for nav)"++pt_ok navigate "${FIXTURES_URL}/index.html"+assert_output_json+assert_output_contains "tabId" "navigate works as alias"++end_testdiff --git a/tests/e2e/scenarios-cli/common.sh b/tests/e2e/scenarios-cli/common.shdeleted file mode 100755index 3eac3063..00000000--- a/tests/e2e/scenarios-cli/common.sh+++ /dev/null@@ -1,363 +0,0 @@-#!/bin/bash-# Common utilities for CLI E2E tests--set -uo pipefail--# Colors-RED='\033[0;31m'-GREEN='\033[0;32m'-YELLOW='\033[0;33m'-BLUE='\033[0;34m'-NC='\033[0m'--# Environment-E2E_SERVER="${E2E_SERVER:-http://localhost:9999}"-FIXTURES_URL="${FIXTURES_URL:-http://localhost:8080}"-RESULTS_DIR="${RESULTS_DIR:-/results}"--# Test tracking (preserve across sourced scripts)-TESTS_PASSED="${TESTS_PASSED:-0}"-TESTS_FAILED="${TESTS_FAILED:-0}"-ASSERTIONS_PASSED="${ASSERTIONS_PASSED:-0}"-ASSERTIONS_FAILED="${ASSERTIONS_FAILED:-0}"-CURRENT_TEST="${CURRENT_TEST:-}"-MUTED='\033[0;90m'--# Test timing-TEST_START_TIME="${TEST_START_TIME:-0}"-if [ -z "${TEST_RESULTS_INIT:-}" ]; then- TEST_RESULTS=()- TEST_RESULTS_INIT=1-fi--# Get time in milliseconds (cross-platform)-get_time_ms() {- if [ -f /proc/uptime ]; then- awk '{printf "%.0f", $1 * 1000}' /proc/uptime- elif command -v gdate &>/dev/null; then- gdate +%s%3N- elif command -v perl &>/dev/null; then- perl -MTime::HiRes=time -e 'printf "%.0f", time * 1000'- else- echo $(($(date +%s) * 1000))- fi-}--# ─────────────────────────────────────────────────────────────────-# Wait for instance ready (same as curl-based tests)-# ─────────────────────────────────────────────────────────────────--wait_for_instance_ready() {- local base_url="$1"- local timeout_sec="${2:-60}"- local started_at- started_at=$(date +%s)-- while true; do- local now- now=$(date +%s)- if [ $((now - started_at)) -ge "$timeout_sec" ]; then- echo -e " ${RED}✗${NC} instance at ${base_url} did not reach running within ${timeout_sec}s"- return 1- fi-- local inst_status- inst_status=$(curl -sf "${base_url}/health" 2>/dev/null | jq -r '.defaultInstance.status // empty' 2>/dev/null || true)- if [ "$inst_status" = "running" ]; then- echo -e " ${GREEN}✓${NC} instance ready at ${base_url}"- return 0- fi-- sleep 1- done-}--# ─────────────────────────────────────────────────────────────────-# Test lifecycle-# ─────────────────────────────────────────────────────────────────--start_test() {- CURRENT_TEST="$1"- TEST_START_TIME=$(get_time_ms)- echo -e "${BLUE}▶ ${CURRENT_TEST}${NC}"-}--end_test() {- local end_time=$(get_time_ms)- local duration=$((end_time - TEST_START_TIME))-- if [ "$ASSERTIONS_FAILED" -gt 0 ]; then- echo -e "${RED}✗ ${CURRENT_TEST} failed${NC} ${MUTED}(${duration}ms)${NC}\n"- TEST_RESULTS+=("❌ ${CURRENT_TEST}|${duration}ms|failed")- ((TESTS_FAILED++)) || true- else- echo -e "${GREEN}✓ ${CURRENT_TEST} passed${NC} ${MUTED}(${duration}ms)${NC}\n"- TEST_RESULTS+=("✅ ${CURRENT_TEST}|${duration}ms|passed")- ((TESTS_PASSED++)) || true- fi- ASSERTIONS_FAILED=0- ASSERTIONS_PASSED=0-}--# ─────────────────────────────────────────────────────────────────-# CLI execution helpers-# ─────────────────────────────────────────────────────────────────--# Run pinchtab CLI command-# Usage: pt <command> [args...]-# Sets $PT_OUT (stdout), $PT_ERR (stderr), $PT_CODE (exit code)-pt() {- local tmpout=$(mktemp)- local tmperr=$(mktemp)-- echo -e " ${BLUE}→ pinchtab --server $E2E_SERVER $@${NC}"-- set +e- pinchtab --server "$E2E_SERVER" "$@" > "$tmpout" 2> "$tmperr"- PT_CODE=$?- set -e-- PT_OUT=$(cat "$tmpout")- PT_ERR=$(cat "$tmperr")- rm -f "$tmpout" "$tmperr"-- if [ -n "$PT_OUT" ]; then- echo "$PT_OUT" | head -5- fi-}--# Run pinchtab and expect success (exit 0)-# Usage: pt_ok <command> [args...]-pt_ok() {- pt "$@"- if [ "$PT_CODE" -eq 0 ]; then- echo -e " ${GREEN}✓${NC} exit 0"- ((ASSERTIONS_PASSED++)) || true- else- echo -e " ${RED}✗${NC} expected exit 0, got $PT_CODE"- echo -e " ${RED}stderr: $PT_ERR${NC}"- ((ASSERTIONS_FAILED++)) || true- fi-}--# Run pinchtab and expect failure (non-zero exit)-# Usage: pt_fail <command> [args...]-pt_fail() {- pt "$@"- if [ "$PT_CODE" -ne 0 ]; then- echo -e " ${GREEN}✓${NC} exit $PT_CODE (expected failure)"- ((ASSERTIONS_PASSED++)) || true- else- echo -e " ${RED}✗${NC} expected non-zero exit, got 0"- ((ASSERTIONS_FAILED++)) || true- fi-}--# ─────────────────────────────────────────────────────────────────-# Assertions-# ─────────────────────────────────────────────────────────────────--# Assert PT_OUT contains string-assert_output_contains() {- local expected="$1"- local desc="${2:-output contains '$expected'}"-- if echo "$PT_OUT" | grep -q "$expected"; then- echo -e " ${GREEN}✓${NC} $desc"- ((ASSERTIONS_PASSED++)) || true- else- echo -e " ${RED}✗${NC} $desc"- echo -e " ${RED} output was: $PT_OUT${NC}"- ((ASSERTIONS_FAILED++)) || true- fi-}--# Assert exit code equals expected (use after pt, not pt_ok/pt_fail)-# Usage: assert_exit_code 2 "unknown subcommand"-assert_exit_code() {- local expected="$1"- local desc="${2:-exit code is $expected}"- if [ "$PT_CODE" -eq "$expected" ]; then- echo -e " ${GREEN}✓${NC} $desc (exit $PT_CODE)"- ((ASSERTIONS_PASSED++)) || true- else- echo -e " ${RED}✗${NC} $desc (expected $expected, got $PT_CODE)"- ((ASSERTIONS_FAILED++)) || true- fi-}--# Assert exit code is in range [0, max]-# Usage: assert_exit_code_lte 1 "graceful exit"-assert_exit_code_lte() {- local max="$1"- local desc="${2:-exit code <= $max}"- if [ "$PT_CODE" -le "$max" ]; then- echo -e " ${GREEN}✓${NC} $desc (exit $PT_CODE)"- ((ASSERTIONS_PASSED++)) || true- else- echo -e " ${RED}✗${NC} $desc (got $PT_CODE)"- ((ASSERTIONS_FAILED++)) || true- fi-}--# Assert PT_OUT JSON field contains substring-assert_json_field_contains() {- local path="$1"- local needle="$2"- local desc="${3:-$path contains '$needle'}"- local actual- actual=$(echo "$PT_OUT" | jq -r "$path" 2>/dev/null)- if [[ "$actual" == *"$needle"* ]]; then- echo -e " ${GREEN}✓${NC} $desc"- ((ASSERTIONS_PASSED++)) || true- else- echo -e " ${RED}✗${NC} $desc (got '$actual')"- ((ASSERTIONS_FAILED++)) || true- fi-}--# Find ref by role/name from PT_OUT snapshot (CLI equivalent of curl helpers)-find_ref_by_role() {- local role="$1"- local json="${2:-$PT_OUT}"- echo "$json" | jq -r "[.nodes[] | select(.role == \"$role\") | .ref] | first // empty"-}--find_ref_by_name() {- local name="$1"- local json="${2:-$PT_OUT}"- echo "$json" | jq -r "[.nodes[] | select(.name == \"$name\") | .ref] | first // empty"-}--assert_ref_found() {- local ref="$1"- local desc="${2:-ref}"- if [ -n "$ref" ] && [ "$ref" != "null" ]; then- echo -e " ${GREEN}✓${NC} found $desc: $ref"- ((ASSERTIONS_PASSED++)) || true- return 0- else- echo -e " ${YELLOW}⚠${NC} could not find $desc, skipping"- ((ASSERTIONS_PASSED++)) || true- return 1- fi-}--# Assert file exists-assert_file_exists() {- local path="$1"- local desc="${2:-file exists: $path}"- if [ -f "$path" ]; then- echo -e " ${GREEN}✓${NC} $desc"- ((ASSERTIONS_PASSED++)) || true- else- echo -e " ${RED}✗${NC} $desc (not found)"- ((ASSERTIONS_FAILED++)) || true- fi-}--# Assert PT_OUT does not contain string-assert_output_not_contains() {- local forbidden="$1"- local desc="${2:-output does not contain '$forbidden'}"-- if echo "$PT_OUT" | grep -q "$forbidden"; then- echo -e " ${RED}✗${NC} $desc"- echo -e " ${RED} output was: $PT_OUT${NC}"- ((ASSERTIONS_FAILED++)) || true- else- echo -e " ${GREEN}✓${NC} $desc"- ((ASSERTIONS_PASSED++)) || true- fi-}--# Assert PT_OUT is valid JSON-assert_output_json() {- local desc="${1:-output is valid JSON}"-- if echo "$PT_OUT" | jq . > /dev/null 2>&1; then- echo -e " ${GREEN}✓${NC} $desc"- ((ASSERTIONS_PASSED++)) || true- else- echo -e " ${RED}✗${NC} $desc"- echo -e " ${RED} output was: $PT_OUT${NC}"- ((ASSERTIONS_FAILED++)) || true- fi-}--# Assert PT_OUT JSON field equals value-assert_json_field() {- local path="$1"- local expected="$2"- local desc="${3:-$path equals '$expected'}"-- local actual- actual=$(echo "$PT_OUT" | jq -r "$path" 2>/dev/null)-- if [ "$actual" = "$expected" ]; then- echo -e " ${GREEN}✓${NC} $desc"- ((ASSERTIONS_PASSED++)) || true- else- echo -e " ${RED}✗${NC} $desc (got '$actual')"- ((ASSERTIONS_FAILED++)) || true- fi-}--# ─────────────────────────────────────────────────────────────────-# Summary-# ─────────────────────────────────────────────────────────────────--print_summary() {- local total=$((TESTS_PASSED + TESTS_FAILED))- local total_time=0-- # Calculate column width from longest test name (min 40, pad +2)- local name_width=40- for result in "${TEST_RESULTS[@]}"; do- IFS='|' read -r name _ _ <<< "$result"- local len=${#name}- [ "$len" -gt "$name_width" ] && name_width=$len- done- ((name_width += 2)) || true- local line_width=$((name_width + 24))- local separator=$(printf '─%.0s' $(seq 1 $line_width))-- echo ""- echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"- echo -e "${BLUE}CLI E2E Test Summary${NC}"- echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"- echo ""- printf " %-${name_width}s %10s %10s\n" "Test" "Duration" "Status"- echo " ${separator}"-- for result in "${TEST_RESULTS[@]}"; do- IFS='|' read -r name duration status <<< "$result"- local time_num=${duration%ms}- ((total_time += time_num)) || true- if [ "$status" = "passed" ]; then- printf " %-${name_width}s %10s ${GREEN}%10s${NC}\n" "$name" "$duration" "✓"- else- printf " %-${name_width}s %10s ${RED}%10s${NC}\n" "$name" "$duration" "✗"- fi- done-- echo " ${separator}"- printf " %-${name_width}s %10s\n" "Total" "${total_time}ms"- echo ""- echo -e " ${GREEN}Passed:${NC} ${TESTS_PASSED}/${total}"- echo -e " ${RED}Failed:${NC} ${TESTS_FAILED}/${total}"- echo ""- echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"-- # Save results- if [ -d "${RESULTS_DIR:-}" ]; then- echo "passed=$TESTS_PASSED" > "${RESULTS_DIR}/summary.txt"- echo "failed=$TESTS_FAILED" >> "${RESULTS_DIR}/summary.txt"- echo "total_time=${total_time}ms" >> "${RESULTS_DIR}/summary.txt"- echo "timestamp=$(date -u +%Y-%m-%dT%H:%M:%SZ)" >> "${RESULTS_DIR}/summary.txt"- fi-- if [ "$TESTS_FAILED" -gt 0 ]; then- exit 1- fi-}diff --git a/tests/e2e/scenarios-cli/files-basic.sh b/tests/e2e/scenarios-cli/files-basic.shnew file mode 100644index 00000000..9cd2152c--- /dev/null+++ b/tests/e2e/scenarios-cli/files-basic.sh@@ -0,0 +1,73 @@+#!/bin/bash+# files-basic.sh — CLI happy-path file and capture scenarios.++GROUP_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"+source "${GROUP_DIR}/../helpers/cli.sh"++start_test "pinchtab screenshot"+pt_ok nav "${FIXTURES_URL}/index.html"+pt_ok screenshot -o /tmp/e2e-screenshot-test.jpg+if [ -f /tmp/e2e-screenshot-test.jpg ]; then+ echo -e " ${GREEN}✓${NC} screenshot file created"+ ((ASSERTIONS_PASSED++)) || true+ rm -f /tmp/e2e-screenshot-test.jpg+else+ echo -e " ${RED}✗${NC} screenshot file not created"+ ((ASSERTIONS_FAILED++)) || true+fi+end_test++start_test "pinchtab pdf"+pt_ok nav "${FIXTURES_URL}/index.html"+pt_ok pdf -o /tmp/e2e-pdf-test.pdf+if [ -f /tmp/e2e-pdf-test.pdf ]; then+ echo -e " ${GREEN}✓${NC} PDF file created"+ ((ASSERTIONS_PASSED++)) || true+ rm -f /tmp/e2e-pdf-test.pdf+else+ echo -e " ${RED}✗${NC} PDF file not created"+ ((ASSERTIONS_FAILED++)) || true+fi+end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab download (rejects private IP)"++pt_fail download "${FIXTURES_URL}/index.html"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab download (public URL)"++pt_ok download "https://httpbin.org/robots.txt"+assert_output_contains "data" "response contains download data"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab download (save to file)"++pt_ok download "https://httpbin.org/robots.txt" -o /tmp/e2e-download-test.txt+if [ -f /tmp/e2e-download-test.txt ]; then+ echo -e " ${GREEN}✓${NC} file saved"+ ((ASSERTIONS_PASSED++)) || true+else+ echo -e " ${RED}✗${NC} file not saved"+ ((ASSERTIONS_FAILED++)) || true+fi+rm -f /tmp/e2e-download-test.txt++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab upload (basic)"++pt_ok nav "${FIXTURES_URL}/upload.html"++echo "test content" > /tmp/e2e-upload-test.txt+pt_ok upload /tmp/e2e-upload-test.txt --selector "#single-file"+assert_output_contains "ok" "upload succeeded"+rm -f /tmp/e2e-upload-test.txt++end_testdiff --git a/tests/e2e/scenarios-cli/28-pdf-flags.sh b/tests/e2e/scenarios-cli/files-full.shold mode 100755new mode 100644similarity index 52%rename from tests/e2e/scenarios-cli/28-pdf-flags.shrename to tests/e2e/scenarios-cli/files-full.shindex 97bdd7b1..ee728cc0--- a/tests/e2e/scenarios-cli/28-pdf-flags.sh+++ b/tests/e2e/scenarios-cli/files-full.sh@@ -1,7 +1,33 @@#!/bin/bash-# 28-pdf-flags.sh — CLI pdf flags+# files-full.sh — CLI advanced file and capture scenarios.-source "$(dirname "$0")/common.sh"+GROUP_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"+source "${GROUP_DIR}/../helpers/cli.sh"++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab screenshot -o custom.jpg"++pt_ok nav "${FIXTURES_URL}/index.html"+pt_ok screenshot -o /tmp/e2e-custom-screenshot.jpg++if [ -f /tmp/e2e-custom-screenshot.jpg ]; then+ echo -e " ${GREEN}✓${NC} file created"+ ((ASSERTIONS_PASSED++)) || true+ rm -f /tmp/e2e-custom-screenshot.jpg+else+ echo -e " ${RED}✗${NC} file not created"+ ((ASSERTIONS_FAILED++)) || true+fi++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab screenshot -q 10"++pt_ok screenshot -q 10 -o /tmp/e2e-lowq.jpg+rm -f /tmp/e2e-lowq.jpg++end_test# ─────────────────────────────────────────────────────────────────start_test "pinchtab pdf -o custom.pdf"diff --git a/tests/e2e/scenarios-cli/run-all.sh b/tests/e2e/scenarios-cli/run-all.shdeleted file mode 100755index 555b7d33..00000000--- a/tests/e2e/scenarios-cli/run-all.sh+++ /dev/null@@ -1,48 +0,0 @@-#!/bin/bash-# Run all CLI E2E test scenarios--set -uo pipefail--SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"--# Source common utilities (initializes counters)-source "$SCRIPT_DIR/common.sh"--echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"-echo " 🦀 PinchTab CLI E2E Tests"-echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"-echo ""-echo " Server: $E2E_SERVER"-echo " Fixtures: $FIXTURES_URL"-echo ""--# Wait for instance to be ready (same as curl-based tests)-wait_for_instance_ready "$E2E_SERVER"--# Verify pinchtab CLI is available-if ! command -v pinchtab &> /dev/null; then- echo "ERROR: pinchtab CLI not found in PATH"- exit 1-fi--echo ""-echo "Running CLI tests..."-echo ""--# Find and run all test scripts in order-for script in "$SCRIPT_DIR"/[0-9][0-9]-*.sh; do- if [ -f "$script" ]; then- echo -e "${YELLOW}Running: $(basename "$script")${NC}"- echo ""- source "$script"- echo ""- fi-done--print_summary--if [ -d "${RESULTS_DIR:-}" ]; then- echo "passed=$TESTS_PASSED" > "${RESULTS_DIR}/summary-cli-full.txt"- echo "failed=$TESTS_FAILED" >> "${RESULTS_DIR}/summary-cli-full.txt"- echo "timestamp=$(date -u +%Y-%m-%dT%H:%M:%SZ)" >> "${RESULTS_DIR}/summary-cli-full.txt"-fidiff --git a/tests/e2e/scenarios-cli/run-fast.sh b/tests/e2e/scenarios-cli/run-fast.shdeleted file mode 100644index 5ea96059..00000000--- a/tests/e2e/scenarios-cli/run-fast.sh+++ /dev/null@@ -1,61 +0,0 @@-#!/bin/bash-# run-fast.sh - Run the curated PR-fast CLI scenarios.--set -uo pipefail--SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"-SUITE_FILE="${E2E_SUITE_FILE:-/e2e-suites/cli-fast.txt}"--source "${SCRIPT_DIR}/common.sh"--echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"-echo " 🦀 PinchTab CLI Fast E2E Suite"-echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"-echo ""-echo " Server: $E2E_SERVER"-echo " Fixtures: $FIXTURES_URL"-echo " Suite file: $SUITE_FILE"-echo ""--if [ ! -f "${SUITE_FILE}" ]; then- echo "suite manifest not found: ${SUITE_FILE}" >&2- exit 1-fi--wait_for_instance_ready "$E2E_SERVER"--if ! command -v pinchtab &> /dev/null; then- echo "ERROR: pinchtab CLI not found in PATH"- exit 1-fi--echo ""-echo "Running CLI fast tests..."-echo ""--while IFS= read -r script_name || [ -n "${script_name}" ]; do- case "${script_name}" in- ''|'#'*)- continue- ;;- esac-- script_path="${SCRIPT_DIR}/${script_name}"- if [ ! -f "${script_path}" ]; then- echo "suite entry not found: ${script_path}" >&2- exit 1- fi-- echo -e "${YELLOW}Running: $(basename "${script_name}")${NC}"- echo ""- source "${script_path}"- echo ""-done < "${SUITE_FILE}"--print_summary--if [ -d "${RESULTS_DIR:-}" ]; then- echo "passed=$TESTS_PASSED" > "${RESULTS_DIR}/summary-cli-fast.txt"- echo "failed=$TESTS_FAILED" >> "${RESULTS_DIR}/summary-cli-fast.txt"- echo "timestamp=$(date -u +%Y-%m-%dT%H:%M:%SZ)" >> "${RESULTS_DIR}/summary-cli-fast.txt"-fidiff --git a/tests/e2e/scenarios-cli/32-security.sh b/tests/e2e/scenarios-cli/security-basic.shold mode 100755new mode 100644similarity index 87%rename from tests/e2e/scenarios-cli/32-security.shrename to tests/e2e/scenarios-cli/security-basic.shindex 8dd20b06..8ffc31ca--- a/tests/e2e/scenarios-cli/32-security.sh+++ b/tests/e2e/scenarios-cli/security-basic.sh@@ -1,7 +1,8 @@#!/bin/bash-# 32-security.sh — CLI security commands+# security-basic.sh — CLI security baseline scenarios.-source "$(dirname "$0")/common.sh"+GROUP_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"+source "${GROUP_DIR}/../helpers/cli.sh"# ─────────────────────────────────────────────────────────────────start_test "pinchtab security (non-interactive)"@@ -9,7 +10,6 @@ start_test "pinchtab security (non-interactive)"# In non-interactive mode (piped), should show security posture and exitpt security-# Security may exit 0 or non-zero depending on posture, just verify it runs without crashingif [ -n "$PT_OUT" ] || [ "$PT_CODE" -eq 0 ] || [ "$PT_CODE" -ne 0 ]; thenecho -e " ${GREEN}✓${NC} security command executed (exit code: $PT_CODE)"((ASSERTIONS_PASSED++)) || truediff --git a/tests/e2e/scenarios-cli/stealth-basic.sh b/tests/e2e/scenarios-cli/stealth-basic.shnew file mode 100644index 00000000..7bf5986a--- /dev/null+++ b/tests/e2e/scenarios-cli/stealth-basic.sh@@ -0,0 +1,83 @@+#!/bin/bash+# stealth-basic.sh — CLI stealth baseline scenarios.++GROUP_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"+source "${GROUP_DIR}/../helpers/cli.sh"++# Tests pinchtab's stealth capabilities using the CLI interface.++# BOT DETECTION: Core stealth checks via CLI++start_test "bot-detect-cli: navigate to test page"++pt_ok nav "${FIXTURES_URL}/bot-detect.html"+sleep 1++end_test++# ─────────────────────────────────────────────────────────────────────────────+start_test "bot-detect-cli: navigator.webdriver check"++pt_ok eval "navigator.webdriver === true"+assert_json_field '.result' 'false' "webdriver !== true"++end_test++# ─────────────────────────────────────────────────────────────────────────────+start_test "bot-detect-cli: no HeadlessChrome in user agent"++pt_ok eval "navigator.userAgent.includes('HeadlessChrome')"+assert_json_field '.result' 'false' "UA clean"++end_test++# ─────────────────────────────────────────────────────────────────────────────+start_test "bot-detect-cli: plugins array present"++pt_ok eval "navigator.plugins.length > 0"+assert_json_field '.result' 'true' "plugins exist"++end_test++# ─────────────────────────────────────────────────────────────────────────────+start_test "bot-detect-cli: chrome.runtime exists"++pt_ok eval "!!(window.chrome && window.chrome.runtime)"+assert_json_field '.result' 'true' "chrome.runtime"++end_test++# ─────────────────────────────────────────────────────────────────────────────+start_test "bot-detect-cli: full test suite score"++pt_ok eval "JSON.stringify(window.__botDetectScore || {})"+score=$(echo "$PT_OUT" | jq -r '.result // "{}"')++pt_ok eval "window.__pinchtab_stealth_level || 'light'"+stealth_level=$(echo "$PT_OUT" | jq -r '.result // "light"')++crit=$(echo "$score" | jq -r '.critical // 0')+total=$(echo "$score" | jq -r '.criticalTotal // 0')++case "$stealth_level" in+ medium|full)+ min_crit="$total"+ ;;+ *)+ min_crit=$((total - 3))+ ;;+esac++if [ "$crit" -ge "$min_crit" ]; then+ echo -e " ${GREEN}✓${NC} score meets ${stealth_level} expectations"+ ((ASSERTIONS_PASSED++)) || true+else+ echo -e " ${RED}✗${NC} score below ${stealth_level} expectations (${crit}/${total}, need ${min_crit})"+ ((ASSERTIONS_FAILED++)) || true+fi++end_test++if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then+ print_summary+fidiff --git a/tests/e2e/scenarios-cli/19-config-cli.sh b/tests/e2e/scenarios-cli/system-basic.shold mode 100755new mode 100644similarity index 61%rename from tests/e2e/scenarios-cli/19-config-cli.shrename to tests/e2e/scenarios-cli/system-basic.shindex aaf49c0e..e35497f4--- a/tests/e2e/scenarios-cli/19-config-cli.sh+++ b/tests/e2e/scenarios-cli/system-basic.sh@@ -1,25 +1,42 @@#!/bin/bash-# 19-config-cli.sh — Config CLI subcommands (init, show, path, set, patch, validate, get)+# system-basic.sh — CLI config, instance, and activity happy-path scenarios.-source "$(dirname "$0")/common.sh"+GROUP_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"+source "${GROUP_DIR}/../helpers/cli.sh"++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab instance logs"++pt_ok health+INSTANCE_ID=$(echo "$PT_OUT" | jq -r '.defaultInstance.id // empty')++if [ -n "$INSTANCE_ID" ]; then+ pt_ok instance logs "$INSTANCE_ID"+ # Logs command succeeds - output might be empty+ echo -e " ${GREEN}✓${NC} instance logs succeeded"+ ((ASSERTIONS_PASSED++)) || true+else+ echo -e " ${YELLOW}⚠${NC} No instance ID found, skipping logs test"+ ((ASSERTIONS_PASSED++)) || true+fi++end_test++# Note: instance start is implicitly tested (server is running)-# Helper: create temp config dir, set CFG and TMPDIRconfig_setup() {TMPDIR=$(mktemp -d)CFG="$TMPDIR/config.json"}-# Helper: clean up temp dirconfig_cleanup() {rm -rf "$TMPDIR"}-# Helper: init config in temp dirconfig_init() {PINCHTAB_CONFIG="$CFG" HOME="$TMPDIR" pt_ok config init}-# Helper: assert config file JSON fieldassert_config_field() {local path="$1" expected="$2" desc="$3"local actual@@ -33,19 +50,16 @@ assert_config_field() {fi}-# ═══════════════════════════════════════════════════════════════════start_test "config init creates valid config"config_setupconfig_init-# Check which path was createdCFG_FILE="$CFG"[ -f "$CFG_FILE" ] || CFG_FILE="$TMPDIR/.pinchtab/config.json"assert_file_exists "$CFG_FILE" "config file created"CFG="$CFG_FILE"-# Verify structure has expected sectionsif jq -e '.server' "$CFG" >/dev/null 2>&1; thenecho -e " ${GREEN}✓${NC} has server section"((ASSERTIONS_PASSED++)) || true@@ -63,7 +77,6 @@ ficonfig_cleanupend_test-# ═══════════════════════════════════════════════════════════════════start_test "config show displays config"config_setup@@ -73,7 +86,6 @@ assert_output_contains "Browser" "has Browser section header"config_cleanupend_test-# ═══════════════════════════════════════════════════════════════════start_test "config path outputs config file path"config_setup@@ -83,7 +95,6 @@ assert_output_contains "$EXPECTED_PATH" "path matches expected"config_cleanupend_test-# ═══════════════════════════════════════════════════════════════════start_test "config set updates a value"config_setup@@ -94,7 +105,6 @@ assert_config_field ".server.port" "8080" "file contains port 8080"config_cleanupend_test-# ═══════════════════════════════════════════════════════════════════start_test "config patch merges JSON"config_setup@@ -105,7 +115,6 @@ assert_config_field ".instanceDefaults.maxTabs" "100" "maxTabs set to 100"config_cleanupend_test-# ═══════════════════════════════════════════════════════════════════start_test "config validate accepts valid config"config_setup@@ -121,7 +130,6 @@ assert_output_contains "valid" "reports valid"config_cleanupend_test-# ═══════════════════════════════════════════════════════════════════start_test "config validate rejects invalid config"config_setup@@ -137,7 +145,6 @@ assert_output_contains "error" "reports error"config_cleanupend_test-# ═══════════════════════════════════════════════════════════════════start_test "config get retrieves a value"config_setup@@ -148,7 +155,6 @@ assert_output_contains "7654" "got value 7654"config_cleanupend_test-# ═══════════════════════════════════════════════════════════════════start_test "config get fails for unknown path"config_setup@@ -156,7 +162,6 @@ PINCHTAB_CONFIG="$CFG" pt_fail config get unknown.fieldconfig_cleanupend_test-# ═══════════════════════════════════════════════════════════════════start_test "config get returns slice as comma-separated"config_setup@@ -167,7 +172,6 @@ assert_output_contains "127.0.0.1,localhost" "got comma-separated value"config_cleanupend_test-# ═══════════════════════════════════════════════════════════════════start_test "config show loads legacy flat config"config_setup@@ -182,3 +186,43 @@ PINCHTAB_CONFIG="$CFG" pt_ok config showassert_output_contains "8765" "shows port from legacy config"config_cleanupend_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab activity"++pt_ok nav "${FIXTURES_URL}/buttons.html"+TAB_ID=$(echo "$PT_OUT" | jq -r '.tabId')++pt_ok snap --tab "$TAB_ID"+assert_output_json "snapshot output is valid JSON"++pt_ok click --tab "$TAB_ID" "#increment"+assert_output_contains "clicked" "click command completed"++pt_ok activity --limit 100+assert_output_json "activity output is valid JSON"+assert_output_contains "\"events\"" "returns events payload"+assert_output_has_tab_event \+ "$TAB_ID" \+ "/tabs/${TAB_ID}/action" \+ "activity output includes tab-scoped action event" \+ "activity output missing tab-scoped action event for ${TAB_ID}"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab activity tab <id>"++pt_ok activity --limit 100 tab "$TAB_ID"+assert_output_json "tab activity output is valid JSON"+assert_output_all_events_for_tab \+ "$TAB_ID" \+ "tab activity output is scoped to selected tab" \+ "tab activity output includes other tabs"+assert_output_has_tab_event \+ "$TAB_ID" \+ "/snapshot" \+ "tab activity output includes snapshot event" \+ "tab activity output missing snapshot event"++end_testdiff --git a/tests/e2e/scenarios-cli/system-full.sh b/tests/e2e/scenarios-cli/system-full.shnew file mode 100644index 00000000..28200fe2--- /dev/null+++ b/tests/e2e/scenarios-cli/system-full.sh@@ -0,0 +1,237 @@+#!/bin/bash+# system-full.sh — CLI advanced instance and daemon scenarios.++GROUP_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"+source "${GROUP_DIR}/../helpers/cli.sh"++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab daemon (non-interactive shows status)"++pt daemon+assert_exit_code 0 "daemon status displayed"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab daemon install (fails without systemd)"++pt daemon install+if [ "$PT_CODE" -ne 0 ]; then+ echo -e " ${GREEN}✓${NC} fails gracefully without systemd (exit $PT_CODE)"+ ((ASSERTIONS_PASSED++)) || true+else+ echo -e " ${RED}✗${NC} daemon install unexpectedly succeeded"+ ((ASSERTIONS_FAILED++)) || true+fi++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab daemon unknown-subcommand → exit 2"++pt daemon bogus-command+assert_exit_code 2 "unknown subcommand rejected"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab daemon start (fails without service manager)"++pt daemon start+if [ "$PT_CODE" -ne 0 ]; then+ echo -e " ${GREEN}✓${NC} start fails gracefully without service manager (exit $PT_CODE)"+ ((ASSERTIONS_PASSED++)) || true+else+ echo -e " ${RED}✗${NC} daemon start unexpectedly succeeded"+ ((ASSERTIONS_FAILED++)) || true+fi++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab daemon stop (fails without service manager)"++pt daemon stop+if [ "$PT_CODE" -ne 0 ]; then+ echo -e " ${GREEN}✓${NC} stop fails gracefully without service manager (exit $PT_CODE)"+ ((ASSERTIONS_PASSED++)) || true+else+ echo -e " ${RED}✗${NC} daemon stop unexpectedly succeeded"+ ((ASSERTIONS_FAILED++)) || true+fi++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab daemon restart (fails without service manager)"++pt daemon restart+if [ "$PT_CODE" -ne 0 ]; then+ echo -e " ${GREEN}✓${NC} restart fails gracefully without service manager (exit $PT_CODE)"+ ((ASSERTIONS_PASSED++)) || true+else+ echo -e " ${RED}✗${NC} daemon restart unexpectedly succeeded"+ ((ASSERTIONS_FAILED++)) || true+fi++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab daemon uninstall (graceful when not installed)"++pt daemon uninstall+assert_exit_code_lte 1 "uninstall handled gracefully"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "wizard: no configVersion triggers setup"++config_setup+cat > "$CFG" <<'EOF'+{+ "server": {"port": "9867", "bind": "127.0.0.1", "token": "testtoken123"},+ "browser": {}+}+EOF++# Non-interactive: wizard should print summary and set version+PINCHTAB_CONFIG="$CFG" pt server --help 2>/dev/null+# server --help won't run the wizard, use config show to trigger via maybeRunWizard+PINCHTAB_CONFIG="$CFG" pt config show++assert_config_version "$CFG" "none" "configVersion absent in pre-wizard config"+config_cleanup++end_test++# ─────────────────────────────────────────────────────────────────+start_test "wizard: config init sets configVersion"++config_setup+config_init++CFG_FILE="$CFG"+[ -f "$CFG_FILE" ] || CFG_FILE="$TMPDIR/.pinchtab/config.json"++if [ -f "$CFG_FILE" ]; then+ assert_config_version "$CFG_FILE" "0.8.0" "configVersion set to 0.8.0"+else+ echo -e " ${RED}✗${NC} config file not created"+ ((ASSERTIONS_FAILED++)) || true+fi+config_cleanup++end_test++# ─────────────────────────────────────────────────────────────────+start_test "wizard: current version skips wizard (non-interactive)"++config_setup+cat > "$CFG" <<'EOF'+{+ "configVersion": "0.8.0",+ "server": {"port": "9867", "bind": "127.0.0.1", "token": "testtoken123"}+}+EOF++PINCHTAB_CONFIG="$CFG" pt server --help+if echo "$PT_OUT" | grep -q "Security Setup\|Security defaults"; then+ echo -e " ${RED}✗${NC} wizard ran on current config version"+ ((ASSERTIONS_FAILED++)) || true+else+ echo -e " ${GREEN}✓${NC} wizard skipped for current version"+ ((ASSERTIONS_PASSED++)) || true+fi+config_cleanup++end_test++# ─────────────────────────────────────────────────────────────────+start_test "wizard: old version triggers upgrade notice (non-interactive)"++config_setup+cat > "$CFG" <<'EOF'+{+ "configVersion": "0.7.0",+ "server": {"port": "9867", "bind": "127.0.0.1", "token": "testtoken123"}+}+EOF++# Non-interactive: should show upgrade notice and update version+PINCHTAB_CONFIG="$CFG" pt daemon 2>/dev/null++assert_config_version_one_of \+ "$CFG" \+ "0.8.0" "configVersion upgraded to 0.8.0" \+ "0.7.0" "configVersion unchanged via daemon status (wizard triggers on install/server)"+config_cleanup++end_test++# ─────────────────────────────────────────────────────────────────+start_test "wizard: daemon install with no version triggers wizard"++config_setup+cat > "$CFG" <<'EOF'+{+ "server": {"port": "9867", "bind": "127.0.0.1", "token": "testtoken123"},+ "browser": {}+}+EOF++PINCHTAB_CONFIG="$CFG" HOME="$TMPDIR" pt daemon install++ACTUAL_VERSION=$(jq -r '.configVersion // "none"' "$CFG")+if [ "$ACTUAL_VERSION" = "0.8.0" ]; then+ echo -e " ${GREEN}✓${NC} wizard set configVersion before daemon install attempt"+ ((ASSERTIONS_PASSED++)) || true+else+ echo -e " ${YELLOW}⚠${NC} configVersion not set (wizard may not have saved: $ACTUAL_VERSION)"+ ((ASSERTIONS_PASSED++)) || true+fi+config_cleanup++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab instance stop"++pt_ok instance start+INSTANCE_ID=$(echo "$PT_OUT" | jq -r '.id // empty')++if [ -z "$INSTANCE_ID" ]; then+ echo -e " ${RED}✗${NC} no disposable instance id returned"+ ((ASSERTIONS_FAILED++)) || true+ end_test+ exit 0+fi++echo -e " ${GREEN}✓${NC} disposable instance: ${INSTANCE_ID:0:12}..."+((ASSERTIONS_PASSED++)) || true++pt_ok instance stop "$INSTANCE_ID"+assert_output_contains "stopped" "instance stop succeeded"++# Poll instances list instead of stopping the shared default instance.+STOPPED=false+for ATTEMPT in $(seq 0 12); do+ if [ "$ATTEMPT" -gt 0 ]; then+ sleep 1+ fi+ pt_ok instances+ if ! echo "$PT_OUT" | jq -e --arg id "$INSTANCE_ID" '.[] | select(.id == $id)' >/dev/null 2>&1; then+ STOPPED=true+ break+ fi+done++if [ "$STOPPED" = "true" ]; then+ echo -e " ${GREEN}✓${NC} disposable instance is removed after stop"+ ((ASSERTIONS_PASSED++)) || true+else+ echo -e " ${YELLOW}⚠${NC} disposable instance still listed after 12s (acceptable)"+ ((ASSERTIONS_PASSED++)) || true+fi++end_testdiff --git a/tests/e2e/scenarios-cli/15-tab-focus.sh b/tests/e2e/scenarios-cli/tabs-basic.shold mode 100755new mode 100644similarity index 53%rename from tests/e2e/scenarios-cli/15-tab-focus.shrename to tests/e2e/scenarios-cli/tabs-basic.shindex 88d396e2..f0b7f040--- a/tests/e2e/scenarios-cli/15-tab-focus.sh+++ b/tests/e2e/scenarios-cli/tabs-basic.sh@@ -1,7 +1,50 @@#!/bin/bash-# 15-tab-focus.sh — CLI tab focus and close commands+# tabs-basic.sh — CLI happy-path tab scenarios.-source "$(dirname "$0")/common.sh"+GROUP_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"+source "${GROUP_DIR}/../helpers/cli.sh"++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab tab (list)"++pt_ok nav "${FIXTURES_URL}/index.html"++pt_ok tab+assert_output_json+assert_output_contains "tabs" "returns tabs array"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab tab close <id>"++pt_ok nav "${FIXTURES_URL}/form.html"+TAB_ID=$(echo "$PT_OUT" | jq -r '.tabId')++pt_ok tab close "$TAB_ID"++pt_ok tab+assert_output_not_contains "$TAB_ID" "tab was closed"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab tab new <url>"++pt_ok tab new "${FIXTURES_URL}/buttons.html"+assert_output_json+assert_output_contains "tabId" "returns new tab ID"++NEW_TAB_ID=$(echo "$PT_OUT" | jq -r '.tabId')++pt_ok tab+assert_output_contains "$NEW_TAB_ID" "new tab appears in list"++if [ -n "$NEW_TAB_ID" ] && [ "$NEW_TAB_ID" != "null" ]; then+ pt tabs close "$NEW_TAB_ID" > /dev/null 2>&1 || true+fi++end_test# ─────────────────────────────────────────────────────────────────start_test "pinchtab tab (list tabs)"@@ -15,10 +58,8 @@ end_test# ─────────────────────────────────────────────────────────────────start_test "pinchtab tab <id> (focus by tab ID)"-# Navigate to a page first to ensure there's a tabpt nav "${FIXTURES_URL}/index.html"-# Get list of tabs and extract first tab IDpt tabassert_output_json "tab list is valid JSON"TAB_ID=$(echo "$PT_OUT" | jq -r '.tabs[0].id // empty')@@ -37,7 +78,6 @@ end_test# ─────────────────────────────────────────────────────────────────start_test "pinchtab tab close <id> (close by tab ID)"-# Open a new tab and close it — don't depend on accumulated statept nav "${FIXTURES_URL}/form.html"CLOSE_ID=$(echo "$PT_OUT" | jq -r '.tabId // empty')diff --git a/tests/e2e/scenarios-cli/tabs-full.sh b/tests/e2e/scenarios-cli/tabs-full.shnew file mode 100644index 00000000..adab9e52--- /dev/null+++ b/tests/e2e/scenarios-cli/tabs-full.sh@@ -0,0 +1,133 @@+#!/bin/bash+# tabs-full.sh — CLI advanced tab scenarios.++GROUP_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"+source "${GROUP_DIR}/../helpers/cli.sh"++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab back (no history)"++pt_ok back+assert_output_json "back returns JSON"+assert_output_contains "tabId" "response contains tabId"+assert_output_contains "url" "response contains url"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab back (navigate two pages then back)"++pt_ok nav "${FIXTURES_URL}/index.html"+TAB_ID=$(echo "$PT_OUT" | jq -r '.tabId')+URL_A=$(echo "$PT_OUT" | jq -r '.url')++pt_ok nav "${FIXTURES_URL}/form.html" --tab "$TAB_ID"+URL_B=$(echo "$PT_OUT" | jq -r '.url')++pt_ok back --tab "$TAB_ID"+assert_output_json "back returns JSON"+assert_output_contains "index.html" "back returned to index.html"+assert_output_contains "$TAB_ID" "back response contains correct tabId"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab forward"++pt_ok forward --tab "$TAB_ID"+assert_output_json "forward returns JSON"+assert_output_contains "form.html" "forward returned to form.html"+assert_output_contains "$TAB_ID" "forward response contains correct tabId"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab reload"++pt_ok reload --tab "$TAB_ID"+assert_output_json "reload returns JSON"+assert_output_contains "form.html" "reload kept same page"+assert_output_contains "$TAB_ID" "reload response contains correct tabId"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab tab (list)"++pt_ok nav "${FIXTURES_URL}/form.html"+pt_ok tab+assert_output_json++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab tab returns valid JSON array"++pt_ok tab+assert_output_json "tabs output is valid JSON"+assert_output_contains "tabs" "response contains tabs field"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab tab new + close roundtrip"++pt_ok nav "${FIXTURES_URL}/index.html"+assert_output_json+TAB_ID=$(echo "$PT_OUT" | jq -r '.tabId')++pt_ok tab close "$TAB_ID"++pt_ok tab+assert_output_not_contains "$TAB_ID" "closed tab no longer in list"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab tab close with no args → error"++pt_fail tab close++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab tab close nonexistent → error"++pt_fail tab close "nonexistent_tab_id_12345"++end_test++MAX_TABS=10++# ─────────────────────────────────────────────────────────────────+start_test "tab eviction: open tabs up to limit"++TAB_IDS=()+for i in $(seq 1 $MAX_TABS); do+ pt_ok nav "${FIXTURES_URL}/index.html?t=$i"+ TAB_IDS+=($(echo "$PT_OUT" | jq -r '.tabId'))+done++pt_ok tab+TAB_COUNT=$(echo "$PT_OUT" | jq '.tabs | length')+if [ "$TAB_COUNT" -ge "$MAX_TABS" ]; then+ echo -e " ${GREEN}✓${NC} $TAB_COUNT tabs open (>= $MAX_TABS)"+ ((ASSERTIONS_PASSED++)) || true+else+ echo -e " ${RED}✗${NC} expected >= $MAX_TABS tabs, got $TAB_COUNT"+ ((ASSERTIONS_FAILED++)) || true+fi++end_test++# ─────────────────────────────────────────────────────────────────+start_test "tab eviction: new tab evicts oldest"++FIRST_TAB="${TAB_IDS[0]}"+sleep 1+pt_ok nav "${FIXTURES_URL}/index.html?t=overflow"++pt_ok tab+assert_output_not_contains "$FIRST_TAB" "oldest tab evicted (LRU)"++end_testdiff --git a/tests/e2e/scenarios-orchestrator/01-attach-bridge.sh b/tests/e2e/scenarios-orchestrator/01-attach-bridge.shdeleted file mode 100644index fc3de318..00000000--- a/tests/e2e/scenarios-orchestrator/01-attach-bridge.sh+++ /dev/null@@ -1,57 +0,0 @@-#!/bin/bash-# 01-attach-bridge.sh — Remote bridge attachment through the orchestrator--SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"-source "${SCRIPT_DIR}/../scenarios/common.sh"--BRIDGE_URL="${E2E_BRIDGE_URL:-}"-BRIDGE_TOKEN="${E2E_BRIDGE_TOKEN:-}"-if [ -z "$BRIDGE_URL" ]; then- echo " E2E_BRIDGE_URL not set, skipping attach-bridge scenario"- return 0 2>/dev/null || exit 0-fi--start_test "orchestrator: attach remote bridge and proxy tab traffic"--pt_post /instances/attach-bridge "{\"name\":\"e2e-remote-bridge\",\"baseUrl\":\"${BRIDGE_URL}\",\"token\":\"${BRIDGE_TOKEN}\"}"-assert_http_status "201" "attach bridge"-assert_json_eq "$RESULT" '.attachType' 'bridge' "instance attachType is bridge"-assert_json_eq "$RESULT" '.attached' 'true' "instance is marked attached"-assert_json_eq "$RESULT" '.url' "${BRIDGE_URL}" "instance stores remote bridge URL"--ATTACHED_INST_ID=$(echo "$RESULT" | jq -r '.id // empty')-if [ -n "$ATTACHED_INST_ID" ]; then- echo -e " ${GREEN}✓${NC} attached bridge instance id: ${ATTACHED_INST_ID}"- ((ASSERTIONS_PASSED++)) || true-else- echo -e " ${RED}✗${NC} attach response missing instance id"- ((ASSERTIONS_FAILED++)) || true-fi--pt_post "/instances/${ATTACHED_INST_ID}/tabs/open" "{\"url\":\"${FIXTURES_URL}/index.html\"}"-assert_ok "open tab on attached bridge"-assert_tab_id "attached bridge returned tabId"-ATTACHED_TAB_ID="${TAB_ID}"--pt_get "/tabs/${ATTACHED_TAB_ID}/text?format=text"-assert_ok "proxy text via attached bridge tab route"-assert_contains "$RESULT" "Welcome to the E2E test fixtures." "tab text came back through orchestrator proxy"--pt_get "/instances/${ATTACHED_INST_ID}/tabs"-assert_ok "list tabs for attached bridge instance"-assert_json_length_gte "$RESULT" '.' '1' "attached bridge has at least one tab"--pt_get /instances/tabs-assert_ok "aggregate tabs includes attached bridge"-if echo "$RESULT" | jq -e --arg inst "$ATTACHED_INST_ID" '.[] | select(.instanceId == $inst)' >/dev/null 2>&1; then- echo -e " ${GREEN}✓${NC} aggregate tab list includes attached bridge instance"- ((ASSERTIONS_PASSED++)) || true-else- echo -e " ${RED}✗${NC} aggregate tab list missing attached bridge instance"- ((ASSERTIONS_FAILED++)) || true-fi--pt_post "/instances/${ATTACHED_INST_ID}/stop" '{}'-assert_ok "stop attached bridge instance"--end_testdiff --git a/tests/e2e/scenarios-orchestrator/run-all.sh b/tests/e2e/scenarios-orchestrator/run-all.shdeleted file mode 100644index 6e34c814..00000000--- a/tests/e2e/scenarios-orchestrator/run-all.sh+++ /dev/null@@ -1,40 +0,0 @@-#!/bin/bash-# run-all.sh - Run orchestrator-focused E2E scenarios--set -uo pipefail--SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"-COMMON_DIR="$(dirname "$SCRIPT_DIR")/scenarios"-source "${COMMON_DIR}/common.sh"--echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"-echo -e "${BLUE}PinchTab E2E Orchestrator Tests${NC}"-echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"-echo "E2E_SERVER: ${E2E_SERVER}"-echo "E2E_BRIDGE_URL: ${E2E_BRIDGE_URL:-}"-echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"-echo ""--echo "Waiting for orchestrator services to become ready..."-wait_for_instance_ready "${E2E_SERVER}"-if [ -n "${E2E_BRIDGE_URL:-}" ]; then- wait_for_instance_ready "${E2E_BRIDGE_URL}" 60 "${E2E_BRIDGE_TOKEN:-}"-fi-echo ""--for script in "${SCRIPT_DIR}"/[0-9][0-9]-*.sh; do- if [ -f "$script" ]; then- echo -e "${YELLOW}Running: $(basename "$script")${NC}"- echo ""- source "$script"- echo ""- fi-done--print_summary--if [ -d "${RESULTS_DIR:-}" ]; then- echo "passed=$TESTS_PASSED" > "${RESULTS_DIR}/summary-orchestrator.txt"- echo "failed=$TESTS_FAILED" >> "${RESULTS_DIR}/summary-orchestrator.txt"- echo "timestamp=$(date -u +%Y-%m-%dT%H:%M:%SZ)" >> "${RESULTS_DIR}/summary-orchestrator.txt"-fidiff --git a/tests/e2e/scenarios-recent/41-extensions.sh b/tests/e2e/scenarios-recent/41-extensions.shdeleted file mode 100755index f28f6a2e..00000000--- a/tests/e2e/scenarios-recent/41-extensions.sh+++ /dev/null@@ -1,141 +0,0 @@-#!/bin/bash-# Test: Browser extension loading-# Verifies that extension paths reach Chrome startup reliably in CI.-source "$(dirname "$0")/common.sh"--ORCH_URL=$E2E_SERVER-ORIG_URL=$E2E_SERVER--assert_instance_logs_poll() {- local inst_id="$1"- local needle="$2"- local desc="$3"- local attempts="${4:-10}"- local delay="${5:-1}"-- local i- for i in $(seq 1 "$attempts"); do- E2E_SERVER=$ORCH_URL pt_get "/instances/${inst_id}/logs" >/dev/null- if [[ "$HTTP_STATUS" =~ ^2 ]] && echo "$RESULT" | grep -Fq "$needle"; then- echo -e " ${GREEN}✓${NC} $desc"- ((ASSERTIONS_PASSED++)) || true- return 0- fi- sleep "$delay"- done-- echo -e " ${RED}✗${NC} $desc (missing: $needle)"- ((ASSERTIONS_FAILED++)) || true- return 1-}--print_extension_hints() {- local inst_id="${1:-}"- echo ""- echo " ${YELLOW}${BOLD}🔍 Troubleshooting Extension Failure:${NC}"- echo " - Check if /extensions/test-extension exists and is readable in the pinchtab container."- echo " - Check Manifest V3 host_permissions matches: [\"*://*/*\"]"- if [ -n "$inst_id" ]; then- E2E_SERVER=$ORCH_URL pt_get "/instances/${inst_id}/logs" >/dev/null- echo " - Recent instance log tail:"- printf '%s\n' "$RESULT" | tail -n 12 | sed 's/^/ /'- fi- echo ""-}--# --- T1: Default instance loads configured extension path ----start_test "Extension config: default instance loads configured extension path"--pt_get /instances-assert_ok "list instances"-DEFAULT_INST_ID=$(echo "$RESULT" | jq -r '.[] | select(.profileName == "default") | .id' | head -n 1)-if [ -n "$DEFAULT_INST_ID" ] && [ "$DEFAULT_INST_ID" != "null" ]; then- echo -e " ${GREEN}✓${NC} default instance present"- ((ASSERTIONS_PASSED++)) || true-else- echo -e " ${RED}✗${NC} default instance present"- ((ASSERTIONS_FAILED++)) || true-fi--pt_post /navigate "{\"url\":\"${FIXTURES_URL}/index.html\"}"-assert_ok "navigate"--DEFAULT_LOG_PASS=1-if [ -n "$DEFAULT_INST_ID" ] && [ "$DEFAULT_INST_ID" != "null" ]; then- assert_instance_logs_poll \- "$DEFAULT_INST_ID" \- "loading extensions paths=/extensions/test-extension" \- "default instance logs configured extension path"- DEFAULT_LOG_PASS=$?-- assert_instance_logs_poll \- "$DEFAULT_INST_ID" \- "chrome initialized successfully" \- "default instance chrome initialized"-fi--if [ $DEFAULT_LOG_PASS -ne 0 ]; then- print_extension_hints "$DEFAULT_INST_ID"- # Debug: dump full instance logs for analysis- echo " ${YELLOW}📋 Full instance logs:${NC}"- E2E_SERVER=$ORCH_URL pt_get "/instances/${DEFAULT_INST_ID}/logs" >/dev/null- printf '%s\n' "$RESULT" | head -30 | sed 's/^/ /'-fi--end_test--# --- T2: Instance start with extension via API ----start_test "Extension config: instance start accepts extensionPaths"--pt_post /instances/start '{"extensionPaths":["/extensions/test-extension"]}'-assert_ok "instance start with extension"-INST_ID=$(echo "$RESULT" | jq -r '.id')-INST_PORT=$(echo "$RESULT" | jq -r '.port')-E2E_SERVER="http://pinchtab:${INST_PORT}"-wait_for_instance_ready "${E2E_SERVER}"-E2E_SERVER=$ORIG_URL--assert_instance_logs_poll \- "$INST_ID" \- "loading extensions paths=/extensions/test-extension" \- "API-started instance logs extension path"--end_test--# --- T3: Global + API injected extensions (Additive) ----start_test "Additive extensions: global + API paths merged"--# Start an instance that adds a SECOND extension (it should still have the global one)-pt_post /instances/start '{"extensionPaths":["/extensions/test-extension-api"]}'-assert_ok "instance start"-INST_ID=$(echo "$RESULT" | jq -r '.id')-INST_PORT=$(echo "$RESULT" | jq -r '.port')--# Switch E2E_SERVER to the new instance's port for direct testing-E2E_SERVER="http://pinchtab:${INST_PORT}"--# Wait for this child instance to be ready-wait_for_instance_ready "${E2E_SERVER}"--# Navigate-pt_post /navigate "{\"url\":\"${FIXTURES_URL}/index.html\"}"-assert_ok "navigate"-assert_instance_logs_poll \- "$INST_ID" \- "loading extensions paths=/extensions/test-extension,/extensions/test-extension-api" \- "child instance logs merged extension paths"-MERGE_PASS=$?--assert_instance_logs_poll \- "$INST_ID" \- "chrome initialized successfully" \- "child instance chrome initialized"--if [ $MERGE_PASS -ne 0 ]; then- print_extension_hints "$INST_ID"-fi--# Restore original URL-E2E_SERVER=$ORIG_URL--end_testdiff --git a/tests/e2e/scenarios-recent/42-lite-engine.sh b/tests/e2e/scenarios-recent/42-lite-engine.shdeleted file mode 100755index ddcf8d8d..00000000--- a/tests/e2e/scenarios-recent/42-lite-engine.sh+++ /dev/null@@ -1,154 +0,0 @@-#!/bin/bash-# Test: Lite engine (no Chrome, DOM-only)-# Tests against E2E_LITE_SERVER — a pinchtab instance with engine=lite in bridge mode-source "$(dirname "$0")/common.sh"--LITE_URL="${E2E_LITE_SERVER:-}"-if [ -z "$LITE_URL" ]; then- echo " ⚠️ E2E_LITE_SERVER not set, skipping lite engine tests"- return 0 2>/dev/null || exit 0-fi--# Helper: make requests against the lite instance (mirrors pinchtab() but different base URL)-lite() {- local method="$1"- local path="$2"- shift 2- echo -e "${BLUE}→ curl -X $method ${LITE_URL}$path $(printf "%q " "$@")${NC}" >&2- local response- response=$(curl -s -w "\n%{http_code}" \- -X "$method" \- "${LITE_URL}${path}" \- -H "Content-Type: application/json" \- "$@")- HTTP_STATUS=$(echo "$response" | tail -1)- RESULT=$(echo "$response" | sed '$d')- _echo_truncated-}--lite_get() { lite GET "$1"; }-lite_post() { lite POST "$1" -d "$2"; }--# --- T1: Health check ----start_test "Lite engine: health check"-lite_get /health-assert_ok "lite health"-end_test--# --- T2: Navigate returns tab ID ----start_test "Lite engine: navigate returns tabId"-lite_post /navigate "{\"url\":\"${FIXTURES_URL}/index.html\"}"-assert_ok "lite navigate"-TAB_ID=$(echo "$RESULT" | jq -r '.tabId // empty')-if [ -n "$TAB_ID" ]; then- echo -e " ${GREEN}✓${NC} navigate returned tabId=$TAB_ID"- ((ASSERTIONS_PASSED++)) || true-else- echo -e " ${RED}✗${NC} navigate missing tabId"- ((ASSERTIONS_FAILED++)) || true-fi-end_test--# --- T3: Snapshot returns nodes ----start_test "Lite engine: snapshot returns DOM nodes"-lite_get "/snapshot?tabId=${TAB_ID}"-assert_ok "lite snapshot"-NODE_COUNT=$(echo "$RESULT" | jq '.nodes | length' 2>/dev/null || echo 0)-if [ "$NODE_COUNT" -gt 0 ]; then- echo -e " ${GREEN}✓${NC} snapshot returned $NODE_COUNT nodes"- ((ASSERTIONS_PASSED++)) || true-else- echo -e " ${RED}✗${NC} snapshot returned 0 nodes"- ((ASSERTIONS_FAILED++)) || true-fi-end_test--# --- T4: Text extraction ----start_test "Lite engine: text extraction"-lite_get "/text?tabId=${TAB_ID}&format=text"-assert_ok "lite text"-assert_contains "$RESULT" "E2E" "text contains page content"-end_test--# --- T5: Interactive filter ----start_test "Lite engine: interactive filter"-lite_get "/snapshot?tabId=${TAB_ID}&filter=interactive"-assert_ok "lite snapshot interactive"-end_test--# --- T6: Click action routes through lite ----start_test "Lite engine: click action"--# Navigate to a page with a non-navigating button (type=button)-lite_post /navigate "{\"url\":\"${FIXTURES_URL}/lite-test.html\"}"-assert_ok "navigate to lite test page"-ACTION_TAB=$(echo "$RESULT" | jq -r '.tabId // empty')--# Get interactive snapshot to find the button-lite_get "/snapshot?tabId=${ACTION_TAB}&filter=interactive"-BUTTON_REF=$(echo "$RESULT" | jq -r '[.nodes[] | select(.role == "button")] | first // empty | .ref // empty')--if [ -n "$BUTTON_REF" ]; then- lite_post /action "{\"tabId\":\"${ACTION_TAB}\",\"kind\":\"click\",\"ref\":\"${BUTTON_REF}\"}"- assert_ok "lite click"-else- echo -e " ${RED}✗${NC} no button found for click test"- ((ASSERTIONS_FAILED++)) || true-fi-end_test--# --- T7: Type action routes through lite ----start_test "Lite engine: type action"--# Reuse the lite-test page which has a textbox-TYPE_TAB="${ACTION_TAB}"--lite_get "/snapshot?tabId=${TYPE_TAB}&filter=interactive"-INPUT_REF=$(echo "$RESULT" | jq -r '[.nodes[] | select(.role == "textbox")] | first // empty | .ref // empty')--if [ -n "$INPUT_REF" ]; then- lite_post /action "{\"tabId\":\"${TYPE_TAB}\",\"kind\":\"type\",\"ref\":\"${INPUT_REF}\",\"text\":\"hello\"}"- assert_ok "lite type"-else- echo -e " ${RED}✗${NC} no textbox found on form.html"- ((ASSERTIONS_FAILED++)) || true-fi-end_test--# --- T8: Unsupported action returns 501 ----start_test "Lite engine: unsupported action returns 501"-lite_post /action "{\"tabId\":\"${TYPE_TAB}\",\"kind\":\"press\",\"ref\":\"e0\",\"key\":\"Enter\"}"-assert_http_status 501 "press returns 501 in lite mode"-end_test--# --- T9: Multi-tab isolation ----start_test "Lite engine: multi-tab isolation"--lite_post /navigate "{\"url\":\"${FIXTURES_URL}/index.html\"}"-assert_ok "navigate page 1"-TAB_A=$(echo "$RESULT" | jq -r '.tabId // empty')--lite_post /navigate "{\"url\":\"${FIXTURES_URL}/form.html\"}"-assert_ok "navigate page 2"-TAB_B=$(echo "$RESULT" | jq -r '.tabId // empty')--# Verify different tab IDs-if [ "$TAB_A" != "$TAB_B" ]; then- echo -e " ${GREEN}✓${NC} different tab IDs: $TAB_A vs $TAB_B"- ((ASSERTIONS_PASSED++)) || true-else- echo -e " ${RED}✗${NC} tabs should have different IDs"- ((ASSERTIONS_FAILED++)) || true-fi--# Verify tab A still returns page 1 content-lite_get "/text?tabId=${TAB_A}&format=text"-assert_ok "text for tab A"-assert_contains "$RESULT" "E2E Test Suite" "tab A returns index.html content"--# Verify tab B returns page 2 content-lite_get "/text?tabId=${TAB_B}&format=text"-assert_ok "text for tab B"-assert_contains "$RESULT" "Form" "tab B returns form.html content"--end_testdiff --git a/tests/e2e/scenarios-recent/43-tab-focus.sh b/tests/e2e/scenarios-recent/43-tab-focus.shdeleted file mode 100755index a29a8320..00000000--- a/tests/e2e/scenarios-recent/43-tab-focus.sh+++ /dev/null@@ -1,79 +0,0 @@-#!/bin/bash-# Test: Tab focus-# Tests for `POST /tab {"action":"focus","tabId":"..."}`-source "$(dirname "$0")/common.sh"--# --- T1: Focus tab by ID ----start_test "Focus tab by ID"--# Navigate to page 1 to get first tab ID-pt_post /navigate "{\"url\":\"${FIXTURES_URL}/index.html\"}"-assert_ok "navigate to index.html"-TAB_ID_A=$(echo "$RESULT" | jq -r '.tabId // empty')-assert_tab_id "tab A"-show_tab "TAB_ID_A" "$TAB_ID_A"--# Navigate to page 2 to get second tab ID-pt_post /navigate "{\"url\":\"${FIXTURES_URL}/form.html\"}"-assert_ok "navigate to form.html"-TAB_ID_B=$(echo "$RESULT" | jq -r '.tabId // empty')-assert_tab_id "tab B"-show_tab "TAB_ID_B" "$TAB_ID_B"--# Focus on tab A-pt_post /tab "{\"action\":\"focus\",\"tabId\":\"${TAB_ID_A}\"}"-assert_ok "focus on tab A"-assert_json_contains "$RESULT" ".focused" "true" "response contains focused=true"--end_test--# --- T2: Focus tab switches active tab ----start_test "Focus tab switches active tab"--# Get snapshot of tab A (should have index.html content)-pt_get "/snapshot?tabId=${TAB_ID_A}"-assert_ok "snapshot of tab A"-assert_result_exists ".title" "snapshot has title"--# Verify we can get tab A's text content (index.html)-pt_get "/text?tabId=${TAB_ID_A}&format=text"-assert_ok "text of tab A"-assert_contains "$RESULT" "E2E" "tab A contains E2E Test Suite content"--# Now focus on tab B-pt_post /tab "{\"action\":\"focus\",\"tabId\":\"${TAB_ID_B}\"}"-assert_ok "focus on tab B"--# Verify tab B has form content-pt_get "/text?tabId=${TAB_ID_B}&format=text"-assert_ok "text of tab B"-assert_contains "$RESULT" "Form" "tab B contains Form content"--end_test--# --- T3: Focus missing tabId returns 400 ----start_test "Focus missing tabId returns 400"--pt_post /tab "{\"action\":\"focus\"}"-assert_http_status 400 "missing tabId returns 400"-assert_json_contains "$RESULT" ".error" "tabId" "error message mentions tabId"--end_test--# --- T4: Focus nonexistent tab returns 404 ----start_test "Focus nonexistent tab returns 404"--pt_post /tab "{\"action\":\"focus\",\"tabId\":\"nonexistent-tab-id-12345\"}"-assert_http_status 404 "nonexistent tabId returns 404"-assert_json_contains "$RESULT" ".error" "not found" "error message indicates tab not found"--end_test--# --- T5: Focus invalid action returns 400 ----start_test "Focus invalid action returns 400"--pt_post /tab "{\"action\":\"invalid\",\"tabId\":\"${TAB_ID_A}\"}"-assert_http_status 400 "invalid action returns 400"-assert_json_contains "$RESULT" ".error" "action" "error message mentions action"--end_testdiff --git a/tests/e2e/scenarios-recent/44-nav-history.sh b/tests/e2e/scenarios-recent/44-nav-history.shdeleted file mode 100755index cad7629c..00000000--- a/tests/e2e/scenarios-recent/44-nav-history.sh+++ /dev/null@@ -1,108 +0,0 @@-#!/bin/bash-# Test: Navigation history (back, forward, reload)-# Tests for `POST /back`, `POST /forward`, `POST /reload` commands-source "$(dirname "$0")/common.sh"--# --- T1: Navigate back to previous page ----start_test "Navigate back to previous page"--# Navigate to page A (index.html)-pt_post /navigate "{\"url\":\"${FIXTURES_URL}/index.html\"}"-assert_ok "navigate to index.html"-TAB_ID=$(echo "$RESULT" | jq -r '.tabId // empty')-assert_tab_id "get tab ID"-show_tab "TAB_ID" "$TAB_ID"-URL_A=$(echo "$RESULT" | jq -r '.url // empty')-echo -e " ${MUTED}URL_A: $URL_A${NC}"--# Navigate same tab to page B (form.html) — must pass tabId to reuse tab-pt_post /navigate "{\"url\":\"${FIXTURES_URL}/form.html\",\"tabId\":\"${TAB_ID}\"}"-assert_ok "navigate to form.html"-URL_B=$(echo "$RESULT" | jq -r '.url // empty')-echo -e " ${MUTED}URL_B: $URL_B${NC}"--# Go back — should return to page A-pt_post "/back?tabId=${TAB_ID}" ''-assert_ok "POST /back"-RESULT_URL=$(echo "$RESULT" | jq -r '.url // empty')-assert_json_contains "$RESULT" ".url" "index.html" "back returned to index.html"-assert_json_contains "$RESULT" ".tabId" "$TAB_ID" "back response contains tabId"--end_test--# --- T2: Navigate forward after back ----start_test "Navigate forward after back"--# Go forward on same tab to page B-pt_post "/forward?tabId=${TAB_ID}" ''-assert_ok "POST /forward"-RESULT_URL=$(echo "$RESULT" | jq -r '.url // empty')-assert_json_contains "$RESULT" ".url" "form.html" "forward returned to form.html"-assert_json_contains "$RESULT" ".tabId" "$TAB_ID" "forward response contains tabId"--end_test--# --- T3: Reload page stays on same URL ----start_test "Reload page stays on same URL"--# Reload the same tab (should still be on form.html from T2)-pt_post "/reload?tabId=${TAB_ID}" ''-assert_ok "POST /reload"-RESULT_URL=$(echo "$RESULT" | jq -r '.url // empty')-assert_json_contains "$RESULT" ".url" "form.html" "reload stayed on form.html"-assert_json_contains "$RESULT" ".tabId" "$TAB_ID" "reload response contains tabId"--end_test--# --- T4: Back with tabId parameter ----start_test "Back with tabId parameter"--# Navigate tab to page A-pt_post /navigate "{\"url\":\"${FIXTURES_URL}/index.html\",\"tabId\":\"${TAB_ID}\"}"-assert_ok "navigate to index.html with tabId"--# Navigate to page B-pt_post /navigate "{\"url\":\"${FIXTURES_URL}/form.html\",\"tabId\":\"${TAB_ID}\"}"-assert_ok "navigate to form.html with tabId"--# Go back using tabId query parameter-pt_post "/back?tabId=${TAB_ID}" ''-assert_ok "POST /back?tabId=<id>"-assert_json_contains "$RESULT" ".url" "index.html" "back with tabId returned to index.html"-assert_json_contains "$RESULT" ".tabId" "$TAB_ID" "back with tabId response contains correct tabId"--end_test--# --- T5: Tab-scoped back using path parameter ----start_test "Tab-scoped back using path parameter"--# Navigate to form.html-pt_post /navigate "{\"url\":\"${FIXTURES_URL}/form.html\",\"tabId\":\"${TAB_ID}\"}"-assert_ok "navigate to form.html"--# Go back using path-scoped endpoint /tabs/{id}/back-pt_post "/tabs/${TAB_ID}/back" ''-assert_ok "POST /tabs/{id}/back"-assert_json_contains "$RESULT" ".url" "index.html" "path-scoped back returned to index.html"-assert_json_contains "$RESULT" ".tabId" "$TAB_ID" "path-scoped back response contains correct tabId"--end_test--# --- T6: Back with no history stays on same page ----start_test "Back with no history stays on same page"--# Create a new tab and navigate to one page only-pt_post /navigate "{\"url\":\"${FIXTURES_URL}/buttons.html\"}"-assert_ok "navigate to buttons.html"-NEW_TAB_ID=$(echo "$RESULT" | jq -r '.tabId // empty')-URL_SINGLE=$(echo "$RESULT" | jq -r '.url // empty')-show_tab "NEW_TAB_ID" "$NEW_TAB_ID"--# Try to go back with no history — should stay on same page-pt_post "/back?tabId=${NEW_TAB_ID}" ''-assert_ok "POST /back with no history (should stay on same page)"-RESULT_URL=$(echo "$RESULT" | jq -r '.url // empty')-assert_json_contains "$RESULT" ".url" "buttons.html" "back with no history stayed on same page"-assert_json_contains "$RESULT" ".tabId" "$NEW_TAB_ID" "back with no history response contains correct tabId"--end_testdiff --git a/tests/e2e/scenarios-recent/45-bot-detection.sh b/tests/e2e/scenarios-recent/45-bot-detection.shdeleted file mode 100755index 0789bec1..00000000--- a/tests/e2e/scenarios-recent/45-bot-detection.sh+++ /dev/null@@ -1,158 +0,0 @@-#!/bin/bash-# 45-bot-detection.sh — Bot detection stealth tests-# Tests the fixes for GitHub issue #275-# Simulates checks from bot.sannysoft.com-#-# Tests run against:-# - E2E_SERVER (light stealth) - basic bot detection evasion-# - E2E_SECURE_SERVER (full stealth) - additional fingerprint protections--source "$(dirname "$0")/common.sh"--# ═══════════════════════════════════════════════════════════════════-# LIGHT STEALTH MODE (main instance)-# ═══════════════════════════════════════════════════════════════════--echo -e "${BLUE}Testing LIGHT stealth mode (main instance)${NC}"--# Navigate to bot detection fixture-pt_post /navigate "{\"url\":\"${FIXTURES_URL}/bot-detect.html\"}"-assert_ok "navigate to bot-detect fixture"-sleep 1--# ─────────────────────────────────────────────────────────────────-start_test "bot-detect: navigator.webdriver is not true"--# The critical test from issue #275: navigator.webdriver must NOT be true-assert_eval_poll "navigator.webdriver !== true" "true" "navigator.webdriver is not true"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "bot-detect: navigator.webdriver is undefined"--# Stricter check: should be undefined (best) or false-assert_eval_poll "navigator.webdriver === undefined || navigator.webdriver === false" "true" "navigator.webdriver is undefined or false"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "bot-detect: webdriver property does not exist"--# Key detection vector: 'webdriver' in navigator should be false-assert_eval_poll "!('webdriver' in navigator)" "true" "webdriver property not in navigator"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "bot-detect: no CDP traces"--# Check for Chrome DevTools Protocol traces left by automation-assert_eval_poll "!(window.cdc_adoQpoasnfa76pfcZLmcfl_Array || window.cdc_adoQpoasnfa76pfcZLmcfl_Promise)" "true" "no CDP automation traces"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "bot-detect: UA not headless"--# User agent should not contain HeadlessChrome-assert_eval_poll "!navigator.userAgent.includes('HeadlessChrome')" "true" "UA not headless"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "bot-detect: plugins instanceof PluginArray"--# Issue #275: navigator.plugins must pass instanceof PluginArray-assert_eval_poll "navigator.plugins instanceof PluginArray" "true" "plugins passes instanceof PluginArray"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "bot-detect: plugins has length > 0"--assert_eval_poll "navigator.plugins.length > 0" "true" "plugins has content"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "bot-detect: chrome.runtime present"--assert_eval_poll "!!(window.chrome && window.chrome.runtime)" "true" "chrome.runtime exists"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "bot-detect: platform matches user agent"--# Platform should match UA to avoid detection-pt_post /evaluate '{"expression":"(() => { const ua = navigator.userAgent; const p = navigator.platform; if (ua.includes(\"Linux\") && !p.includes(\"Linux\")) return false; if (ua.includes(\"Macintosh\") && p !== \"MacIntel\") return false; if (ua.includes(\"Windows\") && !p.includes(\"Win\")) return false; return true; })()"}'-assert_ok "platform matches UA"-assert_json_eq "$RESULT" '.result' "true"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "bot-detect: languages are set"--assert_eval_poll "navigator.languages && navigator.languages.length > 0" "true" "languages present"--end_test----# ═══════════════════════════════════════════════════════════════════-# FULL STEALTH MODE (secure instance)-# NOTE: Secure instance has allowEvaluate=false for security tests,-# so we can only test navigation, not JavaScript evaluation.-# The stealth fixes (enable-automation=false) apply to ALL instances.-# ═══════════════════════════════════════════════════════════════════--echo ""-echo -e "${BLUE}Testing FULL stealth mode (secure instance - limited tests)${NC}"-echo -e "${YELLOW}Note: evaluate disabled on secure instance, testing navigation only${NC}"--# Switch to secure instance for full stealth tests-ORIG_URL="$E2E_SERVER"-E2E_SERVER="$E2E_SECURE_SERVER"--# ─────────────────────────────────────────────────────────────────-start_test "bot-detect-full: can navigate with full stealth"--# Navigate to bot detection fixture on secure instance-pt_post /navigate "{\"url\":\"${FIXTURES_URL}/bot-detect.html\"}"-assert_ok "navigate to bot-detect fixture (full stealth)"--# Verify we got a valid response with tab info-TAB_ID=$(echo "$RESULT" | jq -r '.tabId // empty')-if [ -n "$TAB_ID" ]; then- echo -e " ${GREEN}✓${NC} Got tabId: $TAB_ID"- ((ASSERTIONS_PASSED++)) || true-else- echo -e " ${RED}✗${NC} No tabId in response"- ((ASSERTIONS_FAILED++)) || true-fi--end_test--# ─────────────────────────────────────────────────────────────────-start_test "bot-detect-full: page title loaded correctly"--TITLE=$(echo "$RESULT" | jq -r '.title // empty')-if [ "$TITLE" = "Bot Detection Tests" ]; then- echo -e " ${GREEN}✓${NC} Page title: $TITLE"- ((ASSERTIONS_PASSED++)) || true-else- echo -e " ${YELLOW}⚠${NC} Unexpected title: $TITLE"-fi--end_test--# Restore original URL-E2E_SERVER="$ORIG_URL"--# ═══════════════════════════════════════════════════════════════════-# Note: Full stealth JavaScript tests (WebGL spoofing, etc.) would-# require allowEvaluate=true. The key stealth fix (enable-automation=false)-# is verified in the light mode tests above.-# ═══════════════════════════════════════════════════════════════════diff --git a/tests/e2e/scenarios-recent/46-download-ssrf.sh b/tests/e2e/scenarios-recent/46-download-ssrf.shdeleted file mode 100755index a84774a8..00000000--- a/tests/e2e/scenarios-recent/46-download-ssrf.sh+++ /dev/null@@ -1,36 +0,0 @@-#!/bin/bash-# 46-download-ssrf.sh — Download SSRF regression coverage-#-# Covers:-# - direct internal/private targets rejected at initial validation-# - redirected internal targets rejected during browser-side navigation--source "$(dirname "$0")/common.sh"--build_download_redirect_url() {- local target_url="$1"- local encoded_target- local attacker_url-- encoded_target=$(jq -rn --arg u "$target_url" '$u|@uri')- attacker_url="https://httpbin.org/redirect-to?url=${encoded_target}"- jq -rn --arg u "$attacker_url" '$u|@uri'-}--start_test "download security: direct internal target blocked"--pt_get "/download?url=${FIXTURES_URL}/sample.txt"-assert_http_status 400 "direct internal target blocked"-assert_contains "$RESULT" "blocked\|private" "direct SSRF error message"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "download security: redirected internal target blocked"--ATTACKER_URL=$(build_download_redirect_url "http://127.0.0.1:9999/health")-pt_get "/download?url=${ATTACKER_URL}"-assert_http_status 400 "redirected internal target blocked"-assert_contains "$RESULT" "unsafe browser request\|blocked\|private" "redirect SSRF error message"--end_testdiff --git a/tests/e2e/scenarios-recent/common.sh b/tests/e2e/scenarios-recent/common.shdeleted file mode 120000index 5f1c9ffa..00000000--- a/tests/e2e/scenarios-recent/common.sh+++ /dev/null@@ -1 +0,0 @@-../scenarios/common.sh\ No newline at end of filediff --git a/tests/e2e/scenarios-recent/run.sh b/tests/e2e/scenarios-recent/run.shdeleted file mode 100755index eca68740..00000000--- a/tests/e2e/scenarios-recent/run.sh+++ /dev/null@@ -1,46 +0,0 @@-#!/bin/bash-# run-recent.sh - Run only recently added/changed E2E test scenarios-# This runs a fast subset for fail-fast CI before the full suites.--set -uo pipefail--SCRIPT_DIR="$(dirname "$0")"-COMMON_DIR="$(dirname "$SCRIPT_DIR")/scenarios"-source "${COMMON_DIR}/common.sh"--echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"-echo -e "${BLUE}PinchTab E2E Recent Tests${NC}"-echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"-echo "E2E_SERVER: ${E2E_SERVER}"-echo "FIXTURES_URL: ${FIXTURES_URL}"-echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"-echo ""--echo "Waiting for instances to become ready..."-wait_for_instance_ready "${E2E_SERVER}"-wait_for_instance_ready "${E2E_SECURE_SERVER}"-if [ -n "${E2E_LITE_SERVER:-}" ]; then- wait_for_instance_ready "${E2E_LITE_SERVER}"-fi-echo ""--# Recent test files — add new scenarios here for fast CI feedback.-# Graduate stable coverage into api-fast/cli-fast or full-extended once the-# feature settles, so "recent" stays intentionally small.-# All test files in this directory run as the recent suite.-for script in "${SCRIPT_DIR}"/[0-9][0-9]-*.sh; do- if [ -f "$script" ]; then- echo -e "${YELLOW}Running: $(basename "$script")${NC}"- echo ""- source "$script"- echo ""- fi-done--print_summary--if [ -d "${RESULTS_DIR:-}" ]; then- echo "passed=$TESTS_PASSED" > "${RESULTS_DIR}/summary.txt"- echo "failed=$TESTS_FAILED" >> "${RESULTS_DIR}/summary.txt"- echo "timestamp=$(date -u +%Y-%m-%dT%H:%M:%SZ)" >> "${RESULTS_DIR}/summary.txt"-fidiff --git a/tests/e2e/scenarios/01-health.sh b/tests/e2e/scenarios/01-health.shdeleted file mode 100755index 19d051dd..00000000--- a/tests/e2e/scenarios/01-health.sh+++ /dev/null@@ -1,19 +0,0 @@-#!/bin/bash-# 01-health.sh — Basic connectivity tests--source "$(dirname "$0")/common.sh"--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab health"--pt_get /health-assert_json_eq "$RESULT" '.status' 'ok'--end_test--# ─────────────────────────────────────────────────────────────────-start_test "fixtures server"--assert_fixtures_accessible--end_testdiff --git a/tests/e2e/scenarios/02-navigate.sh b/tests/e2e/scenarios/02-navigate.shdeleted file mode 100755index 13caa5c4..00000000--- a/tests/e2e/scenarios/02-navigate.sh+++ /dev/null@@ -1,84 +0,0 @@-#!/bin/bash-# 02-navigate.sh — Navigation and tab management--source "$(dirname "$0")/common.sh"--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab nav <url>"--pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/\"}"-assert_json_contains "$RESULT" '.title' 'E2E Test'-assert_json_contains "$RESULT" '.url' 'fixtures'--end_test--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab nav (multiple pages)"--pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/form.html\"}"-assert_json_contains "$RESULT" '.title' 'Form'--pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/table.html\"}"-assert_json_contains "$RESULT" '.title' 'Table'--end_test--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab tabs"--assert_tab_count_gte 2--end_test--# ─────────────────────────────────────────────────────────────────-start_test "navigate: blockImages flag"--pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/index.html\",\"blockImages\":true}"-assert_ok "navigate with blockImages"-assert_json_contains "$RESULT" '.url' 'index.html'--end_test--# ─────────────────────────────────────────────────────────────────-start_test "navigate: blockAds flag"--pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/index.html\",\"blockAds\":true}"-assert_ok "navigate with blockAds"-assert_json_contains "$RESULT" '.url' 'index.html'--end_test--# ─────────────────────────────────────────────────────────────────-start_test "navigate: timeout parameter"--# Navigate with a generous timeout (in milliseconds) — should succeed-pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/index.html\",\"timeout\":30000}"-assert_ok "navigate with custom timeout"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "navigate: waitSelector parameter"--# waitSelector waits for a CSS selector after navigation-pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/buttons.html\",\"waitSelector\":\"button\"}"-assert_ok "navigate with waitSelector"-assert_json_contains "$RESULT" '.title' 'Button'--end_test--# ─────────────────────────────────────────────────────────────────-start_test "navigate: missing URL → error"--pt_post /navigate '{}'-assert_not_ok "rejects missing URL"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "navigate: bad JSON → 400"--pt_post_raw /navigate '{broken'-assert_not_ok "rejects bad JSON"--end_testdiff --git a/tests/e2e/scenarios/03-snapshot.sh b/tests/e2e/scenarios/03-snapshot.shdeleted file mode 100755index d33b865a..00000000--- a/tests/e2e/scenarios/03-snapshot.sh+++ /dev/null@@ -1,233 +0,0 @@-#!/bin/bash-# 03-snapshot.sh — Accessibility tree and text extraction--source "$(dirname "$0")/common.sh"--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab snap"--pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/\"}"--pt_get /snapshot-assert_index_page "$RESULT"-assert_json_length_gte "$RESULT" '.nodes' 1--end_test--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab snap (buttons.html)"--pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/buttons.html\"}"-sleep 1--pt_get /snapshot-assert_buttons_page "$RESULT"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab snap (form.html)"--pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/form.html\"}"-sleep 1--pt_get /snapshot-assert_form_page "$RESULT"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab text (table.html)"--pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/table.html\"}"-sleep 1--TEXT_RESULT=$(curl -s "${E2E_SERVER}/text" | jq -r '.text')-assert_table_page "$TEXT_RESULT"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "snapshot: diff mode"--# Take initial snapshot, then take diff — diff should return ok-pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/buttons.html\"}"-sleep 1--pt_get /snapshot-assert_ok "initial snapshot"-INITIAL_COUNT=$(echo "$RESULT" | jq '.nodes | length')--# Second snapshot with diff=true (no changes made, so diff should have fewer/no changed nodes)-pt_get "/snapshot?diff=true"-assert_ok "diff snapshot"-DIFF_COUNT=$(echo "$RESULT" | jq '.nodes | length')--# Diff should return fewer or equal nodes compared to full snapshot-if [ "$DIFF_COUNT" -le "$INITIAL_COUNT" ]; then- echo -e " ${GREEN}✓${NC} diff has <= nodes than full ($DIFF_COUNT <= $INITIAL_COUNT)"- ((ASSERTIONS_PASSED++)) || true-else- echo -e " ${RED}✗${NC} diff has more nodes than full ($DIFF_COUNT > $INITIAL_COUNT)"- ((ASSERTIONS_FAILED++)) || true-fi--end_test--# ─────────────────────────────────────────────────────────────────-start_test "snapshot: maxTokens truncation"--pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/buttons.html\"}"-sleep 1--# Full snapshot-pt_get /snapshot-FULL_COUNT=$(echo "$RESULT" | jq '.nodes | length')--# Snapshot with very small maxTokens — should have fewer nodes-pt_get "/snapshot?maxTokens=50"-assert_ok "snapshot with maxTokens"-LIMITED_COUNT=$(echo "$RESULT" | jq '.nodes | length')--if [ "$LIMITED_COUNT" -le "$FULL_COUNT" ]; then- echo -e " ${GREEN}✓${NC} maxTokens limited nodes ($LIMITED_COUNT <= $FULL_COUNT)"- ((ASSERTIONS_PASSED++)) || true-else- echo -e " ${RED}✗${NC} maxTokens did not limit ($LIMITED_COUNT > $FULL_COUNT)"- ((ASSERTIONS_FAILED++)) || true-fi--end_test--# ─────────────────────────────────────────────────────────────────-start_test "snapshot: depth parameter"--pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/buttons.html\"}"-sleep 1--# Full tree-pt_get /snapshot-FULL_COUNT=$(echo "$RESULT" | jq '.nodes | length')--# Depth=1 should produce a shallower tree with fewer nodes-pt_get "/snapshot?depth=1"-assert_ok "snapshot with depth=1"-SHALLOW_COUNT=$(echo "$RESULT" | jq '.nodes | length')--if [ "$SHALLOW_COUNT" -le "$FULL_COUNT" ]; then- echo -e " ${GREEN}✓${NC} depth=1 limited tree ($SHALLOW_COUNT <= $FULL_COUNT)"- ((ASSERTIONS_PASSED++)) || true-else- echo -e " ${RED}✗${NC} depth=1 did not limit ($SHALLOW_COUNT > $FULL_COUNT)"- ((ASSERTIONS_FAILED++)) || true-fi--end_test--# ─────────────────────────────────────────────────────────────────-start_test "snapshot: format=text"--pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/index.html\"}"-pt_get "/snapshot?format=text"-assert_ok "get text format"--# Should not be JSON (no leading {)-if echo "$RESULT" | head -c1 | grep -q '{'; then- echo -e " ${RED}✗${NC} got JSON instead of text"- ((ASSERTIONS_FAILED++)) || true-else- echo -e " ${GREEN}✓${NC} format is text, not JSON"- ((ASSERTIONS_PASSED++)) || true-fi--end_test--# ─────────────────────────────────────────────────────────────────-start_test "snapshot: nonexistent tabId → error"--pt_get "/snapshot?tabId=nonexistent_xyz_999"-assert_not_ok "rejects bad tab"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "snapshot: ref stability after action"--pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/form.html\"}"-pt_get /snapshot-REFS_BEFORE=$(echo "$RESULT" | jq '[.nodes[].ref] | sort')--pt_post /action '{"kind":"press","key":"Escape"}'-pt_get /snapshot-REFS_AFTER=$(echo "$RESULT" | jq '[.nodes[].ref] | sort')--if [ "$REFS_BEFORE" = "$REFS_AFTER" ]; then- echo -e " ${GREEN}✓${NC} refs stable after action"- ((ASSERTIONS_PASSED++)) || true-else- echo -e " ${YELLOW}⚠${NC} refs changed (may be expected if DOM changed)"- ((ASSERTIONS_PASSED++)) || true-fi--end_test--# ─────────────────────────────────────────────────────────────────-start_test "snapshot: format=yaml"--pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/index.html\"}"-pt_get "/snapshot?format=yaml"-assert_ok "get yaml format"--# Should contain YAML-like content (indentation, : separators, no { braces)-if echo "$RESULT" | grep -q "role:\|name:\|ref:"; then- echo -e " ${GREEN}✓${NC} looks like YAML"- ((ASSERTIONS_PASSED++)) || true-else- echo -e " ${YELLOW}⚠${NC} may not be YAML format"- ((ASSERTIONS_PASSED++)) || true-fi--end_test--# ─────────────────────────────────────────────────────────────────-start_test "snapshot: output=file"--pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/index.html\"}"-pt_get "/snapshot?output=file"-assert_ok "snapshot output=file"-assert_json_exists "$RESULT" '.path' "has file path"--end_test-# ─────────────────────────────────────────────────────────────────-start_test "snapshot: multi-tab content isolation with tabId"--# Navigate to two different pages, capturing tab IDs-pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/index.html\"}"-assert_ok "navigate to index"-TAB_A=$(echo "$RESULT" | jq -r '.tabId')--pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/form.html\"}"-assert_ok "navigate to form"-TAB_B=$(echo "$RESULT" | jq -r '.tabId')--# Snapshot tab A — should return index.html content (not form.html)-pt_get "/snapshot?tabId=${TAB_A}"-assert_ok "snapshot tab A"-assert_json_contains "$RESULT" '.url' "index.html" "tab A has index.html URL"--# Snapshot tab B — should return form.html content-pt_get "/snapshot?tabId=${TAB_B}"-assert_ok "snapshot tab B"-assert_json_contains "$RESULT" '.url' "form.html" "tab B has form.html URL"--# Text from tab A-pt_get "/text?tabId=${TAB_A}&format=text"-assert_ok "text tab A"-assert_contains "$RESULT" "test fixtures" "tab A text matches index.html"--# Text from tab B-pt_get "/text?tabId=${TAB_B}&format=text"-assert_ok "text tab B"-assert_contains "$RESULT" "Form Test" "tab B text matches form.html"--end_testdiff --git a/tests/e2e/scenarios/04-tabs-api.sh b/tests/e2e/scenarios/04-tabs-api.shdeleted file mode 100755index 82acab23..00000000--- a/tests/e2e/scenarios/04-tabs-api.sh+++ /dev/null@@ -1,51 +0,0 @@-#!/bin/bash-# 04-tabs-api.sh — Tab-scoped API tests (regression test for #207)--source "$(dirname "$0")/common.sh"--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab snap --tab <id> (regression #207)"--# Create a tab and capture its ID from the navigate response-pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/index.html\"}"-TAB_ID=$(get_tab_id)-show_tab "created" "$TAB_ID"--# Test: /tabs/{id}/snapshot should work (was broken in #207)-pt_get "/tabs/${TAB_ID}/snapshot"-assert_ok "tab snapshot"-assert_json_contains "$RESULT" '.title' 'E2E Test'--end_test--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab text/screenshot --tab <id>"--pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/form.html\"}"-TAB_ID=$(get_tab_id)--pt_get "/tabs/${TAB_ID}/text"-assert_ok "tab text"--pt_get "/tabs/${TAB_ID}/screenshot"-assert_ok "tab screenshot"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab tab close"--# Create a new tab-pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/buttons.html\"}"-TAB_ID=$(get_tab_id)-AFTER_CREATE=$(get_tab_count)--# Close it-pt_post "/tabs/${TAB_ID}/close" -d '{}'-assert_ok "tab close"--# Verify count decreased-sleep 1-assert_tab_closed "$AFTER_CREATE"--end_testdiff --git a/tests/e2e/scenarios/05b-dblclick.sh b/tests/e2e/scenarios/05b-dblclick.shdeleted file mode 100755index 666a24ee..00000000--- a/tests/e2e/scenarios/05b-dblclick.sh+++ /dev/null@@ -1,93 +0,0 @@-#!/bin/bash-# 05b-dblclick.sh — Double-click action tests--source "$(dirname "$0")/common.sh"--# ─────────────────────────────────────────────────────────────────-start_test "HTTP: dblclick by ref"--pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/buttons.html\"}"-sleep 1--pt_get /snapshot-REF=$(echo "$RESULT" | jq -r '.nodes[0].ref // .tree.ref // "e0"')--pt_post /action -d "{\"kind\":\"dblclick\",\"ref\":\"$REF\"}"-assert_ok "dblclick by ref"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "HTTP: dblclick by CSS selector"--pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/buttons.html\"}"-sleep 1--pt_post /action -d "{\"kind\":\"dblclick\",\"selector\":\"#increment\"}"-assert_ok "dblclick by selector"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "HTTP: dblclick by coordinates"--pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/buttons.html\"}"-sleep 1--pt_post /action -d "{\"kind\":\"dblclick\",\"x\":100,\"y\":100}"-assert_ok "dblclick by coordinates"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "CLI: pinchtab dblclick <ref>"--pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/buttons.html\"}"-sleep 1--pt_get /snapshot-REF=$(echo "$RESULT" | jq -r '.nodes[0].ref // .tree.ref // "e0"')--run_cli dblclick "$REF"-assert_ok "CLI dblclick by ref"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "CLI: pinchtab dblclick --css <selector>"--pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/buttons.html\"}"-sleep 1--run_cli dblclick --css "#increment"-assert_ok "CLI dblclick by selector"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "CLI: pinchtab dblclick --tab <id>"--pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/buttons.html\",\"newTab\":true}"-assert_ok "navigate for new tab"-TAB_ID=$(echo "$RESULT" | jq -r '.tabId')--pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/buttons.html\"}"-sleep 1--pt_get /snapshot-REF=$(echo "$RESULT" | jq -r '.nodes[0].ref // .tree.ref // "e0"')--run_cli dblclick "$REF" --tab "$TAB_ID"-assert_ok "CLI dblclick with --tab flag"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "HTTP: dblclick validation - missing ref/selector/coordinates"--pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/buttons.html\"}"--pt_post /action -d "{\"kind\":\"dblclick\"}"-assert_error "dblclick without parameters should fail"--end_testdiff --git a/tests/e2e/scenarios/06-screenshot-pdf.sh b/tests/e2e/scenarios/06-screenshot-pdf.shdeleted file mode 100755index 1fddb917..00000000--- a/tests/e2e/scenarios/06-screenshot-pdf.sh+++ /dev/null@@ -1,97 +0,0 @@-#!/bin/bash-# 06-screenshot-pdf.sh — Screenshot and PDF export--source "$(dirname "$0")/common.sh"--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab screenshot"--pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/table.html\"}"-sleep 1--pt_get /screenshot-assert_ok "screenshot"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab pdf (default)"--pt_get /pdf-assert_ok "pdf"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab screenshot --tab <id>"--pt_get /tabs-TAB_ID=$(get_first_tab)--pt_get "/tabs/${TAB_ID}/screenshot"-assert_ok "tab screenshot"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab pdf --tab <id>"--pt_get /tabs-TAB_ID=$(get_first_tab)--pt_get "/tabs/${TAB_ID}/pdf"-assert_ok "tab pdf"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab pdf --tab <id> (with options)"--pt_get /tabs-TAB_ID=$(get_first_tab)--pt_post "/tabs/${TAB_ID}/pdf" -d '{"printBackground":true,"scale":0.8}'-assert_ok "tab pdf with options"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "screenshot: quality parameter"--pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/table.html\"}"-sleep 1--# Low quality screenshot should be smaller than default-LOW_Q_SIZE=$(curl -s "${E2E_SERVER}/screenshot?quality=10" | wc -c)-HIGH_Q_SIZE=$(curl -s "${E2E_SERVER}/screenshot?quality=95" | wc -c)--if [ "$LOW_Q_SIZE" -lt "$HIGH_Q_SIZE" ]; then- echo -e " ${GREEN}✓${NC} quality=10 ($LOW_Q_SIZE bytes) < quality=95 ($HIGH_Q_SIZE bytes)"- ((ASSERTIONS_PASSED++)) || true-else- echo -e " ${YELLOW}~${NC} quality=10 ($LOW_Q_SIZE) not smaller than quality=95 ($HIGH_Q_SIZE)"- ((ASSERTIONS_PASSED++)) || true-fi--end_test--# ─────────────────────────────────────────────────────────────────-start_test "screenshot: output=file"--pt_get "/screenshot?output=file"-assert_ok "screenshot output=file"--# Response should contain a file path-assert_json_exists "$RESULT" '.path' "response has path field"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "pdf: output=file"--pt_get "/pdf?output=file"-assert_ok "pdf output=file"--assert_json_exists "$RESULT" '.path' "response has path field"--end_testdiff --git a/tests/e2e/scenarios/07-find.sh b/tests/e2e/scenarios/07-find.shdeleted file mode 100755index 6a815062..00000000--- a/tests/e2e/scenarios/07-find.sh+++ /dev/null@@ -1,103 +0,0 @@-#!/bin/bash-# 07-find.sh — Element finding with semantic search--source "$(dirname "$0")/common.sh"--# Navigate to find test page-pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/find.html\"}"-sleep 1--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab find (login button)"--pt_post /find -d '{"query":"login button"}'-assert_ok "find login"-assert_result_exists ".best_ref" "has best_ref"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab find (email input)"--pt_post /find -d '{"query":"email input field"}'-assert_ok "find email"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab find (delete button)"--pt_post /find -d '{"query":"delete account button","threshold":0.2}'-assert_ok "find delete"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab find (search)"--pt_post /find -d '{"query":"search input","topK":5}'-assert_ok "find search"-assert_json_length_gte "$RESULT" ".matches" 1 "has matches"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab find --tab <id>"--# Open find page in new tab - capture tabId from response-pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/find.html\",\"newTab\":true}"-assert_ok "navigate for find"-TAB_ID=$(echo "$RESULT" | jq -r '.tabId')-sleep 1--pt_post "/tabs/${TAB_ID}/find" -d '{"query":"sign up link"}'-assert_ok "tab find"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab find (explain mode)"--pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/find.html\"}"-sleep 1--pt_post /find -d '{"query":"login button","explain":true}'-assert_ok "find with explain"--# Explain mode should include score breakdown in matches-FIRST_EXPLAIN=$(echo "$RESULT" | jq '.matches[0].explain // empty')-if [ -n "$FIRST_EXPLAIN" ] && [ "$FIRST_EXPLAIN" != "null" ]; then- echo -e " ${GREEN}✓${NC} explain field present in matches"- ((ASSERTIONS_PASSED++)) || true-else- echo -e " ${YELLOW}~${NC} explain field not in response (may need embedding model)"- ((ASSERTIONS_PASSED++)) || true-fi--end_test--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab find (weight overrides)"--pt_post /find -d '{"query":"login button","lexicalWeight":1.0,"embeddingWeight":0.0}'-assert_ok "find with lexical-only weights"-assert_json_length_gte "$RESULT" ".matches" 1 "has matches with custom weights"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab find (low confidence → empty best_ref)"--pt_post /find -d '{"query":"xyzzy_nonexistent_element_12345","threshold":0.99}'-assert_ok "find with high threshold"--BEST_REF=$(echo "$RESULT" | jq -r '.best_ref // empty')-if [ -z "$BEST_REF" ] || [ "$BEST_REF" = "" ] || [ "$BEST_REF" = "null" ]; then- echo -e " ${GREEN}✓${NC} best_ref empty for low-confidence query"- ((ASSERTIONS_PASSED++)) || true-else- echo -e " ${YELLOW}~${NC} best_ref returned: $BEST_REF (threshold may be met)"- ((ASSERTIONS_PASSED++)) || true-fi--end_testdiff --git a/tests/e2e/scenarios/08-evaluate.sh b/tests/e2e/scenarios/08-evaluate.shdeleted file mode 100755index 2d31f34f..00000000--- a/tests/e2e/scenarios/08-evaluate.sh+++ /dev/null@@ -1,87 +0,0 @@-#!/bin/bash-# 08-evaluate.sh — JavaScript evaluation--source "$(dirname "$0")/common.sh"--# Navigate to evaluate test page-pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/evaluate.html\"}"-sleep 1--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab evaluate (simple expression)"--pt_post /evaluate -d '{"expression":"1 + 1"}'-assert_ok "evaluate simple"-assert_result_eq ".result" "2" "1+1=2"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab evaluate (DOM query)"--pt_post /evaluate -d '{"expression":"document.title"}'-assert_ok "evaluate DOM"-assert_result_eq ".result" "Evaluate Test Page" "got title"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab evaluate (call function)"--pt_post /evaluate -d '{"expression":"window.calculate.add(5, 3)"}'-assert_ok "evaluate function"-assert_result_eq ".result" "8" "5+3=8"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab evaluate (get object)"--pt_post /evaluate -d '{"expression":"JSON.stringify(window.testData)"}'-assert_ok "evaluate object"-assert_json_contains "$RESULT" ".result" "PinchTab" "has testData"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab evaluate (modify DOM)"--pt_post /evaluate -d '{"expression":"document.getElementById(\"counter\").textContent = \"42\"; 42"}'-assert_ok "evaluate modify DOM"--# Verify the change stuck-pt_post /evaluate -d '{"expression":"document.getElementById(\"counter\").textContent"}'-assert_result_eq ".result" "42" "counter=42"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab evaluate --tab <id>"--# Open evaluate page in new tab - capture tabId from response-pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/evaluate.html\",\"newTab\":true}"-assert_ok "navigate for evaluate"-TAB_ID=$(echo "$RESULT" | jq -r '.tabId')-sleep 1--pt_post "/tabs/${TAB_ID}/evaluate" -d '{"expression":"1 + 2 + 3"}'-assert_ok "tab evaluate"-assert_result_eq ".result" "6" "1+2+3=6"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "evaluate: missing expression → error"--pt_post /evaluate '{}'-assert_not_ok "rejects missing expression"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "evaluate: bad JSON → 400"--pt_post_raw /evaluate '{broken'-assert_not_ok "rejects bad JSON"--end_testdiff --git a/tests/e2e/scenarios/09-download.sh b/tests/e2e/scenarios/09-download.shdeleted file mode 100755index f0092d92..00000000--- a/tests/e2e/scenarios/09-download.sh+++ /dev/null@@ -1,59 +0,0 @@-#!/bin/bash-# 09-download.sh — File download-#-# NOTE: Download endpoint has SSRF protection that blocks private IPs.-# In Docker, fixtures resolves to internal IP, so we test with public URLs.--source "$(dirname "$0")/common.sh"--build_download_redirect_url() {- local target_url="$1"- local encoded_target- local attacker_url-- encoded_target=$(jq -rn --arg u "$target_url" '$u|@uri')- attacker_url="https://httpbin.org/redirect-to?url=${encoded_target}"- jq -rn --arg u "$attacker_url" '$u|@uri'-}--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab download (public URL)"--# Use a small public file for testing-pt_get "/download?url=https://httpbin.org/robots.txt"-assert_ok "download public"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab download (SSRF blocked)"--# Verify internal URLs are blocked (security feature)-pt_get "/download?url=${FIXTURES_URL}/sample.txt"-assert_http_status 400 "download blocked"--# Verify error message mentions blocking-assert_contains "$RESULT" "blocked\|private" "SSRF error message"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab download (redirected internal target blocked)"--ATTACKER_URL=$(build_download_redirect_url "http://127.0.0.1:9999/health")-pt_get "/download?url=${ATTACKER_URL}"-assert_http_status 400 "redirected internal target blocked"-assert_contains "$RESULT" "unsafe browser request\|blocked\|private" "redirect SSRF error message"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab download --tab <id>"--pt_get /tabs-TAB_ID=$(get_first_tab)--pt_get "/tabs/${TAB_ID}/download?url=https://httpbin.org/robots.txt"-assert_ok "tab download"--end_testdiff --git a/tests/e2e/scenarios/10-upload.sh b/tests/e2e/scenarios/10-upload.shdeleted file mode 100755index fa7e394b..00000000--- a/tests/e2e/scenarios/10-upload.sh+++ /dev/null@@ -1,45 +0,0 @@-#!/bin/bash-# 10-upload.sh — File upload--source "$(dirname "$0")/common.sh"--# Navigate to upload test page-pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/upload.html\"}"-sleep 1--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab upload (base64 file)"--# Files are base64 strings with optional data: prefix-# "Hello from E2E test!" in base64-FILE_CONTENT="data:text/plain;base64,SGVsbG8gZnJvbSBFMkUgdGVzdCE="--pt_post /upload -d "{\"selector\":\"#single-file\",\"files\":[\"${FILE_CONTENT}\"]}"-assert_ok "upload base64"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab upload (multiple files)"--pt_post /upload -d "{\"selector\":\"#multi-file\",\"files\":[\"${FILE_CONTENT}\",\"${FILE_CONTENT}\"]}"-assert_ok "upload multiple"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "pinchtab upload --tab <id>"--# Open upload page in new tab - capture tabId from response-pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/upload.html\",\"newTab\":true}"-assert_ok "navigate for upload"-TAB_ID=$(echo "$RESULT" | jq -r '.tabId')-sleep 1--# 1x1 transparent PNG-PNG_DATA="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg=="--pt_post "/tabs/${TAB_ID}/upload" -d "{\"selector\":\"#single-file\",\"files\":[\"${PNG_DATA}\"]}"-assert_ok "tab upload"--end_testdiff --git a/tests/e2e/scenarios/11-security.sh b/tests/e2e/scenarios/11-security.shdeleted file mode 100755index 00a30e0f..00000000--- a/tests/e2e/scenarios/11-security.sh+++ /dev/null@@ -1,128 +0,0 @@-#!/bin/bash-# 11-security.sh — Security controls verification-#-# Tests that security features properly block/allow requests based on config.-# Uses two pinchtab instances:-# - E2E_SERVER: permissive (evaluate/download/upload enabled)-# - E2E_SECURE_SERVER: restrictive (all disabled)--source "$(dirname "$0")/common.sh"--# Helper to target the secure (restrictive) instance-secure_get() {- local path="$1"- shift- local old_url="$E2E_SERVER"- E2E_SERVER="$E2E_SECURE_SERVER"- pt_get "$path" "$@"- E2E_SERVER="$old_url"-}--secure_post() {- local path="$1"- shift- local old_url="$E2E_SERVER"- E2E_SERVER="$E2E_SECURE_SERVER"- pt_post "$path" "$@"- E2E_SERVER="$old_url"-}--# ═══════════════════════════════════════════════════════════════════-# EVALUATE SECURITY-# ═══════════════════════════════════════════════════════════════════--start_test "security: evaluate ALLOWED when enabled"--pt_post /navigate -d '{"url":"about:blank"}'-pt_post /evaluate -d '{"expression":"1+1"}'-assert_ok "evaluate allowed"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "security: evaluate BLOCKED when disabled"--secure_post /navigate -d '{"url":"about:blank"}'-secure_post /evaluate -d '{"expression":"1+1"}'-assert_http_status 403 "evaluate blocked"-assert_contains "$RESULT" "evaluate_disabled" "correct error code"--end_test--# ═══════════════════════════════════════════════════════════════════-# DOWNLOAD SECURITY-# ═══════════════════════════════════════════════════════════════════--start_test "security: download ALLOWED when enabled"--pt_get "/download?url=https://httpbin.org/robots.txt"-assert_ok "download allowed"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "security: download BLOCKED when disabled"--secure_get "/download?url=https://httpbin.org/robots.txt"-assert_http_status 403 "download blocked"-assert_contains "$RESULT" "download_disabled" "correct error code"--end_test--# ═══════════════════════════════════════════════════════════════════-# UPLOAD SECURITY-# ═══════════════════════════════════════════════════════════════════--start_test "security: upload ALLOWED when enabled"--pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/upload.html\"}"-sleep 1-pt_post /upload -d '{"selector":"#single-file","files":["data:text/plain;base64,dGVzdA=="]}'-assert_ok "upload allowed"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "security: upload BLOCKED when disabled"--# Note: navigation might fail due to IDPI, but upload check happens first-secure_post /upload -d '{"selector":"#single-file","files":["data:text/plain;base64,dGVzdA=="]}'-assert_http_status 403 "upload blocked"-assert_contains "$RESULT" "upload_disabled" "correct error code"--end_test--# ═══════════════════════════════════════════════════════════════════-# IDPI (Navigation Security)-# ═══════════════════════════════════════════════════════════════════--start_test "security: IDPI allows whitelisted domains"--# Main instance has fixtures in allowlist-pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/index.html\"}"-assert_ok "navigate to allowed domain"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "security: IDPI blocks non-whitelisted domains"--# Secure instance has empty allowlist - should block all navigation-secure_post /navigate -d '{"url":"https://example.com"}'-assert_http_status 403 "navigate blocked by IDPI"-assert_contains "$RESULT" "IDPI\|blocked\|allowed" "IDPI error message"--end_test--# ═══════════════════════════════════════════════════════════════════-# VERIFY ERROR RESPONSE FORMAT-# ═══════════════════════════════════════════════════════════════════--start_test "security: blocked responses include helpful info"--secure_post /evaluate -d '{"expression":"1"}'-assert_http_status 403 "returns 403"-assert_json_exists "$RESULT" ".code" "has error code"-assert_json_exists "$RESULT" ".error" "has error message"--end_testdiff --git a/tests/e2e/scenarios/13-tab-variants.sh b/tests/e2e/scenarios/13-tab-variants.shdeleted file mode 100755index 163f3411..00000000--- a/tests/e2e/scenarios/13-tab-variants.sh+++ /dev/null@@ -1,55 +0,0 @@-#!/bin/bash-# 13-tab-variants.sh — Tab-specific upload and download operations--source "$(dirname "$0")/common.sh"--start_test "tab-specific upload: POST /tabs/{id}/upload"--# Navigate to upload page-pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/upload.html\"}"-TAB_ID=$(get_tab_id)-show_tab "created" "$TAB_ID"--# Upload file to specific tab-pt_post "/tabs/${TAB_ID}/upload" -d '{"selector":"#single-file","files":["data:text/plain;base64,dGVzdCBmaWxl"]}'-assert_ok "upload to tab"-assert_json_exists "$RESULT" ".files" "upload response has files count"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "tab-specific upload: multiple files"--pt_post "/tabs/${TAB_ID}/upload" -d '{"selector":"#multi-file","files":["data:text/plain;base64,ZmlsZTE=","data:text/plain;base64,ZmlsZTI="]}'-assert_ok "upload multiple files"-assert_json_contains "$RESULT" ".files" "2" "uploaded 2 files"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "tab-specific download: GET /tabs/{id}/download"--# Navigate to a page with downloadable content-pt_post /navigate -d '{"url":"https://httpbin.org/robots.txt"}'-TAB_ID2=$(get_tab_id)-show_tab "created" "$TAB_ID2"--# Download from specific tab-pt_get "/tabs/${TAB_ID2}/download?url=https://httpbin.org/json"-assert_ok "download from tab"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "tab-specific download: verify content returned"--# Just verify we got non-empty response (endpoint returned 200 above)-if [ -n "$RESULT" ]; then- echo -e " ${GREEN}✓${NC} download returned content"- ((ASSERTIONS_PASSED++)) || true-else- echo -e " ${RED}✗${NC} download returned empty content"- ((ASSERTIONS_FAILED++)) || true-fi--end_testdiff --git a/tests/e2e/scenarios/17-text-extraction.sh b/tests/e2e/scenarios/17-text-extraction.shdeleted file mode 100755index fcd4f973..00000000--- a/tests/e2e/scenarios/17-text-extraction.sh+++ /dev/null@@ -1,149 +0,0 @@-#!/bin/bash-# 17-text-extraction.sh — Text extraction from pages (global and per-tab)--source "$(dirname "$0")/common.sh"--start_test "text extraction: GET /text extracts readable content"--pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/index.html\"}"-pt_get /text-assert_ok "get text"--# Verify text contains expected content from the page-assert_contains "$RESULT" "E2E Test\|Buttons\|Search\|Customize" "text contains page content"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "text extraction: GET /tabs/{id}/text extracts per-tab content"--pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/buttons.html\"}"-TAB_ID=$(get_tab_id)--pt_get "/tabs/${TAB_ID}/text"-assert_ok "get tab text"--# Buttons page has button elements-assert_contains "$RESULT" "Click me\|Button" "text includes button labels"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "text extraction: text differs between tabs"--# Create another tab with different content-pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/form.html\"}"-TAB_ID2=$(get_tab_id)--pt_get "/tabs/${TAB_ID2}/text"-FORM_TEXT="$RESULT"--# Form page should have form labels-assert_contains "$FORM_TEXT" "Name\|Email\|Submit\|Form" "text includes form labels"--end_test--# ─────────────────────────────────────────────────────────────────-# ─────────────────────────────────────────────────────────────────-start_test "text extraction: raw mode"--pt_post /navigate "{\"url\":\"${FIXTURES_URL}/index.html\"}"-assert_ok "navigate"--pt_get "/text?mode=raw"-assert_ok "get text raw"-assert_contains "$RESULT" "E2E Test\|Welcome\|index" "raw text has content"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "text extraction: nonexistent tab → error"--pt_get "/text?tabId=nonexistent_xyz_999"-assert_not_ok "rejects bad tab"--end_test--# ─────────────────────────────────────────────────────────────────-# ─────────────────────────────────────────────────────────────────-start_test "text extraction: maxChars truncation"--pt_post /navigate "{\"url\":\"${FIXTURES_URL}/index.html\"}"-assert_ok "navigate"--pt_get "/text?maxChars=50"-assert_ok "get text with maxChars=50"--TEXT_LEN=$(echo "$RESULT" | jq -r '.text' | wc -c)-if [ "$TEXT_LEN" -le 55 ]; then # small buffer for json encoding- echo -e " ${GREEN}✓${NC} text truncated to ~50 chars (got $TEXT_LEN)"- ((ASSERTIONS_PASSED++)) || true-else- echo -e " ${RED}✗${NC} text not truncated (got $TEXT_LEN chars)"- ((ASSERTIONS_FAILED++)) || true-fi--end_test--# ─────────────────────────────────────────────────────────────────-start_test "text extraction: format=text returns plain text"--pt_post /navigate "{\"url\":\"${FIXTURES_URL}/index.html\"}"-assert_ok "navigate"--# format=text should return plain text content type-RESPONSE=$(curl -s -w "\n%{http_code}\n%{content_type}" "${E2E_SERVER}/text?format=text")-BODY=$(echo "$RESPONSE" | head -n -2)-STATUS=$(echo "$RESPONSE" | tail -n 2 | head -1)-CTYPE=$(echo "$RESPONSE" | tail -n 1)--if [ "$STATUS" = "200" ]; then- echo -e " ${GREEN}✓${NC} format=text returned 200"- ((ASSERTIONS_PASSED++)) || true-else- echo -e " ${RED}✗${NC} format=text returned $STATUS"- ((ASSERTIONS_FAILED++)) || true-fi--# Should be plain text, not JSON-if echo "$CTYPE" | grep -q "text/plain"; then- echo -e " ${GREEN}✓${NC} content-type is text/plain"- ((ASSERTIONS_PASSED++)) || true-else- echo -e " ${YELLOW}~${NC} content-type is $CTYPE (expected text/plain)"- ((ASSERTIONS_PASSED++)) || true-fi--end_test--# ─────────────────────────────────────────────────────────────────-start_test "text extraction: text excludes script/style content"--# Text extraction should not include raw JavaScript or CSS-if echo "$RESULT" | grep -q "function\|var\|css\|<script>"; then- echo -e " ${YELLOW}~${NC} text may contain code (depends on sanitization)"- ((ASSERTIONS_PASSED++)) || true-else- echo -e " ${GREEN}✓${NC} text properly excludes code content"- ((ASSERTIONS_PASSED++)) || true-fi--end_test--# ─────────────────────────────────────────────────────────────────-start_test "text extraction: token efficiency (reasonable length)"--pt_post /navigate "{\"url\":\"${FIXTURES_URL}/index.html\"}"-pt_get /text-assert_ok "get text"--TEXT_LEN=$(echo "$RESULT" | jq -r '.text' | wc -c)-if [ "$TEXT_LEN" -lt 10000 ]; then- echo -e " ${GREEN}✓${NC} text reasonably compact ($TEXT_LEN chars)"- ((ASSERTIONS_PASSED++)) || true-else- echo -e " ${YELLOW}⚠${NC} text may be bloated ($TEXT_LEN chars)"- ((ASSERTIONS_PASSED++)) || true-fi--end_testdiff --git a/tests/e2e/scenarios/21-error-handling.sh b/tests/e2e/scenarios/21-error-handling.shdeleted file mode 100755index 226781d8..00000000--- a/tests/e2e/scenarios/21-error-handling.sh+++ /dev/null@@ -1,73 +0,0 @@-#!/bin/bash-# 21-error-handling.sh — Error handling and edge cases--source "$(dirname "$0")/common.sh"--start_test "error handling: invalid selector syntax"--pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/buttons.html\"}"-TAB_ID=$(get_tab_id)-show_tab "created" "$TAB_ID"--# Try to use invalid selector syntax-pt_post /action -d '{"action":"click","selector":"[invalid:::selector]"}'-assert_http_error 400 "invalid|selector|syntax" "invalid selector rejected"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "error handling: element not found"--# Try to interact with non-existent element-pt_post /action -d '{"action":"click","selector":"#this-element-does-not-exist"}'-assert_contains_any "$RESULT" "not found|no element|404|400" "missing element error"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "error handling: action on missing field"--# Try to fill a field that doesn't exist-pt_post /action -d '{"action":"fill","selector":"#nonexistent-input","text":"test"}'-assert_contains_any "$RESULT" "not found|missing|404|400" "action on missing field rejected"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "error handling: navigate to invalid URL"--# Try to navigate to malformed URL-pt_post /navigate -d '{"url":"not a valid url @#$%"}'-assert_contains_any "$RESULT" "400|200|error" "invalid URL handled"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "error handling: error response format"--# Trigger an error and verify response format-pt_post /action -d '{"action":"click","selector":"#invalid-selector-#$%"}'--# Response should have error field-if echo "$RESULT" | jq -e '.error' >/dev/null 2>&1; then- echo -e " ${GREEN}✓${NC} error response has error field"- ((ASSERTIONS_PASSED++)) || true-else- echo -e " ${YELLOW}~${NC} error format may vary"- ((ASSERTIONS_PASSED++)) || true-fi--end_test--# ─────────────────────────────────────────────────────────────────-start_test "error handling: batch action with error in middle"--# Batch with one invalid action in the middle-pt_post /actions -d '[- {"action":"click","selector":"button"},- {"action":"click","selector":"#nonexistent"},- {"action":"click","selector":"button"}-]'-assert_contains_any "$RESULT" "not found|error|404|400" "batch stops on error"--end_testdiff --git a/tests/e2e/scenarios/22-redirects.sh b/tests/e2e/scenarios/22-redirects.shdeleted file mode 100755index 857a2d14..00000000--- a/tests/e2e/scenarios/22-redirects.sh+++ /dev/null@@ -1,42 +0,0 @@-#!/bin/bash-# 22-redirects.sh — Redirect following with security limits--source "$(dirname "$0")/common.sh"--start_test "redirects: follow single redirect"--# httpbin.org/redirect/1 redirects once to /get-pt_post /navigate -d '{"url":"https://httpbin.org/redirect/1"}'-assert_ok "single redirect followed"--# Verify we ended up at final destination-pt_get /snapshot-assert_json_contains "$RESULT" ".url" "httpbin.org/get" "final URL is /get (redirect successful)"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "redirects: follow multiple redirects"--# httpbin.org/redirect/5 follows 5 redirects total-pt_post /navigate -d '{"url":"https://httpbin.org/redirect/5"}'-assert_ok "five redirects followed"--# Verify final destination-pt_get /snapshot-assert_json_contains "$RESULT" ".url" "httpbin.org/get" "multiple redirects followed to destination"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "redirects: document redirect detection capability"--# When maxRedirects=20 (default), 5 redirects should work fine-# When maxRedirects=3, /redirect/5 should fail (too many redirects)-# (Actual enforcement would require network interception implementation)--echo -e " ${BLUE}ℹ${NC} Redirect limiting available via CDP Fetch domain"-echo -e " ${BLUE}ℹ${NC} Default: -1 (unlimited). Set maxRedirects: N to limit hops"-((ASSERTIONS_PASSED++)) || true--end_testdiff --git a/tests/e2e/scenarios/23-human-type.sh b/tests/e2e/scenarios/23-human-type.shdeleted file mode 100755index 868010db..00000000--- a/tests/e2e/scenarios/23-human-type.sh+++ /dev/null@@ -1,50 +0,0 @@-#!/bin/bash-# 23-human-type.sh — humanType and humanClick actions--source "$(dirname "$0")/common.sh"-source "$(dirname "$0")/helpers/snapshot.sh"-source "$(dirname "$0")/helpers/actions.sh"--# ─────────────────────────────────────────────────────────────────-start_test "humanClick: click input by ref"--navigate_fixture "human-type.html"-fresh_snapshot--require_ref "textbox" "Email" EMAIL_REF && \- action_human_click "$EMAIL_REF"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "humanType: type into input by ref"--fresh_snapshot-require_ref "textbox" "Email" EMAIL_REF && {- action_human_type "$EMAIL_REF" "[email protected]"-- fresh_snapshot- assert_value "textbox" "Email" "[email protected]"-}--end_test--# ─────────────────────────────────────────────────────────────────-start_test "humanType: type into second input by ref"--fresh_snapshot-require_ref "textbox" "Name" NAME_REF && {- action_human_type "$NAME_REF" "John Doe"-- fresh_snapshot- assert_value "textbox" "Name" "John Doe"-}--end_test--# ─────────────────────────────────────────────────────────────────-start_test "humanType: type with CSS selector"--action_human_type_selector "#name" " Jr."--end_testdiff --git a/tests/e2e/scenarios/24-tab-eviction-lru.sh b/tests/e2e/scenarios/24-tab-eviction-lru.shdeleted file mode 100755index 20c9f4bf..00000000--- a/tests/e2e/scenarios/24-tab-eviction-lru.sh+++ /dev/null@@ -1,91 +0,0 @@-#!/bin/bash-# 24-tab-eviction-lru.sh — LRU tab eviction (maxTabs=2 on secure instance)-#-# The secure pinchtab instance is configured with maxTabs=2 and close_lru.-# Tests that opening a 3rd managed tab evicts the least recently used one.-#-# Note: Chrome keeps an initial about:blank target that is unmanaged.-# Eviction is based on managed tab count, not Chrome target count.--source "$(dirname "$0")/common.sh"--# Use the secure instance (maxTabs=2)-E2E_SERVER="$E2E_SECURE_SERVER"--# ─────────────────────────────────────────────────────────────────-start_test "LRU eviction: open 2 tabs (at limit)"--# Tab 1-pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/index.html\"}"-TAB1=$(echo "$RESULT" | jq -r '.tabId')-assert_ok "open tab 1 (index)"-echo -e " ${MUTED}tab1: ${TAB1:0:12}...${NC}"--sleep 1--# Tab 2-pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/form.html\"}"-TAB2=$(echo "$RESULT" | jq -r '.tabId')-assert_ok "open tab 2 (form)"-echo -e " ${MUTED}tab2: ${TAB2:0:12}...${NC}"--# Both tabs should be accessible-pt_get "/tabs/$TAB1/snapshot" > /dev/null-assert_ok "tab1 accessible"-pt_get "/tabs/$TAB2/snapshot" > /dev/null-assert_ok "tab2 accessible"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "LRU eviction: 3rd tab evicts least recently used"--# Touch tab2 to make it recently used (clear time separation)-sleep 1-pt_get "/tabs/$TAB2/snapshot" > /dev/null-sleep 1--# Tab 3 — should evict tab1 (LRU, not touched since creation)-pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/buttons.html\"}"-TAB3=$(echo "$RESULT" | jq -r '.tabId')-assert_ok "open tab 3 (triggers eviction)"-echo -e " ${MUTED}tab3: ${TAB3:0:12}...${NC}"--# Tab1 should be gone (evicted as LRU)-pt_get "/tabs/$TAB1/snapshot"-assert_http_error 404 "tab1 evicted (LRU)"--# Tab2 should still be accessible (recently used)-pt_get "/tabs/$TAB2/snapshot" > /dev/null-assert_ok "tab2 survived (recently used)"--# Tab3 should be accessible (just created)-pt_get "/tabs/$TAB3/snapshot" > /dev/null-assert_ok "tab3 accessible"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "LRU eviction: continuous eviction works"--# Touch tab3 so tab2 becomes LRU-sleep 1-pt_get "/tabs/$TAB3/snapshot" > /dev/null-sleep 1--# Tab 4 — should evict tab2 (LRU)-pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/table.html\"}"-TAB4=$(echo "$RESULT" | jq -r '.tabId')-assert_ok "open tab 4 (triggers second eviction)"--# Tab2 should be gone now-pt_get "/tabs/$TAB2/snapshot"-assert_http_error 404 "tab2 evicted (LRU)"--# Tab3 and tab4 should be accessible-pt_get "/tabs/$TAB3/snapshot" > /dev/null-assert_ok "tab3 survived"-pt_get "/tabs/$TAB4/snapshot" > /dev/null-assert_ok "tab4 accessible"--end_testdiff --git a/tests/e2e/scenarios/25-press-keys.sh b/tests/e2e/scenarios/25-press-keys.shdeleted file mode 100755index 3bde589e..00000000--- a/tests/e2e/scenarios/25-press-keys.sh+++ /dev/null@@ -1,71 +0,0 @@-#!/bin/bash-# 25-press-keys.sh — Verify press action sends actual key events (not text)-#-# Regression test for GitHub issue #236: press action was typing key names-# as literal text instead of dispatching keyboard events.--source "$(dirname "$0")/common.sh"--# Use permissive instance (needs evaluate enabled)-E2E_SERVER="http://pinchtab:9999"--# ─────────────────────────────────────────────────────────────────-start_test "press Enter: does not type 'Enter' as text"--# Navigate to form fixture-pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/form.html\"}"-sleep 1--# Type into username field-pt_post /action -d '{"kind":"type","selector":"#username","text":"testuser"}'-assert_ok "type into username"--# Press Enter-pt_post /action -d '{"kind":"press","key":"Enter"}'-assert_ok "press Enter"--# The critical check: username should NOT contain "Enter" as literal text-assert_input_not_contains "#username" "Enter" "Enter key should dispatch event, not type text (bug #236)"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "press Tab: does not type 'Tab' as text"--# Navigate fresh-pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/form.html\"}"-sleep 1--# Focus on username and type-pt_post /action -d '{"kind":"click","selector":"#username"}'-pt_post /action -d '{"kind":"type","selector":"#username","text":"hello"}'-assert_ok "type hello"--# Press Tab-pt_post /action -d '{"kind":"press","key":"Tab"}'-assert_ok "press Tab"--# The critical check: username should NOT contain "Tab" as literal text-assert_input_not_contains "#username" "Tab" "Tab key should dispatch event, not type text (bug #236)"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "press Escape: does not type 'Escape' as text"--# Navigate fresh-pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/form.html\"}"-sleep 1--# Type something-pt_post /action -d '{"kind":"type","selector":"#username","text":"world"}'-assert_ok "type world"--# Press Escape-pt_post /action -d '{"kind":"press","key":"Escape"}'-assert_ok "press Escape"--# The critical check: username should NOT contain "Escape" as literal text-assert_input_not_contains "#username" "Escape" "Escape key should dispatch event, not type text (bug #236)"--end_testdiff --git a/tests/e2e/scenarios/26-cookies.sh b/tests/e2e/scenarios/26-cookies.shdeleted file mode 100755index 61739078..00000000--- a/tests/e2e/scenarios/26-cookies.sh+++ /dev/null@@ -1,72 +0,0 @@-#!/bin/bash-# 26-cookies.sh — Cookie management API tests-# Migrated from: tests/integration/cookies_test.go--source "$(dirname "$0")/common.sh"--# ─────────────────────────────────────────────────────────────────-start_test "GET /cookies (read cookies)"--pt_post /navigate "{\"url\":\"${FIXTURES_URL}/index.html\"}"-TAB_ID=$(get_tab_id)--pt_get "/cookies?tabId=${TAB_ID}"-assert_ok "get cookies"-assert_json_exists "$RESULT" '.cookies'--# If cookies exist, verify structure has required fields-COOKIE_COUNT=$(echo "$RESULT" | jq '.cookies | length')-if [ "$COOKIE_COUNT" -gt 0 ]; then- assert_json_exists "$RESULT" '.cookies[0].name' "cookie has name"- assert_json_exists "$RESULT" '.cookies[0].value' "cookie has value"- assert_json_exists "$RESULT" '.cookies[0].domain' "cookie has domain"- assert_json_exists "$RESULT" '.cookies[0].path' "cookie has path"-fi--end_test--# ─────────────────────────────────────────────────────────────────-start_test "POST /cookies (set + verify)"--pt_post /cookies "{- \"tabId\": \"${TAB_ID}\",- \"url\": \"${FIXTURES_URL}/index.html\",- \"cookies\": [{\"name\": \"test_e2e\", \"value\": \"hello\", \"path\": \"/\"}]-}"-assert_ok "set cookie"-assert_json_eq "$RESULT" '.set' '1'--# Read back and verify-pt_get "/cookies?tabId=${TAB_ID}&url=${FIXTURES_URL}/index.html"-assert_ok "get cookies after set"-assert_json_exists "$RESULT" '.cookies[] | select(.name == "test_e2e")'--end_test--# ─────────────────────────────────────────────────────────────────-start_test "GET /cookies (non-existent tab → error)"--pt_get "/cookies?tabId=nonexistent_tab_12345"-assert_not_ok "rejects bad tab"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "POST /cookies (bad JSON → error)"--pt_post_raw /cookies "{broken"-assert_http_status "400" "rejects bad JSON"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "POST /cookies (empty array → error)"--pt_post /cookies "{- \"tabId\": \"${TAB_ID}\",- \"url\": \"${FIXTURES_URL}/index.html\",- \"cookies\": []-}"-assert_http_status "400" "rejects empty cookies"--end_testdiff --git a/tests/e2e/scenarios/27-metrics.sh b/tests/e2e/scenarios/27-metrics.shdeleted file mode 100755index 608cb1fd..00000000--- a/tests/e2e/scenarios/27-metrics.sh+++ /dev/null@@ -1,39 +0,0 @@-#!/bin/bash-# 27-metrics.sh — Metrics API tests-# Migrated from: tests/integration/metrics_test.go--source "$(dirname "$0")/common.sh"--# ─────────────────────────────────────────────────────────────────-start_test "GET /instances/metrics"--pt_post /navigate "{\"url\":\"${FIXTURES_URL}/index.html\"}"-assert_ok "navigate"--pt_get "/instances/metrics"-assert_ok "get instance metrics"-assert_json_exists "$RESULT" '.[0].instanceId'-assert_json_exists "$RESULT" '.[0].jsHeapUsedMB'--end_test--# ─────────────────────────────────────────────────────────────────-start_test "GET /tabs/{id}/metrics"--pt_post /navigate "{\"url\":\"${FIXTURES_URL}/form.html\"}"-assert_ok "navigate"-TAB_ID=$(get_tab_id)--pt_get "/tabs/${TAB_ID}/metrics"-assert_ok "get tab metrics"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "GET /tabs/{invalid}/metrics → zeroed response"--pt_get "/tabs/invalid_tab_id/metrics"-assert_ok "proxied to instance (single-instance fallback)"-assert_json_value "$RESULT" '.memoryMB' "0" "zeroed metrics for unknown tab"--end_testdiff --git a/tests/e2e/scenarios/28-action-errors.sh b/tests/e2e/scenarios/28-action-errors.shdeleted file mode 100755index 3a6b6337..00000000--- a/tests/e2e/scenarios/28-action-errors.sh+++ /dev/null@@ -1,57 +0,0 @@-#!/bin/bash-# 28-action-errors.sh — Action error handling and batch operations-# Migrated from: tests/integration/actions_test.go (error cases)--source "$(dirname "$0")/common.sh"--# Navigate first-pt_post /navigate "{\"url\":\"${FIXTURES_URL}/buttons.html\"}"-assert_ok "navigate"--# ─────────────────────────────────────────────────────────────────-start_test "action: unknown kind → error"--pt_post /action '{"kind":"explode","ref":"e0"}'-assert_not_ok "rejects unknown kind"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "action: missing kind → error"--pt_post /action '{"ref":"e0"}'-assert_http_status "400" "rejects missing kind"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "action: ref not found → error"--pt_post /action '{"kind":"click","ref":"e999"}'-assert_not_ok "rejects missing ref"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "action: batch operations"--pt_post /actions '{"actions":[{"kind":"click","ref":"e4"},{"kind":"click","ref":"e5"}]}'-assert_ok "batch actions"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "action: empty batch → error"--pt_post /actions '{"actions":[]}'-assert_not_ok "rejects empty batch"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "action: nonexistent tabId → error"--pt_post /action '{"kind":"click","ref":"e0","tabId":"nonexistent_xyz_999"}'-assert_not_ok "rejects bad tab"--end_testdiff --git a/tests/e2e/scenarios/29-error-edge-cases.sh b/tests/e2e/scenarios/29-error-edge-cases.shdeleted file mode 100755index 0253fed9..00000000--- a/tests/e2e/scenarios/29-error-edge-cases.sh+++ /dev/null@@ -1,65 +0,0 @@-#!/bin/bash-# 29-error-edge-cases.sh — Edge case error handling-# Migrated from: tests/integration/error_handling_test.go (ER4, ER6)--source "$(dirname "$0")/common.sh"--# ─────────────────────────────────────────────────────────────────-start_test "error handling: empty page (about:blank)"--pt_post /navigate '{"url":"about:blank"}'-assert_ok "navigate to about:blank"--TAB_ID=$(get_tab_id)--pt_get "/snapshot?tabId=${TAB_ID}"-assert_ok "snapshot on empty page"--pt_get "/text?tabId=${TAB_ID}"-assert_ok "text on empty page"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "error handling: rapid navigation"--# Fire 3 rapid navigations-pt_post /navigate "{\"url\":\"${FIXTURES_URL}/index.html\"}"-pt_post /navigate "{\"url\":\"${FIXTURES_URL}/form.html\"}"-pt_post /navigate "{\"url\":\"${FIXTURES_URL}/buttons.html\"}"-assert_ok "final navigate succeeded"--# Verify server still works after rapid nav-sleep 1-pt_get /snapshot-assert_ok "snapshot after rapid nav"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "error handling: unicode content"--pt_post /navigate "{\"url\":\"${FIXTURES_URL}/unicode.html\"}"-assert_ok "navigate to unicode page"--pt_get /snapshot-assert_ok "snapshot unicode page"--pt_get /text-assert_ok "text unicode page"-assert_contains "$RESULT" "Unicode" "text has unicode content"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "error handling: binary content (image)"--# Navigate to a binary file (e.g., favicon.ico or sample image)-# Should not crash — may return error or empty content-pt_post /navigate "{\"url\":\"${FIXTURES_URL}/sample.txt\"}"-pt_get /text-# Don't assert_ok — just verify server didn't crash-pt_get /health-assert_ok "server still healthy after binary/text page"--end_testdiff --git a/tests/e2e/scenarios/30-stealth.sh b/tests/e2e/scenarios/30-stealth.shdeleted file mode 100755index 9d6d9648..00000000--- a/tests/e2e/scenarios/30-stealth.sh+++ /dev/null@@ -1,61 +0,0 @@-#!/bin/bash-# 30-stealth.sh — Stealth and fingerprint tests-# Migrated from: tests/integration/stealth_test.go--source "$(dirname "$0")/common.sh"--# Navigate first-pt_post /navigate "{\"url\":\"${FIXTURES_URL}/index.html\"}"-assert_ok "navigate"-sleep 1--# ─────────────────────────────────────────────────────────────────-start_test "stealth: webdriver is undefined"--assert_eval_poll "navigator.webdriver === undefined" "true" "navigator.webdriver is undefined"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "stealth: plugins present"--assert_eval_poll "navigator.plugins.length > 0" "true" "navigator.plugins spoofed"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "stealth: chrome.runtime present"--assert_eval_poll "!!window.chrome && !!window.chrome.runtime" "true" "window.chrome.runtime present"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "stealth: fingerprint rotate"--pt_post /fingerprint/rotate '{"os":"windows"}'-assert_ok "fingerprint rotate (windows)"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "stealth: fingerprint rotate (random)"--pt_post /fingerprint/rotate '{}'-assert_ok "fingerprint rotate (random)"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "stealth: fingerprint rotate (specific tab)"--pt_post /navigate "{\"url\":\"${FIXTURES_URL}/index.html\"}"-assert_ok "navigate"-TAB_ID=$(get_tab_id)--pt_post /fingerprint/rotate "{\"tabId\":\"${TAB_ID}\",\"os\":\"mac\"}"-assert_ok "fingerprint rotate on tab"--end_test--diff --git a/tests/e2e/scenarios/32-tabs-errors.sh b/tests/e2e/scenarios/32-tabs-errors.shdeleted file mode 100755index dc4f03aa..00000000--- a/tests/e2e/scenarios/32-tabs-errors.sh+++ /dev/null@@ -1,68 +0,0 @@-#!/bin/bash-# 32-tabs-errors.sh — Tab management error cases and edge cases-# Migrated from: tests/integration/tabs_test.go (TB4-TB8)--source "$(dirname "$0")/common.sh"--# ─────────────────────────────────────────────────────────────────-start_test "tabs: list returns array"--pt_get /tabs-assert_ok "list tabs"-assert_json_exists "$RESULT" '.tabs'-assert_json_length_gte "$RESULT" '.tabs' '1' "at least 1 tab"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "tabs: new + close roundtrip"--pt_post /tab "{\"action\":\"new\",\"url\":\"${FIXTURES_URL}/index.html\"}"-assert_ok "new tab"-NEW_TAB=$(echo "$RESULT" | jq -r '.tabId')--pt_post /tab "{\"action\":\"close\",\"tabId\":\"${NEW_TAB}\"}"-assert_ok "close tab"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "tabs: close without tabId → 400"--pt_post /tab '{"action":"close"}'-assert_http_status "400" "rejects close without tabId"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "tabs: bad action → 400"--pt_post /tab '{"action":"explode"}'-assert_http_status "400" "rejects bad action"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "tabs: new tab returns tabId"--pt_post /tab '{"action":"new","url":"about:blank"}'-assert_ok "new tab"-assert_tab_id "new tab returns tabId"--# Cleanup-pt_post /tab "{\"action\":\"close\",\"tabId\":\"${TAB_ID}\"}"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "tabs: nonexistent tab → 404"--FAKE_TAB="A25658CE1BA82659EBE9C93C46CEE63A"--pt_post "/tabs/${FAKE_TAB}/navigate" "{\"url\":\"${FIXTURES_URL}/index.html\"}"-assert_http_status "404" "navigate on fake tab"--pt_get "/tabs/${FAKE_TAB}/snapshot"-assert_http_status "404" "snapshot on fake tab"--end_testdiff --git a/tests/e2e/scenarios/33-upload-errors.sh b/tests/e2e/scenarios/33-upload-errors.shdeleted file mode 100755index b85d28a9..00000000--- a/tests/e2e/scenarios/33-upload-errors.sh+++ /dev/null@@ -1,50 +0,0 @@-#!/bin/bash-# 33-upload-errors.sh — Upload error cases-# Migrated from: tests/integration/upload_test.go (UP6-UP9, UP11)--source "$(dirname "$0")/common.sh"--pt_post /navigate "{\"url\":\"${FIXTURES_URL}/upload.html\"}"-assert_ok "navigate"-sleep 1--# ─────────────────────────────────────────────────────────────────-start_test "upload: default selector"--FILE_CONTENT="data:text/plain;base64,SGVsbG8="-pt_post /upload "{\"files\":[\"${FILE_CONTENT}\"]}"-assert_ok "upload with default selector"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "upload: invalid selector → error"--pt_post /upload '{"selector":"#nonexistent","files":["data:text/plain;base64,SGVsbG8="]}'-assert_not_ok "rejects invalid selector"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "upload: missing files → error"--pt_post /upload '{"selector":"#single-file"}'-assert_not_ok "rejects missing files"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "upload: bad JSON → error"--pt_post_raw /upload "{broken"-assert_http_status "400" "rejects bad JSON"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "upload: nonexistent file path → error"--pt_post /upload '{"selector":"#single-file","paths":["/tmp/nonexistent_file_xyz_12345.jpg"]}'-assert_not_ok "rejects missing file"--end_testdiff --git a/tests/e2e/scenarios/35-profile-rename.sh b/tests/e2e/scenarios/35-profile-rename.shdeleted file mode 100755index d97af2c0..00000000--- a/tests/e2e/scenarios/35-profile-rename.sh+++ /dev/null@@ -1,149 +0,0 @@-#!/bin/bash-# 35-profile-rename.sh — Profile CRUD, rename, and security-# Migrated from: tests/integration/profile_rename_test.go + security_profiles_test.go--source "$(dirname "$0")/common.sh"--# ─────────────────────────────────────────────────────────────────-start_test "profile: create + rename + verify"--# Create-pt_post /profiles/create '{"name":"e2e-rename-test"}'-assert_ok "create profile"-ORIG_ID=$(echo "$RESULT" | jq -r '.id')--# Rename via PATCH-pt_patch "/profiles/${ORIG_ID}" '{"name":"e2e-rename-test-renamed"}'-assert_ok "rename profile"-NEW_ID=$(echo "$RESULT" | jq -r '.id')-assert_json_eq "$RESULT" '.name' 'e2e-rename-test-renamed'--# Verify new ID works-pt_get "/profiles/${NEW_ID}"-assert_ok "get by new ID"--# Verify old ID is gone-pt_get "/profiles/${ORIG_ID}"-assert_not_ok "old ID returns error"--# Cleanup-pt_delete "/profiles/${NEW_ID}"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "profile: PATCH requires ID (not name)"--pt_post /profiles/create '{"name":"e2e-patch-by-name"}'-assert_ok "create"-PATCH_ID=$(echo "$RESULT" | jq -r '.id')--pt_patch "/profiles/e2e-patch-by-name" '{"name":"new-name"}'-assert_http_status "404" "PATCH by name rejected"--# Cleanup-pt_delete "/profiles/${PATCH_ID}"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "profile: DELETE requires ID (not name)"--pt_post /profiles/create '{"name":"e2e-delete-by-name"}'-assert_ok "create"-DEL_ID=$(echo "$RESULT" | jq -r '.id')--pt_delete "/profiles/e2e-delete-by-name"-assert_http_status "404" "DELETE by name rejected"--# Cleanup with ID-pt_delete "/profiles/${DEL_ID}"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "profile: rename conflict → 409"--pt_post /profiles/create '{"name":"e2e-conflict-a"}'-assert_ok "create A"-ID_A=$(echo "$RESULT" | jq -r '.id')--pt_post /profiles/create '{"name":"e2e-conflict-b"}'-assert_ok "create B"-ID_B=$(echo "$RESULT" | jq -r '.id')--# Try rename A → B's name-pt_patch "/profiles/${ID_A}" '{"name":"e2e-conflict-b"}'-assert_http_status "409" "conflict on duplicate name"--# Cleanup-pt_delete "/profiles/${ID_A}"-pt_delete "/profiles/${ID_B}"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "profile: path traversal rejected"--pt_post /profiles/create '{"name":"e2e-traversal"}'-assert_ok "create"-TRAV_ID=$(echo "$RESULT" | jq -r '.id')--pt_patch "/profiles/${TRAV_ID}" '{"name":"../etc/passwd"}'-assert_not_ok "rejects path traversal"--pt_patch "/profiles/${TRAV_ID}" '{"name":"foo/../../../bar"}'-assert_not_ok "rejects nested traversal"--# Cleanup-pt_delete "/profiles/${TRAV_ID}"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "profile: empty name rejected"--pt_post /profiles/create '{"name":""}'-assert_not_ok "rejects empty name"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "profile: path separator rejected"--pt_post /profiles/create '{"name":"profile/subdir"}'-assert_not_ok "rejects forward slash"--pt_post /profiles/create '{"name":"dir\\myprofile"}'-assert_not_ok "rejects backslash"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "profile: valid names accepted"--for NAME in "e2e-valid-1" "e2e_valid_2" "e2eVALID3"; do- pt_post /profiles/create "{\"name\":\"${NAME}\"}"- assert_ok "create $NAME"- VALID_ID=$(echo "$RESULT" | jq -r '.id')- pt_delete "/profiles/${VALID_ID}"-done--end_test--# ─────────────────────────────────────────────────────────────────-start_test "profile reset"--# Create a profile-pt_post /profiles -d '{"name":"reset-test-profile"}'-assert_ok "create profile for reset"-PROFILE_ID=$(echo "$RESULT" | jq -r '.id')--# Reset it-pt_post "/profiles/${PROFILE_ID}/reset" ""-assert_ok "reset profile"--# Clean up-pt_delete "/profiles/${PROFILE_ID}"--end_testdiff --git a/tests/e2e/scenarios/36-config.sh b/tests/e2e/scenarios/36-config.shdeleted file mode 100755index ce3b0954..00000000--- a/tests/e2e/scenarios/36-config.sh+++ /dev/null@@ -1,120 +0,0 @@-#!/bin/bash-# 36-config.sh — Config behaviour: Chrome version in UA, fingerprint rotation, config loading--source "$(dirname "$0")/common.sh"--# ═══════════════════════════════════════════════════════════════════-# CF7: Chrome version in user agent-# ═══════════════════════════════════════════════════════════════════--start_test "config: Chrome version in user agent"--pt_post /navigate '{"url":"about:blank"}'-assert_ok "navigate"-TAB_ID=$(echo "$RESULT" | jq -r '.tabId')--pt_post /evaluate "{\"tabId\":\"$TAB_ID\",\"expression\":\"navigator.userAgent\"}"-assert_ok "evaluate UA"-UA=$(echo "$RESULT" | jq -r '.result')--# Should contain Chrome/X.Y.Z.W or HeadlessChrome/X.Y.Z.W-if echo "$UA" | grep -qE '(Headless)?Chrome/[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+'; then- CHROME_VERSION=$(echo "$UA" | grep -oE '(Headless)?Chrome/[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+')- echo -e " ${GREEN}✓${NC} UA contains Chrome version: $CHROME_VERSION"- ((ASSERTIONS_PASSED++)) || true-else- echo -e " ${RED}✗${NC} UA missing Chrome version: $UA"- ((ASSERTIONS_FAILED++)) || true-fi--# Clean up-pt_post /tab "{\"tabId\":\"$TAB_ID\",\"action\":\"close\"}" >/dev/null 2>&1--end_test--# ═══════════════════════════════════════════════════════════════════-# CF8: Fingerprint rotation preserves Chrome version-# ═══════════════════════════════════════════════════════════════════--start_test "config: fingerprint rotation preserves Chrome version"--pt_post /navigate "{\"url\":\"${FIXTURES_URL}/index.html\"}"-assert_ok "navigate"-TAB_ID=$(echo "$RESULT" | jq -r '.tabId')--# Get initial Chrome version-pt_post /evaluate "{\"tabId\":\"$TAB_ID\",\"expression\":\"navigator.userAgent\"}"-assert_ok "initial UA"-INITIAL_UA=$(echo "$RESULT" | jq -r '.result')-INITIAL_VERSION=$(echo "$INITIAL_UA" | grep -oE 'Chrome/[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+' | head -1)--if [ -z "$INITIAL_VERSION" ]; then- echo -e " ${RED}✗${NC} initial UA missing Chrome version"- ((ASSERTIONS_FAILED++)) || true-else- echo -e " ${GREEN}✓${NC} initial version: $INITIAL_VERSION"- ((ASSERTIONS_PASSED++)) || true-fi--# Rotate fingerprint-pt_post /fingerprint/rotate "{\"os\":\"mac\",\"tabId\":\"$TAB_ID\"}"-assert_ok "fingerprint rotate"--# Get post-rotation Chrome version-pt_post /evaluate "{\"tabId\":\"$TAB_ID\",\"expression\":\"navigator.userAgent\"}"-assert_ok "rotated UA"-ROTATED_UA=$(echo "$RESULT" | jq -r '.result')-ROTATED_VERSION=$(echo "$ROTATED_UA" | grep -oE 'Chrome/[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+' | head -1)--if [ "$INITIAL_VERSION" = "$ROTATED_VERSION" ]; then- echo -e " ${GREEN}✓${NC} Chrome version preserved after rotation: $ROTATED_VERSION"- ((ASSERTIONS_PASSED++)) || true-else- echo -e " ${RED}✗${NC} Chrome version changed: $INITIAL_VERSION → $ROTATED_VERSION"- ((ASSERTIONS_FAILED++)) || true-fi--# Clean up-pt_post /tab "{\"tabId\":\"$TAB_ID\",\"action\":\"close\"}" >/dev/null 2>&1--end_test--# ═══════════════════════════════════════════════════════════════════-# CF1: Config file loading (server started successfully)-# ═══════════════════════════════════════════════════════════════════--start_test "config: server loads config file and starts"--pt_post /navigate "{\"url\":\"${FIXTURES_URL}/index.html\"}"-assert_ok "navigate"-TAB_ID=$(echo "$RESULT" | jq -r '.tabId')--pt_post /evaluate "{\"tabId\":\"$TAB_ID\",\"expression\":\"document.title\"}"-assert_ok "evaluate"-assert_json_exists "$RESULT" ".result" "got title result"--# Clean up-pt_post /tab "{\"tabId\":\"$TAB_ID\",\"action\":\"close\"}" >/dev/null 2>&1--end_test--# ═══════════════════════════════════════════════════════════════════-# CF2: Config file port is used (server runs on port from config)-# ═══════════════════════════════════════════════════════════════════--start_test "config: server uses port from config file"--# The server is running on port 9999 from config file.-# Verifies config is loaded correctly.-pt_post /navigate "{\"url\":\"${FIXTURES_URL}/index.html\"}"-assert_ok "navigate (proves env port override works)"--TAB_ID=$(echo "$RESULT" | jq -r '.tabId')-pt_post /evaluate "{\"tabId\":\"$TAB_ID\",\"expression\":\"window.location.href\"}"-assert_ok "evaluate"-assert_json_exists "$RESULT" ".result" "got location result"--# Clean up-pt_post /tab "{\"tabId\":\"$TAB_ID\",\"action\":\"close\"}" >/dev/null 2>&1--end_testdiff --git a/tests/e2e/scenarios/37-idpi.sh b/tests/e2e/scenarios/37-idpi.shdeleted file mode 100755index 0f75a0e2..00000000--- a/tests/e2e/scenarios/37-idpi.sh+++ /dev/null@@ -1,199 +0,0 @@-#!/bin/bash-# 37-idpi.sh — IDPI (Indirect Prompt Injection Detection) on /find and /pdf-#-# Tests content-based IDPI scanning:-# - E2E_SERVER (main): IDPI enabled, scanContent=true (default), warn mode-# - E2E_SECURE_SERVER (secure): IDPI enabled, strictMode=true--source "$(dirname "$0")/common.sh"--# ─────────────────────────────────────────────────────────────────-# IDPI test helpers-# ─────────────────────────────────────────────────────────────────--# Navigate to a page on a specific server, return tab ID-# Usage: TAB_ID=$(idpi_setup <base_url> <page_url>)-idpi_setup() {- local base_url="$1" page_url="$2"- local old_url="$E2E_SERVER"- E2E_SERVER="$base_url"- pt_post /navigate "{\"url\":\"$page_url\"}" >/dev/null- E2E_SERVER="$old_url"- sleep 1- echo "$RESULT" | jq -r '.tabId'-}--# Close a tab on a specific server-idpi_cleanup() {- local base_url="$1" tab_id="$2"- curl -sf -X POST "${base_url}/tab" \- -H "Content-Type: application/json" \- -d "{\"tabId\":\"$tab_id\",\"action\":\"close\"}" >/dev/null 2>&1 || true-}--# Make a request and capture a response header-# Usage: idpi_request POST <base_url> <path> <body> <header_name>-# idpi_request GET <base_url> <path> "" <header_name>-# Sets: RESULT, HTTP_STATUS, HDR_VALUE-idpi_request() {- local method="$1" base_url="$2" path="$3" body="$4" header_name="$5"- echo -e "${BLUE}→ curl -X $method ${base_url}${path}${NC}" >&2- local tmpheaders=$(mktemp)- local curl_args=(-s -w "\n%{http_code}" -X "$method" "${base_url}${path}" -H "Content-Type: application/json" -D "$tmpheaders")- [ -n "$body" ] && curl_args+=(-d "$body")- local response- response=$(curl "${curl_args[@]}")- RESULT=$(echo "$response" | head -n -1)- HTTP_STATUS=$(echo "$response" | tail -n 1)- HDR_VALUE=$(grep -i "^${header_name}:" "$tmpheaders" | sed 's/^[^:]*: *//' | tr -d '\r' | head -1)- rm -f "$tmpheaders"-}--# Assert header is present or absent-assert_header_present() {- local desc="$1"- if [ -n "$HDR_VALUE" ]; then- echo -e " ${GREEN}✓${NC} $desc: $HDR_VALUE"- ((ASSERTIONS_PASSED++)) || true- else- echo -e " ${RED}✗${NC} $desc (header missing)"- ((ASSERTIONS_FAILED++)) || true- fi-}--assert_header_absent() {- local desc="$1"- if [ -z "$HDR_VALUE" ]; then- echo -e " ${GREEN}✓${NC} $desc"- ((ASSERTIONS_PASSED++)) || true- else- echo -e " ${RED}✗${NC} $desc (unexpected: $HDR_VALUE)"- ((ASSERTIONS_FAILED++)) || true- fi-}--FIND_BODY='{"query":"continue button","threshold":0.1,"topK":5}'-FIND_CLEAN='{"query":"safe action button","threshold":0.1,"topK":5}'--# ═══════════════════════════════════════════════════════════════════-# /find — WARN MODE (main instance)-# ═══════════════════════════════════════════════════════════════════--start_test "idpi: /find clean page — no warning (warn mode)"-TAB_ID=$(idpi_setup "$E2E_SERVER" "${FIXTURES_URL}/idpi-clean.html")-idpi_request POST "$E2E_SERVER" "/tabs/${TAB_ID}/find" "$FIND_CLEAN" "X-IDPI-Warning"-assert_ok "/find clean page"-assert_header_absent "no X-IDPI-Warning on clean page"-idpi_cleanup "$E2E_SERVER" "$TAB_ID"-end_test--# ─────────────────────────────────────────────────────────────────-start_test "idpi: /find injection page — warns (warn mode)"-TAB_ID=$(idpi_setup "$E2E_SERVER" "${FIXTURES_URL}/idpi-inject.html")-idpi_request POST "$E2E_SERVER" "/tabs/${TAB_ID}/find" "$FIND_BODY" "X-IDPI-Warning"-assert_ok "/find injection (warn mode returns 200)"-assert_header_present "X-IDPI-Warning header present"-assert_json_exists "$RESULT" ".idpiWarning" "idpiWarning field in body"-idpi_cleanup "$E2E_SERVER" "$TAB_ID"-end_test--# ─────────────────────────────────────────────────────────────────-start_test "idpi: POST /find injection — warns (warn mode)"-TAB_ID=$(idpi_setup "$E2E_SERVER" "${FIXTURES_URL}/idpi-inject.html")-idpi_request POST "$E2E_SERVER" "/find" "{\"query\":\"malicious paragraph\",\"tabId\":\"$TAB_ID\",\"threshold\":0.1}" "X-IDPI-Warning"-assert_ok "POST /find (warn mode)"-assert_header_present "X-IDPI-Warning on POST /find"-idpi_cleanup "$E2E_SERVER" "$TAB_ID"-end_test--# ═══════════════════════════════════════════════════════════════════-# /find — STRICT MODE (secure instance)-# ═══════════════════════════════════════════════════════════════════--start_test "idpi: /find clean page — allowed (strict mode)"-TAB_ID=$(idpi_setup "$E2E_SECURE_SERVER" "${FIXTURES_URL}/idpi-clean.html")-idpi_request POST "$E2E_SECURE_SERVER" "/tabs/${TAB_ID}/find" "$FIND_CLEAN" "X-IDPI-Warning"-assert_ok "/find clean page (strict mode)"-idpi_cleanup "$E2E_SECURE_SERVER" "$TAB_ID"-end_test--# ─────────────────────────────────────────────────────────────────-start_test "idpi: /find injection page — blocked (strict mode)"-TAB_ID=$(idpi_setup "$E2E_SECURE_SERVER" "${FIXTURES_URL}/idpi-inject.html")-idpi_request POST "$E2E_SECURE_SERVER" "/tabs/${TAB_ID}/find" "$FIND_BODY" "X-IDPI-Warning"-assert_http_status 403 "/find blocked in strict mode"-assert_contains "$RESULT" "idpi" "403 body mentions IDPI"-idpi_cleanup "$E2E_SECURE_SERVER" "$TAB_ID"-end_test--# ═══════════════════════════════════════════════════════════════════-# /pdf — WARN MODE (main instance)-# ═══════════════════════════════════════════════════════════════════--start_test "idpi: /pdf clean page — no warning (warn mode)"-TAB_ID=$(idpi_setup "$E2E_SERVER" "${FIXTURES_URL}/idpi-clean.html")-idpi_request GET "$E2E_SERVER" "/tabs/${TAB_ID}/pdf" "" "X-IDPI-Warning"-assert_ok "/pdf clean page"-assert_header_absent "no X-IDPI-Warning on clean PDF"-idpi_cleanup "$E2E_SERVER" "$TAB_ID"-end_test--# ─────────────────────────────────────────────────────────────────-start_test "idpi: /pdf injection page — warns (warn mode)"-TAB_ID=$(idpi_setup "$E2E_SERVER" "${FIXTURES_URL}/idpi-inject.html")-idpi_request GET "$E2E_SERVER" "/tabs/${TAB_ID}/pdf" "" "X-IDPI-Warning"-assert_ok "/pdf injection (warn mode returns 200)"-assert_header_present "X-IDPI-Warning on injection PDF"-idpi_cleanup "$E2E_SERVER" "$TAB_ID"-end_test--# ═══════════════════════════════════════════════════════════════════-# /pdf — STRICT MODE (secure instance)-# ═══════════════════════════════════════════════════════════════════--start_test "idpi: /pdf clean page — allowed (strict mode)"-TAB_ID=$(idpi_setup "$E2E_SECURE_SERVER" "${FIXTURES_URL}/idpi-clean.html")-idpi_request GET "$E2E_SECURE_SERVER" "/tabs/${TAB_ID}/pdf" "" "X-IDPI-Warning"-assert_ok "/pdf clean page (strict mode)"-idpi_cleanup "$E2E_SECURE_SERVER" "$TAB_ID"-end_test--# ─────────────────────────────────────────────────────────────────-start_test "idpi: /pdf injection page — blocked (strict mode)"-TAB_ID=$(idpi_setup "$E2E_SECURE_SERVER" "${FIXTURES_URL}/idpi-inject.html")-idpi_request GET "$E2E_SECURE_SERVER" "/tabs/${TAB_ID}/pdf" "" "X-IDPI-Warning"-assert_http_status 403 "/pdf blocked in strict mode"-assert_contains "$RESULT" "idpi" "403 body mentions IDPI"-idpi_cleanup "$E2E_SECURE_SERVER" "$TAB_ID"-end_test--# ═══════════════════════════════════════════════════════════════════-# EDGE CASES-# ═══════════════════════════════════════════════════════════════════--start_test "idpi: multiple injection phrases — single warning header"-TAB_ID=$(idpi_setup "$E2E_SERVER" "${FIXTURES_URL}/idpi-inject.html")-tmpheaders=$(mktemp)-curl -s -X POST "${E2E_SERVER}/tabs/${TAB_ID}/find" \- -H "Content-Type: application/json" \- -D "$tmpheaders" \- -d "$FIND_BODY" >/dev/null-HDR_COUNT=$(grep -ci "^X-IDPI-Warning:" "$tmpheaders" 2>/dev/null || echo "0")-rm -f "$tmpheaders"-if [ "$HDR_COUNT" -eq 1 ]; then- echo -e " ${GREEN}✓${NC} exactly one X-IDPI-Warning header"- ((ASSERTIONS_PASSED++)) || true-else- echo -e " ${RED}✗${NC} expected 1 X-IDPI-Warning, got $HDR_COUNT"- ((ASSERTIONS_FAILED++)) || true-fi-idpi_cleanup "$E2E_SERVER" "$TAB_ID"-end_test--# ─────────────────────────────────────────────────────────────────-start_test "idpi: /pdf?raw=true blocked in strict mode"-TAB_ID=$(idpi_setup "$E2E_SECURE_SERVER" "${FIXTURES_URL}/idpi-inject.html")-idpi_request GET "$E2E_SECURE_SERVER" "/tabs/${TAB_ID}/pdf?raw=true" "" "X-IDPI-Warning"-assert_http_status 403 "raw PDF blocked in strict mode"-idpi_cleanup "$E2E_SECURE_SERVER" "$TAB_ID"-end_testdiff --git a/tests/e2e/scenarios/38-tab-locking.sh b/tests/e2e/scenarios/38-tab-locking.shdeleted file mode 100755index 4a917c42..00000000--- a/tests/e2e/scenarios/38-tab-locking.sh+++ /dev/null@@ -1,73 +0,0 @@-#!/bin/bash-# 38-tab-locking.sh — Tab lock/unlock functionality--source "$(dirname "$0")/common.sh"--# ─────────────────────────────────────────────────────────────────-start_test "tab lock: lock and unlock"--pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/index.html\"}"-TAB_ID=$(get_tab_id)--# Lock the tab-pt_post /tab/lock -d "{\"tabId\":\"${TAB_ID}\",\"owner\":\"test-agent\"}"-assert_ok "lock tab"-assert_json_eq "$RESULT" '.locked' 'true' "tab is locked"-assert_json_eq "$RESULT" '.owner' 'test-agent' "owner matches"--# Unlock the tab-pt_post /tab/unlock -d "{\"tabId\":\"${TAB_ID}\",\"owner\":\"test-agent\"}"-assert_ok "unlock tab"-assert_json_eq "$RESULT" '.unlocked' 'true' "tab is unlocked"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "tab lock: wrong owner cannot unlock"--pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/index.html\"}"-TAB_ID=$(get_tab_id)--# Lock with one owner-pt_post /tab/lock -d "{\"tabId\":\"${TAB_ID}\",\"owner\":\"agent-a\"}"-assert_ok "lock tab"--# Try unlock with different owner — should fail-pt_post /tab/unlock -d "{\"tabId\":\"${TAB_ID}\",\"owner\":\"agent-b\"}"-assert_not_ok "wrong owner rejected"--# Clean up — unlock with correct owner-pt_post /tab/unlock -d "{\"tabId\":\"${TAB_ID}\",\"owner\":\"agent-a\"}"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "tab lock: lock with timeoutSec"--pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/index.html\"}"-TAB_ID=$(get_tab_id)--pt_post /tab/lock -d "{\"tabId\":\"${TAB_ID}\",\"owner\":\"test-ttl\",\"timeoutSec\":60}"-assert_ok "lock with timeout"-assert_json_exists "$RESULT" '.expiresAt' "has expiration time"--# Clean up-pt_post /tab/unlock -d "{\"tabId\":\"${TAB_ID}\",\"owner\":\"test-ttl\"}"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "tab lock: path-based lock (POST /tabs/{id}/lock)"--pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/index.html\"}"-TAB_ID=$(get_tab_id)--pt_post "/tabs/${TAB_ID}/lock" -d "{\"owner\":\"path-agent\"}"-assert_ok "path-based lock"-assert_json_eq "$RESULT" '.locked' 'true'--# Unlock via path-pt_post "/tabs/${TAB_ID}/unlock" -d "{\"owner\":\"path-agent\"}"-assert_ok "path-based unlock"--end_testdiff --git a/tests/e2e/scenarios/39-scheduler.sh b/tests/e2e/scenarios/39-scheduler.shdeleted file mode 100755index 6aff38eb..00000000--- a/tests/e2e/scenarios/39-scheduler.sh+++ /dev/null@@ -1,213 +0,0 @@-#!/bin/bash-# 39-scheduler.sh — Scheduler task lifecycle E2E tests--source "$(dirname "$0")/common.sh"--AGENT="test-agent-$$"--# Get a tab for task execution-pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/index.html\"}"-TAB_ID=$(echo "$RESULT" | jq -r '.tabId')--# ─────────────────────────────────────────────────────────────────-start_test "POST /tasks — submit task"--pt_post /tasks -d "{\"agentId\":\"${AGENT}\",\"action\":\"snapshot\",\"tabId\":\"${TAB_ID}\"}"-assert_http_status "202" "task accepted"-TASK_ID=$(echo "$RESULT" | jq -r '.taskId')-assert_json_eq "$RESULT" ".state" "queued" "initial state is queued"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "GET /tasks/{id} — get task"--sleep 2-pt_get "/tasks/${TASK_ID}"-assert_ok "get task by id"-assert_json_eq "$RESULT" ".taskId" "$TASK_ID" "correct task id"-assert_json_eq "$RESULT" ".agentId" "$AGENT" "correct agent id"-assert_json_eq "$RESULT" ".action" "snapshot" "correct action"-STATE=$(echo "$RESULT" | jq -r '.state')-if [ "$STATE" = "completed" ] || [ "$STATE" = "running" ] || [ "$STATE" = "failed" ]; then- echo -e " ${GREEN}✓${NC} task reached terminal/active state: $STATE"- ((ASSERTIONS_PASSED++)) || true-else- echo -e " ${RED}✗${NC} unexpected state: $STATE"- ((ASSERTIONS_FAILED++)) || true-fi--end_test--# ─────────────────────────────────────────────────────────────────-start_test "GET /tasks — list tasks"--pt_get "/tasks?agentId=${AGENT}"-assert_ok "list tasks"-COUNT=$(echo "$RESULT" | jq '.count')-if [ "$COUNT" -ge 1 ]; then- echo -e " ${GREEN}✓${NC} found $COUNT tasks for agent"- ((ASSERTIONS_PASSED++)) || true-else- echo -e " ${RED}✗${NC} expected at least 1 task, got $COUNT"- ((ASSERTIONS_FAILED++)) || true-fi--end_test--# ─────────────────────────────────────────────────────────────────-start_test "GET /tasks — filter by state"--pt_get "/tasks?state=completed,failed"-assert_ok "list terminal tasks"-echo "$RESULT" | jq -e '.tasks' > /dev/null 2>&1-if [ $? -eq 0 ]; then- echo -e " ${GREEN}✓${NC} tasks array present in response"- ((ASSERTIONS_PASSED++)) || true-else- echo -e " ${RED}✗${NC} missing tasks array"- ((ASSERTIONS_FAILED++)) || true-fi--end_test--# ─────────────────────────────────────────────────────────────────-start_test "POST /tasks/{id}/cancel — cancel queued task"--pt_post /tasks -d "{\"agentId\":\"${AGENT}\",\"action\":\"snapshot\",\"tabId\":\"${TAB_ID}\"}"-assert_http_status "202" "task accepted for cancel test"-CANCEL_ID=$(echo "$RESULT" | jq -r '.taskId')--pt_post "/tasks/${CANCEL_ID}/cancel" ""-# Could be 200 (cancelled) or 409 (already in terminal state)-if [ "$HTTP_STATUS" = "200" ]; then- assert_json_eq "$RESULT" ".status" "cancelled" "task cancelled"-elif [ "$HTTP_STATUS" = "409" ]; then- echo -e " ${GREEN}✓${NC} task already terminal (409 conflict, acceptable)"- ((ASSERTIONS_PASSED++)) || true-else- echo -e " ${RED}✗${NC} unexpected status: $HTTP_STATUS"- ((ASSERTIONS_FAILED++)) || true-fi--end_test--# ─────────────────────────────────────────────────────────────────-start_test "POST /tasks/{id}/cancel — cancel nonexistent → 404"--pt_post "/tasks/tsk_nonexistent/cancel" ""-assert_http_status "404" "cancel nonexistent task"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "GET /scheduler/stats"--pt_get /scheduler/stats-assert_ok "stats endpoint"-echo "$RESULT" | jq -e '.queue' > /dev/null 2>&1-if [ $? -eq 0 ]; then- echo -e " ${GREEN}✓${NC} has queue stats"- ((ASSERTIONS_PASSED++)) || true-else- echo -e " ${RED}✗${NC} missing queue stats"- ((ASSERTIONS_FAILED++)) || true-fi-echo "$RESULT" | jq -e '.metrics' > /dev/null 2>&1-if [ $? -eq 0 ]; then- echo -e " ${GREEN}✓${NC} has metrics"- ((ASSERTIONS_PASSED++)) || true-else- echo -e " ${RED}✗${NC} missing metrics"- ((ASSERTIONS_FAILED++)) || true-fi-assert_json_eq "$RESULT" ".config.strategy" "fair-fifo" "strategy is fair-fifo"-assert_json_eq "$RESULT" ".config.maxQueueSize" "5" "maxQueueSize matches config"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "POST /tasks/batch — submit 3 tasks"--pt_post /tasks/batch -d "{\"agentId\":\"${AGENT}\",\"tasks\":[{\"action\":\"snapshot\",\"tabId\":\"${TAB_ID}\"},{\"action\":\"text\",\"tabId\":\"${TAB_ID}\"},{\"action\":\"screenshot\",\"tabId\":\"${TAB_ID}\"}]}"-assert_http_status "202" "batch accepted"-SUBMITTED=$(echo "$RESULT" | jq '.submitted')-if [ "$SUBMITTED" = "3" ]; then- echo -e " ${GREEN}✓${NC} all 3 tasks submitted"- ((ASSERTIONS_PASSED++)) || true-else- echo -e " ${RED}✗${NC} expected 3 submitted, got $SUBMITTED"- ((ASSERTIONS_FAILED++)) || true-fi--end_test--# ─────────────────────────────────────────────────────────────────-start_test "POST /tasks/batch — validation: empty tasks"--pt_post /tasks/batch -d '{"agentId":"test","tasks":[]}'-assert_http_status "400" "empty batch rejected"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "POST /tasks/batch — validation: missing agentId"--pt_post /tasks/batch -d '{"tasks":[{"action":"snapshot"}]}'-assert_http_status "400" "missing agentId rejected"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "POST /tasks — deadline in the past → 400"--pt_post /tasks -d "{\"agentId\":\"${AGENT}\",\"action\":\"snapshot\",\"tabId\":\"${TAB_ID}\",\"deadline\":\"2020-01-01T00:00:00Z\"}"-assert_http_status "400" "past deadline rejected"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "POST /tasks — 429 queue full"--# maxPerAgent is 3, submit rapidly for a fresh agent-FLOOD_AGENT="flood-agent-$$"-for i in $(seq 1 4); do- pt_post /tasks -d "{\"agentId\":\"${FLOOD_AGENT}\",\"action\":\"snapshot\",\"tabId\":\"${TAB_ID}\"}"-done-# The 4th should be 429 (maxPerAgent=3) — racy if tasks complete fast-if [ "$HTTP_STATUS" = "429" ]; then- echo -e " ${GREEN}✓${NC} queue full for agent (HTTP 429)"- ((ASSERTIONS_PASSED++)) || true-elif [ "$HTTP_STATUS" = "202" ]; then- echo -e " ${GREEN}✓${NC} task accepted (tasks completed before limit hit)"- ((ASSERTIONS_PASSED++)) || true-else- echo -e " ${RED}✗${NC} unexpected status: $HTTP_STATUS (expected 429 or 202)"- ((ASSERTIONS_FAILED++)) || true-fi--end_test--# ─────────────────────────────────────────────────────────────────-start_test "GET /tasks/{id} — nonexistent → 404"--pt_get /tasks/tsk_doesnotexist-assert_http_status "404" "nonexistent task"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "POST /tasks — missing agentId → 400"--pt_post /tasks -d '{"action":"snapshot"}'-assert_http_status "400" "missing agentId rejected"--end_test--# ─────────────────────────────────────────────────────────────────-start_test "POST /tasks — missing action → 400"--pt_post /tasks -d "{\"agentId\":\"validation-agent-$$\"}"-assert_http_status "400" "missing action rejected"--end_testdiff --git a/tests/e2e/scenarios/40-activity.sh b/tests/e2e/scenarios/40-activity.shdeleted file mode 100755index 481bd45e..00000000--- a/tests/e2e/scenarios/40-activity.sh+++ /dev/null@@ -1,38 +0,0 @@-#!/bin/bash-# 40-activity.sh — Activity API E2E tests--source "$(dirname "$0")/common.sh"--# ─────────────────────────────────────────────────────────────────-start_test "GET /api/activity — records tab-scoped requests"--pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/buttons.html\"}"-TAB_ID=$(get_tab_id)--pt_get "/tabs/${TAB_ID}/snapshot"-assert_ok "tab snapshot succeeded"--pt_post "/tabs/${TAB_ID}/action" -d '{"kind":"click","selector":"#increment"}'-assert_http_status "200" "click action succeeded"--pt_get "/api/activity?tabId=${TAB_ID}&limit=100&ageSec=300"-assert_ok "activity query"-assert_json_exists "$RESULT" '.events' "events array present"--if echo "$RESULT" | jq -e --arg tab "$TAB_ID" --arg path "/tabs/${TAB_ID}/snapshot" '.events[] | select(.tabId == $tab and .path == $path)' > /dev/null; then- echo -e " ${GREEN}✓${NC} tab snapshot event recorded"- ((ASSERTIONS_PASSED++)) || true-else- echo -e " ${RED}✗${NC} missing tab snapshot event for tab ${TAB_ID}"- ((ASSERTIONS_FAILED++)) || true-fi--if echo "$RESULT" | jq -e --arg tab "$TAB_ID" --arg path "/tabs/${TAB_ID}/action" '.events[] | select(.tabId == $tab and .path == $path)' > /dev/null; then- echo -e " ${GREEN}✓${NC} tab action event recorded"- ((ASSERTIONS_PASSED++)) || true-else- echo -e " ${RED}✗${NC} missing tab action event for tab ${TAB_ID}"- ((ASSERTIONS_FAILED++)) || true-fi--end_testdiff --git a/tests/e2e/scenarios/common.sh b/tests/e2e/scenarios/common.shdeleted file mode 100755index c3fa24f5..00000000--- a/tests/e2e/scenarios/common.sh+++ /dev/null@@ -1,889 +0,0 @@-#!/bin/bash-# Common utilities for E2E tests--set -uo pipefail-# Note: not using -e because arithmetic operations can return 1--# Colors-RED='\033[0;31m'-ERROR="$RED"-GREEN='\033[0;32m'-YELLOW='\033[0;33m'-BLUE='\033[0;34m'-MUTED='\033[0;90m'-BOLD='\033[1m'-NC='\033[0m'--# Defaults from environment-E2E_SERVER="${E2E_SERVER:-http://localhost:9999}"-E2E_SECURE_SERVER="${E2E_SECURE_SERVER:-http://localhost:9998}"-E2E_BRIDGE_URL="${E2E_BRIDGE_URL:-}"-E2E_BRIDGE_TOKEN="${E2E_BRIDGE_TOKEN:-}"-FIXTURES_URL="${FIXTURES_URL:-http://localhost:8080}"-RESULTS_DIR="${RESULTS_DIR:-/results}"--# Test tracking (only initialize if not already set)-CURRENT_TEST="${CURRENT_TEST:-}"-TESTS_PASSED="${TESTS_PASSED:-0}"-TESTS_FAILED="${TESTS_FAILED:-0}"-ASSERTIONS_PASSED="${ASSERTIONS_PASSED:-0}"-ASSERTIONS_FAILED="${ASSERTIONS_FAILED:-0}"--# Test timing (using seconds, Alpine doesn't support ms)-TEST_START_TIME="${TEST_START_TIME:-0}"-TEST_START_NS="${TEST_START_NS:-0}"-if [ -z "${TEST_RESULTS_INIT:-}" ]; then- TEST_RESULTS=()- TEST_RESULTS_INIT=1-fi--# Get time in milliseconds (cross-platform)-get_time_ms() {- if [ -f /proc/uptime ]; then- # Linux: use /proc/uptime (gives centiseconds)- awk '{printf "%.0f", $1 * 1000}' /proc/uptime- elif command -v gdate &>/dev/null; then- # macOS with coreutils- gdate +%s%3N- elif command -v perl &>/dev/null; then- # Perl fallback- perl -MTime::HiRes=time -e 'printf "%.0f", time * 1000'- else- # Last resort: seconds * 1000- echo $(($(date +%s) * 1000))- fi-}--wait_for_instance_ready() {- local base_url="$1"- local timeout_sec="${2:-60}"- local token="${3:-}"- local started_at- started_at=$(date +%s)-- while true; do- local now- now=$(date +%s)- if [ $((now - started_at)) -ge "$timeout_sec" ]; then- echo -e " ${RED}✗${NC} instance at ${base_url} did not reach running within ${timeout_sec}s"- return 1- fi-- local health_json- if [ -n "$token" ]; then- health_json=$(curl -sf -H "Authorization: Bearer ${token}" "${base_url}/health" 2>/dev/null || true)- else- health_json=$(curl -sf "${base_url}/health" 2>/dev/null || true)- fi- if [ -n "$health_json" ]; then- local inst_status- inst_status=$(echo "$health_json" | jq -r '.defaultInstance.status // .status // empty' 2>/dev/null || true)- if [ "$inst_status" = "running" ] || [ "$inst_status" = "ok" ]; then- echo -e " ${GREEN}✓${NC} instance ready at ${base_url}"- return 0- fi- fi-- sleep 1- done-}--wait_for_orchestrator_instance_status() {- local base_url="$1"- local instance_id="$2"- local wanted_status="${3:-running}"- local timeout_sec="${4:-60}"- local started_at- started_at=$(date +%s)-- while true; do- local now- now=$(date +%s)- if [ $((now - started_at)) -ge "$timeout_sec" ]; then- echo -e " ${RED}✗${NC} instance ${instance_id} at ${base_url} did not reach ${wanted_status} within ${timeout_sec}s"- return 1- fi-- local inst_json- inst_json=$(curl -sf "${base_url}/instances/${instance_id}" 2>/dev/null || true)- if [ -n "$inst_json" ]; then- local inst_status- inst_status=$(echo "$inst_json" | jq -r '.status // empty' 2>/dev/null || true)- if [ "$inst_status" = "$wanted_status" ]; then- echo -e " ${GREEN}✓${NC} instance ${instance_id} is ${wanted_status}"- return 0- fi- if [ "$inst_status" = "stopped" ] || [ "$inst_status" = "error" ]; then- echo -e " ${RED}✗${NC} instance ${instance_id} reached terminal status ${inst_status} before ${wanted_status}"- return 1- fi- fi-- sleep 1- done-}--# Start a test-start_test() {- CURRENT_TEST="$1"- TEST_START_TIME=$(get_time_ms)- echo -e "${BLUE}▶ ${CURRENT_TEST}${NC}"-}--# End a test-end_test() {- local end_time=$(get_time_ms)- local duration=$((end_time - TEST_START_TIME))-- if [ "$ASSERTIONS_FAILED" -eq 0 ]; then- echo -e "${GREEN}✓ ${CURRENT_TEST} passed${NC} ${MUTED}(${duration}ms)${NC}\n"- TEST_RESULTS+=("✅ ${CURRENT_TEST}|${duration}ms|passed")- ((TESTS_PASSED++)) || true- else- echo -e "${RED}✗ ${CURRENT_TEST} failed${NC} ${MUTED}(${duration}ms)${NC}\n"- TEST_RESULTS+=("❌ ${CURRENT_TEST}|${duration}ms|failed")- ((TESTS_FAILED++)) || true- fi- ASSERTIONS_PASSED=0- ASSERTIONS_FAILED=0-}--# Assert JSON field equals value-assert_json_eq() {- local json="$1"- local path="$2"- local expected="$3"- local desc="${4:-$path = $expected}"-- local actual- actual=$(echo "$json" | jq -r "$path")-- if [ "$actual" = "$expected" ]; then- echo -e " ${GREEN}✓${NC} $desc"- ((ASSERTIONS_PASSED++)) || true- else- echo -e " ${RED}✗${NC} $desc (got: $actual)"- ((ASSERTIONS_FAILED++)) || true- fi-}--# Assert JSON field contains value-assert_json_contains() {- local json="$1"- local path="$2"- local needle="$3"- local desc="${4:-$path contains '$needle'}"-- local actual- actual=$(echo "$json" | jq -r "$path")-- if [[ "$actual" == *"$needle"* ]]; then- echo -e " ${GREEN}✓${NC} $desc"- ((ASSERTIONS_PASSED++)) || true- else- echo -e " ${RED}✗${NC} $desc (got: $actual)"- ((ASSERTIONS_FAILED++)) || true- fi-}--# Assert JSON array length-assert_json_length() {- local json="$1"- local path="$2"- local expected="$3"- local desc="${4:-$path length = $expected}"-- local actual- actual=$(echo "$json" | jq "$path | length")-- if [ "$actual" -eq "$expected" ]; then- echo -e " ${GREEN}✓${NC} $desc"- ((ASSERTIONS_PASSED++)) || true- else- echo -e " ${RED}✗${NC} $desc (got: $actual)"- ((ASSERTIONS_FAILED++)) || true- fi-}--# Assert JSON array length >= value-assert_json_length_gte() {- local json="$1"- local path="$2"- local expected="$3"- local desc="${4:-$path length >= $expected}"-- local actual- actual=$(echo "$json" | jq "$path | length")-- if [ "$actual" -ge "$expected" ]; then- echo -e " ${GREEN}✓${NC} $desc"- ((ASSERTIONS_PASSED++)) || true- else- echo -e " ${RED}✗${NC} $desc (got: $actual)"- ((ASSERTIONS_FAILED++)) || true- fi-}--# Assert JSON field exists (not null)-assert_json_exists() {- local json="$1"- local path="$2"- local desc="${3:-$path exists}"-- if echo "$json" | jq -e "$path" >/dev/null 2>&1; then- echo -e " ${GREEN}✓${NC} $desc"- ((ASSERTIONS_PASSED++)) || true- else- echo -e " ${RED}✗${NC} $desc (field missing or null)"- ((ASSERTIONS_FAILED++)) || true- fi-}--# Assert string contains substring-assert_contains() {- local haystack="$1"- local needle="$2"- local desc="${3:-contains '$needle'}"-- if echo "$haystack" | grep -q "$needle"; then- echo -e " ${GREEN}✓${NC} $desc"- ((ASSERTIONS_PASSED++)) || true- else- echo -e " ${RED}✗${NC} $desc (not found)"- ((ASSERTIONS_FAILED++)) || true- fi-}--# Assert result JSON field equals value (uses global $RESULT)-assert_result_eq() {- local path="$1"- local expected="$2"- local desc="${3:-$path = $expected}"- assert_json_eq "$RESULT" "$path" "$expected" "$desc"-}--# Assert result JSON field exists (uses global $RESULT)-assert_result_exists() {- local path="$1"- local desc="${2:-$path exists}"- assert_json_exists "$RESULT" "$path" "$desc"-}--# Assert input field value does NOT contain text (case-insensitive)-# Usage: assert_input_not_contains "#username" "Enter" "username should not contain Enter"-assert_input_not_contains() {- local selector="$1"- local forbidden="$2"- local desc="${3:-$selector should not contain '$forbidden'}"-- local json_body- json_body=$(jq -n --arg sel "$selector" '{"expression": ("document.querySelector(\"" + $sel + "\")?.value || \"\"")}')- pt_post /evaluate "$json_body"- local value- value=$(echo "$RESULT" | jq -r '.result // empty')-- if echo "$value" | grep -qi "$forbidden"; then- echo -e " ${RED}✗${NC} $desc: found '$forbidden' in value '$value'"- ((ASSERTIONS_FAILED++)) || true- return 1- else- echo -e " ${GREEN}✓${NC} $desc (value: '$value')"- ((ASSERTIONS_PASSED++)) || true- return 0- fi-}--# Assert HTTP error status from $RESULT-# Usage: assert_http_error 400 "error message pattern"-assert_http_error() {- local expected_status="$1"- local error_pattern="${2:-error}"- local desc="${3:-HTTP $expected_status error}"-- local actual_status- actual_status=$(echo "$RESULT" | jq -r '.status // empty')-- if [ "$actual_status" = "$expected_status" ] || grep -q "$error_pattern" <<< "$RESULT"; then- echo -e " ${GREEN}✓${NC} $desc"- ((ASSERTIONS_PASSED++)) || true- else- echo -e " ${YELLOW}~${NC} $desc (got: $actual_status)"- ((ASSERTIONS_PASSED++)) || true- fi-}--# Assert result contains one of multiple patterns-# Usage: assert_contains_any "$RESULT" "pattern1|pattern2" "description"-assert_contains_any() {- local haystack="$1"- local patterns="$2" # pipe-separated- local desc="${3:-contains expected pattern}"-- if echo "$haystack" | grep -qE "$patterns"; then- echo -e " ${GREEN}✓${NC} $desc"- ((ASSERTIONS_PASSED++)) || true- else- echo -e " ${YELLOW}~${NC} $desc (not found)"- ((ASSERTIONS_PASSED++)) || true- fi-}--# ================================================================-# Visible curl wrapper — shows exact command when running-# ================================================================--RESULT=""-HTTP_STATUS=""--pinchtab() {- local method="$1"- local path="$2"- shift 2-- # Print the curl command in cyan so you see what's executed- # Using printf %q to better show quoted arguments- echo -e "${BLUE}→ curl -X $method ${E2E_SERVER}$path $(printf "%q " "$@")${NC}" >&2-- # Execute and capture response + status- local response- response=$(curl -s -w "\n%{http_code}" \- -X "$method" \- "${E2E_SERVER}$path" \- -H "Content-Type: application/json" \- "$@")-- RESULT=$(echo "$response" | head -n -1)- HTTP_STATUS=$(echo "$response" | tail -n 1)-- # Log response body on failure for debugging- if [[ ! "$HTTP_STATUS" =~ ^2 ]]; then- echo -e "${ERROR} HTTP $HTTP_STATUS: $RESULT${NC}" >&2- fi-}--# Aliases for cleaner test files-# Usage: pt_get /path-# pt_post /path '{"json":"data"}'-# pt_post /path -d '{"json":"data"}' (also works)-pt() { pinchtab "$@"; }--# Truncate output for display (avoid flooding logs with base64 blobs)-_echo_truncated() {- if [ ${#RESULT} -gt 1000 ]; then- echo "${RESULT:0:200}...[truncated ${#RESULT} chars]"- else- echo "$RESULT"- fi-}--pt_get() { pinchtab GET "$1"; _echo_truncated; }-pt_post() {- local path="$1"- shift- # Handle both: pt_post /path '{"data"}' and pt_post /path -d '{"data"}'- if [ "$1" = "-d" ]; then- shift- fi- pinchtab POST "$path" -d "$1"- _echo_truncated-}--pt_patch() {- local path="$1"- local body="$2"- echo -e "${BLUE}→ curl -X PATCH ${E2E_SERVER}$path${NC}" >&2- local response- response=$(curl -s -w "\n%{http_code}" \- -X PATCH \- "${E2E_SERVER}$path" \- -H "Content-Type: application/json" \- -d "$body")- RESULT=$(echo "$response" | head -n -1)- HTTP_STATUS=$(echo "$response" | tail -n 1)- _echo_truncated-}--pt_delete() {- local path="$1"- echo -e "${BLUE}→ curl -X DELETE ${E2E_SERVER}$path${NC}" >&2- local response- response=$(curl -s -w "\n%{http_code}" \- -X DELETE \- "${E2E_SERVER}$path")- RESULT=$(echo "$response" | head -n -1)- HTTP_STATUS=$(echo "$response" | tail -n 1)- _echo_truncated-}--# POST raw body (for testing malformed JSON)-pt_post_raw() {- local path="$1"- local body="$2"- echo -e "${BLUE}→ curl -X POST ${E2E_SERVER}$path -d '$body'${NC}" >&2- local response- response=$(curl -s -w "\n%{http_code}" \- -X POST \- "${E2E_SERVER}$path" \- -H "Content-Type: application/json" \- -d "$body")- RESULT=$(echo "$response" | head -n -1)- HTTP_STATUS=$(echo "$response" | tail -n 1)- _echo_truncated-}--# ================================================================-# URL accessibility checks-# ================================================================--# Check if a URL is accessible-assert_url_accessible() {- local url="$1"- local label="${2:-$url}"-- if curl -sf "$url" > /dev/null 2>&1; then- echo -e " ${GREEN}✓${NC} GET $label"- ((ASSERTIONS_PASSED++)) || true- else- echo -e " ${RED}✗${NC} GET $label (not accessible)"- ((ASSERTIONS_FAILED++)) || true- fi-}--# Check all fixture pages-assert_fixtures_accessible() {- assert_url_accessible "${FIXTURES_URL}/" "fixtures/"- assert_url_accessible "${FIXTURES_URL}/form.html" "fixtures/form.html"- assert_url_accessible "${FIXTURES_URL}/table.html" "fixtures/table.html"- assert_url_accessible "${FIXTURES_URL}/buttons.html" "fixtures/buttons.html"-}--# ================================================================-# Skip helper-# ================================================================--# ================================================================-# HTTP status assertions-# ================================================================--# Assert last request returned expected status (uses $HTTP_STATUS from pinchtab())-assert_ok() {- local label="${1:-request}"-- if [ "$HTTP_STATUS" = "200" ] || [ "$HTTP_STATUS" = "201" ]; then- echo -e " ${GREEN}✓${NC} $label → $HTTP_STATUS"- ((ASSERTIONS_PASSED++)) || true- else- echo -e " ${RED}✗${NC} $label failed (status: $HTTP_STATUS)"- ((ASSERTIONS_FAILED++)) || true- fi-}--# Assert last request returned specific status-assert_http_status() {- local expected="$1"- local label="${2:-request}"-- if [ "$HTTP_STATUS" = "$expected" ]; then- echo -e " ${GREEN}✓${NC} $label → $HTTP_STATUS"- ((ASSERTIONS_PASSED++)) || true- else- echo -e " ${RED}✗${NC} $label: expected $expected, got $HTTP_STATUS"- ((ASSERTIONS_FAILED++)) || true- fi-}--# Assert last request returned non-200 status (error expected)-assert_not_ok() {- local label="${1:-request}"-- if [ "$HTTP_STATUS" != "200" ] && [ "$HTTP_STATUS" != "201" ]; then- echo -e " ${GREEN}✓${NC} $label → $HTTP_STATUS (error expected)"- ((ASSERTIONS_PASSED++)) || true- else- echo -e " ${RED}✗${NC} $label: expected error, got $HTTP_STATUS"- ((ASSERTIONS_FAILED++)) || true- fi-}--# ================================================================-# Element interaction helpers-# ================================================================--# Click a button by name (requires snapshot in $RESULT)-click_button() {- local name="$1"- local ref- ref=$(echo "$RESULT" | jq -r "[.nodes[] | select(.name == \"$name\") | .ref] | first // empty")-- if [ -n "$ref" ] && [ "$ref" != "null" ]; then- pt_post /action "{\"kind\":\"click\",\"ref\":\"${ref}\"}" > /dev/null- echo -e " ${GREEN}✓${NC} clicked '$name' (ref: $ref)"- ((ASSERTIONS_PASSED++)) || true- else- echo -e " ${RED}✗${NC} button '$name' not found"- ((ASSERTIONS_FAILED++)) || true- fi-}--# Type into a field by name or role-type_into() {- local name="$1"- local text="$2"- local ref- ref=$(echo "$RESULT" | jq -r "[.nodes[] | select(.name == \"$name\") | .ref] | first // empty")-- # Fallback to textbox role if name not found- if [ -z "$ref" ] || [ "$ref" = "null" ]; then- ref=$(echo "$RESULT" | jq -r '[.nodes[] | select(.role == "textbox") | .ref] | first // empty')- fi-- if [ -n "$ref" ] && [ "$ref" != "null" ]; then- pt_post /action "{\"kind\":\"type\",\"ref\":\"${ref}\",\"text\":\"${text}\"}" > /dev/null- echo -e " ${GREEN}✓${NC} typed '$text' into '$name' (ref: $ref)"- ((ASSERTIONS_PASSED++)) || true- else- echo -e " ${RED}✗${NC} input '$name' not found"- ((ASSERTIONS_FAILED++)) || true- fi-}--# Press a key-press_key() {- local key="$1"- pt_post /action -d "{\"kind\":\"press\",\"key\":\"${key}\"}" > /dev/null- echo -e " ${GREEN}✓${NC} pressed '$key'"- ((ASSERTIONS_PASSED++)) || true-}--# ================================================================-# Tab helpers-# ================================================================--# Get current tab count-get_tab_count() {- curl -s "${E2E_SERVER}/tabs" | jq '.tabs | length'-}--# Get tab ID from last response (e.g., after /navigate)-get_tab_id() {- echo "$RESULT" | jq -r '.tabId'-}--# Extract tabId from RESULT, assert it's non-null, store in TAB_ID-# Usage: assert_tab_id "description"-assert_tab_id() {- local desc="${1:-tabId returned}"- TAB_ID=$(echo "$RESULT" | jq -r '.tabId')- if [ -n "$TAB_ID" ] && [ "$TAB_ID" != "null" ]; then- echo -e " ${GREEN}✓${NC} $desc: ${TAB_ID:0:12}..."- ((ASSERTIONS_PASSED++)) || true- else- echo -e " ${RED}✗${NC} no tabId in response"- ((ASSERTIONS_FAILED++)) || true- fi-}--# Get first tab ID from /tabs response-get_first_tab() {- echo "$RESULT" | jq -r '.tabs[0].id'-}--# Print tab ID (truncated for readability)-show_tab() {- local label="$1"- local id="$2"- echo -e " ${MUTED}$label: ${id:0:12}...${NC}"-}--# Assert tab count equals expected-assert_tab_count() {- local expected="$1"- local actual=$(get_tab_count)-- if [ "$actual" -eq "$expected" ]; then- echo -e " ${GREEN}✓${NC} tab count = $actual"- ((ASSERTIONS_PASSED++)) || true- else- echo -e " ${RED}✗${NC} tab count: expected $expected, got $actual"- ((ASSERTIONS_FAILED++)) || true- fi-}--# Assert tab count >= minimum-assert_tab_count_gte() {- local min="$1"- local actual=$(get_tab_count)-- if [ "$actual" -ge "$min" ]; then- echo -e " ${GREEN}✓${NC} tab count $actual >= $min"- ((ASSERTIONS_PASSED++)) || true- else- echo -e " ${RED}✗${NC} tab count: expected >= $min, got $actual"- ((ASSERTIONS_FAILED++)) || true- fi-}--# Assert tab count decreased after an action-assert_tab_closed() {- local before="$1"- local actual=$(get_tab_count)-- if [ "$actual" -lt "$before" ]; then- echo -e " ${GREEN}✓${NC} tab closed (before: $before, after: $actual)"- ((ASSERTIONS_PASSED++)) || true- else- echo -e " ${RED}✗${NC} tab not closed (before: $before, after: $actual)"- ((ASSERTIONS_FAILED++)) || true- fi-}--# ================================================================-# Ref extraction from snapshot-# ================================================================--# Find first ref by role from RESULT (curl) or PT_OUT (CLI)-# Usage: REF=$(find_ref_by_role "button")-find_ref_by_role() {- local role="$1"- local json="${2:-$RESULT}"- echo "$json" | jq -r "[.nodes[] | select(.role == \"$role\") | .ref] | first // empty"-}--# Find first ref by name from RESULT or PT_OUT-# Usage: REF=$(find_ref_by_name "Username:")-find_ref_by_name() {- local name="$1"- local json="${2:-$RESULT}"- echo "$json" | jq -r "[.nodes[] | select(.name == \"$name\") | .ref] | first // empty"-}--# Assert ref was found, with readable error-# Usage: assert_ref_found "$REF" "button ref"-assert_ref_found() {- local ref="$1"- local desc="${2:-ref}"- if [ -n "$ref" ] && [ "$ref" != "null" ]; then- echo -e " ${GREEN}✓${NC} found $desc: $ref"- ((ASSERTIONS_PASSED++)) || true- return 0- else- echo -e " ${YELLOW}⚠${NC} could not find $desc, skipping"- ((ASSERTIONS_PASSED++)) || true- return 1- fi-}--# ================================================================-# Evaluate with polling (for stealth/async injection)-# ================================================================--# Poll an expression up to N times, assert result equals expected.-# If a tab ID is provided, evaluate in that exact tab instead of the implicit current tab.-# Usage: assert_eval_poll "navigator.webdriver === undefined" "true" "webdriver is undefined" [attempts] [delay] [tab_id]-assert_eval_poll() {- local expr="$1"- local expected="$2"- local desc="${3:-eval poll}"- local attempts="${4:-5}"- local delay="${5:-0.4}"- local tab_id="${6:-}"-- local ok=false- for i in $(seq 1 "$attempts"); do- local json_body- if [ -n "$tab_id" ]; then- json_body=$(jq -n --arg expr "$expr" --arg tabId "$tab_id" '{"expression": $expr, "tabId": $tabId}')- else- json_body=$(jq -n --arg expr "$expr" '{"expression": $expr}')- fi- pt_post /evaluate "$json_body"- local actual- actual=$(echo "$RESULT" | jq -r '.result // empty' 2>/dev/null)- if [ "$actual" = "$expected" ]; then- ok=true- break- fi- sleep "$delay"- done-- if [ "$ok" = "true" ]; then- echo -e " ${GREEN}✓${NC} $desc"- ((ASSERTIONS_PASSED++)) || true- return 0- else- echo -e " ${RED}✗${NC} $desc (got: $actual, expected: $expected)"- ((ASSERTIONS_FAILED++)) || true- return 1- fi-}--# ================================================================-# Page-specific assertions (we control the fixtures!)-# ================================================================--# buttons.html: Increment, Decrement, Reset, Toggle visibility, Show Message-assert_buttons_page() {- local snap="$1"- local expected_buttons=("Increment" "Decrement" "Reset")- local found=0-- for btn in "${expected_buttons[@]}"; do- if echo "$snap" | jq -e ".nodes[] | select(.name == \"$btn\")" > /dev/null 2>&1; then- ((found++))- fi- done-- if [ "$found" -ge 3 ]; then- echo -e " ${GREEN}✓${NC} buttons.html: found $found/3 expected buttons"- ((ASSERTIONS_PASSED++)) || true- else- echo -e " ${RED}✗${NC} buttons.html: found only $found/3 expected buttons"- ((ASSERTIONS_FAILED++)) || true- fi-}--# form.html: username, email, password fields + Submit button-assert_form_page() {- local snap="$1"- local checks=0-- # Check for textboxes (username, email)- local textboxes=$(echo "$snap" | jq '[.nodes[] | select(.role == "textbox")] | length')- [ "$textboxes" -ge 2 ] && ((checks++))-- # Check for Submit button- echo "$snap" | jq -e '.nodes[] | select(.name == "Submit")' > /dev/null 2>&1 && ((checks++))-- # Check for combobox (country select)- echo "$snap" | jq -e '.nodes[] | select(.role == "combobox")' > /dev/null 2>&1 && ((checks++))-- if [ "$checks" -ge 3 ]; then- echo -e " ${GREEN}✓${NC} form.html: found inputs, submit button, and select"- ((ASSERTIONS_PASSED++)) || true- else- echo -e " ${RED}✗${NC} form.html: missing expected elements ($checks/3)"- ((ASSERTIONS_FAILED++)) || true- fi-}--# table.html: Alice Johnson, [email protected], Active/Inactive status-assert_table_page() {- local text="$1"- local checks=0-- echo "$text" | grep -q "Alice Johnson" && ((checks++))- echo "$text" | grep -q "[email protected]" && ((checks++))- echo "$text" | grep -q "Active" && ((checks++))-- if [ "$checks" -ge 3 ]; then- echo -e " ${GREEN}✓${NC} table.html: found expected table data"- ((ASSERTIONS_PASSED++)) || true- else- echo -e " ${RED}✗${NC} table.html: missing expected data ($checks/3)"- ((ASSERTIONS_FAILED++)) || true- fi-}--# index.html: Welcome header-assert_index_page() {- local snap="$1"-- if echo "$snap" | jq -e '.title' | grep -q "E2E Test"; then- echo -e " ${GREEN}✓${NC} index.html: correct title"- ((ASSERTIONS_PASSED++)) || true- else- echo -e " ${RED}✗${NC} index.html: wrong title"- ((ASSERTIONS_FAILED++)) || true- fi-}--# Print summary-print_summary() {- local total=$((TESTS_PASSED + TESTS_FAILED))- local total_time=0-- echo ""- echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"- echo -e "${BLUE}E2E Test Summary${NC}"- echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"- echo ""- # Calculate column width from longest test name (min 40, pad +2)- local name_width=40- for result in "${TEST_RESULTS[@]}"; do- IFS='|' read -r name _ _ <<< "$result"- local len=${#name}- [ "$len" -gt "$name_width" ] && name_width=$len- done- ((name_width += 2)) || true- local line_width=$((name_width + 24))- local separator=$(printf '─%.0s' $(seq 1 $line_width))-- printf " %-${name_width}s %10s %10s\n" "Test" "Duration" "Status"- echo " ${separator}"-- for result in "${TEST_RESULTS[@]}"; do- IFS='|' read -r name duration status <<< "$result"- local time_num=${duration%ms}- ((total_time += time_num)) || true- if [ "$status" = "passed" ]; then- printf " %-${name_width}s %10s ${GREEN}%10s${NC}\n" "$name" "$duration" "✓"- else- printf " %-${name_width}s %10s ${RED}%10s${NC}\n" "$name" "$duration" "✗"- fi- done-- echo " ${separator}"- printf " %-${name_width}s %10s\n" "Total" "${total_time}ms"- echo ""- echo -e " ${GREEN}Passed:${NC} ${TESTS_PASSED}/${total}"- echo -e " ${RED}Failed:${NC} ${TESTS_FAILED}/${total}"- echo ""- echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"-- # Generate markdown report for CI- if [ -d "${RESULTS_DIR:-}" ]; then- generate_markdown_report > "${RESULTS_DIR}/report.md"- echo "passed=$TESTS_PASSED" > "${RESULTS_DIR}/summary.txt"- echo "failed=$TESTS_FAILED" >> "${RESULTS_DIR}/summary.txt"- echo "total_time=${total_time}ms" >> "${RESULTS_DIR}/summary.txt"- echo "timestamp=$(date -u +%Y-%m-%dT%H:%M:%SZ)" >> "${RESULTS_DIR}/summary.txt"- fi-- if [ "$TESTS_FAILED" -gt 0 ]; then- exit 1- fi-}--# Generate markdown report-generate_markdown_report() {- local total=$((TESTS_PASSED + TESTS_FAILED))- local total_time=0-- echo "## 🦀 PinchTab E2E Test Report"- echo ""- if [ "$TESTS_FAILED" -eq 0 ]; then- echo "**Status:** ✅ All tests passed"- else- echo "**Status:** ❌ ${TESTS_FAILED} test(s) failed"- fi- echo ""- echo "| Test | Duration | Status |"- echo "|------|----------|--------|"-- for result in "${TEST_RESULTS[@]}"; do- IFS='|' read -r name duration status <<< "$result"- local time_num=${duration%ms}- ((total_time += time_num)) || true- local icon="✅"- [ "$status" = "failed" ] && icon="❌"- # Remove emoji from name for cleaner table- local clean_name="${name#✅ }"- clean_name="${clean_name#❌ }"- echo "| ${clean_name} | ${duration} | ${icon} |"- done-- echo ""- echo "**Summary:** ${TESTS_PASSED}/${total} passed in ${total_time}ms"- echo ""- echo "<sub>Generated at $(date -u +%Y-%m-%dT%H:%M:%SZ)</sub>"-}diff --git a/tests/e2e/scenarios/run-all.sh b/tests/e2e/scenarios/run-all.shdeleted file mode 100755index fe629c59..00000000--- a/tests/e2e/scenarios/run-all.sh+++ /dev/null@@ -1,42 +0,0 @@-#!/bin/bash-# run-all.sh - Run all E2E test scenarios--set -uo pipefail--SCRIPT_DIR="$(dirname "$0")"-source "${SCRIPT_DIR}/common.sh"--echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"-echo -e "${BLUE}PinchTab E2E Test Suite${NC}"-echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"-echo "E2E_SERVER: ${E2E_SERVER}"-echo "FIXTURES_URL: ${FIXTURES_URL}"-echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"-echo ""--echo "Waiting for instances to become ready..."-wait_for_instance_ready "${E2E_SERVER}"-wait_for_instance_ready "${E2E_SECURE_SERVER}"-if [ -n "${E2E_LITE_SERVER:-}" ]; then- wait_for_instance_ready "${E2E_LITE_SERVER}"-fi-echo ""--# Find and run all test scripts in order-for script in "${SCRIPT_DIR}"/[0-9][0-9]-*.sh; do- if [ -f "$script" ]; then- echo -e "${YELLOW}Running: $(basename "$script")${NC}"- echo ""- source "$script"- echo ""- fi-done--print_summary--# Save results if results dir exists-if [ -d "${RESULTS_DIR:-}" ]; then- echo "passed=$TESTS_PASSED" > "${RESULTS_DIR}/summary.txt"- echo "failed=$TESTS_FAILED" >> "${RESULTS_DIR}/summary.txt"- echo "timestamp=$(date -u +%Y-%m-%dT%H:%M:%SZ)" >> "${RESULTS_DIR}/summary.txt"-fidiff --git a/tests/e2e/scenarios/run-fast.sh b/tests/e2e/scenarios/run-fast.shdeleted file mode 100644index 9157b36f..00000000--- a/tests/e2e/scenarios/run-fast.sh+++ /dev/null@@ -1,58 +0,0 @@-#!/bin/bash-# run-fast.sh - Run the curated PR-fast API scenarios.--set -uo pipefail--SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"-SUITE_FILE="${E2E_SUITE_FILE:-/e2e-suites/api-fast.txt}"--source "${SCRIPT_DIR}/common.sh"--echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"-echo -e "${BLUE}PinchTab E2E API Fast Suite${NC}"-echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"-echo "E2E_SERVER: ${E2E_SERVER}"-echo "FIXTURES_URL: ${FIXTURES_URL}"-echo "SUITE_FILE: ${SUITE_FILE}"-echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"-echo ""--if [ ! -f "${SUITE_FILE}" ]; then- echo "suite manifest not found: ${SUITE_FILE}" >&2- exit 1-fi--echo "Waiting for instances to become ready..."-wait_for_instance_ready "${E2E_SERVER}"-wait_for_instance_ready "${E2E_SECURE_SERVER}"-if [ -n "${E2E_LITE_SERVER:-}" ]; then- wait_for_instance_ready "${E2E_LITE_SERVER}"-fi-echo ""--while IFS= read -r script_name || [ -n "${script_name}" ]; do- case "${script_name}" in- ''|'#'*)- continue- ;;- esac-- script_path="${SCRIPT_DIR}/${script_name}"- if [ ! -f "${script_path}" ]; then- echo "suite entry not found: ${script_path}" >&2- exit 1- fi-- echo -e "${YELLOW}Running: ${script_name}${NC}"- echo ""- source "${script_path}"- echo ""-done < "${SUITE_FILE}"--print_summary--if [ -d "${RESULTS_DIR:-}" ]; then- echo "passed=$TESTS_PASSED" > "${RESULTS_DIR}/summary-api-fast.txt"- echo "failed=$TESTS_FAILED" >> "${RESULTS_DIR}/summary-api-fast.txt"- echo "timestamp=$(date -u +%Y-%m-%dT%H:%M:%SZ)" >> "${RESULTS_DIR}/summary-api-fast.txt"-fidiff --git a/tests/e2e/suites/api-fast.txt b/tests/e2e/suites/api-fast.txtdeleted file mode 100644index 60eb6996..00000000--- a/tests/e2e/suites/api-fast.txt+++ /dev/null@@ -1,8 +0,0 @@-# Stable PR-fast API coverage: health, navigation, tabs, snapshot, actions, find, text.-01-health.sh-02-navigate.sh-03-snapshot.sh-04-tabs-api.sh-05-actions.sh-07-find.sh-17-text-extraction.shdiff --git a/tests/e2e/suites/cli-fast.txt b/tests/e2e/suites/cli-fast.txtdeleted file mode 100644index 2dd982bc..00000000--- a/tests/e2e/suites/cli-fast.txt+++ /dev/null@@ -1,7 +0,0 @@-# Stable PR-fast CLI coverage: health, navigation, tabs, snapshot, actions, text.-09-health.sh-01-nav.sh-02-snap.sh-03-actions.sh-04-tabs.sh-06-text.sh