@sun-asterisk/sungen 2.4.1 → 2.4.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/dist/cli/commands/add.js +2 -2
- package/dist/cli/commands/add.js.map +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/generators/test-generator/code-generator.d.ts.map +1 -1
- package/dist/generators/test-generator/code-generator.js +27 -4
- package/dist/generators/test-generator/code-generator.js.map +1 -1
- package/dist/orchestrator/ai-rules-updater.d.ts.map +1 -1
- package/dist/orchestrator/ai-rules-updater.js +2 -0
- package/dist/orchestrator/ai-rules-updater.js.map +1 -1
- package/dist/orchestrator/project-initializer.d.ts +4 -0
- package/dist/orchestrator/project-initializer.d.ts.map +1 -1
- package/dist/orchestrator/project-initializer.js +20 -3
- package/dist/orchestrator/project-initializer.js.map +1 -1
- package/dist/orchestrator/screen-manager.d.ts +8 -0
- package/dist/orchestrator/screen-manager.d.ts.map +1 -1
- package/dist/orchestrator/screen-manager.js +120 -0
- package/dist/orchestrator/screen-manager.js.map +1 -1
- package/dist/orchestrator/templates/ai-instructions/claude-cmd-add-screen.md +6 -14
- package/dist/orchestrator/templates/ai-instructions/claude-cmd-create-test.md +10 -2
- package/dist/orchestrator/templates/ai-instructions/claude-cmd-review.md +5 -0
- package/dist/orchestrator/templates/ai-instructions/claude-cmd-run-test.md +21 -13
- package/dist/orchestrator/templates/ai-instructions/claude-config.md +4 -97
- package/dist/orchestrator/templates/ai-instructions/claude-skill-gherkin-syntax.md +84 -122
- package/dist/orchestrator/templates/ai-instructions/claude-skill-selector-fix.md +87 -23
- package/dist/orchestrator/templates/ai-instructions/claude-skill-tc-generation.md +71 -30
- package/dist/orchestrator/templates/ai-instructions/claude-skill-tc-review.md +19 -14
- package/dist/orchestrator/templates/ai-instructions/claude-skill-test-design-techniques.md +99 -0
- package/dist/orchestrator/templates/ai-instructions/claude-skill-viewpoint.md +151 -64
- package/dist/orchestrator/templates/ai-instructions/copilot-cmd-add-screen.md +5 -10
- package/dist/orchestrator/templates/ai-instructions/copilot-cmd-create-test.md +10 -3
- package/dist/orchestrator/templates/ai-instructions/copilot-cmd-review.md +5 -0
- package/dist/orchestrator/templates/ai-instructions/copilot-cmd-run-test.md +21 -13
- package/dist/orchestrator/templates/ai-instructions/copilot-config.md +4 -97
- package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-gherkin-syntax.md +85 -123
- package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-selector-fix.md +87 -23
- package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-tc-generation.md +72 -25
- package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-tc-review.md +19 -14
- package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-test-design-techniques.md +99 -0
- package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-viewpoint.md +151 -64
- package/dist/orchestrator/templates/readme.md +1 -1
- package/dist/orchestrator/templates/tsconfig.json +21 -0
- package/package.json +1 -1
- package/src/cli/commands/add.ts +2 -2
- package/src/cli/index.ts +1 -1
- package/src/generators/test-generator/code-generator.ts +29 -4
- package/src/orchestrator/ai-rules-updater.ts +2 -0
- package/src/orchestrator/project-initializer.ts +24 -3
- package/src/orchestrator/screen-manager.ts +124 -0
- package/src/orchestrator/templates/ai-instructions/claude-cmd-add-screen.md +6 -14
- package/src/orchestrator/templates/ai-instructions/claude-cmd-create-test.md +10 -2
- package/src/orchestrator/templates/ai-instructions/claude-cmd-review.md +5 -0
- package/src/orchestrator/templates/ai-instructions/claude-cmd-run-test.md +21 -13
- package/src/orchestrator/templates/ai-instructions/claude-config.md +4 -97
- package/src/orchestrator/templates/ai-instructions/claude-skill-gherkin-syntax.md +84 -122
- package/src/orchestrator/templates/ai-instructions/claude-skill-selector-fix.md +87 -23
- package/src/orchestrator/templates/ai-instructions/claude-skill-tc-generation.md +71 -30
- package/src/orchestrator/templates/ai-instructions/claude-skill-tc-review.md +19 -14
- package/src/orchestrator/templates/ai-instructions/claude-skill-test-design-techniques.md +99 -0
- package/src/orchestrator/templates/ai-instructions/claude-skill-viewpoint.md +151 -64
- package/src/orchestrator/templates/ai-instructions/copilot-cmd-add-screen.md +5 -10
- package/src/orchestrator/templates/ai-instructions/copilot-cmd-create-test.md +10 -3
- package/src/orchestrator/templates/ai-instructions/copilot-cmd-review.md +5 -0
- package/src/orchestrator/templates/ai-instructions/copilot-cmd-run-test.md +21 -13
- package/src/orchestrator/templates/ai-instructions/copilot-config.md +4 -97
- package/src/orchestrator/templates/ai-instructions/github-skill-sungen-gherkin-syntax.md +85 -123
- package/src/orchestrator/templates/ai-instructions/github-skill-sungen-selector-fix.md +87 -23
- package/src/orchestrator/templates/ai-instructions/github-skill-sungen-tc-generation.md +72 -25
- package/src/orchestrator/templates/ai-instructions/github-skill-sungen-tc-review.md +19 -14
- package/src/orchestrator/templates/ai-instructions/github-skill-sungen-test-design-techniques.md +99 -0
- package/src/orchestrator/templates/ai-instructions/github-skill-sungen-viewpoint.md +151 -64
- package/src/orchestrator/templates/readme.md +1 -1
- package/src/orchestrator/templates/tsconfig.json +21 -0
|
@@ -32,15 +32,10 @@ Ask the user: "Would you like to fill in `requirements/spec.md` now? This helps
|
|
|
32
32
|
- If they have UI designs (screenshots, Figma exports, mockups) → suggest copying them to `requirements/ui/`.
|
|
33
33
|
- If no → proceed to step 3.
|
|
34
34
|
|
|
35
|
-
### 3.
|
|
35
|
+
### 3. Next steps
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
Tell the user what was created and offer next steps:
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
If the user declined test case creation, tell them next steps:
|
|
44
|
-
- Fill `requirements/spec.md` with screen specs (if not done)
|
|
45
|
-
- Run `/sungen-create-test` to create test cases
|
|
46
|
-
- Run `/sungen-run-test` to generate selectors, compile, and run tests
|
|
39
|
+
- **`/sungen-create-test ${input:screen}`** — Create test cases from requirements/designs (Recommended)
|
|
40
|
+
- **Fill `requirements/spec.md`** — Write screen specs first for better test quality
|
|
41
|
+
- **Done for now** — I'll come back later
|
|
@@ -23,15 +23,22 @@ You are a **Senior QA Engineer**. You structure test cases by viewpoint categori
|
|
|
23
23
|
3. **Read requirements** — check `qa/screens/${input:screen}/requirements/`:
|
|
24
24
|
- If `spec.md` exists → read it as PRIMARY source (sections, fields, validation rules, business rules, states).
|
|
25
25
|
- If `ui/` has images → read them for visual context (layout, element positions, states).
|
|
26
|
-
- If `
|
|
26
|
+
- If `test-viewpoint.md` exists → read it. If it only contains HTML comments (scaffold template), ask:
|
|
27
|
+
- **1) Fill test-viewpoint.md first** — identify edge cases, known issues, and design decisions before generating tests
|
|
28
|
+
- **2) Continue without it** — generate tests from spec and other sources only
|
|
27
29
|
- Summarize what you found in requirements and present to the user.
|
|
28
30
|
4. **Screen input** (supplements requirements, or is primary source if no requirements):
|
|
29
31
|
- 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
32
|
- Recommend Figma or UI images first. Live page scan is optional — useful to verify specs vs actual UI or capture real data.
|
|
31
|
-
- If live page
|
|
33
|
+
- If live page: `browser_navigate` → ONE `browser_snapshot`. If auth redirect → ask user to log in manually. Never use `browser_run_code` or `browser_evaluate` to inject cookies.
|
|
32
34
|
- If exploring, verify and supplement requirements — flag any discrepancies found.
|
|
33
35
|
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.
|
|
34
36
|
6. Generate or update `.feature` + `test-data.yaml` following `sungen-gherkin-syntax` and `sungen-tc-generation` skills.
|
|
35
|
-
7. Show summary
|
|
37
|
+
7. Show summary and offer next steps:
|
|
38
|
+
|
|
39
|
+
- **`/sungen-review ${input:screen}`** — Review syntax, coverage, viewpoint quality (Recommended)
|
|
40
|
+
- **`/sungen-run-test ${input:screen}`** — Skip review, generate selectors and run tests now
|
|
41
|
+
- **`/sungen-create-test ${input:screen}`** — Add more test cases for another section/viewpoint
|
|
42
|
+
- **Done for now** — I'll come back later
|
|
36
43
|
|
|
37
44
|
**No selectors.yaml** — selectors are generated during `/sungen-run-test`.
|
|
@@ -22,3 +22,8 @@ You are a **Senior QA Reviewer**. You evaluate Gherkin test cases using the `sun
|
|
|
22
22
|
2. Follow the `sungen-tc-review` skill — score 3 dimensions: Syntax (30pts), Coverage (40pts), Viewpoint (30pts). Use `sungen-viewpoint` for pattern checklists.
|
|
23
23
|
3. Output review report per `sungen-tc-review` format. **>= 60%**: PASS. **< 60%**: FAIL with recommendations.
|
|
24
24
|
4. If FAIL and user confirms → update test cases following `sungen-gherkin-syntax` and `sungen-tc-generation` skills, then re-review.
|
|
25
|
+
5. After PASS (or user decides to proceed), offer next steps:
|
|
26
|
+
|
|
27
|
+
- **`/sungen-run-test ${input:screen}`** — Generate selectors, compile, and run tests (Recommended)
|
|
28
|
+
- **`/sungen-create-test ${input:screen}`** — Add more test cases before running
|
|
29
|
+
- **Done for now** — I'll come back later
|
|
@@ -16,20 +16,28 @@ You are a **Senior Developer**. Use `sungen-selector-fix`, `sungen-selector-keys
|
|
|
16
16
|
|
|
17
17
|
- **screen** — ${input:screen:screen name (e.g., login, dashboard)}
|
|
18
18
|
|
|
19
|
-
##
|
|
19
|
+
## Compile
|
|
20
20
|
|
|
21
21
|
1. Verify `qa/screens/${input:screen}/` has `.feature` + `test-data.yaml`
|
|
22
22
|
2. Ensure `selectors.yaml` has page selector. If missing, ask user for URL path
|
|
23
23
|
3. `sungen generate --screen ${input:screen}`
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
6.
|
|
30
|
-
7.
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
24
|
+
|
|
25
|
+
## Run & Fix (phased — per `sungen-selector-fix` skill)
|
|
26
|
+
|
|
27
|
+
4. **Phase 1 — Smoke Check**: Run first 5 `@critical`/`@high` scenarios only. If failures → diagnose, fix fundamentals (page selector, auth, base @steps), re-run. Max 2 attempts. If still broken → ask user.
|
|
28
|
+
5. **Phase 2 — Priority Wave**: Run all `@critical` + `@high` scenarios. Fix only failures from this wave. Max 2 attempts. Shared selectors fixed here cascade to later phases.
|
|
29
|
+
6. **Phase 3 — Full Run**: Run all tests. Fix only **new** failures (elements unique to `@normal`/`@low`). Max 1 attempt. Don't loop on low-priority failures.
|
|
30
|
+
7. **Phase 4 — Regression**: One final full run. Report results. No more fix loops.
|
|
31
|
+
|
|
32
|
+
## Next steps
|
|
33
|
+
|
|
34
|
+
After showing results, offer next steps:
|
|
35
|
+
|
|
36
|
+
If all tests **passed**:
|
|
37
|
+
- **`/sungen-create-test ${input:screen}`** — Add more test cases (Recommended)
|
|
38
|
+
- **Done** — All tests passed, I'm finished
|
|
39
|
+
|
|
40
|
+
If tests **failed** (after retries):
|
|
41
|
+
- **`/sungen-run-test ${input:screen}`** — Re-run after manual fixes
|
|
42
|
+
- **`/sungen-create-test ${input:screen}`** — Revise test cases
|
|
43
|
+
- **Done for now** — I'll fix manually later
|
|
@@ -10,8 +10,9 @@ You generate 3 files for sungen — a Gherkin compiler that produces Playwright
|
|
|
10
10
|
| `sungen-gherkin-syntax` | All 70+ step patterns, selector types, YAML key rules, tags, element types |
|
|
11
11
|
| `sungen-error-mapping` | Playwright & sungen error → fix mapping |
|
|
12
12
|
| `sungen-tc-generation` | Test case generation strategy, output format |
|
|
13
|
+
| `sungen-test-design-techniques` | EP, BVA, Decision Table, State Transition — systematic scenario generation |
|
|
13
14
|
| `sungen-tc-review` | Review scoring, quality rules, checklist |
|
|
14
|
-
| `sungen-viewpoint` |
|
|
15
|
+
| `sungen-viewpoint` | 10 UI patterns x 4 viewpoints — coverage checklists |
|
|
15
16
|
| `sungen-selector-keys` | YAML key generation from `[Reference]` names, suffixes, lookup priority |
|
|
16
17
|
| `sungen-selector-fix` | Selector generation from live page, auto-fix strategy |
|
|
17
18
|
|
|
@@ -26,6 +27,8 @@ You generate 3 files for sungen — a Gherkin compiler that produces Playwright
|
|
|
26
27
|
|
|
27
28
|
**Order:** add-screen → create-test → review → run-test.
|
|
28
29
|
|
|
30
|
+
After each command completes, present the next actions as selectable options. Never just print text — always give clickable choices so the user can continue the workflow seamlessly.
|
|
31
|
+
|
|
29
32
|
## File Structure
|
|
30
33
|
|
|
31
34
|
```
|
|
@@ -38,102 +41,6 @@ qa/screens/<screen-name>/
|
|
|
38
41
|
└── ui/ # Screenshots, mockups
|
|
39
42
|
```
|
|
40
43
|
|
|
41
|
-
## Complete Example
|
|
42
|
-
|
|
43
|
-
Given a login page, here are the 3 files you generate:
|
|
44
|
-
|
|
45
|
-
**qa/screens/login/features/login.feature**
|
|
46
|
-
```gherkin
|
|
47
|
-
@no-auth
|
|
48
|
-
Feature: Login Screen
|
|
49
|
-
|
|
50
|
-
Scenario: VP-LOGIC-001 Successful login
|
|
51
|
-
Given User is on [login] page
|
|
52
|
-
When User fill [Email] field with {{email}}
|
|
53
|
-
And User fill [Password] field with {{password}}
|
|
54
|
-
And User click [Submit] button
|
|
55
|
-
Then User see [Welcome] heading with {{welcome_text}}
|
|
56
|
-
And User see [Dashboard] link
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
**qa/screens/login/selectors/login.yaml**
|
|
60
|
-
```yaml
|
|
61
|
-
login:
|
|
62
|
-
type: 'page'
|
|
63
|
-
value: '/login'
|
|
64
|
-
|
|
65
|
-
email:
|
|
66
|
-
type: 'placeholder'
|
|
67
|
-
value: 'Enter your email'
|
|
68
|
-
|
|
69
|
-
password:
|
|
70
|
-
type: 'placeholder'
|
|
71
|
-
value: 'Enter your password'
|
|
72
|
-
|
|
73
|
-
submit:
|
|
74
|
-
type: 'role'
|
|
75
|
-
value: 'button'
|
|
76
|
-
name: 'Submit'
|
|
77
|
-
|
|
78
|
-
welcome:
|
|
79
|
-
type: 'role'
|
|
80
|
-
value: 'heading'
|
|
81
|
-
name: 'Welcome'
|
|
82
|
-
|
|
83
|
-
dashboard:
|
|
84
|
-
type: 'role'
|
|
85
|
-
value: 'link'
|
|
86
|
-
name: 'Dashboard'
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
**qa/screens/login/test-data/login.yaml**
|
|
90
|
-
```yaml
|
|
91
|
-
email: 'admin@example.com'
|
|
92
|
-
password: 'password123'
|
|
93
|
-
welcome_text: 'Welcome back'
|
|
94
|
-
```
|
|
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
|
-
|
|
106
|
-
## Using Playwright MCP to explore pages
|
|
107
|
-
|
|
108
|
-
When exploring a page to generate test files:
|
|
109
|
-
1. Read `playwright.config.ts` for `baseURL`
|
|
110
|
-
2. Use `browser_navigate` to open `baseURL + /path`
|
|
111
|
-
3. Use `browser_snapshot` to see all elements
|
|
112
|
-
4. Generate the 3 files from the snapshot
|
|
113
|
-
|
|
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
|
|
127
|
-
|
|
128
|
-
1. `browser_navigate` to `baseURL`
|
|
129
|
-
2. If redirected to login, ask the user to log in manually:
|
|
130
|
-
> "This page requires login. Please log in using the browser. Confirm when you're done."
|
|
131
|
-
3. Once confirmed, `browser_navigate` to the target page and take `browser_snapshot`
|
|
132
|
-
|
|
133
|
-
**Never use `sungen makeauth`.** Always let the user log in manually via the MCP browser.
|
|
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.
|
|
135
|
-
**Minimize navigations** — take one snapshot per page, do not navigate repeatedly.
|
|
136
|
-
|
|
137
44
|
## CLI Commands
|
|
138
45
|
|
|
139
46
|
```bash
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: sungen-gherkin-syntax
|
|
3
|
-
description: 'Sungen Gherkin patterns, selector types, and YAML key rules.
|
|
3
|
+
description: 'Sungen Gherkin patterns, selector types, and YAML key rules. Auto-loaded when writing .feature, selectors.yaml, or test-data.yaml.'
|
|
4
4
|
user-invocable: false
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -27,150 +27,68 @@ AND → inherits from preceding keyword
|
|
|
27
27
|
|
|
28
28
|
## Step Patterns (70 patterns)
|
|
29
29
|
|
|
30
|
-
### Setup
|
|
30
|
+
### Setup / Form / Interaction
|
|
31
31
|
|
|
32
32
|
```
|
|
33
|
-
User is on [T] page
|
|
34
|
-
User
|
|
35
|
-
User
|
|
33
|
+
User is on [T] page | page with {{v}} | dialog
|
|
34
|
+
User fill [T] field | textarea | search | slider | date-picker with {{v}}
|
|
35
|
+
User fill [T] uploader with {{f}}
|
|
36
|
+
User clear [T] field
|
|
37
|
+
User check [T] checkbox | toggle | radio
|
|
38
|
+
User uncheck [T] checkbox | toggle
|
|
39
|
+
User select [T] dropdown with {{v}}
|
|
40
|
+
User click [T] button | tab | column | breadcrumb
|
|
41
|
+
User click [T] row with {{v}}
|
|
42
|
+
User double click [T] element
|
|
43
|
+
User hover [T] icon | row
|
|
44
|
+
User drag [T] to [T2]
|
|
45
|
+
User expand | collapse [T] row
|
|
36
46
|
```
|
|
37
47
|
|
|
38
|
-
|
|
48
|
+
**click + with {{Value}} rule**: NO value for static (`button`, `link`, `icon`, `tab`). WITH value only for dynamic lists (`row`, `item`, `card`, `option`).
|
|
39
49
|
|
|
40
|
-
|
|
41
|
-
User fill [T] field with {{v}} # text input
|
|
42
|
-
User fill [T] textarea with {{v}} # multiline input
|
|
43
|
-
User fill [T] search with {{v}} # search input
|
|
44
|
-
User fill [T] slider with {{v}} # set slider value
|
|
45
|
-
User fill [T] date picker with {{v}} # date input
|
|
46
|
-
User clear [T] field # clear input
|
|
47
|
-
User check [T] checkbox # check
|
|
48
|
-
User check [T] toggle # toggle on (same as check)
|
|
49
|
-
User check [T] radio # select radio
|
|
50
|
-
User uncheck [T] checkbox # uncheck
|
|
51
|
-
User uncheck [T] toggle # toggle off
|
|
52
|
-
User select [T] dropdown with {{v}} # select option
|
|
53
|
-
User fill [T] uploader with {{f}} # file upload
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
### Interaction
|
|
57
|
-
|
|
58
|
-
```
|
|
59
|
-
User click [T] button # click (static element, no value)
|
|
60
|
-
User click [T] row with {{v}} # click dynamic list item (row/item/card/option)
|
|
61
|
-
User click [T] tab # switch tab
|
|
62
|
-
User click [T] column # sort column
|
|
63
|
-
User click [T] breadcrumb # navigate breadcrumb
|
|
64
|
-
User double click [T] element # double click
|
|
65
|
-
User hover [T] icon # hover (must have see/click after)
|
|
66
|
-
User hover [T] row # hover row for hidden actions
|
|
67
|
-
User drag [T] to [T2] # drag and drop
|
|
68
|
-
User expand [T] row # expand (aria-expanded)
|
|
69
|
-
User collapse [T] row # collapse (aria-expanded)
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
#### click + with {{Value}} rule
|
|
73
|
-
|
|
74
|
-
- **NO value** for static elements: `button`, `link`, `icon`, `tab`, `toggle`
|
|
75
|
-
- **WITH value** only for dynamic lists: `row`, `item`, `card`, `option`
|
|
76
|
-
|
|
77
|
-
### Browser Alert (system dialog)
|
|
50
|
+
### Alert / Keyboard / Wait / Scroll
|
|
78
51
|
|
|
79
52
|
```
|
|
80
|
-
User click [OK] alert
|
|
81
|
-
User
|
|
82
|
-
User
|
|
83
|
-
User
|
|
53
|
+
User click [OK | Cancel] alert
|
|
54
|
+
User fill [T] alert with {{v}}
|
|
55
|
+
User see [message text] alert
|
|
56
|
+
User press Escape key | Enter on [T] field
|
|
57
|
+
User wait for N seconds | [T] dialog | [T] dialog is STATE | [T] page
|
|
58
|
+
User scroll to [T] section
|
|
59
|
+
User switch to [T] frame | [main] frame
|
|
84
60
|
```
|
|
85
61
|
|
|
86
62
|
> Alert steps must appear BEFORE the action that triggers the dialog.
|
|
87
63
|
|
|
88
|
-
###
|
|
89
|
-
|
|
90
|
-
```
|
|
91
|
-
User press Escape key # global key press
|
|
92
|
-
User press Enter on [T] field # key on element
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
### Wait
|
|
96
|
-
|
|
97
|
-
```
|
|
98
|
-
User wait for N seconds # wait timeout
|
|
99
|
-
User wait for [T] dialog # wait for element
|
|
100
|
-
User wait for [T] dialog is STATE # wait for state
|
|
101
|
-
User wait for [T] dialog with {{v}} # wait for element with text
|
|
102
|
-
User wait for [T] page # wait for navigation
|
|
103
|
-
User wait for [T] message # wait for toast/feedback
|
|
104
|
-
User wait for [T] button # wait for button to appear
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
### Scroll & Frame
|
|
108
|
-
|
|
109
|
-
```
|
|
110
|
-
User scroll to [T] section # scroll into view
|
|
111
|
-
User switch to [T] frame # enter iframe
|
|
112
|
-
User switch to [main] frame # exit iframe
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
### Assertions (8 verify patterns)
|
|
64
|
+
### Assertions (8 patterns → determines Playwright assertion)
|
|
116
65
|
|
|
117
66
|
```
|
|
118
|
-
# 1. Visibility
|
|
119
|
-
User see [T] message
|
|
120
|
-
User see [T]
|
|
121
|
-
|
|
122
|
-
#
|
|
123
|
-
User see [T]
|
|
124
|
-
User see [T]
|
|
125
|
-
User see [T]
|
|
126
|
-
|
|
127
|
-
# 3. Partial Text Match (toContainText)
|
|
128
|
-
User see [T] text contains {{v}} # partial text match
|
|
129
|
-
|
|
130
|
-
# 4. Input Value (toHaveValue)
|
|
131
|
-
User see [T] field with {{v}} # input value
|
|
132
|
-
User see [T] dropdown with {{v}} # selected value
|
|
133
|
-
User see [T] date picker with {{v}} # date value
|
|
134
|
-
User see [T] search with {{v}} # search input value
|
|
135
|
-
User see [T] slider with {{v}} # slider value
|
|
136
|
-
|
|
137
|
-
# 5. Component State
|
|
138
|
-
User see [T] button is disabled # state assertion
|
|
139
|
-
User see [T] checkbox is checked # checked state
|
|
140
|
-
User see [T] toggle is unchecked # unchecked state
|
|
141
|
-
User see [T] dialog with {{v}} is hidden # text + state combined
|
|
142
|
-
|
|
143
|
-
# 6. Attribute (toHaveAttribute — when selector YAML has `attribute` field)
|
|
144
|
-
User see [T] image with {{v}} # image src
|
|
145
|
-
User see [T] link with {{v}} # link href
|
|
146
|
-
|
|
147
|
-
# 7. Count
|
|
148
|
-
User see [T] row with {{count}} # element count
|
|
149
|
-
|
|
150
|
-
# 8. Page Context
|
|
151
|
-
User see [T] page # URL assertion
|
|
67
|
+
# 1. Visibility: User see [T] type (NEVER add "is visible") | is hidden
|
|
68
|
+
# 2. Text (toHaveText): User see [T] message | header | label with {{v}}
|
|
69
|
+
# 3. Partial (toContainText): User see [T] text contains {{v}}
|
|
70
|
+
# 4. Input (toHaveValue): User see [T] field | dropdown | date-picker | search | slider with {{v}}
|
|
71
|
+
# 5. State: User see [T] button is disabled | checkbox is checked | dialog with {{v}} is hidden
|
|
72
|
+
# 6. Attribute (toHaveAttribute): User see [T] image | link with {{v}}
|
|
73
|
+
# 7. Count: User see [T] row with {{count}}
|
|
74
|
+
# 8. Page: User see [T] page
|
|
152
75
|
```
|
|
153
76
|
|
|
154
77
|
### Table
|
|
155
78
|
|
|
156
79
|
```
|
|
157
|
-
User see [Col] column in [Table] table
|
|
158
|
-
User see [Ref] row in [Table] table with {{v}}
|
|
159
|
-
User see [Ref] row in [Table] table with {{v}} is hidden
|
|
160
|
-
User see [Table] table with {{count}}
|
|
161
|
-
User see [
|
|
162
|
-
User
|
|
163
|
-
User
|
|
164
|
-
User see [Table] table match data: # exact table match (inline DataTable)
|
|
80
|
+
User see [Col] column in [Table] table
|
|
81
|
+
User see [Ref] row in [Table] table with {{v}}
|
|
82
|
+
User see [Ref] row in [Table] table with {{v}} is hidden
|
|
83
|
+
User see [Table] table with {{count}} | is empty
|
|
84
|
+
User see [Col] column with {{v}}
|
|
85
|
+
User click [Act] button in [Table] table with {{v}}
|
|
86
|
+
User see [Table] table match data:
|
|
165
87
|
| Header1 | Header2 |
|
|
166
88
|
| {{value1}} | {{value2}} |
|
|
167
89
|
```
|
|
168
90
|
|
|
169
|
-
|
|
170
|
-
|
|
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 })`.
|
|
172
|
-
|
|
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.
|
|
91
|
+
Row scope: `see [Ref] row in [Table] table with {{v}}` enters scope. Subsequent `see [Col] column with {{v}}` checks cell in that row. Use `table match data:` for multi-row verification.
|
|
174
92
|
|
|
175
93
|
### States
|
|
176
94
|
|
|
@@ -223,6 +141,10 @@ Options: `nth` `exact` `scope` `match` `variant` `frame` `contenteditable` `colu
|
|
|
223
141
|
| `@auto` | Standard scenario, ready for automation |
|
|
224
142
|
| `@manual` | Skip in generation |
|
|
225
143
|
| `@smoke` / `@regression` | Test suite grouping |
|
|
144
|
+
| `@critical` | Priority: system unusable if fails (login, auth, core CRUD) |
|
|
145
|
+
| `@high` | Priority: major feature broken (required validation, key business rules) |
|
|
146
|
+
| `@normal` | Priority: degraded experience (UI layout, secondary flows) |
|
|
147
|
+
| `@low` | Priority: minor/cosmetic (tooltips, hover states, empty states) |
|
|
226
148
|
| `@auth:role` | Use auth storage state for role |
|
|
227
149
|
| `@no-auth` | Disable inherited auth |
|
|
228
150
|
| `@steps:name` | Define reusable step block (base scenario) |
|
|
@@ -232,6 +154,8 @@ Options: `nth` `exact` `scope` `match` `variant` `frame` `contenteditable` `colu
|
|
|
232
154
|
|
|
233
155
|
- Tool executes **only Given→When** of `@steps` scenario (skips Then)
|
|
234
156
|
- The `Given` in `@extend` scenario is the **entry assertion** (confirms state after base steps)
|
|
157
|
+
- **Entry assertion MUST use `Given User is on [X] type`** — NEVER `Given User see [X] type`
|
|
158
|
+
- `Given` keyword ONLY allows `is on` action. `see` = `Then` only.
|
|
235
159
|
- If `@steps` scenario fails, `@extend` scenario is **skipped**
|
|
236
160
|
- Name format: `snake_case` or `kebab-case` with module prefix: `@steps:kudos__open_modal`
|
|
237
161
|
|
|
@@ -240,6 +164,8 @@ Options: `nth` `exact` `scope` `match` `variant` `frame` `contenteditable` `colu
|
|
|
240
164
|
| Error | Wrong | Correct |
|
|
241
165
|
|---|---|---|
|
|
242
166
|
| Wrong keyword | `Given User click [T] button` | `When User click [T] button` |
|
|
167
|
+
| `see` after Given | `Given User see [T] heading with {{v}}` | `Then User see [T] heading with {{v}}` (or `Given User is on [T] page` for entry assertion) |
|
|
168
|
+
| Name ≠ step type | Scenario name says "modal" but step uses `dialog` | Use the **same element type** in both: "...dialog opens" + `[X] dialog` |
|
|
243
169
|
| Wrong action for type | `When User click [T] checkbox` | `When User check [T] checkbox` |
|
|
244
170
|
| press wrong target | `When User press [Submit] button` | `When User press Enter key` |
|
|
245
171
|
| uncheck radio | `When User uncheck [Male] radio` | `When User check [Female] radio` |
|
|
@@ -247,3 +173,39 @@ Options: `nth` `exact` `scope` `match` `variant` `frame` `contenteditable` `colu
|
|
|
247
173
|
| Missing `is` for state | `with {{text}} hidden` | `with {{text}} is hidden` |
|
|
248
174
|
| State as value | `with {{disabled}}` | `is disabled` |
|
|
249
175
|
| Missing target type | `fill [email] with {{v}}` | `fill [email] field with {{v}}` |
|
|
176
|
+
| Using Background | `Background: Given User is on...` | Use `@steps` + `@extend` instead |
|
|
177
|
+
| `is on` after When | `When ... And User is on [X] dialog` | `And User see [X] dialog` or separate Given |
|
|
178
|
+
|
|
179
|
+
## Background vs @steps/@extend
|
|
180
|
+
|
|
181
|
+
**Do NOT use `Background:` block.** Use `@steps` + `@extend` instead.
|
|
182
|
+
|
|
183
|
+
**Why:**
|
|
184
|
+
- `Background` runs before EVERY scenario but cannot set dialog/frame scope correctly
|
|
185
|
+
- `Background` with `When` + `And User is on [X] dialog` creates keyword mismatch (`is on` = Given, not When)
|
|
186
|
+
- `@steps` + `@extend` gives explicit control: base steps run Given→When, extending scenario starts with `Given User is on [X] dialog` (correct scope setup)
|
|
187
|
+
|
|
188
|
+
**Wrong:**
|
|
189
|
+
```gherkin
|
|
190
|
+
Background:
|
|
191
|
+
Given User is on [Kudos] page
|
|
192
|
+
When User click [Open] button
|
|
193
|
+
And User is on [Modal] dialog ← keyword mismatch
|
|
194
|
+
|
|
195
|
+
Scenario: VP-UI-001 Title visible
|
|
196
|
+
Then User see [Title] heading
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
**Correct:**
|
|
200
|
+
```gherkin
|
|
201
|
+
@steps:open_modal
|
|
202
|
+
Scenario: Open modal
|
|
203
|
+
Given User is on [Kudos] page
|
|
204
|
+
When User click [Open] button
|
|
205
|
+
Then User see [Modal] dialog
|
|
206
|
+
|
|
207
|
+
@extend:open_modal
|
|
208
|
+
Scenario: VP-UI-001 Title visible
|
|
209
|
+
Given User is on [Modal] dialog
|
|
210
|
+
Then User see [Title] heading
|
|
211
|
+
```
|
|
@@ -1,20 +1,80 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: sungen-selector-fix
|
|
3
|
-
description: 'Selector fixing strategy —
|
|
3
|
+
description: 'Selector fixing strategy — phased execution, priority-first diagnosis, targeted MCP exploration. Auto-loaded by run-test command.'
|
|
4
4
|
user-invocable: false
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
## Strategy:
|
|
7
|
+
## Strategy: Phased Execution
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Run tests in priority waves — catch fundamental issues early, fix critical paths first, let shared fixes cascade to lower-priority tests.
|
|
10
10
|
|
|
11
|
-
**
|
|
11
|
+
**Never run all tests blindly.** Always start with a smoke check.
|
|
12
12
|
|
|
13
13
|
---
|
|
14
14
|
|
|
15
|
-
##
|
|
15
|
+
## Phase 1: Smoke Check (catch fundamentals)
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
Run **up to 5 scenarios** — pick the first `@critical` or `@high` scenarios in the feature file.
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npx playwright test --grep "VP-.*-001|VP-.*-002|VP-.*-003|VP-.*-004|VP-.*-005" --reporter=line
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
**Purpose:** Detect broken fundamentals before running 50+ tests:
|
|
24
|
+
- Page selector wrong → ALL tests would fail (1 fix, not 50 diagnoses)
|
|
25
|
+
- Auth redirect → need `@no-auth` or user login
|
|
26
|
+
- Base `@steps:` scenario broken → all `@extend:` scenarios would fail
|
|
27
|
+
|
|
28
|
+
**If all 5 pass** → skip to Phase 2.
|
|
29
|
+
**If failures** → diagnose and fix (see Diagnosis & Fix below), then re-run smoke. Max 2 attempts here.
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## Phase 2: Priority Wave (@critical + @high)
|
|
34
|
+
|
|
35
|
+
Run all `@critical` and `@high` scenarios:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
npx playwright test --grep "@critical|@high" --reporter=line
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
If your Playwright config doesn't support tag grep, use scenario name grep from the feature file — collect VP IDs of `@critical` and `@high` scenarios.
|
|
42
|
+
|
|
43
|
+
**Fix only failures from this wave.** Most shared selectors (buttons, headings, navigation) get fixed here because critical/high scenarios exercise them.
|
|
44
|
+
|
|
45
|
+
Max 2 fix attempts in this phase.
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## Phase 3: Full Run (@normal + @low)
|
|
50
|
+
|
|
51
|
+
Run remaining scenarios:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
npx playwright test --reporter=line
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Many selectors already fixed from Phase 2 (shared elements). Only diagnose **new** failures — selectors that only appear in lower-priority scenarios.
|
|
58
|
+
|
|
59
|
+
Max 1 fix attempt. If `@low` scenarios still fail after fix → **report and move on**, don't loop.
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## Phase 4: Regression
|
|
64
|
+
|
|
65
|
+
One final full run to confirm all phases together:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
npx playwright test --reporter=line
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Report results. Do NOT enter another fix loop here.
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## Diagnosis & Fix (used in each phase)
|
|
76
|
+
|
|
77
|
+
### Step 1: Parse Failures
|
|
18
78
|
|
|
19
79
|
| Error pattern | Root cause | Fix target |
|
|
20
80
|
|---|---|---|
|
|
@@ -28,9 +88,7 @@ Parse Playwright error output to categorize failures:
|
|
|
28
88
|
|
|
29
89
|
**Check `test-results/` first** — Playwright captures failure screenshots automatically. Use these to diagnose before any MCP exploration.
|
|
30
90
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
## Step 2: Targeted MCP Exploration
|
|
91
|
+
### Step 2: Targeted MCP Exploration
|
|
34
92
|
|
|
35
93
|
Only when `test-results/` screenshots are insufficient:
|
|
36
94
|
|
|
@@ -41,11 +99,7 @@ Only when `test-results/` screenshots are insufficient:
|
|
|
41
99
|
|
|
42
100
|
**Never use `sungen makeauth`.** Never use `browser_evaluate` to inject cookies.
|
|
43
101
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
## Step 3: Fix Broken Selectors
|
|
47
|
-
|
|
48
|
-
For each failed selector, find the correct locator from the snapshot:
|
|
102
|
+
### Step 3: Fix Broken Selectors
|
|
49
103
|
|
|
50
104
|
Selector priority (use first applicable):
|
|
51
105
|
|
|
@@ -73,9 +127,18 @@ Common fixes:
|
|
|
73
127
|
- Element in iframe → add `frame` field
|
|
74
128
|
- Dynamic content → use `testid` or structural `role` + `nth`
|
|
75
129
|
|
|
130
|
+
### Step 4: Recompile After Fix
|
|
131
|
+
|
|
132
|
+
Always recompile before re-running:
|
|
133
|
+
```bash
|
|
134
|
+
sungen generate --screen <screen>
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
Then re-run only the current phase's failing tests, not all tests.
|
|
138
|
+
|
|
76
139
|
---
|
|
77
140
|
|
|
78
|
-
##
|
|
141
|
+
## Table Selectors
|
|
79
142
|
|
|
80
143
|
For table patterns, add table selectors with `columns` config:
|
|
81
144
|
|
|
@@ -100,7 +163,7 @@ users:
|
|
|
100
163
|
|
|
101
164
|
---
|
|
102
165
|
|
|
103
|
-
##
|
|
166
|
+
## Detail Screens with Dynamic IDs
|
|
104
167
|
|
|
105
168
|
For screens like `/admin/users/:id`:
|
|
106
169
|
1. Navigate to list page via MCP to find a real record ID
|
|
@@ -114,12 +177,13 @@ user detail:
|
|
|
114
177
|
|
|
115
178
|
---
|
|
116
179
|
|
|
117
|
-
##
|
|
180
|
+
## Attempt Budget Summary
|
|
118
181
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
182
|
+
| Phase | What runs | Max fix attempts | On failure after max |
|
|
183
|
+
|---|---|---|---|
|
|
184
|
+
| 1. Smoke | First 5 @critical/@high | 2 | Ask user — fundamentals broken |
|
|
185
|
+
| 2. Priority | All @critical + @high | 2 | Report failures, continue to Phase 3 |
|
|
186
|
+
| 3. Full | All tests | 1 | Report @low/@normal failures, continue |
|
|
187
|
+
| 4. Regression | All tests | 0 | Report final results |
|
|
124
188
|
|
|
125
|
-
|
|
189
|
+
**Total worst case: 5 fix attempts** (2+2+1), not unbounded loops.
|