@matware/e2e-runner 1.1.1 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/.claude-plugin/marketplace.json +21 -0
  2. package/.claude-plugin/plugin.json +9 -0
  3. package/.mcp.json +9 -0
  4. package/.opencode/commands/create-test.md +63 -0
  5. package/.opencode/commands/run.md +50 -0
  6. package/.opencode/commands/verify-issue.md +62 -0
  7. package/.opencode/skills/e2e-testing/SKILL.md +181 -0
  8. package/.opencode/skills/e2e-testing/references/action-types.md +143 -0
  9. package/.opencode/skills/e2e-testing/references/auth-strategies.md +91 -0
  10. package/.opencode/skills/e2e-testing/references/graphql.md +59 -0
  11. package/.opencode/skills/e2e-testing/references/issue-verification.md +59 -0
  12. package/.opencode/skills/e2e-testing/references/multi-pool.md +60 -0
  13. package/.opencode/skills/e2e-testing/references/network-debugging.md +62 -0
  14. package/.opencode/skills/e2e-testing/references/test-json-format.md +163 -0
  15. package/.opencode/skills/e2e-testing/references/troubleshooting.md +224 -0
  16. package/.opencode/skills/e2e-testing/references/variables.md +41 -0
  17. package/.opencode/skills/e2e-testing/references/visual-verification.md +89 -0
  18. package/OPENCODE.md +166 -0
  19. package/README.md +990 -296
  20. package/agents/test-analyzer.md +81 -0
  21. package/agents/test-creator.md +155 -0
  22. package/agents/test-improver.md +177 -0
  23. package/bin/cli.js +602 -22
  24. package/commands/create-test.md +65 -0
  25. package/commands/run.md +49 -0
  26. package/commands/verify-issue.md +63 -0
  27. package/opencode.json +11 -0
  28. package/package.json +15 -2
  29. package/scripts/setup-opencode.sh +113 -0
  30. package/skills/e2e-testing/SKILL.md +173 -0
  31. package/skills/e2e-testing/references/action-types.md +143 -0
  32. package/skills/e2e-testing/references/auth-strategies.md +91 -0
  33. package/skills/e2e-testing/references/graphql.md +59 -0
  34. package/skills/e2e-testing/references/issue-verification.md +59 -0
  35. package/skills/e2e-testing/references/multi-pool.md +60 -0
  36. package/skills/e2e-testing/references/network-debugging.md +62 -0
  37. package/skills/e2e-testing/references/test-json-format.md +163 -0
  38. package/skills/e2e-testing/references/troubleshooting.md +224 -0
  39. package/skills/e2e-testing/references/variables.md +41 -0
  40. package/skills/e2e-testing/references/visual-verification.md +89 -0
  41. package/src/actions.js +597 -20
  42. package/src/ai-generate.js +142 -12
  43. package/src/config.js +171 -0
  44. package/src/dashboard.js +299 -17
  45. package/src/db.js +335 -13
  46. package/src/index.js +15 -8
  47. package/src/learner-markdown.js +177 -0
  48. package/src/learner-neo4j.js +255 -0
  49. package/src/learner-sqlite.js +658 -0
  50. package/src/learner.js +418 -0
  51. package/src/mcp-tools.js +1558 -50
  52. package/src/module-resolver.js +310 -0
  53. package/src/narrate.js +262 -0
  54. package/src/neo4j-pool.js +124 -0
  55. package/src/pool-manager.js +223 -0
  56. package/src/reporter.js +117 -3
  57. package/src/runner.js +274 -71
  58. package/src/sync/auth.js +354 -0
  59. package/src/sync/client.js +572 -0
  60. package/src/sync/hub-routes.js +816 -0
  61. package/src/sync/index.js +68 -0
  62. package/src/sync/middleware.js +347 -0
  63. package/src/sync/queue.js +209 -0
  64. package/src/sync/schema.js +540 -0
  65. package/src/verify.js +14 -9
  66. package/src/watch.js +384 -0
  67. package/templates/build-dashboard.js +69 -0
  68. package/templates/dashboard/js/api.js +60 -0
  69. package/templates/dashboard/js/init.js +13 -0
  70. package/templates/dashboard/js/keyboard.js +46 -0
  71. package/templates/dashboard/js/state.js +40 -0
  72. package/templates/dashboard/js/toast.js +41 -0
  73. package/templates/dashboard/js/utils.js +196 -0
  74. package/templates/dashboard/js/view-live.js +143 -0
  75. package/templates/dashboard/js/view-runs.js +572 -0
  76. package/templates/dashboard/js/view-tests.js +294 -0
  77. package/templates/dashboard/js/view-watch.js +242 -0
  78. package/templates/dashboard/js/websocket.js +110 -0
  79. package/templates/dashboard/styles/base.css +69 -0
  80. package/templates/dashboard/styles/components.css +110 -0
  81. package/templates/dashboard/styles/view-live.css +74 -0
  82. package/templates/dashboard/styles/view-runs.css +207 -0
  83. package/templates/dashboard/styles/view-tests.css +96 -0
  84. package/templates/dashboard/styles/view-watch.css +53 -0
  85. package/templates/dashboard/template.html +267 -0
  86. package/templates/dashboard.html +2171 -530
  87. package/templates/docker-compose-neo4j.yml +19 -0
  88. package/templates/e2e.config.js +3 -0
  89. package/templates/sample-test.json +0 -8
@@ -0,0 +1,65 @@
1
+ ---
2
+ description: Create a new E2E test by exploring the UI and designing test actions
3
+ user_invocable: true
4
+ allowed_tools:
5
+ - mcp__e2e-runner__e2e_pool_status
6
+ - mcp__e2e-runner__e2e_capture
7
+ - mcp__e2e-runner__e2e_list
8
+ - mcp__e2e-runner__e2e_create_test
9
+ - mcp__e2e-runner__e2e_create_module
10
+ - mcp__e2e-runner__e2e_run
11
+ - mcp__e2e-runner__e2e_screenshot
12
+ - Read
13
+ - Grep
14
+ - Glob
15
+ ---
16
+
17
+ # Create E2E Test
18
+
19
+ Help the user create a new E2E test file by exploring the application and designing appropriate test actions.
20
+
21
+ ## Workflow
22
+
23
+ 1. **Understand the goal** — Ask the user what they want to test if not already specified. Identify the page(s), user flow, and expected outcomes.
24
+
25
+ 2. **Check pool** — Call `e2e_pool_status` to ensure the Chrome pool is available.
26
+
27
+ 3. **Explore the UI** — Use `e2e_capture` to screenshot the target page(s). This helps understand the current state of the UI, available elements, and layout.
28
+
29
+ 4. **Check existing tests** — Call `e2e_list` to see what test suites already exist. Read relevant existing test files with `Read` to follow conventions and avoid duplication.
30
+
31
+ 5. **Explore source code** (optional) — If needed, use `Grep` and `Read` to find selectors, form field IDs, API endpoints, or component structure in the application source code.
32
+
33
+ 6. **Design the test** — Based on UI exploration and source code analysis, design the test actions:
34
+ - Use the most specific selectors available (data-testid > id > class > text)
35
+ - Prefer granular assertion actions over `evaluate`
36
+ - Use framework-aware actions for React/MUI (`type_react`, `click_option`, `focus_autocomplete`)
37
+ - Add `wait` actions before assertions on dynamic content
38
+ - Add `assert_no_network_errors` after critical page loads
39
+ - Consider adding an `expect` field for visual verification
40
+ - **DRY**: If auth/setup is repeated across tests, use `beforeEach` hook (object format) instead of repeating per test
41
+ - **DRY**: If 3+ tests repeat the same action pattern, create a module with `e2e_create_module` first
42
+
43
+ 7. **Create the test** — Call `e2e_create_test` with the designed test structure.
44
+ - Check existing modules (`e2e/modules/`) — reuse them via `$use` instead of duplicating actions
45
+ - Create new modules with `e2e_create_module` for repeated sequences (auth, navigation, screenshot patterns)
46
+ - Use object format `{ "beforeEach": [...], "tests": [...] }` when hooks are needed
47
+
48
+ 8. **Validate** — Run the newly created test with `e2e_run` using the `suite` parameter. Analyze results and iterate if needed.
49
+
50
+ ## Naming Rules (CRITICAL)
51
+
52
+ Suite names MUST be unique and specific to the feature, issue, or user flow:
53
+ - GOOD: `login-valid-credentials`, `issue-1743-auth-redirect`, `checkout-payment-flow`
54
+ - BAD: `all`, `test`, `debug`, `new`, `temp`, `main`, `suite`
55
+
56
+ If testing a GitHub/GitLab issue, include the issue number: `issue-1743-auth-timeout`, `bug-502-duplicate-submit`
57
+
58
+ Before creating, always call `e2e_list` to verify the name doesn't already exist.
59
+
60
+ ## Arguments
61
+
62
+ The user may provide:
63
+ - A test name: `/e2e-runner:create-test login-flow`
64
+ - A description of what to test: `/e2e-runner:create-test test the checkout process`
65
+ - A URL to start from: `/e2e-runner:create-test http://localhost:3000/checkout`
@@ -0,0 +1,49 @@
1
+ ---
2
+ description: Run E2E tests and analyze results with screenshots and network drill-down
3
+ user_invocable: true
4
+ allowed_tools:
5
+ - mcp__e2e-runner__e2e_pool_status
6
+ - mcp__e2e-runner__e2e_list
7
+ - mcp__e2e-runner__e2e_run
8
+ - mcp__e2e-runner__e2e_screenshot
9
+ - mcp__e2e-runner__e2e_network_logs
10
+ - mcp__e2e-runner__e2e_learnings
11
+ ---
12
+
13
+ # Run E2E Tests
14
+
15
+ Execute E2E tests and provide a complete analysis of results.
16
+
17
+ ## Workflow
18
+
19
+ 1. **Check pool availability** — Call `e2e_pool_status` to confirm the Chrome pool is running. If not available, tell the user to run `npx e2e-runner pool start` via CLI.
20
+
21
+ 2. **List available suites** — Call `e2e_list` to show the user what test suites are available.
22
+
23
+ 3. **Run tests** — Call `e2e_run` based on user input:
24
+ - If user specified a suite name: use `suite` parameter
25
+ - If user specified a file: use `file` parameter
26
+ - If user said "all" or didn't specify: use `all: true`
27
+ - Always pass `cwd` with the current working directory
28
+ - Pass any user-specified overrides: `baseUrl`, `concurrency`, `retries`, `failOnNetworkError`
29
+
30
+ 4. **Analyze results** — Parse the run response:
31
+ - Report pass/fail summary and duration
32
+ - For failures: show error messages and retrieve error screenshots with `e2e_screenshot`
33
+ - For verifications (tests with `expect`): retrieve verification screenshots and judge against descriptions
34
+ - Highlight flaky tests if any
35
+ - Summarize network activity (failed requests, slow requests)
36
+
37
+ 5. **Drill down if needed** — For failed tests:
38
+ - Use `e2e_network_logs` with `runDbId` to investigate network failures
39
+ - Use `e2e_learnings` to check if this is a known pattern or new failure
40
+
41
+ 6. **Report** — Provide a clear summary to the user with actionable next steps.
42
+
43
+ ## Arguments
44
+
45
+ The user may pass arguments after the command:
46
+ - Suite name: `/e2e-runner:run auth` → run the auth suite
47
+ - `--all`: run all suites
48
+ - `--base-url <url>`: override base URL
49
+ - `--retries <n>`: set retry count
@@ -0,0 +1,63 @@
1
+ ---
2
+ description: Verify a GitHub/GitLab issue by creating and running E2E tests
3
+ user_invocable: true
4
+ allowed_tools:
5
+ - mcp__e2e-runner__e2e_pool_status
6
+ - mcp__e2e-runner__e2e_issue
7
+ - mcp__e2e-runner__e2e_create_test
8
+ - mcp__e2e-runner__e2e_run
9
+ - mcp__e2e-runner__e2e_screenshot
10
+ - mcp__e2e-runner__e2e_network_logs
11
+ - mcp__e2e-runner__e2e_capture
12
+ - Read
13
+ - Grep
14
+ ---
15
+
16
+ # Verify Issue
17
+
18
+ Turn a GitHub or GitLab bug report into executable E2E tests to confirm or dismiss the bug.
19
+
20
+ ## Workflow
21
+
22
+ 1. **Check pool** — Call `e2e_pool_status` to ensure the Chrome pool is available.
23
+
24
+ 2. **Fetch the issue** — Call `e2e_issue` with the issue URL. Default `mode: "prompt"` returns issue details + a structured prompt for test creation.
25
+
26
+ 3. **Analyze the issue** — Parse the issue details:
27
+ - Understand the reported bug or expected behavior
28
+ - Identify affected pages/flows
29
+ - Note any reproduction steps provided
30
+
31
+ 4. **Explore the app** — Use `e2e_capture` to screenshot relevant pages. Use `Read` and `Grep` to check source code for related components, API endpoints, or selectors.
32
+
33
+ 5. **Design tests** — Create tests that assert the **correct behavior**:
34
+ - If tests **fail** → bug is confirmed (correct behavior is not working)
35
+ - If tests **pass** → bug is not reproducible
36
+
37
+ 6. **Create and run** — Use `e2e_create_test` to write the test file, then `e2e_run` to execute it.
38
+
39
+ 7. **Analyze results** — For failures:
40
+ - Retrieve error screenshots with `e2e_screenshot`
41
+ - Check network logs with `e2e_network_logs` for API-related issues
42
+ - Determine if the failure confirms the bug
43
+
44
+ 8. **Report verdict** — Clearly state:
45
+ - **BUG CONFIRMED**: tests failed, reproducing the issue
46
+ - **NOT REPRODUCIBLE**: tests passed, correct behavior works as expected
47
+ - Include evidence (screenshots, error messages, network details)
48
+
49
+ ## Alternative: Verify Mode
50
+
51
+ If `ANTHROPIC_API_KEY` is set, use `e2e_issue` with `mode: "verify"` for a fully automated flow — it generates tests via Claude API, runs them, and reports the result.
52
+
53
+ ## Arguments
54
+
55
+ **Required**: GitHub or GitLab issue URL
56
+
57
+ ```
58
+ /e2e-runner:verify-issue https://github.com/org/repo/issues/123
59
+ ```
60
+
61
+ Optional flags:
62
+ - `--test-type api` — generate API tests instead of UI tests
63
+ - `--verify` — use verify mode (requires ANTHROPIC_API_KEY)
package/opencode.json ADDED
@@ -0,0 +1,11 @@
1
+ {
2
+ "$schema": "https://opencode.ai/schemas/opencode.json",
3
+ "mcp": {
4
+ "e2e-runner": {
5
+ "type": "local",
6
+ "command": "node",
7
+ "args": ["bin/mcp-server.js"],
8
+ "cwd": "${workspaceFolder}"
9
+ }
10
+ }
11
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@matware/e2e-runner",
3
- "version": "1.1.1",
3
+ "version": "1.3.0",
4
4
  "mcpName": "io.github.fastslack/e2e-runner",
5
5
  "description": "E2E test runner using Chrome Pool (browserless/chrome) with parallel execution",
6
6
  "type": "module",
@@ -15,7 +15,16 @@
15
15
  "files": [
16
16
  "bin/",
17
17
  "src/",
18
- "templates/"
18
+ "templates/",
19
+ ".claude-plugin/",
20
+ ".mcp.json",
21
+ "skills/",
22
+ "commands/",
23
+ "agents/",
24
+ ".opencode/",
25
+ "opencode.json",
26
+ "OPENCODE.md",
27
+ "scripts/setup-opencode.sh"
19
28
  ],
20
29
  "keywords": [
21
30
  "e2e",
@@ -26,6 +35,7 @@
26
35
  "parallel",
27
36
  "mcp",
28
37
  "claude-code",
38
+ "opencode",
29
39
  "github-issues",
30
40
  "ai-testing"
31
41
  ],
@@ -41,6 +51,9 @@
41
51
  "better-sqlite3": "^11.0.0",
42
52
  "puppeteer-core": "^24.0.0"
43
53
  },
54
+ "scripts": {
55
+ "build:dashboard": "node templates/build-dashboard.js"
56
+ },
44
57
  "engines": {
45
58
  "node": ">=20.0.0"
46
59
  }
@@ -0,0 +1,113 @@
1
+ #!/usr/bin/env bash
2
+ # Setup @matware/e2e-runner for OpenCode
3
+ # Usage: ./setup-opencode.sh [--global]
4
+
5
+ set -e
6
+
7
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
8
+ PACKAGE_DIR="$(dirname "$SCRIPT_DIR")"
9
+
10
+ # Colors
11
+ RED='\033[0;31m'
12
+ GREEN='\033[0;32m'
13
+ YELLOW='\033[1;33m'
14
+ NC='\033[0m' # No Color
15
+
16
+ log_info() { echo -e "${GREEN}✓${NC} $1"; }
17
+ log_warn() { echo -e "${YELLOW}!${NC} $1"; }
18
+ log_error() { echo -e "${RED}✗${NC} $1"; }
19
+
20
+ # Check if --global flag is passed
21
+ GLOBAL_INSTALL=false
22
+ if [[ "$1" == "--global" ]]; then
23
+ GLOBAL_INSTALL=true
24
+ fi
25
+
26
+ if [ "$GLOBAL_INSTALL" = true ]; then
27
+ echo "Setting up e2e-runner for OpenCode (global)..."
28
+
29
+ # Global config directory
30
+ OPENCODE_CONFIG="${HOME}/.config/opencode"
31
+
32
+ # Create directories
33
+ mkdir -p "${OPENCODE_CONFIG}/skills"
34
+ mkdir -p "${OPENCODE_CONFIG}/commands"
35
+
36
+ # Copy skills
37
+ if [ -d "${PACKAGE_DIR}/.opencode/skills" ]; then
38
+ cp -r "${PACKAGE_DIR}/.opencode/skills/"* "${OPENCODE_CONFIG}/skills/"
39
+ log_info "Installed skills to ${OPENCODE_CONFIG}/skills/"
40
+ fi
41
+
42
+ # Copy commands
43
+ if [ -d "${PACKAGE_DIR}/.opencode/commands" ]; then
44
+ cp -r "${PACKAGE_DIR}/.opencode/commands/"* "${OPENCODE_CONFIG}/commands/"
45
+ log_info "Installed commands to ${OPENCODE_CONFIG}/commands/"
46
+ fi
47
+
48
+ echo ""
49
+ log_warn "To use the MCP server, add this to your project's opencode.json:"
50
+ echo ""
51
+ cat << 'EOF'
52
+ {
53
+ "mcp": {
54
+ "e2e-runner": {
55
+ "type": "local",
56
+ "command": "e2e-runner-mcp"
57
+ }
58
+ }
59
+ }
60
+ EOF
61
+ echo ""
62
+
63
+ else
64
+ echo "Setting up e2e-runner for OpenCode (project-local)..."
65
+
66
+ # Check if we're in the package directory or a project that installed it
67
+ if [ -f "${PWD}/opencode.json" ] && [ -d "${PWD}/.opencode" ]; then
68
+ # We're in the package directory
69
+ log_info "Already in e2e-runner package directory"
70
+ exit 0
71
+ fi
72
+
73
+ # Look for node_modules/@matware/e2e-runner
74
+ if [ -d "${PWD}/node_modules/@matware/e2e-runner" ]; then
75
+ PACKAGE_DIR="${PWD}/node_modules/@matware/e2e-runner"
76
+ elif [ ! -f "${PACKAGE_DIR}/package.json" ]; then
77
+ log_error "Cannot find @matware/e2e-runner package"
78
+ log_error "Run: npm install @matware/e2e-runner"
79
+ exit 1
80
+ fi
81
+
82
+ # Copy opencode.json if it doesn't exist
83
+ if [ ! -f "${PWD}/opencode.json" ]; then
84
+ cp "${PACKAGE_DIR}/opencode.json" "${PWD}/opencode.json"
85
+ log_info "Created opencode.json"
86
+ else
87
+ log_warn "opencode.json already exists - merge manually if needed"
88
+ fi
89
+
90
+ # Copy .opencode directory
91
+ mkdir -p "${PWD}/.opencode"
92
+
93
+ if [ -d "${PACKAGE_DIR}/.opencode/skills" ]; then
94
+ mkdir -p "${PWD}/.opencode/skills"
95
+ cp -r "${PACKAGE_DIR}/.opencode/skills/"* "${PWD}/.opencode/skills/"
96
+ log_info "Installed skills to .opencode/skills/"
97
+ fi
98
+
99
+ if [ -d "${PACKAGE_DIR}/.opencode/commands" ]; then
100
+ mkdir -p "${PWD}/.opencode/commands"
101
+ cp -r "${PACKAGE_DIR}/.opencode/commands/"* "${PWD}/.opencode/commands/"
102
+ log_info "Installed commands to .opencode/commands/"
103
+ fi
104
+ fi
105
+
106
+ echo ""
107
+ log_info "OpenCode setup complete!"
108
+ echo ""
109
+ echo "Next steps:"
110
+ echo " 1. Start the Chrome pool: npx e2e-runner pool start"
111
+ echo " 2. Restart OpenCode to load the MCP server"
112
+ echo " 3. Ask: 'Run all E2E tests'"
113
+ echo ""
@@ -0,0 +1,173 @@
1
+ ---
2
+ name: e2e-testing
3
+ description: Create, run, and debug JSON-driven E2E browser tests with Chrome pool integration
4
+ ---
5
+
6
+ # E2E Testing with @matware/e2e-runner
7
+
8
+ ## Overview
9
+
10
+ `@matware/e2e-runner` is a JSON-driven E2E test runner. Tests are defined as JSON files with sequential browser actions — no JavaScript test code. Tests run in parallel against a Chrome pool (browserless/chrome via Docker) using Puppeteer.
11
+
12
+ **Key capabilities:** 13 MCP tools for running tests, creating test files, capturing screenshots, analyzing network traffic, verifying GitHub/GitLab issues, and querying a learning system for stability insights.
13
+
14
+ ## Prerequisites
15
+
16
+ Before running any tests, verify the Chrome pool is available:
17
+
18
+ ```
19
+ e2e_pool_status → check "Available: yes" and session capacity
20
+ ```
21
+
22
+ If the pool is not running, the user must start it via CLI (not available via MCP):
23
+ ```bash
24
+ npx e2e-runner pool start
25
+ ```
26
+
27
+ ## Core Workflow
28
+
29
+ The standard test execution flow:
30
+
31
+ 1. **Check pool** → `e2e_pool_status` — confirm Chrome pool is ready
32
+ 2. **List suites** → `e2e_list` — discover available test files and modules
33
+ 3. **Run tests** → `e2e_run` — execute with `all`, `suite`, or `file` parameter
34
+ 4. **Interpret results** — check `summary`, `failures`, `narratives`, `networkSummary`
35
+ 5. **View screenshots** → `e2e_screenshot` — retrieve error/verification screenshots by `ss:HASH`
36
+ 6. **Drill into network** → `e2e_network_logs` — use `runDbId` to inspect requests/responses
37
+ 7. **Check learnings** → `e2e_learnings` — query stability trends, flaky tests, error patterns
38
+
39
+ ### Interpreting Run Results
40
+
41
+ The `e2e_run` response includes:
42
+
43
+ - **summary**: pass/fail counts, duration, `runDbId` for drill-down
44
+ - **failures**: failed test names with error messages and error screenshot hashes
45
+ - **narratives**: step-by-step human-readable story of each test execution
46
+ - **networkSummary**: per-test request stats (status distribution, slow/failed requests)
47
+ - **verifications**: tests with `expect` field — call `e2e_screenshot` to visually verify
48
+ - **learnings**: stability insights from the learning system (new failures, flaky patterns)
49
+
50
+ ## Creating Tests
51
+
52
+ ### Basic Structure
53
+
54
+ ```json
55
+ [
56
+ {
57
+ "name": "login-flow",
58
+ "actions": [
59
+ { "type": "goto", "value": "/login" },
60
+ { "type": "type", "selector": "#email", "value": "user@example.com" },
61
+ { "type": "type", "selector": "#password", "value": "secret" },
62
+ { "type": "click", "text": "Sign In" },
63
+ { "type": "wait", "selector": ".dashboard" },
64
+ { "type": "assert_url", "value": "/dashboard" }
65
+ ]
66
+ }
67
+ ]
68
+ ```
69
+
70
+ Use `e2e_create_test` to write test files. Use `e2e_create_module` for reusable action sequences.
71
+
72
+ ### Key Action Patterns
73
+
74
+ - **Navigation**: `goto` (full page load), `navigate` (SPA-friendly, non-blocking)
75
+ - **Interaction**: `click` (selector or text), `type`/`fill`, `select`, `press`, `hover`, `scroll`
76
+ - **React/MUI**: `type_react` (controlled inputs), `click_option`, `focus_autocomplete`, `click_chip`, `click_regex`
77
+ - **Assertions**: `assert_text` (page-wide), `assert_element_text` (scoped), `assert_url`, `assert_visible`, `assert_not_visible`, `assert_count`, `assert_attribute`, `assert_class`, `assert_input_value`, `assert_matches`
78
+ - **Extraction**: `get_text` (non-assertion, returns element text), `screenshot`
79
+ - **Advanced**: `evaluate` (run JS in browser), `assert_no_network_errors`, `clear_cookies`
80
+
81
+ ### Visual Verification
82
+
83
+ Add an `expect` field to any test for AI-powered visual verification:
84
+
85
+ ```json
86
+ {
87
+ "name": "dashboard-loads",
88
+ "expect": "Should show data table with at least 3 rows and no error messages",
89
+ "actions": [...]
90
+ }
91
+ ```
92
+
93
+ After running, call `e2e_screenshot` with each verification hash and judge the screenshot against the description.
94
+
95
+ ### Reusable Modules
96
+
97
+ Create modules with `e2e_create_module`, reference them in tests:
98
+
99
+ ```json
100
+ { "$use": "auth-jwt", "params": { "email": "admin@test.com" } }
101
+ ```
102
+
103
+ For complete action type reference, see [action-types.md](references/action-types.md).
104
+ For JSON format details (hooks, serial, retries, modules), see [test-json-format.md](references/test-json-format.md).
105
+
106
+ ## Issue Verification
107
+
108
+ Turn GitHub/GitLab bug reports into executable tests:
109
+
110
+ ### Prompt Mode (default, no API key needed)
111
+
112
+ 1. `e2e_issue` with issue URL → returns structured prompt with issue details
113
+ 2. Analyze the issue and design test actions
114
+ 3. `e2e_create_test` → create the test file
115
+ 4. `e2e_run` → execute and verify
116
+
117
+ ### Verify Mode (requires ANTHROPIC_API_KEY)
118
+
119
+ 1. `e2e_issue` with `mode: "verify"` → auto-generates tests via Claude API, runs them, reports result
120
+ 2. Test failure = bug confirmed, all pass = not reproducible
121
+
122
+ Supports both UI tests (`testType: "e2e"`) and API tests (`testType: "api"`).
123
+
124
+ ## Debugging & Analysis
125
+
126
+ ### Network Inspection
127
+
128
+ ```
129
+ e2e_network_logs(runDbId) → all requests
130
+ e2e_network_logs(runDbId, errorsOnly: true) → failed requests only
131
+ e2e_network_logs(runDbId, includeBodies: true) → full request/response bodies
132
+ e2e_network_logs(runDbId, urlPattern: "/api/") → filter by URL pattern
133
+ ```
134
+
135
+ ### Learning System
136
+
137
+ ```
138
+ e2e_learnings("summary") → full project overview
139
+ e2e_learnings("flaky") → flaky test analysis
140
+ e2e_learnings("selectors") → selector stability
141
+ e2e_learnings("errors") → recurring error patterns
142
+ e2e_learnings("test:name") → drill into specific test history
143
+ ```
144
+
145
+ ### On-Demand Capture
146
+
147
+ Use `e2e_capture` to screenshot any URL without running a full test suite. Useful for visual exploration or verifying current state.
148
+
149
+ ### Dashboard
150
+
151
+ Start/stop the web dashboard with `e2e_dashboard_start` / `e2e_dashboard_stop` for a visual UI at `http://localhost:8484`.
152
+
153
+ ## Important Rules
154
+
155
+ 1. **Always pass `cwd`** — All MCP tools accept `cwd` (the project root). Always pass it so config files and test directories resolve correctly.
156
+ 2. **`baseUrl` default is `http://host.docker.internal:3000`** — Chrome runs inside Docker, so it uses `host.docker.internal` to reach the host machine. Override with `baseUrl` if the app runs on a different port.
157
+ 3. **Pool management is CLI-only** — `pool start` and `pool stop` are not available via MCP. Only `e2e_pool_status` is an MCP tool.
158
+ 4. **`evaluate` is strict** — Returns starting with `FAIL:`/`ERROR:` or returning `false` will fail the test. Prefer granular assertion actions over `evaluate` with inline JS.
159
+ 5. **Serial tests** — Mark tests with `"serial": true` if they share mutable state. They run after all parallel tests.
160
+ 6. **Action retries** — Use `"retries": N` on individual actions for flaky selectors, or globally via config.
161
+
162
+ ## References
163
+
164
+ - [Action Types Reference](references/action-types.md) — Complete catalog of 28+ action types with fields and examples
165
+ - [Test JSON Format](references/test-json-format.md) — JSON structure, hooks, serial, retries, modules, exclude patterns, environment profiles, CI output
166
+ - [GraphQL Action](references/graphql.md) — GQL action config, variables, inline assertions, __e2eGql helper
167
+ - [Authentication Strategies](references/auth-strategies.md) — 6 auth methods + auto-login + reusable auth modules
168
+ - [Network Debugging](references/network-debugging.md) — Error handling, request logging, drill-down pattern
169
+ - [Visual Verification](references/visual-verification.md) — Expect field, double screenshots, strictness levels, verdict format
170
+ - [Multi-Pool Support](references/multi-pool.md) — Config, selection algorithm, failover, pool-aware queue
171
+ - [Variables](references/variables.md) — SQLite-backed variables, syntax, MCP tool, dashboard UI, REST API
172
+ - [Issue Verification](references/issue-verification.md) — GitHub/GitLab, AI modes, test categories, GitLab limitations
173
+ - [Troubleshooting](references/troubleshooting.md) — Common problems, pre-validation, screenshot hashes, dashboard
@@ -0,0 +1,143 @@
1
+ # Action Types Reference
2
+
3
+ Complete catalog of all action types supported by @matware/e2e-runner.
4
+
5
+ ## Navigation
6
+
7
+ | Action | Fields | Description |
8
+ |--------|--------|-------------|
9
+ | `goto` | `value` (URL or path) | Full page navigation. Relative paths are prefixed with `baseUrl`. Waits for `domcontentloaded`. |
10
+ | `navigate` | `value` (URL or path) | SPA-friendly navigation. Uses `load` event with a 5s race timeout — won't block if client-side routing doesn't fire `load`. |
11
+
12
+ ## Interaction
13
+
14
+ | Action | Fields | Description |
15
+ |--------|--------|-------------|
16
+ | `click` | `selector` OR `text` | Click by CSS selector or by visible text content. Text search covers: `button, a, [role="button"], [role="tab"], [role="menuitem"], [role="option"], [role="listitem"], div[class*="cursor"], span, li, td, th, label, p, h1-h6, dd, dt`. |
17
+ | `type` / `fill` | `selector`, `value` | Triple-clicks to select all, then Backspace to clear, then types with 20ms delay per character. |
18
+ | `select` | `selector`, `value` | Select an `<option>` value in a `<select>` element. |
19
+ | `clear` | `selector` | Triple-click + Backspace to clear an input field. |
20
+ | `press` | `value` (key name) | Press a keyboard key (e.g. `"Enter"`, `"Tab"`, `"Escape"`, `"ArrowDown"`). |
21
+ | `scroll` | `selector` (optional), `value` (optional) | Scroll element into view, or scroll window by Y pixels (default 300). |
22
+ | `hover` | `selector` | Hover over an element. |
23
+
24
+ ## Framework-Aware (React/MUI)
25
+
26
+ | Action | Fields | Description |
27
+ |--------|--------|-------------|
28
+ | `type_react` | `selector`, `value` | Types into React controlled inputs using native value setter. Dispatches `input` + `change` events so React state updates. Supports `<input>` and `<textarea>`. |
29
+ | `click_regex` | `text` (regex), `selector` (optional), `value` (`"last"` optional) | Click element whose textContent matches regex (case-insensitive). Default: first match. `value: "last"` for last match. `selector` scopes the search. |
30
+ | `click_option` | `text` | Click a `[role="option"]` element by text — for autocomplete/select dropdowns. Waits for option to appear. |
31
+ | `focus_autocomplete` | `text` (label text) | Focus an autocomplete input by label. Supports MUI `.MuiAutocomplete-root` and `[role="combobox"]`. |
32
+ | `click_chip` | `text` | Click a chip/tag element by text. Searches `[class*="Chip"]`, `[class*="chip"]`, `[data-chip]`. |
33
+
34
+ ## Storage
35
+
36
+ | Action | Fields | Description |
37
+ |--------|--------|-------------|
38
+ | `set_storage` | `value` (`"key=val"`), `selector` (`"session"` optional) | Set a `localStorage` key (default) or `sessionStorage` key (with `selector: "session"`). |
39
+ | `assert_storage` | `value` (`"key"` or `"key=expected"`), `selector` (`"session"` optional) | Without `=`: checks key exists. With `=`: checks exact value match. Uses `localStorage` by default, `sessionStorage` with `selector: "session"`. |
40
+
41
+ ## Smart Interaction
42
+
43
+ | Action | Fields | Description |
44
+ |--------|--------|-------------|
45
+ | `click_icon` | `value` (icon identifier), `selector` (scope, optional) | Click an icon by `data-testid`, `data-icon`, `aria-label`, CSS class, or SVG title. Walks up to nearest clickable ancestor (`button`, `a`, `[role="button"]`). Works with MUI, FontAwesome, Heroicons, Bootstrap Icons, Lucide. |
46
+ | `click_menu_item` | `text` (menu item text), `selector` (scope, optional) | Click a menu item by text. Searches `[role="menuitem"]`, `[role="menuitemradio"]`, `[role="menuitemcheckbox"]`, `.dropdown-item`, `.menu-item`, `[class*="MenuItem"]`, `[role="menu"] > li`. Waits for element to appear. |
47
+ | `click_in_context` | `text` (container text), `selector` (child to click) | Find the smallest container whose text includes `text`, then click the `selector` child within it. Containers: `section`, `article`, `[class*="card"]`, `li`, `tr`, `div[class]`, etc. Both fields required. |
48
+
49
+ ## Assertions
50
+
51
+ | Action | Fields | Description |
52
+ |--------|--------|-------------|
53
+ | `assert_text` | `text` | Check entire page body contains text (substring match). |
54
+ | `assert_element_text` | `selector`, `text`, `value` (`"exact"` optional) | Check specific element's `textContent`. Default: substring match. With `value: "exact"`: strict `trim() ===` comparison. |
55
+ | `assert_url` | `value` | Check current URL. Path-only (`/dashboard`) compares pathname. Full URL does substring match. |
56
+ | `assert_visible` | `selector` | Element exists and is visible (`display`, `visibility`, `opacity` checks). |
57
+ | `assert_not_visible` | `selector` | Passes if element doesn't exist OR is hidden. |
58
+ | `assert_count` | `selector`, `value` | Count matching elements. Supports exact (`"5"`) and operators (`">3"`, `">=1"`, `"<10"`, `"<=5"`). |
59
+ | `assert_attribute` | `selector`, `value` (`"attr=expected"` or `"attr"`) | With `=`: checks attribute value. Without: checks attribute existence. |
60
+ | `assert_class` | `selector`, `value` | Checks `classList.contains(value)`. |
61
+ | `assert_input_value` | `selector`, `value` | Checks `element.value.includes(value)` on input/select/textarea. |
62
+ | `assert_matches` | `selector`, `value` (regex) | Tests element's `textContent` against `new RegExp(value)`. |
63
+ | `assert_no_network_errors` | — | Checks accumulated `requestfailed` events during the test. Fails with error details if any exist. |
64
+
65
+ ### Assertion Disambiguation
66
+
67
+ - **`assert_text`** → searches the **entire page body** (substring)
68
+ - **`assert_element_text`** → checks a **specific element** (substring, or exact with `value: "exact"`)
69
+ - **`assert_matches`** → checks a specific element against a **regex** pattern
70
+ - **`assert_input_value`** → reads the `.value` property (for form fields)
71
+
72
+ ## Extraction & Utility
73
+
74
+ | Action | Fields | Description |
75
+ |--------|--------|-------------|
76
+ | `get_text` | `selector` | Returns `{ value: textContent.trim() }`. Non-assertion — never fails. |
77
+ | `screenshot` | `value` (filename, optional) | Captures screenshot. Filename gets timestamp suffix for uniqueness. |
78
+ | `wait` | `selector` OR `text` OR `value` (ms) | Wait for selector, text on page, or fixed delay. |
79
+ | `wait_network_idle` | `value` (idle ms, default 500), `timeout` (max wait ms, default 30000) | Waits for all network requests to complete. Uses Puppeteer's `page.waitForNetworkIdle()`. Useful after SPA page transitions or data loading. |
80
+ | `evaluate` | `value` (JS code) | Run JavaScript in browser context. See **Strict Evaluate** below. |
81
+ | `clear_cookies` | `value` (origin, optional) | Clears cookies, localStorage, sessionStorage for origin. |
82
+
83
+ ### Strict Evaluate Semantics
84
+
85
+ The `evaluate` action checks the return value:
86
+
87
+ - If the JS returns a string starting with `FAIL:`, `ERROR:`, or `FAILED:` → the test **fails** with that message.
88
+ - If the JS returns `false` → the test **fails** (`evaluate returned false`).
89
+ - If the JS returns any other non-null value → stored as `{ value: result }` for visibility.
90
+ - If the JS throws → the test **fails** (standard Puppeteer error).
91
+
92
+ This prevents false PASSes where evaluate actions return error strings that were previously silently ignored.
93
+
94
+ ## Action-Level Retry
95
+
96
+ Any action can have `"retries": N` for per-action retry on failure:
97
+
98
+ ```json
99
+ { "type": "click", "selector": "#dynamic-btn", "retries": 3 }
100
+ { "type": "wait", "selector": ".lazy-loaded", "retries": 2 }
101
+ ```
102
+
103
+ Delay between retries: `actionRetryDelay` config (default 500ms).
104
+
105
+ ## Examples
106
+
107
+ ### React input + autocomplete flow
108
+ ```json
109
+ { "type": "focus_autocomplete", "text": "Category" },
110
+ { "type": "type_react", "selector": "#category-input", "value": "Electr" },
111
+ { "type": "click_option", "text": "Electronics" }
112
+ ```
113
+
114
+ ### Regex click (last match)
115
+ ```json
116
+ { "type": "click_regex", "text": "add to cart", "selector": "button", "value": "last" }
117
+ ```
118
+
119
+ ### Form validation assertions
120
+ ```json
121
+ { "type": "assert_attribute", "selector": "input#email", "value": "type=email" },
122
+ { "type": "assert_attribute", "selector": "button.submit", "value": "disabled" },
123
+ { "type": "assert_class", "selector": ".nav-item:first-child", "value": "active" },
124
+ { "type": "assert_input_value", "selector": "#email", "value": "user@example.com" },
125
+ { "type": "assert_matches", "selector": ".phone", "value": "\\d{3}-\\d{3}-\\d{4}" },
126
+ { "type": "assert_count", "selector": ".table-row", "value": ">3" }
127
+ ```
128
+
129
+ ### Storage operations
130
+ ```json
131
+ { "type": "set_storage", "value": "authToken=eyJhbGciOiJIUzI1NiJ9..." },
132
+ { "type": "assert_storage", "value": "authToken" },
133
+ { "type": "set_storage", "value": "theme=dark", "selector": "session" },
134
+ { "type": "assert_storage", "value": "theme=dark", "selector": "session" }
135
+ ```
136
+
137
+ ### Icon, menu, and contextual clicks
138
+ ```json
139
+ { "type": "click_icon", "value": "edit" },
140
+ { "type": "click_icon", "value": "delete", "selector": ".user-card" },
141
+ { "type": "click_menu_item", "text": "Export as PDF" },
142
+ { "type": "click_in_context", "text": "John Doe", "selector": "button.edit" }
143
+ ```