@sun-asterisk/sungen 2.3.1 → 2.4.1
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 +10 -11
- package/dist/cli/index.js +1 -1
- package/dist/generators/gherkin-parser/index.d.ts +8 -0
- package/dist/generators/gherkin-parser/index.d.ts.map +1 -1
- package/dist/generators/gherkin-parser/index.js +12 -0
- package/dist/generators/gherkin-parser/index.js.map +1 -1
- package/dist/generators/test-generator/adapters/playwright/templates/steps/actions/table-action-in-row.hbs +1 -1
- package/dist/generators/test-generator/adapters/playwright/templates/steps/assertions/table-column-exists.hbs +5 -1
- package/dist/generators/test-generator/adapters/playwright/templates/steps/assertions/table-match-data.hbs +15 -0
- package/dist/generators/test-generator/adapters/playwright/templates/steps/assertions/table-row-exists.hbs +7 -1
- package/dist/generators/test-generator/adapters/playwright/templates/steps/assertions/table-row-not-exists.hbs +5 -1
- package/dist/generators/test-generator/patterns/index.d.ts.map +1 -1
- package/dist/generators/test-generator/patterns/index.js +2 -1
- package/dist/generators/test-generator/patterns/index.js.map +1 -1
- package/dist/generators/test-generator/patterns/table-patterns.d.ts +12 -0
- package/dist/generators/test-generator/patterns/table-patterns.d.ts.map +1 -1
- package/dist/generators/test-generator/patterns/table-patterns.js +142 -98
- package/dist/generators/test-generator/patterns/table-patterns.js.map +1 -1
- package/dist/generators/test-generator/patterns/types.d.ts +2 -0
- package/dist/generators/test-generator/patterns/types.d.ts.map +1 -1
- package/dist/generators/test-generator/step-mapper.d.ts +13 -0
- package/dist/generators/test-generator/step-mapper.d.ts.map +1 -1
- package/dist/generators/test-generator/step-mapper.js +80 -0
- package/dist/generators/test-generator/step-mapper.js.map +1 -1
- package/dist/orchestrator/ai-rules-updater.d.ts.map +1 -1
- package/dist/orchestrator/ai-rules-updater.js +8 -6
- package/dist/orchestrator/ai-rules-updater.js.map +1 -1
- package/dist/orchestrator/project-initializer.d.ts.map +1 -1
- package/dist/orchestrator/project-initializer.js +33 -2
- package/dist/orchestrator/project-initializer.js.map +1 -1
- package/dist/orchestrator/screen-manager.js +1 -1
- package/dist/orchestrator/screen-manager.js.map +1 -1
- package/dist/orchestrator/templates/ai-instructions/claude-cmd-add-screen.md +5 -5
- package/{src/orchestrator/templates/ai-instructions/claude-cmd-make-tc.md → dist/orchestrator/templates/ai-instructions/claude-cmd-create-test.md} +7 -7
- package/dist/orchestrator/templates/ai-instructions/claude-cmd-review.md +21 -0
- package/dist/orchestrator/templates/ai-instructions/claude-cmd-run-test.md +32 -0
- package/dist/orchestrator/templates/ai-instructions/claude-config.md +65 -12
- package/dist/orchestrator/templates/ai-instructions/claude-skill-error-mapping.md +128 -52
- package/dist/orchestrator/templates/ai-instructions/claude-skill-gherkin-syntax.md +15 -39
- package/dist/orchestrator/templates/ai-instructions/claude-skill-selector-fix.md +72 -259
- package/dist/orchestrator/templates/ai-instructions/claude-skill-tc-generation.md +57 -205
- package/dist/orchestrator/templates/ai-instructions/claude-skill-tc-review.md +104 -0
- package/dist/orchestrator/templates/ai-instructions/claude-skill-viewpoint.md +188 -0
- package/dist/orchestrator/templates/ai-instructions/copilot-cmd-add-screen.md +4 -4
- package/dist/orchestrator/templates/ai-instructions/{copilot-cmd-make-tc.md → copilot-cmd-create-test.md} +8 -8
- package/dist/orchestrator/templates/ai-instructions/copilot-cmd-review.md +24 -0
- package/dist/orchestrator/templates/ai-instructions/copilot-cmd-run-test.md +35 -0
- package/dist/orchestrator/templates/ai-instructions/copilot-config.md +66 -13
- package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-error-mapping.md +128 -52
- package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-gherkin-syntax.md +15 -39
- package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-selector-fix.md +72 -234
- package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-tc-generation.md +57 -205
- package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-tc-review.md +104 -0
- package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-viewpoint.md +188 -0
- package/dist/orchestrator/templates/readme.md +85 -22
- package/package.json +1 -1
- package/src/cli/index.ts +1 -1
- package/src/generators/gherkin-parser/index.ts +23 -0
- package/src/generators/test-generator/adapters/playwright/templates/steps/actions/table-action-in-row.hbs +1 -1
- package/src/generators/test-generator/adapters/playwright/templates/steps/assertions/table-column-exists.hbs +5 -1
- package/src/generators/test-generator/adapters/playwright/templates/steps/assertions/table-match-data.hbs +15 -0
- package/src/generators/test-generator/adapters/playwright/templates/steps/assertions/table-row-exists.hbs +7 -1
- package/src/generators/test-generator/adapters/playwright/templates/steps/assertions/table-row-not-exists.hbs +5 -1
- package/src/generators/test-generator/patterns/index.ts +2 -1
- package/src/generators/test-generator/patterns/table-patterns.ts +155 -111
- package/src/generators/test-generator/patterns/types.ts +2 -0
- package/src/generators/test-generator/step-mapper.ts +87 -1
- package/src/orchestrator/ai-rules-updater.ts +8 -6
- package/src/orchestrator/project-initializer.ts +38 -2
- package/src/orchestrator/screen-manager.ts +1 -1
- package/src/orchestrator/templates/ai-instructions/claude-cmd-add-screen.md +5 -5
- package/{dist/orchestrator/templates/ai-instructions/claude-cmd-make-tc.md → src/orchestrator/templates/ai-instructions/claude-cmd-create-test.md} +7 -7
- package/src/orchestrator/templates/ai-instructions/claude-cmd-review.md +21 -0
- package/src/orchestrator/templates/ai-instructions/claude-cmd-run-test.md +32 -0
- package/src/orchestrator/templates/ai-instructions/claude-config.md +65 -12
- package/src/orchestrator/templates/ai-instructions/claude-skill-error-mapping.md +128 -52
- package/src/orchestrator/templates/ai-instructions/claude-skill-gherkin-syntax.md +15 -39
- package/src/orchestrator/templates/ai-instructions/claude-skill-selector-fix.md +72 -259
- package/src/orchestrator/templates/ai-instructions/claude-skill-tc-generation.md +57 -205
- package/src/orchestrator/templates/ai-instructions/claude-skill-tc-review.md +104 -0
- package/src/orchestrator/templates/ai-instructions/claude-skill-viewpoint.md +188 -0
- package/src/orchestrator/templates/ai-instructions/copilot-cmd-add-screen.md +4 -4
- package/src/orchestrator/templates/ai-instructions/{copilot-cmd-make-tc.md → copilot-cmd-create-test.md} +8 -8
- package/src/orchestrator/templates/ai-instructions/copilot-cmd-review.md +24 -0
- package/src/orchestrator/templates/ai-instructions/copilot-cmd-run-test.md +35 -0
- package/src/orchestrator/templates/ai-instructions/copilot-config.md +66 -13
- package/src/orchestrator/templates/ai-instructions/github-skill-sungen-error-mapping.md +128 -52
- package/src/orchestrator/templates/ai-instructions/github-skill-sungen-gherkin-syntax.md +15 -39
- package/src/orchestrator/templates/ai-instructions/github-skill-sungen-selector-fix.md +72 -234
- package/src/orchestrator/templates/ai-instructions/github-skill-sungen-tc-generation.md +57 -205
- package/src/orchestrator/templates/ai-instructions/github-skill-sungen-tc-review.md +104 -0
- package/src/orchestrator/templates/ai-instructions/github-skill-sungen-viewpoint.md +188 -0
- package/src/orchestrator/templates/readme.md +85 -22
- package/dist/generators/test-generator/adapters/playwright/templates/steps/assertions/table-cell-by-filter.hbs +0 -2
- package/dist/generators/test-generator/adapters/playwright/templates/steps/assertions/table-cell-by-index.hbs +0 -2
- package/dist/orchestrator/templates/ai-instructions/claude-cmd-make-test.md +0 -29
- package/dist/orchestrator/templates/ai-instructions/claude-skill-gherkin-review.md +0 -228
- package/dist/orchestrator/templates/ai-instructions/copilot-cmd-make-test.md +0 -32
- package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-gherkin-review.md +0 -228
- package/src/generators/test-generator/adapters/playwright/templates/steps/assertions/table-cell-by-filter.hbs +0 -2
- package/src/generators/test-generator/adapters/playwright/templates/steps/assertions/table-cell-by-index.hbs +0 -2
- package/src/orchestrator/templates/ai-instructions/claude-cmd-make-test.md +0 -29
- package/src/orchestrator/templates/ai-instructions/claude-skill-gherkin-review.md +0 -228
- package/src/orchestrator/templates/ai-instructions/copilot-cmd-make-test.md +0 -32
- package/src/orchestrator/templates/ai-instructions/github-skill-sungen-gherkin-review.md +0 -228
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
---
|
|
2
|
-
name: sungen-
|
|
2
|
+
name: sungen-create-test
|
|
3
3
|
description: 'Create or update test cases for a Sungen screen — generates feature + test-data files (20+ scenarios per viewpoint). Uses sungen-gherkin-syntax and sungen-tc-generation skills.'
|
|
4
4
|
argument-hint: '[screen-name]'
|
|
5
5
|
agent: 'agent'
|
|
6
6
|
tools: [vscode, execute, read, agent, edit, search, web, browser, todo, 'playwright/*']
|
|
7
7
|
---
|
|
8
8
|
|
|
9
|
-
**Input**: Screen name (e.g., `/sungen-
|
|
9
|
+
**Input**: Screen name (e.g., `/sungen-create-test admin-users`).
|
|
10
10
|
|
|
11
11
|
## Role
|
|
12
12
|
|
|
13
|
-
You are a **Senior QA Engineer**. You structure test cases by viewpoint categories and translate UI into Gherkin test cases following the `sungen-gherkin-syntax` and `sungen-tc-generation` skills. **Gherkin scenarios and test data only** — selectors are handled during `/sungen-
|
|
13
|
+
You are a **Senior QA Engineer**. You structure test cases by viewpoint categories and translate UI into Gherkin test cases following the `sungen-gherkin-syntax` and `sungen-tc-generation` skills. **Gherkin scenarios and test data only** — selectors are handled during `/sungen-run-test`.
|
|
14
14
|
|
|
15
15
|
## Parameters
|
|
16
16
|
|
|
@@ -25,13 +25,13 @@ You are a **Senior QA Engineer**. You structure test cases by viewpoint categori
|
|
|
25
25
|
- If `ui/` has images → read them for visual context (layout, element positions, states).
|
|
26
26
|
- If `notes.md` exists → read for edge cases and additional context.
|
|
27
27
|
- Summarize what you found in requirements and present to the user.
|
|
28
|
-
4. **
|
|
29
|
-
- Ask: "How should I
|
|
28
|
+
4. **Screen input** (supplements requirements, or is primary source if no requirements):
|
|
29
|
+
- Ask: "How should I get the screen design? **1) Figma design** (provide Figma URL — recommended), **2) UI images** (screenshots/mockups in `requirements/ui/`), or **3) Live page scan** (optional, via Playwright MCP)?"
|
|
30
|
+
- Recommend Figma or UI images first. Live page scan is optional — useful to verify specs vs actual UI or capture real data.
|
|
30
31
|
- If live page, explore via #tool:playwright (see [copilot-instructions.md](../../copilot-instructions.md) for MCP rules). If auth needed, ask user to log in manually.
|
|
31
32
|
- If exploring, verify and supplement requirements — flag any discrepancies found.
|
|
32
33
|
5. Identify screen sections → ask user which to focus on (per `sungen-tc-generation` skill). When requirements exist, use the "Requirements-Driven Generation" strategy. Present sections as a numbered list and let user pick.
|
|
33
34
|
6. Generate or update `.feature` + `test-data.yaml` following `sungen-gherkin-syntax` and `sungen-tc-generation` skills.
|
|
34
|
-
7.
|
|
35
|
-
8. Show summary → next: `/sungen-make-test ${input:screen}`
|
|
35
|
+
7. Show summary → next: `/sungen-review ${input:screen}` or `/sungen-run-test ${input:screen}`
|
|
36
36
|
|
|
37
|
-
**No selectors.yaml** — selectors are generated during `/sungen-
|
|
37
|
+
**No selectors.yaml** — selectors are generated during `/sungen-run-test`.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: sungen-review
|
|
3
|
+
description: 'Review test cases for a Sungen screen — validate syntax, score coverage, check viewpoint quality.'
|
|
4
|
+
argument-hint: '[screen-name]'
|
|
5
|
+
agent: 'agent'
|
|
6
|
+
tools: [vscode, read, edit, search, todo]
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
**Input**: Screen name (e.g., `/sungen-review admin-users`).
|
|
10
|
+
|
|
11
|
+
## Role
|
|
12
|
+
|
|
13
|
+
You are a **Senior QA Reviewer**. You evaluate Gherkin test cases using the `sungen-tc-review`, `sungen-viewpoint`, and `sungen-gherkin-syntax` skills.
|
|
14
|
+
|
|
15
|
+
## Parameters
|
|
16
|
+
|
|
17
|
+
- **screen** — ${input:screen:screen name (e.g., login, dashboard)}
|
|
18
|
+
|
|
19
|
+
## Steps
|
|
20
|
+
|
|
21
|
+
1. Read `qa/screens/${input:screen}/features/${input:screen}.feature` and `qa/screens/${input:screen}/test-data/${input:screen}.yaml`. If missing → `/sungen-create-test` first.
|
|
22
|
+
2. Follow the `sungen-tc-review` skill — score 3 dimensions: Syntax (30pts), Coverage (40pts), Viewpoint (30pts). Use `sungen-viewpoint` for pattern checklists.
|
|
23
|
+
3. Output review report per `sungen-tc-review` format. **>= 60%**: PASS. **< 60%**: FAIL with recommendations.
|
|
24
|
+
4. If FAIL and user confirms → update test cases following `sungen-gherkin-syntax` and `sungen-tc-generation` skills, then re-review.
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: sungen-run-test
|
|
3
|
+
description: 'Compile and run Playwright tests — auto-fixes selectors on failure. Uses sungen-selector-fix, sungen-selector-keys, and sungen-error-mapping skills.'
|
|
4
|
+
argument-hint: '[screen-name]'
|
|
5
|
+
agent: 'agent'
|
|
6
|
+
tools: [vscode, execute, read, agent, edit, search, web, browser, todo, 'playwright/*']
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
**Input**: Screen name (e.g., `/sungen-run-test admin-users`).
|
|
10
|
+
|
|
11
|
+
## Role
|
|
12
|
+
|
|
13
|
+
You are a **Senior Developer**. Use `sungen-selector-fix`, `sungen-selector-keys`, and `sungen-error-mapping` skills.
|
|
14
|
+
|
|
15
|
+
## Parameters
|
|
16
|
+
|
|
17
|
+
- **screen** — ${input:screen:screen name (e.g., login, dashboard)}
|
|
18
|
+
|
|
19
|
+
## Phase 1: Compile & Run (no MCP)
|
|
20
|
+
|
|
21
|
+
1. Verify `qa/screens/${input:screen}/` has `.feature` + `test-data.yaml`
|
|
22
|
+
2. Ensure `selectors.yaml` has page selector. If missing, ask user for URL path
|
|
23
|
+
3. `sungen generate --screen ${input:screen}`
|
|
24
|
+
4. `npx playwright test specs/generated/${input:screen}/*.spec.ts --reporter=line`
|
|
25
|
+
5. If all pass → done
|
|
26
|
+
|
|
27
|
+
## Phase 2: Targeted Fix (only if failures)
|
|
28
|
+
|
|
29
|
+
6. Parse failures → group by root cause
|
|
30
|
+
7. Navigate to page ONCE via #tool:playwright → ONE `browser_snapshot`
|
|
31
|
+
8. Fix broken selectors per `sungen-selector-fix` skill
|
|
32
|
+
9. Recompile → re-run only failing tests
|
|
33
|
+
10. Repeat up to 3 attempts
|
|
34
|
+
11. Final full run for regression check
|
|
35
|
+
12. Still failing → ask user
|
|
@@ -3,8 +3,40 @@
|
|
|
3
3
|
You generate 3 files for sungen — a Gherkin compiler that produces Playwright tests.
|
|
4
4
|
**You do NOT write Playwright code.** You only write `.feature`, `selectors.yaml`, and `test-data.yaml`.
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
## Skills (auto-loaded when needed)
|
|
7
|
+
|
|
8
|
+
| Skill | Purpose |
|
|
9
|
+
|---|---|
|
|
10
|
+
| `sungen-gherkin-syntax` | All 70+ step patterns, selector types, YAML key rules, tags, element types |
|
|
11
|
+
| `sungen-error-mapping` | Playwright & sungen error → fix mapping |
|
|
12
|
+
| `sungen-tc-generation` | Test case generation strategy, output format |
|
|
13
|
+
| `sungen-tc-review` | Review scoring, quality rules, checklist |
|
|
14
|
+
| `sungen-viewpoint` | 7 UI patterns x 4 viewpoints — coverage checklists |
|
|
15
|
+
| `sungen-selector-keys` | YAML key generation from `[Reference]` names, suffixes, lookup priority |
|
|
16
|
+
| `sungen-selector-fix` | Selector generation from live page, auto-fix strategy |
|
|
17
|
+
|
|
18
|
+
## Workflow (4 AI commands)
|
|
19
|
+
|
|
20
|
+
| Command | What it does |
|
|
21
|
+
|---|---|
|
|
22
|
+
| `/sungen-add-screen <name> <path>` | Scaffold `qa/screens/<name>/` directories |
|
|
23
|
+
| `/sungen-create-test <name>` | Generate `.feature` + `test-data.yaml` (no selectors) |
|
|
24
|
+
| `/sungen-review <name>` | Score syntax, coverage, viewpoint quality (60% threshold) |
|
|
25
|
+
| `/sungen-run-test <name>` | Generate `selectors.yaml` from live page, compile, run, auto-fix |
|
|
26
|
+
|
|
27
|
+
**Order:** add-screen → create-test → review → run-test.
|
|
28
|
+
|
|
29
|
+
## File Structure
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
qa/screens/<screen-name>/
|
|
33
|
+
├── features/<screen>.feature # Gherkin scenarios
|
|
34
|
+
├── selectors/<screen>.yaml # Element locators (generated during run-test)
|
|
35
|
+
├── test-data/<screen>.yaml # Test data variables
|
|
36
|
+
└── requirements/
|
|
37
|
+
├── spec.md # Screen specification (primary source)
|
|
38
|
+
└── ui/ # Screenshots, mockups
|
|
39
|
+
```
|
|
8
40
|
|
|
9
41
|
## Complete Example
|
|
10
42
|
|
|
@@ -12,16 +44,16 @@ Given a login page, here are the 3 files you generate:
|
|
|
12
44
|
|
|
13
45
|
**qa/screens/login/features/login.feature**
|
|
14
46
|
```gherkin
|
|
15
|
-
@auth
|
|
47
|
+
@no-auth
|
|
16
48
|
Feature: Login Screen
|
|
17
49
|
|
|
18
|
-
Scenario: Successful login
|
|
50
|
+
Scenario: VP-LOGIC-001 Successful login
|
|
19
51
|
Given User is on [login] page
|
|
20
52
|
When User fill [Email] field with {{email}}
|
|
21
53
|
And User fill [Password] field with {{password}}
|
|
22
54
|
And User click [Submit] button
|
|
23
55
|
Then User see [Welcome] heading with {{welcome_text}}
|
|
24
|
-
And User see [Dashboard] link
|
|
56
|
+
And User see [Dashboard] link
|
|
25
57
|
```
|
|
26
58
|
|
|
27
59
|
**qa/screens/login/selectors/login.yaml**
|
|
@@ -61,6 +93,16 @@ password: 'password123'
|
|
|
61
93
|
welcome_text: 'Welcome back'
|
|
62
94
|
```
|
|
63
95
|
|
|
96
|
+
## Critical Gherkin Rules (quick reference)
|
|
97
|
+
|
|
98
|
+
1. **NEVER write `is visible`** — `User see [T] type` already asserts visibility. Only use `is hidden` to assert absence.
|
|
99
|
+
2. **Use `@no-auth` for pre-login pages** (login, register, forgot-password). Use `@auth:role` for authenticated pages.
|
|
100
|
+
3. **Scenario names use VP prefix** — `VP-UI-001`, `VP-VAL-001`, `VP-LOGIC-001`, `VP-SEC-001`.
|
|
101
|
+
4. **Values use `{{snake_case}}`** — never hardcode data in `.feature`. All values go in `test-data.yaml`.
|
|
102
|
+
5. **Selectors are deferred** — `selectors.yaml` is generated during `/sungen-run-test` from the live page, NOT during `/sungen-create-test`.
|
|
103
|
+
6. **Every `{{variable}}` must exist in `test-data.yaml`** — missing variables cause compile failures.
|
|
104
|
+
7. **Assertion type is determined by element type** — input types (`field`, `textarea`, `search`, `dropdown`, `slider`, `date-picker`) → `toHaveValue()`. Everything else → `toHaveText()`. Wrong type = wrong assertion = test failure.
|
|
105
|
+
|
|
64
106
|
## Using Playwright MCP to explore pages
|
|
65
107
|
|
|
66
108
|
When exploring a page to generate test files:
|
|
@@ -69,23 +111,34 @@ When exploring a page to generate test files:
|
|
|
69
111
|
3. Use `browser_snapshot` to see all elements
|
|
70
112
|
4. Generate the 3 files from the snapshot
|
|
71
113
|
|
|
72
|
-
|
|
73
|
-
|
|
114
|
+
### Allowed MCP tools
|
|
115
|
+
|
|
116
|
+
| Tool | Use for |
|
|
117
|
+
|---|---|
|
|
118
|
+
| `browser_navigate` | Open pages |
|
|
119
|
+
| `browser_snapshot` | Capture all accessible elements |
|
|
120
|
+
| `browser_click` | Interact with elements (open dialogs, dropdowns) |
|
|
121
|
+
| `browser_fill_form` | Fill form fields |
|
|
122
|
+
| `browser_evaluate` | **Read-only DOM queries only** (e.g., detect `data-testid` attributes) |
|
|
123
|
+
|
|
124
|
+
**NEVER use `browser_run_code`** — fails with `require is not defined`.
|
|
125
|
+
|
|
126
|
+
### Authentication via MCP
|
|
74
127
|
|
|
75
|
-
To browse authenticated pages via MCP:
|
|
76
128
|
1. `browser_navigate` to `baseURL`
|
|
77
129
|
2. If redirected to login, ask the user to log in manually:
|
|
78
130
|
> "This page requires login. Please log in using the browser. Confirm when you're done."
|
|
79
131
|
3. Once confirmed, `browser_navigate` to the target page and take `browser_snapshot`
|
|
80
132
|
|
|
81
133
|
**Never use `sungen makeauth`.** Always let the user log in manually via the MCP browser.
|
|
82
|
-
**NEVER use `browser_evaluate` to inject cookies or localStorage
|
|
134
|
+
**NEVER use `browser_evaluate` to inject cookies or localStorage** — causes size limit issues and server 500 errors. Use `browser_evaluate` ONLY for read-only DOM queries.
|
|
83
135
|
**Minimize navigations** — take one snapshot per page, do not navigate repeatedly.
|
|
84
136
|
|
|
85
|
-
## Commands
|
|
137
|
+
## CLI Commands
|
|
86
138
|
|
|
87
139
|
```bash
|
|
88
|
-
sungen add --screen <name> --path <url-path>
|
|
89
|
-
sungen
|
|
90
|
-
sungen generate --
|
|
140
|
+
sungen add --screen <name> --path <url-path> # Scaffold screen directories
|
|
141
|
+
sungen add --screen <name> --path <path> --feature <name> # Scaffold with sub-feature
|
|
142
|
+
sungen generate --screen <name> # Compile .feature → .spec.ts
|
|
143
|
+
sungen generate --all # Compile all screens
|
|
91
144
|
```
|
|
@@ -1,69 +1,145 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: sungen-error-mapping
|
|
3
|
-
description: '
|
|
3
|
+
description: 'Error diagnosis and fix strategy — systematic debugging flow, error patterns, fix priorities. Auto-loaded during run-test.'
|
|
4
4
|
user-invocable: false
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
##
|
|
7
|
+
## Diagnosis Flow (before fixing anything)
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|---|---|
|
|
11
|
-
| strict mode violation | add `nth`, `exact: true`, or specific `name` in selectors.yaml |
|
|
12
|
-
| Element is not an input | change `type` or `value` in selectors.yaml |
|
|
13
|
-
| Timeout waiting for selector | fix `type`/`value`/`name` to match element in selectors.yaml |
|
|
14
|
-
| toBeVisible Timeout | verify accessible name or use `testid` in selectors.yaml |
|
|
15
|
-
| toHaveText mismatch | fix expected text in `test-data.yaml` — OR if element is an input (field/textarea/search/dropdown), change Gherkin type so compiler uses `toHaveValue` instead |
|
|
16
|
-
| toHaveValue mismatch | fix expected value in `test-data.yaml` — this is for input elements (field, textarea, search, dropdown, slider, date-picker) |
|
|
17
|
-
| toContainText mismatch | fix expected partial text in `test-data.yaml` |
|
|
18
|
-
| Navigation failed | fix page `value` path in selectors.yaml |
|
|
19
|
-
| not a select | set `variant: 'custom'` in selectors.yaml |
|
|
20
|
-
| Frame not found | fix `frame` value in selectors.yaml |
|
|
21
|
-
| dialog was dismissed | alert step is AFTER the trigger — move `click [OK] alert` BEFORE the button click that opens the dialog |
|
|
22
|
-
| page.once('dialog') never fired | no browser dialog appeared — check if the action actually triggers a `window.alert/confirm/prompt`, not a CSS modal |
|
|
23
|
-
|
|
24
|
-
### Assertion type mismatch (toHaveText vs toHaveValue)
|
|
25
|
-
|
|
26
|
-
Sungen picks the assertion based on element type:
|
|
27
|
-
- **Input types** (`field`, `textarea`, `search`, `dropdown`, `slider`, `date-picker`) → `toHaveValue()`
|
|
28
|
-
- **Text types** (everything else: `message`, `header`, `label`, `row`, etc.) → `toHaveText()`
|
|
29
|
-
- **Partial match** (uses `contains` keyword) → `toContainText()`
|
|
30
|
-
|
|
31
|
-
If you see `toHaveText` failing on an input element, the Gherkin step has the wrong target type. Fix: change the target type in the `.feature` file (e.g., `see [Email] message with {{v}}` → `see [Email] field with {{v}}`).
|
|
32
|
-
|
|
33
|
-
## Auth Errors → Fix
|
|
9
|
+
**Step 1: Read the error** — extract: error type, element name, expected vs actual, file:line.
|
|
34
10
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
11
|
+
**Step 2: Read error context** — check `test-results/` for the snapshot at failure time. This shows the exact page state when the test failed — more reliable than re-navigating with MCP.
|
|
12
|
+
|
|
13
|
+
**Step 3: Compare** — match the failing selector against the snapshot. Ask:
|
|
14
|
+
- Does the element exist on the page?
|
|
15
|
+
- Does the accessible name match exactly?
|
|
16
|
+
- Are there multiple matches (strict mode)?
|
|
17
|
+
- Is the element inside an iframe or dialog?
|
|
18
|
+
- Is the page in the expected state (correct URL, loaded)?
|
|
19
|
+
|
|
20
|
+
Then choose the fix from the patterns below.
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## Fix Priority (try in order)
|
|
25
|
+
|
|
26
|
+
1. **Auth issue** — page redirected to login? Fix auth first, everything else is noise
|
|
27
|
+
2. **Element not found** — wrong name/type/value in selectors.yaml. Re-snapshot, copy exact name
|
|
28
|
+
3. **Multiple matches** — add `nth`, `exact: true`, or `scope` to narrow down
|
|
29
|
+
4. **Wrong assertion** — `toHaveText` vs `toHaveValue` mismatch, wrong expected data
|
|
30
|
+
5. **Timing** — SPA not loaded, async content. Add `wait for` step in .feature
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## Playwright Errors
|
|
35
|
+
|
|
36
|
+
### Selector errors → fix in `selectors.yaml`
|
|
37
|
+
|
|
38
|
+
| Error | Diagnosis | Fix |
|
|
39
|
+
|---|---|---|
|
|
40
|
+
| strict mode violation | Multiple elements match | Add `nth: 0`, `exact: true`, or more specific `name` |
|
|
41
|
+
| Timeout / not found | Element doesn't exist or name wrong | Re-snapshot → copy exact accessible name. Check iframe/dialog scope |
|
|
42
|
+
| Element is not an input | Wrong element type targeted | Change `type` or `value` to match actual element |
|
|
43
|
+
| not a select | Custom dropdown, not native `<select>` | Set `variant: 'custom'` |
|
|
44
|
+
| Frame not found | iframe selector wrong or doesn't exist | Fix `frame` value, verify iframe in snapshot |
|
|
45
|
+
|
|
46
|
+
### Assertion errors → fix in `test-data.yaml` or `.feature`
|
|
47
|
+
|
|
48
|
+
| Error | Diagnosis | Fix |
|
|
49
|
+
|---|---|---|
|
|
50
|
+
| toHaveText mismatch | Expected text differs from actual | Fix value in test-data. If element is input type → change Gherkin type to `field`/`textarea` (triggers `toHaveValue` instead) |
|
|
51
|
+
| toHaveValue mismatch | Expected value differs from actual | Fix value in test-data |
|
|
52
|
+
| toContainText mismatch | Partial text not found | Fix expected partial text in test-data |
|
|
53
|
+
| toBeVisible timeout | Element exists but hidden, or name wrong | Check: is element conditionally visible? Wrong name? Inside dialog? |
|
|
54
|
+
| toHaveCount mismatch | Row count differs | Fix expected count in test-data. Verify: is table loaded? Filtered? |
|
|
41
55
|
|
|
42
|
-
|
|
56
|
+
### Assertion type rule
|
|
43
57
|
|
|
44
|
-
|
|
58
|
+
Sungen picks assertion based on element type:
|
|
59
|
+
- **Input** (`field`, `textarea`, `search`, `dropdown`, `slider`) → `toHaveValue()`
|
|
60
|
+
- **Text** (everything else: `message`, `heading`, `label`, `row`) → `toHaveText()`
|
|
61
|
+
- **Partial** (`contains` keyword) → `toContainText()`
|
|
45
62
|
|
|
46
|
-
|
|
63
|
+
If `toHaveText` fails on an input → the Gherkin step has wrong target type. Fix: change type in `.feature`.
|
|
47
64
|
|
|
48
|
-
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## Table-Specific Errors
|
|
68
|
+
|
|
69
|
+
| Error | Diagnosis | Fix |
|
|
70
|
+
|---|---|---|
|
|
71
|
+
| `tableRow is not defined` | Column assertion without preceding row scope step | Add `User see [Ref] row in [Table] table with {{v}}` before `User see [Col] column with {{v}}` |
|
|
72
|
+
| `toHaveText` on cell fails (with columns) | Wrong column index in `columns` config | Re-count columns in snapshot (0-indexed). Fix `index` in selectors.yaml |
|
|
73
|
+
| `toBeVisible` on cell fails (no columns) | `filter({ hasText })` didn't match | Check exact cell text in snapshot. Fix value in test-data |
|
|
74
|
+
| Row filter matches 0 rows | Filter text doesn't match any row content | Re-snapshot → find actual row text. Fix filter value in test-data |
|
|
75
|
+
| Row filter matches multiple rows | Filter text is too generic (matches multiple rows) | Use more specific filter text (unique identifier like email, ID) |
|
|
76
|
+
| Table not found | Wrong table name or table not rendered | Re-snapshot → copy exact table accessible name |
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## Auth Errors
|
|
81
|
+
|
|
82
|
+
| Symptom | Fix |
|
|
49
83
|
|---|---|
|
|
50
|
-
|
|
|
51
|
-
|
|
|
52
|
-
|
|
|
53
|
-
|
|
|
54
|
-
| Multiple session invalidation errors | Too many contexts created — ensure `contextCache.get(cacheKey)` returns existing context |
|
|
84
|
+
| Redirect to login page | Auth expired. Ask user to log in manually via MCP browser |
|
|
85
|
+
| `storageState` file not found | Ask user to log in manually via MCP browser, then save storage state |
|
|
86
|
+
| Most tests timeout on first step | Auth expired — ask user to re-authenticate via MCP browser |
|
|
87
|
+
| Page shows home instead of target | SPA + expired auth. Re-authenticate + add `wait for` step |
|
|
55
88
|
|
|
56
|
-
**
|
|
57
|
-
- `base.ts` changes affect ALL tests — edit carefully
|
|
58
|
-
- Small project-specific tweaks are OK (e.g., custom overlay dismiss, timeout tuning, extra wait logic)
|
|
59
|
-
- Do NOT move individual selector/data fixes into `base.ts` — those belong in `selectors.yaml` / `test-data.yaml`
|
|
60
|
-
- If unsure whether a fix belongs in `base.ts` or selectors, ask the user
|
|
89
|
+
**Never use `sungen makeauth`.** Always let the user log in manually via the MCP browser.
|
|
61
90
|
|
|
62
|
-
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## Sungen Compile Errors
|
|
63
94
|
|
|
64
95
|
| Error | Fix |
|
|
65
96
|
|---|---|
|
|
66
|
-
| Unknown step pattern |
|
|
67
|
-
| Missing selector |
|
|
68
|
-
| Missing variable |
|
|
69
|
-
| Invalid selector type |
|
|
97
|
+
| Unknown step pattern | Rewrite step to match `sungen-gherkin-syntax` patterns |
|
|
98
|
+
| Missing selector | Add key to `selectors.yaml` |
|
|
99
|
+
| Missing variable | Add key to `test-data.yaml` |
|
|
100
|
+
| Invalid selector type | Use: role/testid/placeholder/label/text/locator/page/upload/frame |
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## Performance & Infrastructure Errors → Fix in `specs/base.ts`
|
|
105
|
+
|
|
106
|
+
All generated `.spec.ts` import from `specs/base.ts` — shared context caching, navigation, overlay cleanup. AI **can and should** tune `base.ts` to match the project.
|
|
107
|
+
|
|
108
|
+
| Symptom | Root cause | Fix |
|
|
109
|
+
|---|---|---|
|
|
110
|
+
| Server 429 (rate limited) | Too many browser contexts | Fix `contextCache` to reuse sessions per `storageState` |
|
|
111
|
+
| Tests slow with `--workers=1` | Redundant navigation | Fix goto patch: skip if `currentPath === url` |
|
|
112
|
+
| Previous test's modal blocks next | Overlay not cleaned up | Add/improve Escape + backdrop click in cleanup hook |
|
|
113
|
+
| All tests fail on first navigation | `page.url()` is `about:blank` | Add try/catch in goto patch |
|
|
114
|
+
| Flaky timeouts on SPA pages | Default timeout too short for app | Increase `actionTimeout` / `navigationTimeout` |
|
|
115
|
+
| Tests pass individually but fail in batch | Shared state leaking between tests | Isolate context per test or reset state in `beforeEach` |
|
|
116
|
+
|
|
117
|
+
### What AI CAN fix in `base.ts`
|
|
118
|
+
|
|
119
|
+
- Timeout tuning (increase for slow APIs, decrease for fast apps)
|
|
120
|
+
- Custom overlay/modal dismiss logic (project has unique close patterns)
|
|
121
|
+
- Navigation wait strategy (`networkidle` vs `domcontentloaded` vs custom)
|
|
122
|
+
- Context caching strategy (per-role, per-session)
|
|
123
|
+
- Cookie/localStorage cleanup between tests
|
|
124
|
+
|
|
125
|
+
### What AI should NOT move into `base.ts`
|
|
126
|
+
|
|
127
|
+
- Individual selector fixes → belong in `selectors.yaml`
|
|
128
|
+
- Test data values → belong in `test-data.yaml`
|
|
129
|
+
- Single-test workarounds → belong in the `.spec.ts` directly
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
## Smart Fix Strategy
|
|
134
|
+
|
|
135
|
+
### When multiple tests fail on the same element
|
|
136
|
+
Fix the **root cause once** — don't fix each test individually. Group by selector key, fix selectors.yaml, recompile, re-run batch.
|
|
137
|
+
|
|
138
|
+
### When you're unsure about the fix
|
|
139
|
+
**Re-snapshot** — `browser_navigate` to the failing page, take `browser_snapshot`, compare the live state against what the test expects. This is faster than guessing.
|
|
140
|
+
|
|
141
|
+
### When the fix might break other tests
|
|
142
|
+
After fixing selectors.yaml, run ALL tests (not just the failing one) to catch regressions from renamed/changed selectors.
|
|
143
|
+
|
|
144
|
+
### When nothing works after 3 attempts
|
|
145
|
+
Ask the user. The issue might be: dynamic content, race condition, environment-specific state, or a real application bug.
|
|
@@ -33,7 +33,6 @@ AND → inherits from preceding keyword
|
|
|
33
33
|
User is on [T] page # navigate to page
|
|
34
34
|
User is on [T] page with {{v}} # navigate with data (e.g., detail page with ID)
|
|
35
35
|
User is on [T] dialog # enter dialog scope
|
|
36
|
-
User is logged in | is not logged in # auth state
|
|
37
36
|
```
|
|
38
37
|
|
|
39
38
|
### Form
|
|
@@ -51,7 +50,7 @@ User check [T] radio # select radio
|
|
|
51
50
|
User uncheck [T] checkbox # uncheck
|
|
52
51
|
User uncheck [T] toggle # toggle off
|
|
53
52
|
User select [T] dropdown with {{v}} # select option
|
|
54
|
-
User
|
|
53
|
+
User fill [T] uploader with {{f}} # file upload
|
|
55
54
|
```
|
|
56
55
|
|
|
57
56
|
### Interaction
|
|
@@ -155,29 +154,23 @@ User see [T] page # URL assertion
|
|
|
155
154
|
### Table
|
|
156
155
|
|
|
157
156
|
```
|
|
158
|
-
User see [Col] column in [Table] table
|
|
159
|
-
User see [Table] table
|
|
160
|
-
User see [
|
|
161
|
-
User see [Table] table with {{count}}
|
|
162
|
-
User see [Table] table is empty
|
|
163
|
-
User see [
|
|
164
|
-
User
|
|
165
|
-
User
|
|
157
|
+
User see [Col] column in [Table] table # column exists
|
|
158
|
+
User see [Ref] row in [Table] table with {{v}} # row exists (enters row scope)
|
|
159
|
+
User see [Ref] row in [Table] table with {{v}} is hidden # row hidden
|
|
160
|
+
User see [Table] table with {{count}} # row count
|
|
161
|
+
User see [Table] table is empty # empty table
|
|
162
|
+
User see [Col] column with {{v}} # cell value (row scoped)
|
|
163
|
+
User click [Act] button in [Table] table with {{v}} # action in row
|
|
164
|
+
User see [Table] table match data: # exact table match (inline DataTable)
|
|
165
|
+
| Header1 | Header2 |
|
|
166
|
+
| {{value1}} | {{value2}} |
|
|
166
167
|
```
|
|
167
168
|
|
|
168
|
-
|
|
169
|
+
**Priority**: Use row scope patterns for single-row verification + actions. Use `table match data` only when verifying multiple rows at once.
|
|
169
170
|
|
|
170
|
-
|
|
171
|
-
User click [Submit] button in [User Info] form # button inside specific form
|
|
172
|
-
User fill [Email] field in [Registration] form with {{v}} # field inside specific form
|
|
173
|
-
User see [Total] text in [Summary] section with {{v}} # text inside specific section
|
|
174
|
-
User click [Delete] button in [Active Users] table # button inside specific table
|
|
175
|
-
```
|
|
171
|
+
Row scope: `see [Ref] row in [Table] table with {{v}}` defines `tableRow`. Subsequent `see [Col] column with {{v}}` checks the cell in that row. With `columns` config → exact `nth(index)`, without → `filter({ hasText })`.
|
|
176
172
|
|
|
177
|
-
- **
|
|
178
|
-
- **Valid parent types**: `table`, `list`, `section`, `dialog`, `form`
|
|
179
|
-
- **Max 2 levels**: `[Target] in [Parent]`. **NEVER** nest 3 levels: `[A] in [B] in [C]`
|
|
180
|
-
- Parent resolves from selectors YAML first, falls back to auto-infer `getByRole(parentType, { name })`
|
|
173
|
+
Table match data: `see [Table] table match data:` followed by a Cucumber DataTable. First row = headers, remaining rows = expected data. Uses **filter-based matching** — verifies rows containing expected values exist, resilient to data changes, extra rows, and row reordering. Use `{{variable}}` for cell values.
|
|
181
174
|
|
|
182
175
|
### States
|
|
183
176
|
|
|
@@ -196,24 +189,7 @@ User click [Delete] button in [Active Users] table # button inside specifi
|
|
|
196
189
|
|
|
197
190
|
### Auto-infer (no YAML entry needed)
|
|
198
191
|
|
|
199
|
-
|
|
200
|
-
|---|---|
|
|
201
|
-
| `[Submit] button` | `getByRole('button', { name: 'Submit' })` |
|
|
202
|
-
| `[Home] link` | `getByRole('link', { name: 'Home' })` |
|
|
203
|
-
| `[Welcome] heading` / `header` | `getByRole('heading', { name: 'Welcome' })` |
|
|
204
|
-
| `[Email] field` | `getByPlaceholder('Email')` |
|
|
205
|
-
| `[Success] text` / `message` / `label` | `getByText('Success')` |
|
|
206
|
-
| `[Terms] checkbox` | `getByRole('checkbox', { name: 'Terms' })` |
|
|
207
|
-
| `[Male] radio` | `getByRole('radio', { name: 'Male' })` |
|
|
208
|
-
| `[Global] search` | `getByRole('searchbox', { name: 'Global' })` |
|
|
209
|
-
| `[Vietnam] option` | `getByRole('option', { name: 'Vietnam' })` |
|
|
210
|
-
| `[Price] slider` | `getByRole('slider', { name: 'Price' })` |
|
|
211
|
-
| `[Notification] toggle` | `getByRole('switch', { name: 'Notification' })` |
|
|
212
|
-
| `[Profile] tab` | `getByRole('tab', { name: 'Profile' })` |
|
|
213
|
-
| `[Orders] table` | `getByRole('table', { name: 'Orders' })` |
|
|
214
|
-
| `[Products] list` | `getByRole('list', { name: 'Products' })` |
|
|
215
|
-
| `[Name] column` | `getByRole('columnheader', { name: 'Name' })` |
|
|
216
|
-
| `[Confirm] dialog` / `modal` / `drawer` | `getByRole('dialog', { name: 'Confirm' })` |
|
|
192
|
+
Most elements auto-infer from `[Label] type` → `getByRole(type, { name: 'Label' })`. Only add YAML when the accessible name differs, needs `nth`, or needs `testid`. Full auto-infer table → see `sungen-selector-keys` skill.
|
|
217
193
|
|
|
218
194
|
## YAML Keys
|
|
219
195
|
|