@bugzy-ai/bugzy 1.19.0 → 1.19.2

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 (58) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +273 -273
  3. package/dist/cli/index.cjs +157 -13
  4. package/dist/cli/index.cjs.map +1 -1
  5. package/dist/cli/index.js +156 -12
  6. package/dist/cli/index.js.map +1 -1
  7. package/dist/index.cjs +153 -10
  8. package/dist/index.cjs.map +1 -1
  9. package/dist/index.js +153 -10
  10. package/dist/index.js.map +1 -1
  11. package/dist/subagents/index.cjs +150 -10
  12. package/dist/subagents/index.cjs.map +1 -1
  13. package/dist/subagents/index.js +150 -10
  14. package/dist/subagents/index.js.map +1 -1
  15. package/dist/subagents/metadata.cjs +8 -0
  16. package/dist/subagents/metadata.cjs.map +1 -1
  17. package/dist/subagents/metadata.js +8 -0
  18. package/dist/subagents/metadata.js.map +1 -1
  19. package/dist/tasks/index.cjs.map +1 -1
  20. package/dist/tasks/index.js.map +1 -1
  21. package/package.json +95 -95
  22. package/templates/init/.bugzy/runtime/hooks/pre-compact.sh +53 -53
  23. package/templates/init/.bugzy/runtime/hooks/session-start.sh +68 -68
  24. package/templates/init/.bugzy/runtime/knowledge-base.md +61 -61
  25. package/templates/init/.bugzy/runtime/knowledge-maintenance-guide.md +140 -140
  26. package/templates/init/.bugzy/runtime/project-context.md +35 -35
  27. package/templates/init/.bugzy/runtime/subagent-memory-guide.md +122 -122
  28. package/templates/init/.bugzy/runtime/templates/event-examples.md +194 -194
  29. package/templates/init/.bugzy/runtime/templates/test-plan-template.md +50 -50
  30. package/templates/init/.bugzy/runtime/templates/test-result-schema.md +498 -498
  31. package/templates/init/.claude/settings.json +49 -49
  32. package/templates/init/.env.testdata +18 -18
  33. package/templates/init/.gitignore-template +24 -24
  34. package/templates/init/AGENTS.md +155 -155
  35. package/templates/init/CLAUDE.md +157 -157
  36. package/templates/init/test-runs/README.md +45 -45
  37. package/templates/init/tests/CLAUDE.md +199 -199
  38. package/templates/init/tests/docs/test-execution-strategy.md +535 -535
  39. package/templates/init/tests/docs/testing-best-practices.md +724 -724
  40. package/templates/playwright/BasePage.template.ts +190 -190
  41. package/templates/playwright/auth.setup.template.ts +89 -89
  42. package/templates/playwright/dataGenerators.helper.template.ts +148 -148
  43. package/templates/playwright/dateUtils.helper.template.ts +96 -96
  44. package/templates/playwright/pages.fixture.template.ts +50 -50
  45. package/templates/playwright/playwright.config.template.ts +97 -97
  46. package/templates/playwright/reporters/__tests__/bugzy-reporter-failure-classification.test.ts +299 -299
  47. package/templates/playwright/reporters/__tests__/bugzy-reporter-manifest-merge.test.ts +329 -329
  48. package/templates/playwright/reporters/__tests__/playwright.config.ts +5 -5
  49. package/templates/playwright/reporters/bugzy-reporter.ts +784 -784
  50. package/dist/templates/init/.bugzy/runtime/knowledge-base.md +0 -61
  51. package/dist/templates/init/.bugzy/runtime/knowledge-maintenance-guide.md +0 -97
  52. package/dist/templates/init/.bugzy/runtime/project-context.md +0 -35
  53. package/dist/templates/init/.bugzy/runtime/subagent-memory-guide.md +0 -87
  54. package/dist/templates/init/.bugzy/runtime/templates/test-plan-template.md +0 -50
  55. package/dist/templates/init/.bugzy/runtime/templates/test-result-schema.md +0 -498
  56. package/dist/templates/init/.bugzy/runtime/test-execution-strategy.md +0 -535
  57. package/dist/templates/init/.bugzy/runtime/testing-best-practices.md +0 -632
  58. package/dist/templates/init/.gitignore-template +0 -25
@@ -1,199 +1,199 @@
1
- # Testing Framework
2
-
3
- ## Framework
4
- Playwright with TypeScript
5
-
6
- ## Environment
7
-
8
- Playwright and Chromium browser binaries are **pre-installed** in the execution environment. npm packages from `package.json` are also pre-installed in the project root.
9
-
10
- **DO NOT** run `npx playwright install` or `npm install` — all dependencies are already available.
11
-
12
- ## Test Execution
13
-
14
- Run commands from the project root directory.
15
-
16
- **Run all tests:**
17
- ```bash
18
- npm test
19
- ```
20
-
21
- **Run specific file:**
22
- ```bash
23
- npm test -- tests/specs/login.spec.ts
24
- ```
25
-
26
- **Run by file pattern:**
27
- ```bash
28
- npm test -- [selector]
29
- ```
30
-
31
- **Run by tag:**
32
- ```bash
33
- npm test -- --grep "@smoke"
34
- ```
35
-
36
- **Run single test file directly:**
37
- ```bash
38
- npx playwright test [test-file]
39
- ```
40
-
41
- **Configuration:** `playwright.config.ts` automatically loads environment variables from `.env.testdata` and `.env` files. No manual env export needed.
42
-
43
- **Custom Reporter:** The Bugzy reporter runs automatically via `playwright.config.ts` — do NOT use `--reporter` flag, as the custom reporter must run to create the hierarchical test-runs output.
44
-
45
- ## Directory Structure
46
-
47
- - **Test specs:** `./tests/specs/` — organized by feature in subdirectories
48
- - **Page Objects:** `./tests/pages/` — extend BasePage class
49
- - **Components:** `./tests/components/` — reusable UI element objects
50
- - **Fixtures:** `./tests/fixtures/` — common test setup (e.g., `pages.fixture.ts`)
51
- - **Helpers:** `./tests/helpers/` — data generation and utilities (e.g., `dateUtils.ts`, `dataGenerators.ts`)
52
- - **Types:** `./tests/types/` — TypeScript type definitions
53
- - **Setup:** `./tests/setup/` — auth setup and global config (e.g., `auth.setup.ts`)
54
- - **Test data:** `./tests/data/` — static test data files
55
- - **Auth state:** `./tests/.auth/` — stored authentication state
56
- - **Reporters:** `./reporters/` — custom Bugzy reporter (`bugzy-reporter.ts`)
57
- - **Test results:** `./test-runs/` — hierarchical results: `{timestamp}/{testCaseId}/exec-{N}/`
58
-
59
- ## Conventions
60
-
61
- ### Test Structure
62
- - Every test uses `test.step()` calls matching the manual test case steps one-to-one
63
- - Each `test.step()` should directly correspond to a numbered step in the manual test case
64
- - Reference manual test case ID in comments
65
- - Tag critical tests with `@smoke`
66
- - Tests must be independent — no test interdependencies
67
-
68
- ### Page Object Model
69
- - Page Objects extend `BasePage` class
70
- - **No assertions in Page Objects** — only actions and getters
71
- - Page Objects contain semantic selectors verified in the live application
72
- - Properly typed with TypeScript
73
-
74
- ### Selector Priority
75
- Use selectors in this priority order:
76
- 1. `getByRole('button', { name: 'Sign In' })` — role-based (preferred)
77
- 2. `getByLabel('Email')` — label-based
78
- 3. `getByText('Welcome')` — text content
79
- 4. `[data-testid="submit"]` — test IDs
80
- 5. CSS selectors — **last resort only**
81
-
82
- **NEVER assume selectors** — always verify in the live application using browser automation before writing tests.
83
-
84
- ### Waiting and Synchronization
85
- - **Never use `waitForTimeout()`** — rely on Playwright's auto-waiting
86
- - Use `toBeVisible()`, `toHaveCount()`, `toHaveText()` assertions for waits
87
- - Prefer `waitFor({ state: 'visible' })` over arbitrary delays
88
- - Use `page.waitForLoadState('networkidle')` after navigation
89
- - Handle dynamic content with explicit waits for specific conditions
90
-
91
- ### Environment Variables
92
- - Reference variables using `process.env.VAR_NAME` in tests
93
- - Read `.env.testdata` for available non-secret environment variables
94
- - **NEVER read `.env` file** (contains secrets only)
95
- - Add new required variables to `.env.testdata` with `# TODO: configure` comment
96
-
97
- ## Common Fix Patterns
98
-
99
- ### Fix Type 1: Brittle Selectors
100
- - **Problem**: CSS selectors or fragile XPath that breaks when UI changes
101
- - **Fix**: Replace with role-based selectors
102
- ```typescript
103
- // BEFORE (brittle)
104
- await page.locator('.btn-primary').click();
105
- // AFTER (semantic)
106
- await page.getByRole('button', { name: 'Sign In' }).click();
107
- ```
108
-
109
- ### Fix Type 2: Missing Wait Conditions
110
- - **Problem**: Test doesn't wait for elements or actions to complete
111
- - **Fix**: Add explicit wait for expected state
112
- ```typescript
113
- // BEFORE (race condition)
114
- await page.goto('/dashboard');
115
- const items = await page.locator('.item').count();
116
- // AFTER (explicit wait)
117
- await page.goto('/dashboard');
118
- await expect(page.locator('.item')).toHaveCount(5);
119
- ```
120
-
121
- ### Fix Type 3: Race Conditions
122
- - **Problem**: Test executes actions before application is ready
123
- - **Fix**: Wait for specific application state
124
- ```typescript
125
- // BEFORE
126
- await saveButton.click();
127
- await expect(successMessage).toBeVisible();
128
- // AFTER
129
- await page.locator('.validation-complete').waitFor();
130
- await saveButton.click();
131
- await expect(successMessage).toBeVisible();
132
- ```
133
-
134
- ### Fix Type 4: Wrong Assertions
135
- - **Problem**: Assertion expects incorrect value or state
136
- - **Fix**: Update assertion to match actual application behavior (if application is correct)
137
-
138
- ### Fix Type 5: Test Isolation Issues
139
- - **Problem**: Test depends on state from previous tests
140
- - **Fix**: Add proper setup/teardown or use fixtures
141
-
142
- ### Fix Type 6: Flaky Tests
143
- - **Problem**: Test passes inconsistently
144
- - **Fix**: Identify non-determinism source (timing, race conditions, animation delays)
145
- - Run test 10 times to confirm stability after fix
146
-
147
- ## Failure Triage Guide
148
-
149
- **Classification Decision Matrix:**
150
-
151
- | Failure Type | Root Cause | Action |
152
- |--------------|------------|--------|
153
- | Selector not found | Element exists, wrong selector | Replace with semantic selector |
154
- | Timeout waiting | Missing wait condition | Add explicit wait |
155
- | Flaky (timing) | Race condition | Add synchronization wait |
156
- | Wrong assertion | Incorrect expected value | Update assertion (if app is correct) |
157
- | Test isolation | Depends on other tests | Add setup/teardown or fixtures |
158
- | Product bug | App behaves incorrectly | STOP — report as bug, don't fix test |
159
-
160
- **Product Bug Indicators:**
161
- - Selectors are correct and elements exist
162
- - Test logic matches intended user flow
163
- - Application behavior doesn't match requirements
164
- - Error indicates functional problem (API error, validation failure)
165
- - Screenshots show application in wrong state
166
-
167
- **Test Issue Indicators:**
168
- - Selector not found (element exists but selector is wrong)
169
- - Timeout errors (missing wait conditions)
170
- - Flaky behavior (passes sometimes, fails other times)
171
- - Wrong assertions (expecting incorrect values)
172
- - Test isolation problems (depends on other tests)
173
-
174
- ## Test Result Artifacts
175
-
176
- Test results follow the hierarchical structure created by the Bugzy reporter:
177
-
178
- - **Manifest**: `test-runs/{timestamp}/manifest.json` — overall run summary
179
- - **Per-execution results**: `test-runs/{timestamp}/{testCaseId}/exec-{num}/result.json`
180
- - **Attachments**: Video, trace, and screenshots in the same `exec-{num}/` folder
181
- - **Execution ID**: `test-runs/{timestamp}/execution-id.txt` (from BUGZY_EXECUTION_ID)
182
-
183
- Video recording is automatic via playwright-cli `--save-video` flag. Videos are saved to `.playwright-mcp/` and uploaded to GCS by external service. Do NOT copy, move, or delete video files.
184
-
185
- ## Reference Guides
186
-
187
- Detailed testing guides are available in `./docs/`:
188
- - `testing-best-practices.md` — Test organization, Page Object Model, selector strategies, authentication, debugging, and production-ready checklist
189
- - `test-execution-strategy.md` — Test tier selection (Smoke, Component, Full Regression), tag taxonomy, and decision tree for choosing which tests to run
190
-
191
- ## Anti-Patterns
192
-
193
- - **DO NOT** use `waitForTimeout()` — masks real timing issues
194
- - **DO NOT** put assertions in Page Objects — only in test files
195
- - **DO NOT** hardcode test data — use environment variables
196
- - **DO NOT** create test interdependencies — tests must be independent
197
- - **DO NOT** assume selectors without verifying in the live application
198
- - **DO NOT** make tests pass by lowering expectations
199
- - **DO NOT** skip proper verification of fixes
1
+ # Testing Framework
2
+
3
+ ## Framework
4
+ Playwright with TypeScript
5
+
6
+ ## Environment
7
+
8
+ Playwright and Chromium browser binaries are **pre-installed** in the execution environment. npm packages from `package.json` are also pre-installed in the project root.
9
+
10
+ **DO NOT** run `npx playwright install` or `npm install` — all dependencies are already available.
11
+
12
+ ## Test Execution
13
+
14
+ Run commands from the project root directory.
15
+
16
+ **Run all tests:**
17
+ ```bash
18
+ npm test
19
+ ```
20
+
21
+ **Run specific file:**
22
+ ```bash
23
+ npm test -- tests/specs/login.spec.ts
24
+ ```
25
+
26
+ **Run by file pattern:**
27
+ ```bash
28
+ npm test -- [selector]
29
+ ```
30
+
31
+ **Run by tag:**
32
+ ```bash
33
+ npm test -- --grep "@smoke"
34
+ ```
35
+
36
+ **Run single test file directly:**
37
+ ```bash
38
+ npx playwright test [test-file]
39
+ ```
40
+
41
+ **Configuration:** `playwright.config.ts` automatically loads environment variables from `.env.testdata` and `.env` files. No manual env export needed.
42
+
43
+ **Custom Reporter:** The Bugzy reporter runs automatically via `playwright.config.ts` — do NOT use `--reporter` flag, as the custom reporter must run to create the hierarchical test-runs output.
44
+
45
+ ## Directory Structure
46
+
47
+ - **Test specs:** `./tests/specs/` — organized by feature in subdirectories
48
+ - **Page Objects:** `./tests/pages/` — extend BasePage class
49
+ - **Components:** `./tests/components/` — reusable UI element objects
50
+ - **Fixtures:** `./tests/fixtures/` — common test setup (e.g., `pages.fixture.ts`)
51
+ - **Helpers:** `./tests/helpers/` — data generation and utilities (e.g., `dateUtils.ts`, `dataGenerators.ts`)
52
+ - **Types:** `./tests/types/` — TypeScript type definitions
53
+ - **Setup:** `./tests/setup/` — auth setup and global config (e.g., `auth.setup.ts`)
54
+ - **Test data:** `./tests/data/` — static test data files
55
+ - **Auth state:** `./tests/.auth/` — stored authentication state
56
+ - **Reporters:** `./reporters/` — custom Bugzy reporter (`bugzy-reporter.ts`)
57
+ - **Test results:** `./test-runs/` — hierarchical results: `{timestamp}/{testCaseId}/exec-{N}/`
58
+
59
+ ## Conventions
60
+
61
+ ### Test Structure
62
+ - Every test uses `test.step()` calls matching the manual test case steps one-to-one
63
+ - Each `test.step()` should directly correspond to a numbered step in the manual test case
64
+ - Reference manual test case ID in comments
65
+ - Tag critical tests with `@smoke`
66
+ - Tests must be independent — no test interdependencies
67
+
68
+ ### Page Object Model
69
+ - Page Objects extend `BasePage` class
70
+ - **No assertions in Page Objects** — only actions and getters
71
+ - Page Objects contain semantic selectors verified in the live application
72
+ - Properly typed with TypeScript
73
+
74
+ ### Selector Priority
75
+ Use selectors in this priority order:
76
+ 1. `getByRole('button', { name: 'Sign In' })` — role-based (preferred)
77
+ 2. `getByLabel('Email')` — label-based
78
+ 3. `getByText('Welcome')` — text content
79
+ 4. `[data-testid="submit"]` — test IDs
80
+ 5. CSS selectors — **last resort only**
81
+
82
+ **NEVER assume selectors** — always verify in the live application using browser automation before writing tests.
83
+
84
+ ### Waiting and Synchronization
85
+ - **Never use `waitForTimeout()`** — rely on Playwright's auto-waiting
86
+ - Use `toBeVisible()`, `toHaveCount()`, `toHaveText()` assertions for waits
87
+ - Prefer `waitFor({ state: 'visible' })` over arbitrary delays
88
+ - Use `page.waitForLoadState('networkidle')` after navigation
89
+ - Handle dynamic content with explicit waits for specific conditions
90
+
91
+ ### Environment Variables
92
+ - Reference variables using `process.env.VAR_NAME` in tests
93
+ - Read `.env.testdata` for available non-secret environment variables
94
+ - **NEVER read `.env` file** (contains secrets only)
95
+ - Add new required variables to `.env.testdata` with `# TODO: configure` comment
96
+
97
+ ## Common Fix Patterns
98
+
99
+ ### Fix Type 1: Brittle Selectors
100
+ - **Problem**: CSS selectors or fragile XPath that breaks when UI changes
101
+ - **Fix**: Replace with role-based selectors
102
+ ```typescript
103
+ // BEFORE (brittle)
104
+ await page.locator('.btn-primary').click();
105
+ // AFTER (semantic)
106
+ await page.getByRole('button', { name: 'Sign In' }).click();
107
+ ```
108
+
109
+ ### Fix Type 2: Missing Wait Conditions
110
+ - **Problem**: Test doesn't wait for elements or actions to complete
111
+ - **Fix**: Add explicit wait for expected state
112
+ ```typescript
113
+ // BEFORE (race condition)
114
+ await page.goto('/dashboard');
115
+ const items = await page.locator('.item').count();
116
+ // AFTER (explicit wait)
117
+ await page.goto('/dashboard');
118
+ await expect(page.locator('.item')).toHaveCount(5);
119
+ ```
120
+
121
+ ### Fix Type 3: Race Conditions
122
+ - **Problem**: Test executes actions before application is ready
123
+ - **Fix**: Wait for specific application state
124
+ ```typescript
125
+ // BEFORE
126
+ await saveButton.click();
127
+ await expect(successMessage).toBeVisible();
128
+ // AFTER
129
+ await page.locator('.validation-complete').waitFor();
130
+ await saveButton.click();
131
+ await expect(successMessage).toBeVisible();
132
+ ```
133
+
134
+ ### Fix Type 4: Wrong Assertions
135
+ - **Problem**: Assertion expects incorrect value or state
136
+ - **Fix**: Update assertion to match actual application behavior (if application is correct)
137
+
138
+ ### Fix Type 5: Test Isolation Issues
139
+ - **Problem**: Test depends on state from previous tests
140
+ - **Fix**: Add proper setup/teardown or use fixtures
141
+
142
+ ### Fix Type 6: Flaky Tests
143
+ - **Problem**: Test passes inconsistently
144
+ - **Fix**: Identify non-determinism source (timing, race conditions, animation delays)
145
+ - Run test 10 times to confirm stability after fix
146
+
147
+ ## Failure Triage Guide
148
+
149
+ **Classification Decision Matrix:**
150
+
151
+ | Failure Type | Root Cause | Action |
152
+ |--------------|------------|--------|
153
+ | Selector not found | Element exists, wrong selector | Replace with semantic selector |
154
+ | Timeout waiting | Missing wait condition | Add explicit wait |
155
+ | Flaky (timing) | Race condition | Add synchronization wait |
156
+ | Wrong assertion | Incorrect expected value | Update assertion (if app is correct) |
157
+ | Test isolation | Depends on other tests | Add setup/teardown or fixtures |
158
+ | Product bug | App behaves incorrectly | STOP — report as bug, don't fix test |
159
+
160
+ **Product Bug Indicators:**
161
+ - Selectors are correct and elements exist
162
+ - Test logic matches intended user flow
163
+ - Application behavior doesn't match requirements
164
+ - Error indicates functional problem (API error, validation failure)
165
+ - Screenshots show application in wrong state
166
+
167
+ **Test Issue Indicators:**
168
+ - Selector not found (element exists but selector is wrong)
169
+ - Timeout errors (missing wait conditions)
170
+ - Flaky behavior (passes sometimes, fails other times)
171
+ - Wrong assertions (expecting incorrect values)
172
+ - Test isolation problems (depends on other tests)
173
+
174
+ ## Test Result Artifacts
175
+
176
+ Test results follow the hierarchical structure created by the Bugzy reporter:
177
+
178
+ - **Manifest**: `test-runs/{timestamp}/manifest.json` — overall run summary
179
+ - **Per-execution results**: `test-runs/{timestamp}/{testCaseId}/exec-{num}/result.json`
180
+ - **Attachments**: Video, trace, and screenshots in the same `exec-{num}/` folder
181
+ - **Execution ID**: `test-runs/{timestamp}/execution-id.txt` (from BUGZY_EXECUTION_ID)
182
+
183
+ Video recording is automatic via playwright-cli `--save-video` flag. Videos are saved to `.playwright-mcp/` and uploaded to GCS by external service. Do NOT copy, move, or delete video files.
184
+
185
+ ## Reference Guides
186
+
187
+ Detailed testing guides are available in `./docs/`:
188
+ - `testing-best-practices.md` — Test organization, Page Object Model, selector strategies, authentication, debugging, and production-ready checklist
189
+ - `test-execution-strategy.md` — Test tier selection (Smoke, Component, Full Regression), tag taxonomy, and decision tree for choosing which tests to run
190
+
191
+ ## Anti-Patterns
192
+
193
+ - **DO NOT** use `waitForTimeout()` — masks real timing issues
194
+ - **DO NOT** put assertions in Page Objects — only in test files
195
+ - **DO NOT** hardcode test data — use environment variables
196
+ - **DO NOT** create test interdependencies — tests must be independent
197
+ - **DO NOT** assume selectors without verifying in the live application
198
+ - **DO NOT** make tests pass by lowering expectations
199
+ - **DO NOT** skip proper verification of fixes