@sun-asterisk/sungen 2.3.0 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/README.md +12 -13
  2. package/dist/cli/index.js +1 -1
  3. package/dist/generators/test-generator/adapters/playwright/templates/steps/actions/table-action-in-row.hbs +1 -1
  4. package/dist/generators/test-generator/adapters/playwright/templates/steps/assertions/table-column-exists.hbs +5 -1
  5. package/dist/generators/test-generator/adapters/playwright/templates/steps/assertions/table-row-exists.hbs +7 -1
  6. package/dist/generators/test-generator/adapters/playwright/templates/steps/assertions/table-row-not-exists.hbs +5 -1
  7. package/dist/generators/test-generator/patterns/interaction-patterns.d.ts.map +1 -1
  8. package/dist/generators/test-generator/patterns/interaction-patterns.js +0 -13
  9. package/dist/generators/test-generator/patterns/interaction-patterns.js.map +1 -1
  10. package/dist/generators/test-generator/patterns/table-patterns.d.ts +9 -0
  11. package/dist/generators/test-generator/patterns/table-patterns.d.ts.map +1 -1
  12. package/dist/generators/test-generator/patterns/table-patterns.js +94 -98
  13. package/dist/generators/test-generator/patterns/table-patterns.js.map +1 -1
  14. package/dist/generators/test-generator/patterns/types.d.ts +2 -0
  15. package/dist/generators/test-generator/patterns/types.d.ts.map +1 -1
  16. package/dist/generators/test-generator/step-mapper.d.ts +13 -0
  17. package/dist/generators/test-generator/step-mapper.d.ts.map +1 -1
  18. package/dist/generators/test-generator/step-mapper.js +80 -0
  19. package/dist/generators/test-generator/step-mapper.js.map +1 -1
  20. package/dist/orchestrator/ai-rules-updater.d.ts.map +1 -1
  21. package/dist/orchestrator/ai-rules-updater.js +8 -4
  22. package/dist/orchestrator/ai-rules-updater.js.map +1 -1
  23. package/dist/orchestrator/project-initializer.d.ts.map +1 -1
  24. package/dist/orchestrator/project-initializer.js +33 -2
  25. package/dist/orchestrator/project-initializer.js.map +1 -1
  26. package/dist/orchestrator/screen-manager.js +1 -1
  27. package/dist/orchestrator/screen-manager.js.map +1 -1
  28. package/dist/orchestrator/templates/ai-instructions/claude-cmd-add-screen.md +5 -5
  29. package/{src/orchestrator/templates/ai-instructions/claude-cmd-make-tc.md → dist/orchestrator/templates/ai-instructions/claude-cmd-create-test.md} +7 -6
  30. package/dist/orchestrator/templates/ai-instructions/claude-cmd-review.md +21 -0
  31. package/{src/orchestrator/templates/ai-instructions/claude-cmd-make-test.md → dist/orchestrator/templates/ai-instructions/claude-cmd-run-test.md} +2 -2
  32. package/dist/orchestrator/templates/ai-instructions/claude-config.md +65 -12
  33. package/dist/orchestrator/templates/ai-instructions/claude-skill-error-mapping.md +128 -52
  34. package/dist/orchestrator/templates/ai-instructions/claude-skill-gherkin-syntax.md +12 -43
  35. package/dist/orchestrator/templates/ai-instructions/claude-skill-selector-fix.md +67 -239
  36. package/dist/orchestrator/templates/ai-instructions/claude-skill-tc-generation.md +40 -240
  37. package/dist/orchestrator/templates/ai-instructions/claude-skill-tc-review.md +104 -0
  38. package/dist/orchestrator/templates/ai-instructions/claude-skill-viewpoint.md +186 -0
  39. package/dist/orchestrator/templates/ai-instructions/copilot-cmd-add-screen.md +4 -4
  40. package/dist/orchestrator/templates/ai-instructions/{copilot-cmd-make-tc.md → copilot-cmd-create-test.md} +8 -7
  41. package/dist/orchestrator/templates/ai-instructions/copilot-cmd-review.md +24 -0
  42. package/{src/orchestrator/templates/ai-instructions/copilot-cmd-make-test.md → dist/orchestrator/templates/ai-instructions/copilot-cmd-run-test.md} +3 -3
  43. package/dist/orchestrator/templates/ai-instructions/copilot-config.md +66 -13
  44. package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-error-mapping.md +128 -52
  45. package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-gherkin-syntax.md +12 -43
  46. package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-selector-fix.md +67 -214
  47. package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-tc-generation.md +40 -240
  48. package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-tc-review.md +104 -0
  49. package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-viewpoint.md +186 -0
  50. package/dist/orchestrator/templates/readme.md +4 -4
  51. package/package.json +1 -1
  52. package/src/cli/index.ts +1 -1
  53. package/src/generators/test-generator/adapters/playwright/templates/steps/actions/table-action-in-row.hbs +1 -1
  54. package/src/generators/test-generator/adapters/playwright/templates/steps/assertions/table-column-exists.hbs +5 -1
  55. package/src/generators/test-generator/adapters/playwright/templates/steps/assertions/table-row-exists.hbs +7 -1
  56. package/src/generators/test-generator/adapters/playwright/templates/steps/assertions/table-row-not-exists.hbs +5 -1
  57. package/src/generators/test-generator/patterns/interaction-patterns.ts +0 -14
  58. package/src/generators/test-generator/patterns/table-patterns.ts +98 -111
  59. package/src/generators/test-generator/patterns/types.ts +2 -0
  60. package/src/generators/test-generator/step-mapper.ts +87 -1
  61. package/src/orchestrator/ai-rules-updater.ts +8 -4
  62. package/src/orchestrator/project-initializer.ts +38 -2
  63. package/src/orchestrator/screen-manager.ts +1 -1
  64. package/src/orchestrator/templates/ai-instructions/claude-cmd-add-screen.md +5 -5
  65. package/{dist/orchestrator/templates/ai-instructions/claude-cmd-make-tc.md → src/orchestrator/templates/ai-instructions/claude-cmd-create-test.md} +7 -6
  66. package/src/orchestrator/templates/ai-instructions/claude-cmd-review.md +21 -0
  67. package/{dist/orchestrator/templates/ai-instructions/claude-cmd-make-test.md → src/orchestrator/templates/ai-instructions/claude-cmd-run-test.md} +2 -2
  68. package/src/orchestrator/templates/ai-instructions/claude-config.md +65 -12
  69. package/src/orchestrator/templates/ai-instructions/claude-skill-error-mapping.md +128 -52
  70. package/src/orchestrator/templates/ai-instructions/claude-skill-gherkin-syntax.md +12 -43
  71. package/src/orchestrator/templates/ai-instructions/claude-skill-selector-fix.md +67 -239
  72. package/src/orchestrator/templates/ai-instructions/claude-skill-tc-generation.md +40 -240
  73. package/src/orchestrator/templates/ai-instructions/claude-skill-tc-review.md +104 -0
  74. package/src/orchestrator/templates/ai-instructions/claude-skill-viewpoint.md +186 -0
  75. package/src/orchestrator/templates/ai-instructions/copilot-cmd-add-screen.md +4 -4
  76. package/src/orchestrator/templates/ai-instructions/{copilot-cmd-make-tc.md → copilot-cmd-create-test.md} +8 -7
  77. package/src/orchestrator/templates/ai-instructions/copilot-cmd-review.md +24 -0
  78. package/{dist/orchestrator/templates/ai-instructions/copilot-cmd-make-test.md → src/orchestrator/templates/ai-instructions/copilot-cmd-run-test.md} +3 -3
  79. package/src/orchestrator/templates/ai-instructions/copilot-config.md +66 -13
  80. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-error-mapping.md +128 -52
  81. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-gherkin-syntax.md +12 -43
  82. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-selector-fix.md +67 -214
  83. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-tc-generation.md +40 -240
  84. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-tc-review.md +104 -0
  85. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-viewpoint.md +186 -0
  86. package/src/orchestrator/templates/readme.md +4 -4
  87. package/dist/generators/test-generator/adapters/playwright/templates/steps/assertions/table-cell-by-filter.hbs +0 -2
  88. package/dist/generators/test-generator/adapters/playwright/templates/steps/assertions/table-cell-by-index.hbs +0 -2
  89. package/src/generators/test-generator/adapters/playwright/templates/steps/assertions/table-cell-by-filter.hbs +0 -2
  90. package/src/generators/test-generator/adapters/playwright/templates/steps/assertions/table-cell-by-index.hbs +0 -2
@@ -1,244 +1,72 @@
1
1
  ---
2
2
  name: sungen-tc-generation
3
- description: 'Exhaustive test case generation strategy — section-focused, 20+ scenarios per viewpoint per section, Gherkin + test-data only, no selectors. Use this when creating test cases for a screen with Gherkin scenarios.'
3
+ description: 'Test case generation strategy — section-focused, viewpoint-driven, Gherkin + test-data only. Auto-loaded by create-test command.'
4
4
  user-invocable: false
5
5
  ---
6
6
 
7
- ## Test Case Generation Strategy
7
+ ## Goal
8
8
 
9
- ### Goal
9
+ Generate **focused test cases per screen section** with **20+ scenarios per viewpoint**. Output `.feature` + `test-data.yaml` only — selectors are deferred to `/sungen:run-test`.
10
10
 
11
- Generate **focused, high-quality test cases per screen section** with **at least 20 scenarios per viewpoint category**. Output only `.feature` and `test-data.yaml` — selectors are deferred to `/sungen:make-test`.
11
+ ## Update Mode
12
12
 
13
- ### Update Mode (existing test cases)
13
+ When `.feature` already has scenarios, summarize and ask:
14
+ 1. **Add new sections** — append, continue numbering
15
+ 2. **Add viewpoints** — add to existing sections
16
+ 3. **Replace all** — overwrite
14
17
 
15
- When the `.feature` file already has scenarios, read it first and summarize what exists:
18
+ For append: read highest `VP-<CAT>-<NNN>`, continue from next number. Never modify existing scenarios.
16
19
 
17
- > This screen already has **57 scenarios**:
18
- > - Section: Filters & Search — 22 scenarios (UI: 7, VAL: 8, LOGIC: 5, SEC: 2)
19
- > - Section: User Table — 23 scenarios (UI: 13, LOGIC: 11, SEC: 3)
20
- > - Section: Pagination — 12 scenarios (UI: 4, LOGIC: 6, SEC: 2)
21
- >
22
- > What would you like to do?
23
- > 1. **Add new sections** — keep existing, add tests for uncovered sections
24
- > 2. **Add viewpoints to existing sections** — e.g., more edge cases, more security tests
25
- > 3. **Replace all** — start fresh
20
+ ## Requirements-Driven Generation
26
21
 
27
- For options 1 and 2:
28
- - Read the existing scenarios to understand current coverage and the highest `VP-<CAT>-<NNN>` number
29
- - Continue numbering from the next available number (e.g., if last is `VP-UI-024`, start at `VP-UI-025`)
30
- - **Append** new scenarios to the end of the relevant section never modify or delete existing scenarios
31
- - Merge new test-data variables into `test-data.yaml` without overwriting existing ones
22
+ When `qa/screens/<screen>/requirements/` exists:
23
+ - **`spec.md`** primary: sections, field constraints, validation messages, business rules, states
24
+ - **`ui/`** supplementary: screenshots for layout/visual context
25
+ - **`notes.md`**supplementary: edge cases, known issues
32
26
 
33
- For option 3:
34
- - Overwrite both `.feature` and `test-data.yaml` completely
27
+ Requirements improve every viewpoint: exact error messages for VAL, business rules for LOGIC, role permissions for SEC.
35
28
 
36
- ### Requirements-Driven Generation
29
+ If also exploring live page: verify spec vs actual, flag mismatches, capture exact text.
37
30
 
38
- When `qa/screens/<screen>/requirements/` exists, use it as the **primary source** for test case generation. This produces higher quality tests because requirements contain exact validation messages, field constraints, business rules, and states.
31
+ ## Screen Input Sources
39
32
 
40
- #### Reading Requirements
33
+ **Recommended** (in priority order):
34
+ 1. **Figma designs** — use Figma MCP to read design context, screenshots, and component metadata
35
+ 2. **UI images** — screenshots or mockups in `qa/screens/<screen>/requirements/ui/`
36
+ 3. **`spec.md`** — written specification with sections, fields, validation rules
41
37
 
42
- 1. **`spec.md`** (primary) structured screen specification:
43
- - **Sections** → map directly to test case sections
44
- - **Fields table** → generate boundary value tests (min/max constraints), required field tests, format tests
45
- - **Validation Rules table** → generate exact assertion tests using the error messages as `{{test_data}}` values
46
- - **Actions table** → generate interaction tests (click, submit, navigate)
47
- - **States table** → generate state transition tests (loading, error, success, disabled)
48
- - **Business Rules** → generate logic tests (limits, permissions, conditional behavior)
49
- - **Accessibility** → generate tab-order and aria tests
38
+ **Optional**: **Live page scan** via Playwright MCP — useful to verify specs vs actual UI, capture real data (error messages, labels). If auth needed → ask user to log in manually via MCP browser.
50
39
 
51
- 2. **`ui/`** (supplementary) screenshots, mockups, design images:
52
- - Read images to understand layout, element positions, visual states
53
- - Cross-reference with spec.md — identify elements visible in UI but missing from spec
54
- - Use for UI/UX viewpoint tests (element visibility, placement, responsive)
40
+ **Single screen focus**: one URL = one screen. Don't explore sibling paths. Modals on same page = part of this screen.
55
41
 
56
- 3. **`notes.md`** (supplementary) — free-form edge cases, decisions, known issues:
57
- - Extract edge cases → add to test coverage
58
- - Flag known issues → add TODO scenarios
42
+ ### Capture Real Data
59
43
 
60
- #### How Requirements Improve Each Viewpoint
44
+ When exploring live page or reading Figma designs, actively collect to hardcode in `test-data.yaml`:
45
+ - User names, option labels, card content, error messages, counter keywords
46
+ - **Hardcode first, @manual last** — stale data that fails fast > @manual that never runs
61
47
 
62
- | Viewpoint | Without Requirements | With Requirements |
63
- |-----------|---------------------|-------------------|
64
- | **UI/UX** | "see [Field] is visible" (generic) | "see [Field] field" + verify label, placeholder, default from spec |
65
- | **Validation** | "submit empty → see error" (vague) | "submit empty email → see {{email_required_error}}" with exact message from spec |
66
- | **Logic** | Based on observed page behavior | Business rules drive specific tests (lockout after N attempts, session expiry) |
67
- | **Security** | Generic injection tests | Role-based tests from auth requirements, permission-specific scenarios |
48
+ ## Section Identification
68
49
 
69
- #### Merging Requirements + Live Page
50
+ Identify sections from page patterns. Use `sungen-viewpoint` skill for the 7 pattern types (Form, Table, Search, Filter, Pagination, Modal, List/Card). Present sections and ask user which to focus on.
70
51
 
71
- If the user also explores the live page:
72
- - **Verify** spec.md against actual page — flag mismatches (e.g., field in spec but not on page)
73
- - **Supplement** — discover elements on page not in spec (e.g., footer links, tooltips)
74
- - **Exact text** — capture actual placeholder text, button labels, error messages from live page and update test-data accordingly
52
+ ## Viewpoint & Coverage
75
53
 
76
- ### Page Exploration & Auth
54
+ Use `sungen-viewpoint` skill for per-pattern checklists across 4 viewpoints: UI/UX, Data & Validate, Logic, Security.
77
55
 
78
- Use Playwright MCP to explore the live page. If the page requires authentication:
79
- 1. `browser_navigate` to `baseURL` (from `playwright.config.ts`)
80
- 2. If redirected to login, ask the user to log in manually:
81
- > "This page requires login. Please log in using the browser. Confirm when you're done."
82
- 3. Once confirmed, `browser_navigate` to the target page and take `browser_snapshot`
56
+ Generate **20+ scenarios per applicable viewpoint**. Skip viewpoints truly N/A.
83
57
 
84
- **Never use `sungen makeauth`.** Always let the user log in manually via the MCP browser.
58
+ **Validation rule**: capture actual error messages from live page or spec.md. Use `User see {{error_var}}` — never assert just "is visible".
85
59
 
86
- ### Single Screen Focus
87
-
88
- **One screen = one URL path.** Only generate test cases for elements visible on the target page.
89
-
90
- - Navigate to the target screen path — do NOT explore sibling paths (e.g., testing `/admin/users` should not scan `/admin/review`)
91
- - Take ONE snapshot of the target page — do not click links to navigate away
92
- - If a link goes to a different path, test only that the link is visible and clickable — the destination page is a SEPARATE screen
93
- - If a modal/dialog opens on the same page, that IS part of this screen
94
- - Each screen gets its own `qa/screens/<name>/` directory — never mix screens
95
-
96
- #### Detail screens with dynamic IDs
97
-
98
- For screens like `/admin/users/:id` or `/products/:slug`, write Gherkin normally (`User is on [User Detail] page`). The real ID will be resolved during `/sungen-make-test` when selectors are generated from the live page. See `sungen-selector-fix` skill for details.
99
-
100
- ### Section-Focused Approach
101
-
102
- After exploring the page, identify distinct **sections** based on common UI patterns. Present them as a numbered list and ask the user which to focus on.
103
-
104
- #### Common Section Patterns
105
-
106
- Identify which patterns exist on the screen:
107
-
108
- | Pattern | Elements to look for |
109
- |---|---|
110
- | **Header / Navigation** | Logo, nav links, breadcrumbs, user menu, notifications, language selector |
111
- | **Form** | Input fields, dropdowns, checkboxes, radio buttons, date pickers, file uploads, submit/cancel buttons |
112
- | **Data Table** | Column headers, sortable columns, row data, row actions, bulk actions, column filters |
113
- | **Search & Filters** | Search input, filter dropdowns, clear/reset, active filter tags |
114
- | **Card Grid / List** | Cards with title/image/description, load more, infinite scroll |
115
- | **Pagination** | Previous/next buttons, page numbers, page size selector, total count |
116
- | **Tabs / Accordion** | Tab headers, tab panels, expand/collapse |
117
- | **Modal / Dialog** | Open trigger, close button, form inside modal, confirmation dialog |
118
- | **Sidebar** | Stats, quick actions, related links, mini widgets |
119
- | **File Upload** | Drop zone, file picker, progress bar, file list, delete |
120
- | **Rich Text Editor** | Toolbar, content area, formatting buttons, preview |
121
- | **Carousel / Slider** | Prev/next arrows, dots/indicators, auto-play, swipe |
122
-
123
- Example output:
124
-
125
- > This screen has the following sections:
126
- > 1. Header (logo, navigation tabs, user menu)
127
- > 2. Create Form (name, email, role dropdown, department, submit)
128
- > 3. User Table (columns: name, email, status, actions; sortable, filterable)
129
- > 4. Pagination (previous/next, page indicator)
130
- >
131
- > Which sections do you want to create test cases for? (e.g., "2, 3" or "all")
132
-
133
- For each selected section, generate **20+ scenarios per applicable viewpoint**. Skip viewpoint categories that don't apply.
134
-
135
- Present a test plan summary and wait for user confirmation before generating files.
136
-
137
- ### Assertion Quality Rules
138
-
139
- **CRITICAL** — these rules prevent shallow, low-value test cases:
140
-
141
- 1. **NEVER use `is visible`** — `User see [T] type` already asserts visibility. Writing `is visible` is redundant noise. Only use `is hidden` to assert something is NOT shown.
142
- 2. **Group related assertions** — one scenario can have 3-7 `Then/And` steps. Don't waste a whole scenario on one element. Group elements that verify the same concern.
143
- 3. **Assert content, not just existence** — verify values, text, states, not just "it's there":
144
- - `User see [Title] heading with {{page_title}}` — verify text
145
- - `User see [Email] field with {{default_email}}` — verify default value
146
- - `User see [Submit] button is disabled` — verify state
147
- - `User see [Error] message with {{error_text}}` — verify exact error
148
- 4. **Every assertion must have test value** — if you write `User see [T] type`, ask: what EXACTLY should the user see? Add `with {{value}}` or `is state` whenever the expected content/state is known.
149
-
150
- **Bad** (shallow — just checks existence):
151
- ```gherkin
152
- Scenario: VP-UI-001 Email field is visible
153
- Given User is on [Login] page
154
- Then User see [Email] field is visible
155
-
156
- Scenario: VP-UI-002 Password field is visible
157
- Given User is on [Login] page
158
- Then User see [Password] field is visible
159
- ```
160
-
161
- **Good** (rich — verifies content, states, groups related checks):
162
- ```gherkin
163
- Scenario: VP-UI-001 Login form displays all fields with correct defaults
164
- Given User is on [Login] page
165
- Then User see [Login] heading with {{login_title}}
166
- And User see [Email] field
167
- And User see [Password] field
168
- And User see [Remember me] checkbox is unchecked
169
- And User see [Submit] button is enabled
170
- And User see [Forgot password] link
171
- ```
172
-
173
- ### Viewpoint Categories
174
-
175
- | VP Category | Description |
176
- |---|---|
177
- | **UI/UX** | Default appearance, default values/text, default states. Group related elements per scenario. |
178
- | **Validation** | Input validation, error messages, edge cases. **Assert exact error messages via `User see [T] with {{error_var}}`** — store texts in test-data.yaml. |
179
- | **Logic** | Business logic, interactions, state changes |
180
- | **Security** | Auth guards, injection, permission checks |
181
-
182
- ### Coverage Checklist per Section Pattern
183
-
184
- #### Form sections
185
- - **UI/UX**: All fields + labels + default values in 1-2 grouped scenarios. Default states (button enabled/disabled, checkbox unchecked). Placeholder text via `with {{placeholder}}`.
186
- - **Validation**: Empty submit → verify all error messages. Each required field empty individually → verify specific error. Invalid formats → verify specific error. Boundary values (min/max length). Special chars, unicode, XSS, SQL injection.
187
- - **Logic**: Successful submit → verify success state/redirect. Edit existing → verify pre-filled values. Cancel → verify form resets. Field dependencies (show/hide).
188
- - **Security**: Unauthorized submit, role-based field visibility, input sanitization
189
-
190
- #### Data Table sections
191
- - **UI/UX**: All column headers in one scenario (`User see [Col] column in [Table] table`). Row data displays with correct values. Empty state message. Action buttons per row.
192
- - **Logic**: Sort ascending/descending. Filter by column. Search. Row actions (edit/delete/view). Bulk select + action.
193
- - **Security**: Action permissions per role
194
-
195
- #### Search & Filter sections
196
- - **UI/UX**: Search field + filter buttons + clear button states in one scenario
197
- - **Validation**: Empty search, special chars, injection, long text, unicode
198
- - **Logic**: Apply/clear single filter, combine filters, no results state with message
199
- - **Security**: Injection via search/filter params
200
-
201
- #### Pagination sections
202
- - **UI/UX**: Page indicator + button states (previous disabled on page 1, next enabled)
203
- - **Logic**: Navigate pages, boundary behavior, indicator updates
204
-
205
- #### Modal / Dialog sections
206
- - **UI/UX**: Modal content + all fields + close button in one scenario
207
- - **Validation**: Field validation inside modal with exact errors
208
- - **Logic**: Open/close methods (X, Escape, overlay), submit success/error behavior
209
-
210
- #### Tabs / Accordion sections
211
- - **UI/UX**: All tab labels + active tab highlighted + default tab content
212
- - **Logic**: Switch tabs → verify content changes, accordion expand/collapse
213
-
214
- ### General Coverage Dimensions (aim for 20+ total per viewpoint)
215
-
216
- **Happy paths (3-5):** Standard flow with full assertion of result state
217
- **Edge cases (5-8):** Empty, max length, special chars, unicode, whitespace, boundary values
218
- **Negative cases (3-5):** Invalid format, missing required, wrong type, exact error messages
219
- **State transitions (2-4):** Before/after action, verify both old and new state
220
- **Combinatorial (2-4):** Multiple invalid fields, valid+invalid combos
221
-
222
- ### SPA Wait-For Steps
223
-
224
- If the page is an SPA (Next.js, Nuxt, React Router, etc.), add a `wait for` step after navigation:
60
+ ## SPA Wait-For Steps
225
61
 
226
62
  ```gherkin
227
63
  Given User is on [Screen] page
228
64
  And User wait for [Page Title] heading is visible
229
65
  ```
230
66
 
231
- For scenarios needing dynamic data, add a second wait:
67
+ ## Output Format
232
68
 
233
- ```gherkin
234
- And User wait for [Data Element] button is visible
235
- ```
236
-
237
- ### Output Files
238
-
239
- **1. Feature file** — `qa/screens/<screen>/features/<screen>.feature`
240
-
241
- Group by section, then by viewpoint within each section:
69
+ **Feature file** — `qa/screens/<screen>/features/<screen>.feature`
242
70
 
243
71
  ```gherkin
244
72
  @auth:role
@@ -252,20 +80,15 @@ Feature: <Screen> Screen
252
80
 
253
81
  Scenario: VP-UI-001 Form displays all fields with correct defaults
254
82
  Given User is on [Create User] page
255
- Then User see [Create User] heading with {{form_title}}
256
- And User see [Name] field
83
+ Then User see [Name] field
257
84
  And User see [Email] field
258
- And User see [Role] dropdown with {{default_role}}
259
85
  And User see [Submit] button is disabled
260
- And User see [Cancel] button is enabled
261
86
 
262
87
  # --- Validation ---
263
88
 
264
89
  Scenario: VP-VAL-001 Submit with all empty fields shows errors
265
- Given User is on [Create User] page
266
90
  When User click [Submit] button
267
91
  Then User see [Name error] message with {{name_required_error}}
268
- And User see [Email error] message with {{email_required_error}}
269
92
 
270
93
  # ============================================================
271
94
  # Section: User Table
@@ -274,36 +97,13 @@ Feature: <Screen> Screen
274
97
  # --- UI/UX ---
275
98
 
276
99
  Scenario: VP-UI-010 Table displays all columns
277
- Given User is on [Users] page
278
100
  Then User see [Name] column in [Users] table
279
101
  And User see [Email] column in [Users] table
280
102
  And User see [Status] column in [Users] table
281
- And User see [Actions] column in [Users] table
282
103
  ```
283
104
 
284
- **Naming convention:** `VP-<CATEGORY>-<NNN>` prefix in Scenario name.
285
-
286
- **2. Test data file** — `qa/screens/<screen>/test-data/<screen>.yaml`
287
-
288
- Group variables by section:
289
-
290
- ```yaml
291
- # ============================================================
292
- # Create User Form
293
- # ============================================================
294
- valid_name: 'John Doe'
295
- valid_email: 'john@example.com'
296
- empty_input: ''
297
- special_chars: '!@#$%^&*()'
298
-
299
- # ============================================================
300
- # User Table
301
- # ============================================================
302
- sort_column: 'Name'
303
- search_term: 'John'
304
- ```
105
+ **Naming**: `VP-<CATEGORY>-<NNN>` prefix.
305
106
 
306
- ### Do NOT Generate
107
+ **Test data** `qa/screens/<screen>/test-data/<screen>.yaml`, grouped by section.
307
108
 
308
- - `selectors.yaml` this is created during `/sungen:make-test`
309
- - Playwright code — sungen compiles Gherkin to Playwright
109
+ **Do NOT generate**: `selectors.yaml` (created during run-test), Playwright code (sungen compiles).
@@ -0,0 +1,104 @@
1
+ ---
2
+ name: sungen-tc-review
3
+ description: 'Test case review — scoring rubric, quality rules, checklist. Auto-loaded by review command.'
4
+ user-invocable: false
5
+ ---
6
+
7
+ ## Scoring (3 dimensions, 100 points total)
8
+
9
+ **>= 60%**: PASS | **< 60%**: FAIL — guide improvements
10
+
11
+ ### Syntax (30 pts)
12
+
13
+ | Check | Pts |
14
+ |---|---|
15
+ | Steps match `sungen-gherkin-syntax` patterns | 10 |
16
+ | Correct `[Ref] type with {{value}}` structure | 5 |
17
+ | Given = setup, When = action, Then = assertion | 5 |
18
+ | All `{{variables}}` exist in test-data.yaml | 5 |
19
+ | Valid tags, no duplicate scenarios | 5 |
20
+
21
+ ### Coverage (40 pts)
22
+
23
+ | Dimension | Pts | Min scenarios |
24
+ |---|---|---|
25
+ | Happy paths | 8 | 3-5 |
26
+ | Negative cases | 8 | 3-5 |
27
+ | Edge cases | 8 | 5-8 |
28
+ | Boundary values | 6 | 3-5 |
29
+ | State transitions | 5 | 2-4 |
30
+ | Combinatorial | 5 | 2-4 |
31
+
32
+ Score: `(dimensions_covered / 6) * 40`. Per-pattern checklists → `sungen-viewpoint` skill.
33
+
34
+ ### Viewpoint (30 pts)
35
+
36
+ | Check | Pts |
37
+ |---|---|
38
+ | All applicable VP present (UI/VAL/LOGIC/SEC) | 10 |
39
+ | Correct classification | 8 |
40
+ | `VP-<CAT>-<NNN>` naming + section grouping | 8 |
41
+ | Assertion quality (see rules below) | 4 |
42
+
43
+ **Classification**: UI = static/always-same appearance. VAL = input validation/errors. LOGIC = behavior/state changes (includes persisted state without When). SEC = auth/permissions.
44
+
45
+ ---
46
+
47
+ ## Quality Rules
48
+
49
+ ### Assertion Quality
50
+
51
+ 1. **No bare `is visible`** — `User see [T] type` already asserts visibility. Only use `is hidden` for negation.
52
+ 2. **Assert content, not existence** — add `with {{value}}` or `is state`. Every assertion answers: what EXACTLY should the user see?
53
+ 3. **Group related assertions** — one scenario can have 3-7 Then/And steps. Don't waste a scenario on one element.
54
+
55
+ ### Action-Result Coherence
56
+
57
+ 1. **`When click [X]`** → Then must assert a **new element** (dialog, dropdown, page) or **state change** on X (disabled, checked). Never assert X unchanged.
58
+ 2. **`When fill [X]`** → Then must assert the **visible result** (search results, validation error). Don't re-assert the field value.
59
+ 3. **UI-only scenarios** (no action needed) → use Given + Then without When.
60
+ 4. **Scenario name must match the assertion**, not the action.
61
+
62
+ ### @manual Rules
63
+
64
+ Only use `@manual` when environment can't be set up automatically:
65
+ - Real files on disk, network simulation, backend-only state, timing-dependent
66
+
67
+ Do NOT mark `@manual` when data is visible in snapshot or documented in spec — hardcode it in test-data.yaml.
68
+
69
+ `@manual` scenarios must still have complete Given/When/Then + comment explaining why manual.
70
+
71
+ ---
72
+
73
+ ## Checklist (auto-fix on detection)
74
+
75
+ 1. **Redundant scenarios** — keep stronger assertion, remove weaker duplicate
76
+ 2. **Misclassified VP** — UI tests behavior? Move to LOGIC. Logic tests appearance? Move to UI
77
+ 3. **Dynamic content** — exact match on counters/timestamps? Use `contains` instead
78
+ 4. **Duplicate across sections** — SEC scenario identical to UI? Remove duplicate
79
+ 5. **Always-enabled elements** — `is enabled` on never-disabled element? Remove
80
+ 6. **Test-data completeness** — every `{{var}}` must exist in test-data.yaml
81
+ 7. **Missing negative/boundary** — every form section needs at least: empty field, invalid format, boundary value
82
+
83
+ ---
84
+
85
+ ## Output Format
86
+
87
+ ```markdown
88
+ ## Review: <screen>
89
+
90
+ | Dimension | Score | Max |
91
+ |---|---|---|
92
+ | Syntax | <n> | 30 |
93
+ | Coverage | <n> | 40 |
94
+ | Viewpoint | <n> | 30 |
95
+ | **Total** | **<n>%** | **100** |
96
+
97
+ ### Issues
98
+ 1. [SYNTAX] ...
99
+ 2. [COVERAGE] ...
100
+ 3. [VIEWPOINT] ...
101
+
102
+ ### Recommendations (if < 60%)
103
+ - ...
104
+ ```
@@ -0,0 +1,186 @@
1
+ ---
2
+ name: sungen-viewpoint
3
+ description: '7 UI patterns x 4 viewpoints — structured checklist for test case generation and review. Auto-loaded by make-tc and review commands.'
4
+ user-invocable: false
5
+ ---
6
+
7
+ ## 4 Viewpoints
8
+
9
+ | VP | Focus | Keyword |
10
+ |---|---|---|
11
+ | **UI/UX** | Interface states, layout, feedback | VP-UI |
12
+ | **Data & Validate** | Input constraints, data integrity, error messages | VP-VAL |
13
+ | **Logic** | Business rules, interactions, state changes | VP-LOGIC |
14
+ | **Security** | Auth, injection, permissions | VP-SEC |
15
+
16
+ ---
17
+
18
+ ## 1. Form & Inputs
19
+
20
+ **UI/UX**
21
+ - Field States: disabled/readonly fields are dimmed and locked
22
+ - Button States: Submit disabled when invalid, enabled when valid
23
+ - Loading States: Spinner + block UI while waiting for server
24
+ - Keyboard Navigation: Tab order correct, Enter submits form
25
+
26
+ **Data & Validate**
27
+ - Requirements: required field blank shows error, optional allowed blank
28
+ - Boundaries & Types: min/max length, format (email, number) with error messages
29
+ - Whitespace: trims excess whitespace or errors on spaces-only
30
+ - Error Messaging: error at correct location, disappears on correction (Error Recovery)
31
+
32
+ **Logic**
33
+ - Dependencies: Field A value determines Field B status/data
34
+ - Submission Control: prevent double submit (disable button after first click)
35
+ - Success Flow: redirect / success toast / reset form
36
+ - Failure Flow: server error retains form data + shows system error
37
+
38
+ **Security**
39
+ - Injection Protection: XSS/SQL injection sanitized to plain text, never executed
40
+
41
+ ---
42
+
43
+ ## 2. Data Table
44
+
45
+ **UI/UX**
46
+ - Empty State: clear message when no data, layout intact
47
+ - Loading State: skeleton/spinner, table interaction locked during fetch
48
+ - Layout & Truncation: long content truncated with tooltip, column width stable
49
+ - Sticky Elements: fixed header on vertical scroll, fixed action column on horizontal scroll
50
+
51
+ **Data & Validate**
52
+ - Consistency: total record count on UI matches server data
53
+ - Row Limit: displayed rows never exceed page size/limit
54
+ - Cell Integrity: cell data matches database, correct format (date, currency, status)
55
+
56
+ **Logic**
57
+ - Sorting: column sort refreshes data with correct order, updates header icon
58
+ - Row Actions: Edit/Delete/View buttons act on correct row ID
59
+
60
+ **Security**
61
+ - UI-level RBAC: hide sensitive columns or privileged buttons without authority
62
+ - XSS Rendering: malicious code in database displayed as plain text
63
+
64
+ ---
65
+
66
+ ## 3. Search
67
+
68
+ **UI/UX**
69
+ - No Results: "No results found" message, list empty, Clear button visible
70
+ - Loading State: spinner/skeleton, list dimmed, interaction locked
71
+ - Clear Action: search box empties, list reloads default data
72
+
73
+ **Data & Validate**
74
+ - Cleanup: auto-trim whitespace, results match cleaned keyword
75
+ - Input Limits: prevent input beyond max length or show error
76
+ - Normalization: case-insensitive matching, handles Vietnamese accents
77
+
78
+ **Logic**
79
+ - Matching: partial/exact match returns correct results, no 500 errors
80
+ - Multi-keyword: results based on AND/OR logic
81
+ - Performance: debounce ~300ms before API call
82
+
83
+ **Security**
84
+ - Injection: XSS/SQL encoded as plain text, never executed
85
+ - Wildcards: %, _, * treated as normal text (escaped)
86
+
87
+ ---
88
+
89
+ ## 4. Filter
90
+
91
+ **UI/UX**
92
+ - Feedback: selected filters displayed as tags/badges
93
+ - Persistence: collapse/expand retains selected values
94
+ - Conflicts: conflicting conditions show "No data" message, header layout intact
95
+
96
+ **Data & Validate**
97
+ - Range Validation: start > end or min > max shows field error, Apply button disabled
98
+ - Dropdown Integrity: options match 100% of actual data, hide unauthorized values
99
+
100
+ **Logic**
101
+ - Logic AND/OR: results satisfy correct filter logic, Total Count updated
102
+ - Dependent Filters: selecting Filter A updates Filter B options
103
+ - Reset & Navigation: reset returns original data or preserves state depending on action
104
+
105
+ **Security**
106
+ - URL Manipulation: erroneous URL params ignored, defaults assigned, no 500 error
107
+
108
+ ---
109
+
110
+ ## 5. Pagination
111
+
112
+ **UI/UX**
113
+ - Boundary States: Previous/First disabled on page 1, Next/Last disabled on last page
114
+ - Active & Loading: active page highlighted, loading effect during page transition
115
+ - Hidden State: pagination bar hidden when data fits one page
116
+
117
+ **Data & Validate**
118
+ - Label Consistency: "Viewing X of Y" matches actual data
119
+ - Zero Records: pagination hidden, empty state displayed
120
+
121
+ **Logic**
122
+ - Navigation: loads correct dataset for page (page 2, limit 10 = records 11-20)
123
+ - Change Page Size: shows correct quantity, resets to page 1
124
+ - Interaction Resets: new search/filter resets to page 1
125
+ - Delete Fallback: deleting all records on last page pushes to previous page
126
+
127
+ **Security**
128
+ - URL Manipulation: invalid page/size in URL fallbacks to defaults, no server crash
129
+
130
+ ---
131
+
132
+ ## 6. Modal / Dialog
133
+
134
+ **UI/UX**
135
+ - Overlay & Backdrop: centered modal, backdrop blur, background scroll locked
136
+ - Focus Trapping: Tab key cycles only within modal elements
137
+ - Responsive: modal resizes, action buttons always visible or scrollable
138
+
139
+ **Data & Validate**
140
+ - Dismiss Actions: close via X, Cancel, Escape, backdrop click. Resets data on reopen
141
+
142
+ **Logic**
143
+ - Submissions: action button shows loading, modal closes on success, background data updated
144
+ - Failure: modal stays open on API error, shows error message, retains entered data
145
+ - Stacked Modals: Modal B over A has higher z-index, closing B keeps A intact
146
+
147
+ **Security**
148
+ - Reload & Security: handles deep linking if present, removes HTML from DOM on close (protect sensitive data)
149
+
150
+ ---
151
+
152
+ ## 7. List / Card
153
+
154
+ **UI/UX**
155
+ - Visual States: empty state when empty, skeleton when loading, hover effect (shadow/scale) on card
156
+ - Content: text truncation without breaking card height, placeholder image on broken image
157
+
158
+ **Data & Validate**
159
+ - Integrity: data fields (price, status, tag) 100% accurate vs system
160
+ - Total Count: matches actual database count after filtering
161
+
162
+ **Logic**
163
+ - Navigation: clicking card navigates to correct detail page
164
+ - Direct Actions: Like/Add to Cart updates immediately without reloading list
165
+ - Loading Flows: Load More / Infinite Scroll appends records, maintains scroll position
166
+ - Layout Toggle: Grid/List view switch changes UI but preserves data
167
+
168
+ **Security**
169
+ - RBAC & Resilience: hide sensitive data/privileged buttons from DOM. Network loss shows error + "Try again" button
170
+
171
+ ---
172
+
173
+ ## Security Tag Rules
174
+
175
+ For VP-SEC scenarios testing **unauthorized access** (no login, wrong role, direct URL access):
176
+ - Use **`@no-auth`** tag — this runs the test without authentication, which is exactly what you want to verify.
177
+ - Do NOT use `@manual` for these — they are automatable with `@no-auth`.
178
+
179
+ ```gherkin
180
+ @no-auth
181
+ Scenario: VP-SEC-001 Unauthenticated user cannot access admin page
182
+ Given User is on [Admin] page
183
+ Then User see [Login] page
184
+ ```
185
+
186
+ Use `@manual` only when the environment truly cannot be set up automatically (e.g., third-party OAuth, physical device).
@@ -39,7 +39,7 @@ sungen generate → compiles Gherkin + selectors + data → Playwright .spec.ts
39
39
  ```
40
40
  Step 1 Step 2 Step 3
41
41
  ┌──────────┐ ┌──────────┐ ┌──────────┐
42
- │ /add- │────────▶│ /make-tc │────────▶│ /make- │
42
+ │ /add- │────────▶│ /create-test │────────▶│ /make- │
43
43
  │ screen │ │ │ │ test │
44
44
  └──────────┘ └──────────┘ └──────────┘
45
45
  Scaffold Pick sections Generate
@@ -63,7 +63,7 @@ Scaffolds `qa/screens/<name>/` with empty feature, selectors, test-data, and req
63
63
 
64
64
  | Claude Code | GitHub Copilot (VS Code) |
65
65
  |---|---|
66
- | `/sungen:make-tc login` | `/sungen-make-tc login` |
66
+ | `/sungen:create-test login` | `/sungen-create-test login` |
67
67
 
68
68
  AI acts as a **Senior QA Engineer**:
69
69
  1. Reads `requirements/spec.md` for screen specs (fields, validation, business rules, states)
@@ -76,7 +76,7 @@ AI acts as a **Senior QA Engineer**:
76
76
 
77
77
  | Claude Code | GitHub Copilot (VS Code) |
78
78
  |---|---|
79
- | `/sungen:make-test login` | `/sungen-make-test login` |
79
+ | `/sungen:run-test login` | `/sungen-run-test login` |
80
80
 
81
81
  AI acts as a **Senior Developer**:
82
82
  1. Navigates to live page, takes snapshot, verifies DOM properties
@@ -141,7 +141,7 @@ User <action> [<Target>] <type> with {{<Value>}}
141
141
  | Assert text | `User see [Title] heading with {{title}}` |
142
142
  | Assert state | `User see [Submit] button is disabled` |
143
143
  | Wait for | `User wait for [Modal] dialog is visible` |
144
- | Table row | `User see [Users] table row with {{name}}` |
144
+ | Table row | `User see [Username] row in [Users] table with {{name}}` |
145
145
  | Table column | `User see [Email] column in [Users] table` |
146
146
 
147
147
  States: `hidden` `visible` `disabled` `enabled` `checked` `unchecked` `focused` `empty` `loading` `selected`