File size: 4,149 Bytes
6a7089a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | # E2E Test Suite
End-to-end tests for PinchTab that exercise the full stack including browser automation.
## Quick Start
### With Docker (recommended)
```bash
./dev e2e # Run all E2E tests
./dev e2e recent # Run only recently added/changed scenarios (fast feedback)
./dev e2e orchestrator # Run orchestrator-heavy scenarios only
./dev e2e curl # Run only Curl-based scenarios
./dev e2e cli # Run only CLI-based scenarios
```
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
```
## Architecture
```
tests/e2e/
βββ docker-compose.yml # Generic curl scenarios
βββ docker-compose-orchestrator.yml # Orchestrator-specific services
βββ config/ # E2E-specific PinchTab configs
β βββ pinchtab.json
β βββ pinchtab-secure.json
β βββ pinchtab-bridge.json
βββ fixtures/ # Static HTML test pages
β βββ index.html
β βββ form.html
β βββ table.html
β βββ buttons.html
βββ scenarios/ # Test scripts
β βββ common.sh # Shared utilities
β βββ run-all.sh # Generic curl scenarios
β βββ 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-orchestrator/ # Multi-instance and attach flows
β βββ run-all.sh
β βββ 01-attach-bridge.sh
β βββ 31-multi-instance.sh
βββ runner/ # 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.
## Test Scenarios
| 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 actions |
| 06-screenshot-pdf | Screenshot and PDF export |
| 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 |
## 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:
```bash
#!/bin/bash
source "$(dirname "$0")/common.sh"
start_test "My test name"
# Assert HTTP status
assert_status 200 "${PINCHTAB_URL}/health"
# Assert JSON field equals value
RESULT=$(pt_get "/some/endpoint")
assert_json_eq "$RESULT" '.field' 'expected'
# Assert JSON contains substring
assert_json_contains "$RESULT" '.message' 'success'
# Assert array length
assert_json_length "$RESULT" '.items' 5
end_test
```
## Adding Fixtures
Add HTML files to `fixtures/` for testing specific scenarios:
- Forms and inputs
- Tables and data
- Dynamic content
- iframes
- File upload/download
## CI Integration
The E2E tests run automatically:
- On release tags (`v*`)
- On PRs that modify `tests/e2e/`
- Manually via workflow dispatch
## Debugging
### View container logs
```bash
docker compose -f tests/e2e/docker-compose.yml logs pinchtab
```
### Interactive shell in runner
```bash
docker compose -f tests/e2e/docker-compose.yml run runner 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
```
### 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
```
|