@ai-qa/workflow 2.0.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.
- package/.github/agents/playwright-test-generator.agent.md +33 -0
- package/.github/agents/playwright-test-healer.agent.md +36 -0
- package/.github/agents/playwright-test-planner.agent.md +44 -0
- package/.opencode/agents/qa-generator.md +19 -0
- package/.opencode/agents/qa-healer.md +25 -0
- package/.opencode/agents/qa-planner.md +20 -0
- package/.qa-workflow.json +22 -0
- package/README.md +365 -0
- package/ai-qa-workflow.js +330 -0
- package/cli.js +7 -0
- package/docs/application-context.md +20 -0
- package/install.js +303 -0
- package/opencode.json +31 -0
- package/package.json +30 -0
- package/prompts/QAe2eprompt.md +513 -0
- package/prompts/general_prompt.md +13 -0
- package/qa-dashboard/.env +3 -0
- package/qa-dashboard/app.js +46 -0
- package/qa-dashboard/package.json +18 -0
- package/qa-dashboard/public/css/style.css +266 -0
- package/qa-dashboard/public/js/main.js +6 -0
- package/qa-dashboard/routes/analytics.js +52 -0
- package/qa-dashboard/routes/export.js +153 -0
- package/qa-dashboard/routes/index.js +10 -0
- package/qa-dashboard/routes/projects.js +92 -0
- package/qa-dashboard/routes/runs.js +66 -0
- package/qa-dashboard/routes/stories.js +101 -0
- package/qa-dashboard/routes/test-data.js +82 -0
- package/qa-dashboard/services/cli-bridge.js +143 -0
- package/qa-dashboard/services/project-manager.js +61 -0
- package/qa-dashboard/views/analytics.ejs +188 -0
- package/qa-dashboard/views/error.ejs +8 -0
- package/qa-dashboard/views/index.ejs +83 -0
- package/qa-dashboard/views/layouts/main.ejs +28 -0
- package/qa-dashboard/views/project-add.ejs +23 -0
- package/qa-dashboard/views/project.ejs +97 -0
- package/qa-dashboard/views/projects.ejs +29 -0
- package/qa-dashboard/views/run.ejs +84 -0
- package/qa-dashboard/views/runs.ejs +64 -0
- package/qa-dashboard/views/stories.ejs +53 -0
- package/qa-dashboard/views/story.ejs +63 -0
- package/qa-dashboard/views/test-data.ejs +117 -0
- package/scripts/executor.js +142 -0
- package/scripts/generator.js +130 -0
- package/scripts/healer.js +207 -0
- package/scripts/planner.js +142 -0
- package/scripts/reporter.js +190 -0
- package/scripts/utils.js +244 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: playwright-test-generator
|
|
3
|
+
description: Use this agent when you need to create automated browser tests using Playwright
|
|
4
|
+
tools:
|
|
5
|
+
- search
|
|
6
|
+
- edit
|
|
7
|
+
- playwright/browser_click
|
|
8
|
+
- playwright/browser_navigate
|
|
9
|
+
- playwright/browser_type
|
|
10
|
+
- playwright/browser_snapshot
|
|
11
|
+
- playwright/generator_setup_page
|
|
12
|
+
- playwright/generator_read_log
|
|
13
|
+
- playwright/generator_write_test
|
|
14
|
+
mcp-servers:
|
|
15
|
+
playwright:
|
|
16
|
+
type: stdio
|
|
17
|
+
command: npx
|
|
18
|
+
args:
|
|
19
|
+
- -y
|
|
20
|
+
- @playwright/mcp
|
|
21
|
+
tools:
|
|
22
|
+
- "*"
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
You are a Playwright test generator. Create robust E2E tests from test plans.
|
|
26
|
+
|
|
27
|
+
For each test:
|
|
28
|
+
1. Read the test plan scenario
|
|
29
|
+
2. Use Playwright to manually execute steps in real-time
|
|
30
|
+
3. Capture selectors and locators from actual page interaction
|
|
31
|
+
4. Generate the test file using `generator_write_test`
|
|
32
|
+
|
|
33
|
+
Always prefer: data-testid > aria-label > role > text > xpath (last resort)
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: playwright-test-healer
|
|
3
|
+
description: Use this agent when you need to debug and fix failing Playwright tests
|
|
4
|
+
tools:
|
|
5
|
+
- search
|
|
6
|
+
- edit
|
|
7
|
+
- playwright/browser_console_messages
|
|
8
|
+
- playwright/browser_evaluate
|
|
9
|
+
- playwright/browser_generate_locator
|
|
10
|
+
- playwright/browser_network_requests
|
|
11
|
+
- playwright/browser_snapshot
|
|
12
|
+
- playwright/test_debug
|
|
13
|
+
- playwright/test_list
|
|
14
|
+
- playwright/test_run
|
|
15
|
+
mcp-servers:
|
|
16
|
+
playwright:
|
|
17
|
+
type: stdio
|
|
18
|
+
command: npx
|
|
19
|
+
args:
|
|
20
|
+
- -y
|
|
21
|
+
- @playwright/mcp
|
|
22
|
+
tools:
|
|
23
|
+
- "*"
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
You are the Playwright Test Healer. Debug and fix failing tests systematically.
|
|
27
|
+
|
|
28
|
+
Protocol (token-efficient):
|
|
29
|
+
1. Run only failing tests with `test_run`
|
|
30
|
+
2. Debug with `test_debug` — examine the error state
|
|
31
|
+
3. Classify the failure:
|
|
32
|
+
- Selector broken → edit 1-3 lines, re-run once
|
|
33
|
+
- Timing issue → add 1 wait, re-run once
|
|
34
|
+
- App bug → mark `test.fixme()`, log defect, move on
|
|
35
|
+
4. Max 1 fix attempt per test. If still failing, it's a defect.
|
|
36
|
+
5. Never rewrite entire files — targeted edits only.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: playwright-test-planner
|
|
3
|
+
description: Use this agent when you need to create comprehensive test plan for a web application or website
|
|
4
|
+
tools:
|
|
5
|
+
- search
|
|
6
|
+
- playwright/browser_click
|
|
7
|
+
- playwright/browser_close
|
|
8
|
+
- playwright/browser_console_messages
|
|
9
|
+
- playwright/browser_drag
|
|
10
|
+
- playwright/browser_evaluate
|
|
11
|
+
- playwright/browser_file_upload
|
|
12
|
+
- playwright/browser_handle_dialog
|
|
13
|
+
- playwright/browser_hover
|
|
14
|
+
- playwright/browser_navigate
|
|
15
|
+
- playwright/browser_navigate_back
|
|
16
|
+
- playwright/browser_network_requests
|
|
17
|
+
- playwright/browser_press_key
|
|
18
|
+
- playwright/browser_run_code
|
|
19
|
+
- playwright/browser_select_option
|
|
20
|
+
- playwright/browser_snapshot
|
|
21
|
+
- playwright/browser_take_screenshot
|
|
22
|
+
- playwright/browser_type
|
|
23
|
+
- playwright/browser_wait_for
|
|
24
|
+
- playwright/planner_setup_page
|
|
25
|
+
- playwright/planner_save_plan
|
|
26
|
+
mcp-servers:
|
|
27
|
+
playwright:
|
|
28
|
+
type: stdio
|
|
29
|
+
command: npx
|
|
30
|
+
args:
|
|
31
|
+
- -y
|
|
32
|
+
- @playwright/mcp
|
|
33
|
+
tools:
|
|
34
|
+
- "*"
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
You are an expert web test planner. You explore web apps and create detailed test plans.
|
|
38
|
+
|
|
39
|
+
1. Navigate and explore the application
|
|
40
|
+
2. Map user flows and identify critical paths
|
|
41
|
+
3. Design comprehensive scenarios (happy path, edge cases, error handling)
|
|
42
|
+
4. Save test plan using `planner_save_plan`
|
|
43
|
+
|
|
44
|
+
Each scenario must include: title, steps, expected outcomes, success criteria.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Use when generating Playwright test code from test plans. Opens browser via MCP, captures real selectors, writes .spec.ts files.
|
|
3
|
+
mode: subagent
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
You are a Playwright test generator. Create robust E2E tests from test plans.
|
|
7
|
+
|
|
8
|
+
Workflow:
|
|
9
|
+
1. Read the test plan from `specs/` directory
|
|
10
|
+
2. Run: `node ai-qa-workflow.js generate <plan-name>` to create the test skeleton
|
|
11
|
+
3. For each scenario, use Playwright MCP to manually execute steps in real-time
|
|
12
|
+
4. Capture selectors and locators from actual page interaction
|
|
13
|
+
5. Write the complete test in the generated `.spec.ts` file
|
|
14
|
+
6. Use proper Playwright patterns: `test.describe`, `test.beforeEach`, assertions
|
|
15
|
+
|
|
16
|
+
Always prefer: data-testid > aria-label > role > text > xpath (last resort)
|
|
17
|
+
Use `expect(page.locator('body')).toContainText('...')` for content checks (more stable).
|
|
18
|
+
Avoid hardcoded waits — use `waitForSelector`, `waitForURL`, `waitForLoadState`.
|
|
19
|
+
Token efficiency: body text assertions > complex selectors.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Use when Playwright tests are failing. Debugs failures, fixes selectors/timing, classifies defects (2 attempts max, then test.fixme()).
|
|
3
|
+
mode: subagent
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
You are the Playwright Test Healer. Debug and fix failing tests systematically.
|
|
7
|
+
|
|
8
|
+
Protocol (token-efficient):
|
|
9
|
+
1. Run: `node ai-qa-workflow.js heal <run-id>` for automated healing
|
|
10
|
+
2. If still failing, debug manually:
|
|
11
|
+
a. Examine the error message and stack trace
|
|
12
|
+
b. Use Playwright MCP to inspect the page state
|
|
13
|
+
c. Classify the failure:
|
|
14
|
+
- Selector broken → edit 1-3 lines in the test, re-run once
|
|
15
|
+
- Timing issue → add 1 wait/retry, re-run once
|
|
16
|
+
- App bug → mark `test.fixme()`, log defect in report, move on
|
|
17
|
+
- Environment issue → mark as defect, no retry
|
|
18
|
+
3. Max 1 fix attempt per test. If still failing after attempt, it's a defect.
|
|
19
|
+
4. Never rewrite entire files — targeted edits only.
|
|
20
|
+
5. After all fixes, run: `node ai-qa-workflow.js report <run-id>`
|
|
21
|
+
|
|
22
|
+
Healing rules:
|
|
23
|
+
- Attempt 1: standard re-run → if fails, classify
|
|
24
|
+
- Attempt 2: longer timeout (60s) → if fails, STOP
|
|
25
|
+
- STOP → `test.fixme()` + screenshot + defect classification
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Use when creating test plans from user stories. Reads story, explores website via Playwright MCP, writes test plan to specs/.
|
|
3
|
+
mode: subagent
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
You are an expert web test planner. You explore web apps and create detailed test plans from user stories.
|
|
7
|
+
|
|
8
|
+
Workflow:
|
|
9
|
+
1. Read the user story from `user-story/` directory
|
|
10
|
+
2. Use Playwright MCP to navigate and explore the application
|
|
11
|
+
3. Map user flows and identify critical paths
|
|
12
|
+
4. Design comprehensive scenarios (happy path, edge cases, error handling)
|
|
13
|
+
5. Run: `node ai-qa-workflow.js plan <story-name>` to generate the draft plan
|
|
14
|
+
6. Review and enhance the generated plan
|
|
15
|
+
7. Save final plan to `specs/` directory
|
|
16
|
+
|
|
17
|
+
Each scenario must include: title, steps, expected outcomes, success criteria.
|
|
18
|
+
Prioritize scenarios as P0 (critical), P1 (important), P2 (nice-to-have).
|
|
19
|
+
|
|
20
|
+
Always prefer: data-testid > aria-label > role > text > xpath (last resort)
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"project": {
|
|
3
|
+
"name": "ai-qa-workflow-template",
|
|
4
|
+
"description": "Reusable AI QA Workflow - User Story to Test Report pipeline",
|
|
5
|
+
"url": "http://localhost:4000",
|
|
6
|
+
"environment": ""
|
|
7
|
+
},
|
|
8
|
+
"browser": {
|
|
9
|
+
"type": "chromium",
|
|
10
|
+
"cdpPort": 9222,
|
|
11
|
+
"headed": false
|
|
12
|
+
},
|
|
13
|
+
"test": {
|
|
14
|
+
"timeout": 120000,
|
|
15
|
+
"retries": 0,
|
|
16
|
+
"workers": 1
|
|
17
|
+
},
|
|
18
|
+
"auth": {
|
|
19
|
+
"user": "",
|
|
20
|
+
"credentials": {}
|
|
21
|
+
}
|
|
22
|
+
}
|
package/README.md
ADDED
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
# AI QA Pipeline
|
|
2
|
+
|
|
3
|
+
**User Story → Test Plan → Test Generation → Execution → Self-Healing → Dashboard**
|
|
4
|
+
|
|
5
|
+
One-command install into any web project. Works standalone or with any AI assistant (opencode, GitHub Copilot, Claude Code).
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## One-Command Install
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npx @ai-qa/workflow init --yes
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
That's it. This single command installs the full pipeline into your current project:
|
|
16
|
+
|
|
17
|
+
- Copies pipeline scripts (planner, generator, executor, healer, reporter)
|
|
18
|
+
- Installs Playwright + dashboard dependencies
|
|
19
|
+
- Adds npm scripts (`qa:*` commands)
|
|
20
|
+
- Creates directories (`user-story/`, `specs/`, `tests/`, `test-results/`)
|
|
21
|
+
- Registers your project in the dashboard
|
|
22
|
+
|
|
23
|
+
### Update an existing installation
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npx @ai-qa/workflow update --yes
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Updates pipeline files while **preserving** your configuration (`.qa-workflow.json`, `opencode.json`), user stories, test specs, and run results.
|
|
30
|
+
|
|
31
|
+
### What you get
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
your-project/
|
|
35
|
+
├── ai-qa-workflow.js # CLI orchestrator (10 commands)
|
|
36
|
+
├── .qa-workflow.json # Project config (auto-detected, editable)
|
|
37
|
+
├── scripts/ # 6 automation modules
|
|
38
|
+
├── opencode.json # MCP config (Playwright + GitHub)
|
|
39
|
+
├── .github/agents/ # AI agent definitions
|
|
40
|
+
├── prompts/ # AI workflow instructions
|
|
41
|
+
├── qa-dashboard/ # Web UI (port 4000)
|
|
42
|
+
├── user-story/ # Your .md stories
|
|
43
|
+
├── specs/ # Generated test plans
|
|
44
|
+
├── tests/ # Generated Playwright specs
|
|
45
|
+
└── test-results/ # Run results, reports, screenshots
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Quick start after install
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
# 1. Initialize (auto-detects project config)
|
|
52
|
+
npm run qa:init
|
|
53
|
+
|
|
54
|
+
# 2. Write a user story in user-story/ or let the AI create one
|
|
55
|
+
|
|
56
|
+
# 3. Run full pipeline
|
|
57
|
+
npm run qa:run my-story.md
|
|
58
|
+
|
|
59
|
+
# 4. Start the dashboard
|
|
60
|
+
npm run dashboard
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## How It Works
|
|
66
|
+
|
|
67
|
+
The pipeline takes a **user story** (Markdown file) through 5 automated stages:
|
|
68
|
+
|
|
69
|
+
```
|
|
70
|
+
user-story.md → Test Plan → Test Spec (.spec.ts) → Execute → Heal → Report
|
|
71
|
+
│ │ │ │ │ │
|
|
72
|
+
planner.js generator.js executor.js healer.js reporter.js └→ docs/
|
|
73
|
+
│ │ │ │ │
|
|
74
|
+
(AI creates (AI generates (Playwright runs (2 auto-retry └→ dashboard
|
|
75
|
+
scenarios) Playwright tests, captures attempts, then
|
|
76
|
+
code with results) marks as defect)
|
|
77
|
+
real selectors)
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Each stage can run standalone (`npm run qa:plan`, `qa:generate`, `qa:execute`, `qa:heal`, `qa:report`) or all at once (`npm run qa:run`).
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
## Zero-Config Design
|
|
85
|
+
|
|
86
|
+
The template works out of the box by **auto-detecting** your project configuration.
|
|
87
|
+
|
|
88
|
+
On `npm run qa:init`, it scans your project and generates `.qa-workflow.json`:
|
|
89
|
+
|
|
90
|
+
| Scan source | What it detects |
|
|
91
|
+
|-------------|----------------|
|
|
92
|
+
| `package.json` | Project name, description, dev server port |
|
|
93
|
+
| `README.md` | Project name, URL, description |
|
|
94
|
+
| `docker-compose.yml` | Exposed port, project name |
|
|
95
|
+
| `.env` | `APP_URL`, `APP_ENV` / `NODE_ENV` |
|
|
96
|
+
| `playwright.config.*` | Browser type (edge, webkit) |
|
|
97
|
+
| Directory structure | Framework (Angular, Next.js, Python) |
|
|
98
|
+
|
|
99
|
+
If a file is missing, the template falls back to sensible defaults. No manual setup required.
|
|
100
|
+
|
|
101
|
+
### The Config File (`.qa-workflow.json`)
|
|
102
|
+
|
|
103
|
+
```json
|
|
104
|
+
{
|
|
105
|
+
"project": {
|
|
106
|
+
"name": "my-app",
|
|
107
|
+
"description": "My web application",
|
|
108
|
+
"url": "http://localhost:5173",
|
|
109
|
+
"environment": "Development"
|
|
110
|
+
},
|
|
111
|
+
"browser": {
|
|
112
|
+
"type": "chromium",
|
|
113
|
+
"cdpPort": 9222,
|
|
114
|
+
"headed": false
|
|
115
|
+
},
|
|
116
|
+
"test": {
|
|
117
|
+
"timeout": 120000,
|
|
118
|
+
"retries": 0,
|
|
119
|
+
"workers": 1
|
|
120
|
+
},
|
|
121
|
+
"auth": {
|
|
122
|
+
"user": "",
|
|
123
|
+
"credentials": {}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Edit this file to override auto-detected values. The template merges your settings with defaults — you only need to set what differs.
|
|
129
|
+
|
|
130
|
+
### Application Context (`docs/application-context.md`)
|
|
131
|
+
|
|
132
|
+
This file serves as a **knowledge base for AI agents** during test planning and healing. On `init` it's created from config values. As you use the pipeline, AI agents populate it with:
|
|
133
|
+
|
|
134
|
+
- **Stable selectors** — CSS/XPath selectors discovered during exploration
|
|
135
|
+
- **Known flaky areas** — elements or flows that frequently break
|
|
136
|
+
- **Auth details** — users, tokens, environments
|
|
137
|
+
- **Tech stack notes** — framework specifics the AI should know
|
|
138
|
+
|
|
139
|
+
For best results, edit this file with your project's specifics before running the pipeline.
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
143
|
+
## Installation
|
|
144
|
+
|
|
145
|
+
### Requirements
|
|
146
|
+
|
|
147
|
+
| Component | Needed for | Install |
|
|
148
|
+
|-----------|-----------|---------|
|
|
149
|
+
| **Node.js 18+** | Running the pipeline | — |
|
|
150
|
+
| **Playwright** | Test execution | `npm install @playwright/test` |
|
|
151
|
+
| **Chromium** | Running tests | `npx playwright install chromium` |
|
|
152
|
+
| **Playwright MCP** | AI browser automation (explore, click, type) | `npm install -D @playwright/mcp` |
|
|
153
|
+
| **GitHub MCP** | AI creating PRs/issues from results | `npm install -D @modelcontextprotocol/server-github` + `GITHUB_TOKEN` env |
|
|
154
|
+
|
|
155
|
+
### Install into a project
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
# From npm (recommended — works anywhere)
|
|
159
|
+
npx @ai-qa/workflow init --yes
|
|
160
|
+
|
|
161
|
+
# From local template
|
|
162
|
+
node install.js ../my-project --yes
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
The installer copies all pipeline files, creates directories, adds npm scripts, installs dashboard dependencies, and registers your project in the dashboard.
|
|
166
|
+
|
|
167
|
+
### Update an installed project
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
# From npm
|
|
171
|
+
npx @ai-qa/workflow update --yes
|
|
172
|
+
|
|
173
|
+
# From local template
|
|
174
|
+
node install.js ../my-project --update --yes
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
Updates pipeline files while preserving: `.qa-workflow.json`, `opencode.json`, `user-story/`, `specs/`, `tests/`, `test-results/`, `qa-dashboard/data/`, `qa-dashboard/node_modules/`.
|
|
178
|
+
|
|
179
|
+
### Commands added to your project
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
npm run qa:init # Initialize + auto-detect config
|
|
183
|
+
npm run qa:run <story> # Full pipeline: plan → generate → execute → heal → report
|
|
184
|
+
npm run qa:plan <story> # Generate test plan only
|
|
185
|
+
npm run qa:generate # Generate test code from plan
|
|
186
|
+
npm run qa:execute # Run Playwright tests
|
|
187
|
+
npm run qa:heal # Self-heal failed tests
|
|
188
|
+
npm run qa:report # Generate final report
|
|
189
|
+
npm run qa:status # Check pipeline state
|
|
190
|
+
npm run qa:list # List stories, plans, specs
|
|
191
|
+
npm run dashboard # Launch web dashboard at :4000
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
---
|
|
195
|
+
|
|
196
|
+
## How to Get the Most Out of It
|
|
197
|
+
|
|
198
|
+
### 1. Provide good context upfront
|
|
199
|
+
|
|
200
|
+
Before running the pipeline, populate `docs/application-context.md`:
|
|
201
|
+
|
|
202
|
+
```markdown
|
|
203
|
+
## Project
|
|
204
|
+
- Name: My App
|
|
205
|
+
- URL: https://staging.myapp.com
|
|
206
|
+
- Environment: Staging
|
|
207
|
+
|
|
208
|
+
## Authentication
|
|
209
|
+
- Login flow: email + password via /api/auth/login
|
|
210
|
+
- Test user: test@example.com / TestPass123
|
|
211
|
+
|
|
212
|
+
## Stable Selectors
|
|
213
|
+
- Login button: button[data-testid="login-btn"]
|
|
214
|
+
- Error toast: .toast-error
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
The AI reads this file during test planning and healing. The more accurate this is, the better the generated tests.
|
|
218
|
+
|
|
219
|
+
### 2. Write structured user stories
|
|
220
|
+
|
|
221
|
+
Your `user-story/*.md` files should follow this format:
|
|
222
|
+
|
|
223
|
+
```markdown
|
|
224
|
+
# User Login
|
|
225
|
+
|
|
226
|
+
**Story ID**: US-001
|
|
227
|
+
**Title**: User Login
|
|
228
|
+
**Feature**: Authentication
|
|
229
|
+
|
|
230
|
+
## Description
|
|
231
|
+
As a registered user, I want to log in with my credentials so I can access the dashboard.
|
|
232
|
+
|
|
233
|
+
## Preconditions
|
|
234
|
+
- User exists with email test@example.com
|
|
235
|
+
- Browser is on the login page
|
|
236
|
+
|
|
237
|
+
## Acceptance Criteria
|
|
238
|
+
1. Enter valid email and password
|
|
239
|
+
2. Click "Sign In"
|
|
240
|
+
3. Redirected to dashboard
|
|
241
|
+
4. User name displayed in header
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
Well-structured stories produce better test plans. The planner extracts acceptance criteria, preconditions, and feature name automatically.
|
|
245
|
+
|
|
246
|
+
### 3. Review generated test plans
|
|
247
|
+
|
|
248
|
+
After `npm run qa:plan`, check `specs/*-test-plan.md`. The AI generates scenarios from acceptance criteria. Review and edit before generating test code:
|
|
249
|
+
|
|
250
|
+
- Add edge cases the AI missed
|
|
251
|
+
- Add negative test scenarios
|
|
252
|
+
- Fix any incorrect assumptions about the app
|
|
253
|
+
|
|
254
|
+
### 4. Use the run mode that fits your workflow
|
|
255
|
+
|
|
256
|
+
| Mode | Command | Best for |
|
|
257
|
+
|------|---------|----------|
|
|
258
|
+
| **Full auto** | `npm run qa:run <story>` | Quick smoke tests, CI pipelines |
|
|
259
|
+
| **Step by step** | plan → generate → execute → heal → report | Reviewing each stage, manual edits |
|
|
260
|
+
| **Manual test only** | `npm run qa:execute <test>` | When tests are already written |
|
|
261
|
+
| **Heal only** | `npm run qa:heal [runId]` | After manual test edits |
|
|
262
|
+
|
|
263
|
+
### 5. Understand self-healing
|
|
264
|
+
|
|
265
|
+
The healer makes up to **2 attempts** per failed test:
|
|
266
|
+
|
|
267
|
+
1. **Standard re-run** — flakes due to timing or network
|
|
268
|
+
2. **Longer timeout (60s)** — slow responses
|
|
269
|
+
3. **Stop** — marks as defect, classifies the failure
|
|
270
|
+
|
|
271
|
+
Failure classification:
|
|
272
|
+
| Type | Label | Auto-healed? |
|
|
273
|
+
|------|-------|-------------|
|
|
274
|
+
| Selector not found | `selector` | ✅ Usually |
|
|
275
|
+
| Timeout | `timing` | ✅ Usually |
|
|
276
|
+
| Target closed | `environment` | ❌ Bug |
|
|
277
|
+
| Network error | `environment` | ❌ Bug |
|
|
278
|
+
| Test syntax error | `test-syntax` | ❌ Manual fix |
|
|
279
|
+
|
|
280
|
+
### 6. Check the dashboard
|
|
281
|
+
|
|
282
|
+
```bash
|
|
283
|
+
npm run dashboard
|
|
284
|
+
# → http://localhost:4000
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
The dashboard shows multi-project management, execution history with pass/fail/healed stats, analytics charts (pass rate, duration, healing vs defects), and test data generation tools.
|
|
288
|
+
|
|
289
|
+
---
|
|
290
|
+
|
|
291
|
+
## Self-Healing Rules
|
|
292
|
+
|
|
293
|
+
| Attempt | Strategy | If still fails |
|
|
294
|
+
|---------|----------|----------------|
|
|
295
|
+
| 1 | Standard re-run | Classify failure |
|
|
296
|
+
| 2 | Longer timeout (60s) | Mark as defect |
|
|
297
|
+
| STOP | — | `test.fixme()` + classify |
|
|
298
|
+
|
|
299
|
+
---
|
|
300
|
+
|
|
301
|
+
## Project Structure
|
|
302
|
+
|
|
303
|
+
```
|
|
304
|
+
your-project/
|
|
305
|
+
├── ai-qa-workflow.js # CLI orchestrator (9 commands)
|
|
306
|
+
├── .qa-workflow.json # Project config (auto-detected, editable)
|
|
307
|
+
├── scripts/
|
|
308
|
+
│ ├── utils.js # Config loading, auto-detection, shared helpers
|
|
309
|
+
│ ├── planner.js # user-story → test-plan template
|
|
310
|
+
│ ├── generator.js # test-plan → test spec skeleton
|
|
311
|
+
│ ├── executor.js # runs Playwright tests
|
|
312
|
+
│ ├── healer.js # 2 attempts max, classifies defects
|
|
313
|
+
│ └── reporter.js # markdown + JSON reports
|
|
314
|
+
├── opencode.json # MCP config (Playwright + GitHub)
|
|
315
|
+
├── .github/agents/ # AI agent definitions
|
|
316
|
+
├── prompts/ # AI workflow instructions
|
|
317
|
+
├── qa-dashboard/ # Web UI (port 4000)
|
|
318
|
+
├── user-story/ # Your .md stories
|
|
319
|
+
├── specs/ # Generated test plans
|
|
320
|
+
├── tests/ # Generated Playwright specs
|
|
321
|
+
├── test-results/ # Run results, reports, screenshots
|
|
322
|
+
└── docs/ # Application context (AI knowledge base)
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
---
|
|
326
|
+
|
|
327
|
+
## Allure Reports
|
|
328
|
+
|
|
329
|
+
The pipeline supports **Allure** for rich, interactive test reports.
|
|
330
|
+
|
|
331
|
+
### Setup
|
|
332
|
+
|
|
333
|
+
```bash
|
|
334
|
+
# 1. Install Allure dependencies
|
|
335
|
+
npm install -D allure-playwright
|
|
336
|
+
|
|
337
|
+
# 2. Add to Playwright config (playwright.config.ts or .js)
|
|
338
|
+
# reporter: [["list"], ["allure-playwright"]],
|
|
339
|
+
|
|
340
|
+
# 3. Run tests (generates allure-results/)
|
|
341
|
+
npm run qa:execute
|
|
342
|
+
|
|
343
|
+
# 4. Generate the HTML report
|
|
344
|
+
npm run qa:report:allure
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
### View in Dashboard
|
|
348
|
+
|
|
349
|
+
Once generated, the Allure report is available from the dashboard:
|
|
350
|
+
|
|
351
|
+
- **Runs list** → "Allure Report" button on each run
|
|
352
|
+
- **Run detail** → "Open Allure Report ↗" in the Report Actions card
|
|
353
|
+
- Direct URL: `/allure-report?project=<project-id>`
|
|
354
|
+
|
|
355
|
+
The dashboard auto-detects `allure-report/index.html` and shows the buttons only when the report exists.
|
|
356
|
+
|
|
357
|
+
---
|
|
358
|
+
|
|
359
|
+
## Token Efficiency (for AI)
|
|
360
|
+
|
|
361
|
+
1. Body text assertions over complex selectors
|
|
362
|
+
2. Screenshots off by default (only on failure)
|
|
363
|
+
3. Healer makes 1 fix attempt max per test
|
|
364
|
+
4. Real bugs classified immediately — no retries
|
|
365
|
+
5. AI edits 1-3 lines maximum per fix
|