@sun-asterisk/sungen 2.2.2 → 2.2.3
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/README.md +63 -34
- package/dist/cli/index.js +1 -1
- package/dist/generators/gherkin-parser/index.js +1 -1
- package/dist/generators/gherkin-parser/index.js.map +1 -1
- package/dist/generators/test-generator/adapters/playwright/templates/steps/actions/alert-accept-action.hbs +1 -0
- package/dist/generators/test-generator/adapters/playwright/templates/steps/actions/alert-dismiss-action.hbs +1 -0
- package/dist/generators/test-generator/adapters/playwright/templates/steps/actions/alert-fill-action.hbs +1 -0
- package/dist/generators/test-generator/adapters/playwright/templates/steps/assertions/alert-text-assertion.hbs +8 -0
- package/dist/generators/test-generator/adapters/playwright/templates/steps/assertions/have-value-assertion.hbs +1 -0
- package/dist/generators/test-generator/patterns/assertion-patterns.d.ts.map +1 -1
- package/dist/generators/test-generator/patterns/assertion-patterns.js +83 -57
- package/dist/generators/test-generator/patterns/assertion-patterns.js.map +1 -1
- package/dist/generators/test-generator/patterns/interaction-patterns.d.ts +1 -1
- package/dist/generators/test-generator/patterns/interaction-patterns.d.ts.map +1 -1
- package/dist/generators/test-generator/patterns/interaction-patterns.js +56 -1
- package/dist/generators/test-generator/patterns/interaction-patterns.js.map +1 -1
- package/dist/generators/test-generator/utils/selector-resolver.d.ts.map +1 -1
- package/dist/generators/test-generator/utils/selector-resolver.js +16 -0
- package/dist/generators/test-generator/utils/selector-resolver.js.map +1 -1
- package/dist/orchestrator/templates/ai-instructions/claude-cmd-make-test.md +11 -4
- package/dist/orchestrator/templates/ai-instructions/claude-skill-error-mapping.md +22 -9
- package/dist/orchestrator/templates/ai-instructions/claude-skill-gherkin-syntax.md +148 -21
- package/dist/orchestrator/templates/ai-instructions/claude-skill-selector-fix.md +51 -11
- package/dist/orchestrator/templates/ai-instructions/claude-skill-selector-keys.md +16 -2
- package/dist/orchestrator/templates/ai-instructions/copilot-cmd-make-test.md +11 -4
- package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-error-mapping.md +22 -9
- package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-gherkin-syntax.md +148 -21
- package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-selector-fix.md +51 -11
- package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-selector-keys.md +16 -2
- package/docs/gherkin standards/gherkin-core-standard.md +163 -160
- package/docs/gherkin standards/gherkin-core-standard.vi.md +290 -404
- package/docs/gherkin-dictionary.md +71 -16
- package/package.json +1 -1
- package/src/cli/index.ts +1 -1
- package/src/generators/gherkin-parser/index.ts +1 -1
- package/src/generators/test-generator/adapters/playwright/templates/steps/actions/alert-accept-action.hbs +1 -0
- package/src/generators/test-generator/adapters/playwright/templates/steps/actions/alert-dismiss-action.hbs +1 -0
- package/src/generators/test-generator/adapters/playwright/templates/steps/actions/alert-fill-action.hbs +1 -0
- package/src/generators/test-generator/adapters/playwright/templates/steps/assertions/alert-text-assertion.hbs +8 -0
- package/src/generators/test-generator/adapters/playwright/templates/steps/assertions/have-value-assertion.hbs +1 -0
- package/src/generators/test-generator/patterns/assertion-patterns.ts +93 -65
- package/src/generators/test-generator/patterns/interaction-patterns.ts +58 -1
- package/src/generators/test-generator/utils/selector-resolver.ts +16 -0
- package/src/orchestrator/templates/ai-instructions/claude-cmd-make-test.md +11 -4
- package/src/orchestrator/templates/ai-instructions/claude-skill-error-mapping.md +22 -9
- package/src/orchestrator/templates/ai-instructions/claude-skill-gherkin-syntax.md +148 -21
- package/src/orchestrator/templates/ai-instructions/claude-skill-selector-fix.md +51 -11
- package/src/orchestrator/templates/ai-instructions/claude-skill-selector-keys.md +16 -2
- package/src/orchestrator/templates/ai-instructions/copilot-cmd-make-test.md +11 -4
- package/src/orchestrator/templates/ai-instructions/github-skill-sungen-error-mapping.md +22 -9
- package/src/orchestrator/templates/ai-instructions/github-skill-sungen-gherkin-syntax.md +148 -21
- package/src/orchestrator/templates/ai-instructions/github-skill-sungen-selector-fix.md +51 -11
- package/src/orchestrator/templates/ai-instructions/github-skill-sungen-selector-keys.md +16 -2
|
@@ -168,9 +168,16 @@ Many elements don't need a YAML entry — sungen auto-infers from the Gherkin la
|
|
|
168
168
|
|---|---|
|
|
169
169
|
| `[Submit] button` | `getByRole('button', { name: 'Submit' })` |
|
|
170
170
|
| `[Home] link` | `getByRole('link', { name: 'Home' })` |
|
|
171
|
-
| `[Welcome] heading` | `getByRole('heading', { name: 'Welcome' })` |
|
|
171
|
+
| `[Welcome] heading` / `header` | `getByRole('heading', { name: 'Welcome' })` |
|
|
172
172
|
| `[Email] field` | `getByPlaceholder('Email')` |
|
|
173
|
-
| `[Success] text` | `getByText('Success')` |
|
|
173
|
+
| `[Success] text` / `message` / `label` | `getByText('Success')` |
|
|
174
|
+
| `[Terms] checkbox` | `getByRole('checkbox', { name: 'Terms' })` |
|
|
175
|
+
| `[Global] search` | `getByRole('searchbox', { name: 'Global' })` |
|
|
176
|
+
| `[Vietnam] option` | `getByRole('option', { name: 'Vietnam' })` |
|
|
177
|
+
| `[Price] slider` | `getByRole('slider', { name: 'Price' })` |
|
|
178
|
+
| `[Notification] toggle` | `getByRole('switch', { name: 'Notification' })` |
|
|
179
|
+
| `[Profile] tab` | `getByRole('tab', { name: 'Profile' })` |
|
|
180
|
+
| `[Confirm] dialog` / `modal` / `drawer` | `getByRole('dialog', { name: 'Confirm' })` |
|
|
174
181
|
|
|
175
182
|
**Only add a YAML entry when auto-infer won't work:**
|
|
176
183
|
- The accessible name differs from the Gherkin label
|
|
@@ -181,19 +188,52 @@ Many elements don't need a YAML entry — sungen auto-infers from the Gherkin la
|
|
|
181
188
|
|
|
182
189
|
---
|
|
183
190
|
|
|
184
|
-
### Fix Loop on Test Failure
|
|
191
|
+
### Fix Loop on Test Failure (Batched Strategy)
|
|
185
192
|
|
|
193
|
+
Running all tests every iteration is slow. Use a batched approach to fix faster:
|
|
194
|
+
|
|
195
|
+
```
|
|
196
|
+
1. INITIAL RUN — run ALL tests, collect full failure list
|
|
197
|
+
npx playwright test <spec> --reporter=line
|
|
198
|
+
|
|
199
|
+
2. BATCHED FIX LOOP (max 5 attempts):
|
|
200
|
+
a. Read test output → group failures by root cause:
|
|
201
|
+
- Same selector broken → 1 fix covers many tests
|
|
202
|
+
- Same error type (strict mode, timeout, text mismatch)
|
|
203
|
+
b. Fix selectors.yaml or test-data.yaml for current batch
|
|
204
|
+
c. Recompile: sungen generate --screen <screen>
|
|
205
|
+
d. Re-run ONLY previously-failing tests (max 20):
|
|
206
|
+
npx playwright test <spec> --grep "VP-UI-001|VP-UI-002|VP-VAL-001" --reporter=line
|
|
207
|
+
e. If batch passes → pick next batch of remaining failures
|
|
208
|
+
f. If batch still fails → fix and retry (counts toward max 5)
|
|
209
|
+
|
|
210
|
+
3. FINAL CONFIRMATION — run ALL tests once:
|
|
211
|
+
npx playwright test <spec> --reporter=line
|
|
212
|
+
This catches regressions from selector changes.
|
|
213
|
+
|
|
214
|
+
4. If still failing after 5 fix attempts → ask user about direct .spec.ts fix
|
|
186
215
|
```
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
if still failing → ask user about direct .spec.ts fix
|
|
216
|
+
|
|
217
|
+
#### Building the `--grep` pattern
|
|
218
|
+
|
|
219
|
+
Extract scenario names from the failure output and join with `|`:
|
|
220
|
+
```bash
|
|
221
|
+
# Example: re-run only 3 failing tests
|
|
222
|
+
npx playwright test <spec> --grep "VP-VAL-001|VP-VAL-002|VP-VAL-003" --reporter=line
|
|
195
223
|
```
|
|
196
224
|
|
|
225
|
+
- Max 20 test names per `--grep` to keep the pattern manageable
|
|
226
|
+
- If >20 failures share the same root cause, fix the cause and run the first 20 to verify
|
|
227
|
+
|
|
228
|
+
#### Grouping failures by root cause
|
|
229
|
+
|
|
230
|
+
Common patterns where 1 fix resolves many failures:
|
|
231
|
+
- **Same selector** — e.g., all `[Email Error]` tests fail → fix `email error` in selectors.yaml once
|
|
232
|
+
- **Same error type** — e.g., all `strict mode violation` → add `exact: true` or `nth`
|
|
233
|
+
- **Same assertion** — e.g., all `toHaveText` on inputs fail → change Gherkin pattern (inputs have no text)
|
|
234
|
+
|
|
235
|
+
Fix the root cause first, verify with the batch, then move on.
|
|
236
|
+
|
|
197
237
|
**Always read the error context snapshot first** — it shows the exact page state when the test failed, which is more reliable than re-navigating with MCP.
|
|
198
238
|
|
|
199
239
|
---
|
|
@@ -51,6 +51,10 @@ Type aliases (normalized automatically):
|
|
|
51
51
|
| logo, image, icon | `img` |
|
|
52
52
|
| btn | `button` |
|
|
53
53
|
| input, textbox, textarea, editor | `field` |
|
|
54
|
+
| search | `searchbox` |
|
|
55
|
+
| toggle | `switch` |
|
|
56
|
+
| alert | `alertdialog` |
|
|
57
|
+
| modal, drawer | `dialog` |
|
|
54
58
|
| column | `columnheader` |
|
|
55
59
|
| list-item | `listitem` |
|
|
56
60
|
|
|
@@ -83,10 +87,20 @@ If no YAML key exists, the resolver infers from the Gherkin element type:
|
|
|
83
87
|
|---|---|
|
|
84
88
|
| `[X] button` | `getByRole('button', { name: 'X' })` |
|
|
85
89
|
| `[X] link` | `getByRole('link', { name: 'X' })` |
|
|
86
|
-
| `[X] heading` | `getByRole('heading', { name: 'X' })` |
|
|
90
|
+
| `[X] heading` / `header` | `getByRole('heading', { name: 'X' })` |
|
|
87
91
|
| `[X] checkbox` | `getByRole('checkbox', { name: 'X' })` |
|
|
92
|
+
| `[X] radio` | `getByRole('radio', { name: 'X' })` |
|
|
88
93
|
| `[X] field` | `getByPlaceholder('X')` |
|
|
89
|
-
| `[X] text` | `getByText('X')` |
|
|
94
|
+
| `[X] text` / `message` / `label` | `getByText('X')` |
|
|
90
95
|
| `[X] logo/image/icon` | `getByRole('img', { name: 'X' })` |
|
|
96
|
+
| `[X] search` | `getByRole('searchbox', { name: 'X' })` |
|
|
97
|
+
| `[X] option` | `getByRole('option', { name: 'X' })` |
|
|
98
|
+
| `[X] slider` | `getByRole('slider', { name: 'X' })` |
|
|
99
|
+
| `[X] toggle` | `getByRole('switch', { name: 'X' })` |
|
|
100
|
+
| `[X] tab` | `getByRole('tab', { name: 'X' })` |
|
|
101
|
+
| `[X] table` | `getByRole('table', { name: 'X' })` |
|
|
102
|
+
| `[X] list` | `getByRole('list', { name: 'X' })` |
|
|
103
|
+
| `[X] column` | `getByRole('columnheader', { name: 'X' })` |
|
|
104
|
+
| `[X] dialog` / `modal` / `drawer` | `getByRole('dialog', { name: 'X' })` |
|
|
91
105
|
|
|
92
106
|
**Only add a YAML entry when** the auto-inferred locator won't work (wrong name, need testid, need nth, etc.).
|