@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.
Files changed (105) hide show
  1. package/README.md +10 -11
  2. package/dist/cli/index.js +1 -1
  3. package/dist/generators/gherkin-parser/index.d.ts +8 -0
  4. package/dist/generators/gherkin-parser/index.d.ts.map +1 -1
  5. package/dist/generators/gherkin-parser/index.js +12 -0
  6. package/dist/generators/gherkin-parser/index.js.map +1 -1
  7. package/dist/generators/test-generator/adapters/playwright/templates/steps/actions/table-action-in-row.hbs +1 -1
  8. package/dist/generators/test-generator/adapters/playwright/templates/steps/assertions/table-column-exists.hbs +5 -1
  9. package/dist/generators/test-generator/adapters/playwright/templates/steps/assertions/table-match-data.hbs +15 -0
  10. package/dist/generators/test-generator/adapters/playwright/templates/steps/assertions/table-row-exists.hbs +7 -1
  11. package/dist/generators/test-generator/adapters/playwright/templates/steps/assertions/table-row-not-exists.hbs +5 -1
  12. package/dist/generators/test-generator/patterns/index.d.ts.map +1 -1
  13. package/dist/generators/test-generator/patterns/index.js +2 -1
  14. package/dist/generators/test-generator/patterns/index.js.map +1 -1
  15. package/dist/generators/test-generator/patterns/table-patterns.d.ts +12 -0
  16. package/dist/generators/test-generator/patterns/table-patterns.d.ts.map +1 -1
  17. package/dist/generators/test-generator/patterns/table-patterns.js +142 -98
  18. package/dist/generators/test-generator/patterns/table-patterns.js.map +1 -1
  19. package/dist/generators/test-generator/patterns/types.d.ts +2 -0
  20. package/dist/generators/test-generator/patterns/types.d.ts.map +1 -1
  21. package/dist/generators/test-generator/step-mapper.d.ts +13 -0
  22. package/dist/generators/test-generator/step-mapper.d.ts.map +1 -1
  23. package/dist/generators/test-generator/step-mapper.js +80 -0
  24. package/dist/generators/test-generator/step-mapper.js.map +1 -1
  25. package/dist/orchestrator/ai-rules-updater.d.ts.map +1 -1
  26. package/dist/orchestrator/ai-rules-updater.js +8 -6
  27. package/dist/orchestrator/ai-rules-updater.js.map +1 -1
  28. package/dist/orchestrator/project-initializer.d.ts.map +1 -1
  29. package/dist/orchestrator/project-initializer.js +33 -2
  30. package/dist/orchestrator/project-initializer.js.map +1 -1
  31. package/dist/orchestrator/screen-manager.js +1 -1
  32. package/dist/orchestrator/screen-manager.js.map +1 -1
  33. package/dist/orchestrator/templates/ai-instructions/claude-cmd-add-screen.md +5 -5
  34. package/{src/orchestrator/templates/ai-instructions/claude-cmd-make-tc.md → dist/orchestrator/templates/ai-instructions/claude-cmd-create-test.md} +7 -7
  35. package/dist/orchestrator/templates/ai-instructions/claude-cmd-review.md +21 -0
  36. package/dist/orchestrator/templates/ai-instructions/claude-cmd-run-test.md +32 -0
  37. package/dist/orchestrator/templates/ai-instructions/claude-config.md +65 -12
  38. package/dist/orchestrator/templates/ai-instructions/claude-skill-error-mapping.md +128 -52
  39. package/dist/orchestrator/templates/ai-instructions/claude-skill-gherkin-syntax.md +15 -39
  40. package/dist/orchestrator/templates/ai-instructions/claude-skill-selector-fix.md +72 -259
  41. package/dist/orchestrator/templates/ai-instructions/claude-skill-tc-generation.md +57 -205
  42. package/dist/orchestrator/templates/ai-instructions/claude-skill-tc-review.md +104 -0
  43. package/dist/orchestrator/templates/ai-instructions/claude-skill-viewpoint.md +188 -0
  44. package/dist/orchestrator/templates/ai-instructions/copilot-cmd-add-screen.md +4 -4
  45. package/dist/orchestrator/templates/ai-instructions/{copilot-cmd-make-tc.md → copilot-cmd-create-test.md} +8 -8
  46. package/dist/orchestrator/templates/ai-instructions/copilot-cmd-review.md +24 -0
  47. package/dist/orchestrator/templates/ai-instructions/copilot-cmd-run-test.md +35 -0
  48. package/dist/orchestrator/templates/ai-instructions/copilot-config.md +66 -13
  49. package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-error-mapping.md +128 -52
  50. package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-gherkin-syntax.md +15 -39
  51. package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-selector-fix.md +72 -234
  52. package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-tc-generation.md +57 -205
  53. package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-tc-review.md +104 -0
  54. package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-viewpoint.md +188 -0
  55. package/dist/orchestrator/templates/readme.md +85 -22
  56. package/package.json +1 -1
  57. package/src/cli/index.ts +1 -1
  58. package/src/generators/gherkin-parser/index.ts +23 -0
  59. package/src/generators/test-generator/adapters/playwright/templates/steps/actions/table-action-in-row.hbs +1 -1
  60. package/src/generators/test-generator/adapters/playwright/templates/steps/assertions/table-column-exists.hbs +5 -1
  61. package/src/generators/test-generator/adapters/playwright/templates/steps/assertions/table-match-data.hbs +15 -0
  62. package/src/generators/test-generator/adapters/playwright/templates/steps/assertions/table-row-exists.hbs +7 -1
  63. package/src/generators/test-generator/adapters/playwright/templates/steps/assertions/table-row-not-exists.hbs +5 -1
  64. package/src/generators/test-generator/patterns/index.ts +2 -1
  65. package/src/generators/test-generator/patterns/table-patterns.ts +155 -111
  66. package/src/generators/test-generator/patterns/types.ts +2 -0
  67. package/src/generators/test-generator/step-mapper.ts +87 -1
  68. package/src/orchestrator/ai-rules-updater.ts +8 -6
  69. package/src/orchestrator/project-initializer.ts +38 -2
  70. package/src/orchestrator/screen-manager.ts +1 -1
  71. package/src/orchestrator/templates/ai-instructions/claude-cmd-add-screen.md +5 -5
  72. package/{dist/orchestrator/templates/ai-instructions/claude-cmd-make-tc.md → src/orchestrator/templates/ai-instructions/claude-cmd-create-test.md} +7 -7
  73. package/src/orchestrator/templates/ai-instructions/claude-cmd-review.md +21 -0
  74. package/src/orchestrator/templates/ai-instructions/claude-cmd-run-test.md +32 -0
  75. package/src/orchestrator/templates/ai-instructions/claude-config.md +65 -12
  76. package/src/orchestrator/templates/ai-instructions/claude-skill-error-mapping.md +128 -52
  77. package/src/orchestrator/templates/ai-instructions/claude-skill-gherkin-syntax.md +15 -39
  78. package/src/orchestrator/templates/ai-instructions/claude-skill-selector-fix.md +72 -259
  79. package/src/orchestrator/templates/ai-instructions/claude-skill-tc-generation.md +57 -205
  80. package/src/orchestrator/templates/ai-instructions/claude-skill-tc-review.md +104 -0
  81. package/src/orchestrator/templates/ai-instructions/claude-skill-viewpoint.md +188 -0
  82. package/src/orchestrator/templates/ai-instructions/copilot-cmd-add-screen.md +4 -4
  83. package/src/orchestrator/templates/ai-instructions/{copilot-cmd-make-tc.md → copilot-cmd-create-test.md} +8 -8
  84. package/src/orchestrator/templates/ai-instructions/copilot-cmd-review.md +24 -0
  85. package/src/orchestrator/templates/ai-instructions/copilot-cmd-run-test.md +35 -0
  86. package/src/orchestrator/templates/ai-instructions/copilot-config.md +66 -13
  87. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-error-mapping.md +128 -52
  88. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-gherkin-syntax.md +15 -39
  89. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-selector-fix.md +72 -234
  90. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-tc-generation.md +57 -205
  91. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-tc-review.md +104 -0
  92. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-viewpoint.md +188 -0
  93. package/src/orchestrator/templates/readme.md +85 -22
  94. package/dist/generators/test-generator/adapters/playwright/templates/steps/assertions/table-cell-by-filter.hbs +0 -2
  95. package/dist/generators/test-generator/adapters/playwright/templates/steps/assertions/table-cell-by-index.hbs +0 -2
  96. package/dist/orchestrator/templates/ai-instructions/claude-cmd-make-test.md +0 -29
  97. package/dist/orchestrator/templates/ai-instructions/claude-skill-gherkin-review.md +0 -228
  98. package/dist/orchestrator/templates/ai-instructions/copilot-cmd-make-test.md +0 -32
  99. package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-gherkin-review.md +0 -228
  100. package/src/generators/test-generator/adapters/playwright/templates/steps/assertions/table-cell-by-filter.hbs +0 -2
  101. package/src/generators/test-generator/adapters/playwright/templates/steps/assertions/table-cell-by-index.hbs +0 -2
  102. package/src/orchestrator/templates/ai-instructions/claude-cmd-make-test.md +0 -29
  103. package/src/orchestrator/templates/ai-instructions/claude-skill-gherkin-review.md +0 -228
  104. package/src/orchestrator/templates/ai-instructions/copilot-cmd-make-test.md +0 -32
  105. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-gherkin-review.md +0 -228
@@ -1,212 +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. Auto-loaded by make-tc command.'
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 & Review Quality
138
-
139
- For assertion quality rules, action-result coherence rules, and the 9-point quality review checklist, see the `sungen-gherkin-review` skill. That skill is auto-loaded during the self-review step.
140
-
141
- ### Viewpoint Categories
142
-
143
- | VP Category | Description |
144
- |---|---|
145
- | **UI/UX** | Default appearance, default values/text, default states. Group related elements per scenario. |
146
- | **Validation** | Input validation, error messages, edge cases. **Assert exact error messages via `User see [T] with {{error_var}}`** — store texts in test-data.yaml. |
147
- | **Logic** | Business logic, interactions, state changes |
148
- | **Security** | Auth guards, injection, permission checks |
149
-
150
- ### Coverage Checklist per Section Pattern
151
-
152
- #### Form sections
153
- - **UI/UX**: All fields + labels + default values in 1-2 grouped scenarios. Default states (button enabled/disabled, checkbox unchecked). Placeholder text via `with {{placeholder}}`.
154
- - **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.
155
- - **Logic**: Successful submit → verify success state/redirect. Edit existing → verify pre-filled values. Cancel → verify form resets. Field dependencies (show/hide).
156
- - **Security**: Unauthorized submit, role-based field visibility, input sanitization
157
-
158
- #### Data Table sections
159
- - **UI/UX**: All column headers in one scenario. Row data displays with correct values. Empty state message. Action buttons per row.
160
- - **Logic**: Sort ascending/descending. Filter by column. Search. Row actions (edit/delete/view). Bulk select + action.
161
- - **Security**: Action permissions per role
162
-
163
- #### Search & Filter sections
164
- - **UI/UX**: Search field + filter buttons + clear button states in one scenario
165
- - **Validation**: Empty search, special chars, injection, long text, unicode
166
- - **Logic**: Apply/clear single filter, combine filters, no results state with message
167
- - **Security**: Injection via search/filter params
168
-
169
- #### Pagination sections
170
- - **UI/UX**: Page indicator + button states (previous disabled on page 1, next enabled)
171
- - **Logic**: Navigate pages, boundary behavior, indicator updates
172
-
173
- #### Modal / Dialog sections
174
- - **UI/UX**: Modal content + all fields + close button in one scenario
175
- - **Validation**: Field validation inside modal with exact errors
176
- - **Logic**: Open/close methods (X, Escape, overlay), submit success/error behavior
177
-
178
- #### Tabs / Accordion sections
179
- - **UI/UX**: All tab labels + active tab highlighted + default tab content
180
- - **Logic**: Switch tabs → verify content changes, accordion expand/collapse
181
-
182
- ### General Coverage Dimensions (aim for 20+ total per viewpoint)
183
-
184
- **Happy paths (3-5):** Standard flow with full assertion of result state
185
- **Edge cases (5-8):** Empty, max length, special chars, unicode, whitespace, boundary values
186
- **Negative cases (3-5):** Invalid format, missing required, wrong type, exact error messages
187
- **State transitions (2-4):** Before/after action, verify both old and new state
188
- **Combinatorial (2-4):** Multiple invalid fields, valid+invalid combos
189
-
190
- ### SPA Wait-For Steps
191
-
192
- If the page is an SPA (Next.js, Nuxt, React Router, etc.), add a `wait for` step after navigation:
60
+ ## SPA Wait-For Steps
193
61
 
194
62
  ```gherkin
195
63
  Given User is on [Screen] page
196
64
  And User wait for [Page Title] heading is visible
197
65
  ```
198
66
 
199
- For scenarios needing dynamic data, add a second wait:
200
-
201
- ```gherkin
202
- And User wait for [Data Element] button is visible
203
- ```
204
-
205
- ### Output Files
67
+ ## Output Format
206
68
 
207
- **1. Feature file** — `qa/screens/<screen>/features/<screen>.feature`
208
-
209
- Group by section, then by viewpoint within each section:
69
+ **Feature file** — `qa/screens/<screen>/features/<screen>.feature`
210
70
 
211
71
  ```gherkin
212
72
  @auth:role
@@ -220,20 +80,15 @@ Feature: <Screen> Screen
220
80
 
221
81
  Scenario: VP-UI-001 Form displays all fields with correct defaults
222
82
  Given User is on [Create User] page
223
- Then User see [Create User] heading with {{form_title}}
224
- And User see [Name] field
83
+ Then User see [Name] field
225
84
  And User see [Email] field
226
- And User see [Role] dropdown with {{default_role}}
227
85
  And User see [Submit] button is disabled
228
- And User see [Cancel] button is enabled
229
86
 
230
87
  # --- Validation ---
231
88
 
232
89
  Scenario: VP-VAL-001 Submit with all empty fields shows errors
233
- Given User is on [Create User] page
234
90
  When User click [Submit] button
235
91
  Then User see [Name error] message with {{name_required_error}}
236
- And User see [Email error] message with {{email_required_error}}
237
92
 
238
93
  # ============================================================
239
94
  # Section: User Table
@@ -242,36 +97,33 @@ Feature: <Screen> Screen
242
97
  # --- UI/UX ---
243
98
 
244
99
  Scenario: VP-UI-010 Table displays all columns
245
- Given User is on [Users] page
246
100
  Then User see [Name] column in [Users] table
247
101
  And User see [Email] column in [Users] table
248
102
  And User see [Status] column in [Users] table
249
- And User see [Actions] column in [Users] table
250
- ```
251
103
 
252
- **Naming convention:** `VP-<CATEGORY>-<NNN>` prefix in Scenario name.
104
+ # --- Data & Validate ---
253
105
 
254
- **2. Test data file** `qa/screens/<screen>/test-data/<screen>.yaml`
106
+ Scenario: VP-VAL-010 Table displays correct data
107
+ Then User see [Users] table match data:
108
+ | Name | Email | Status |
109
+ | {{name_1}} | {{email_1}} | {{status_1}} |
110
+ | {{name_2}} | {{email_2}} | {{status_2}} |
255
111
 
256
- Group variables by section:
112
+ Scenario: VP-VAL-011 Edit button targets correct row
113
+ Given User see [Target] row in [Users] table with {{name_1}}
114
+ When User click [Edit] button in [Users] table with {{name_1}}
115
+ Then User see [Name] field with {{name_1}}
116
+ ```
257
117
 
258
- ```yaml
259
- # ============================================================
260
- # Create User Form
261
- # ============================================================
262
- valid_name: 'John Doe'
263
- valid_email: 'john@example.com'
264
- empty_input: ''
265
- special_chars: '!@#$%^&*()'
118
+ ### When to use DataTable vs Row Scope
266
119
 
267
- # ============================================================
268
- # User Table
269
- # ============================================================
270
- sort_column: 'Name'
271
- search_term: 'John'
272
- ```
120
+ | Pattern | Use when |
121
+ |---|---|
122
+ | `table match data:` + DataTable | Verifying **multiple rows** exist with expected values |
123
+ | `row in [Table] table with {{v}}` + `column with {{v}}` | Checking **single row** details or **acting** on a row (click, edit) |
124
+
125
+ **Naming**: `VP-<CATEGORY>-<NNN>` prefix.
273
126
 
274
- ### Do NOT Generate
127
+ **Test data** `qa/screens/<screen>/test-data/<screen>.yaml`, grouped by section.
275
128
 
276
- - `selectors.yaml` this is created during `/sungen:make-test`
277
- - Playwright code — sungen compiles Gherkin to Playwright
129
+ **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,188 @@
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
+ - **Use `table match data:` with inline DataTable** for multi-row content verification (filter-based, resilient to data changes)
56
+ - Use row scope (`row in [Table] table with {{v}}` + `column with {{v}}`) for single-row detail checks or when you need actions on a row
57
+
58
+ **Logic**
59
+ - Sorting: column sort refreshes data with correct order, updates header icon
60
+ - Row Actions: Edit/Delete/View buttons act on correct row ID
61
+
62
+ **Security**
63
+ - UI-level RBAC: hide sensitive columns or privileged buttons without authority
64
+ - XSS Rendering: malicious code in database displayed as plain text
65
+
66
+ ---
67
+
68
+ ## 3. Search
69
+
70
+ **UI/UX**
71
+ - No Results: "No results found" message, list empty, Clear button visible
72
+ - Loading State: spinner/skeleton, list dimmed, interaction locked
73
+ - Clear Action: search box empties, list reloads default data
74
+
75
+ **Data & Validate**
76
+ - Cleanup: auto-trim whitespace, results match cleaned keyword
77
+ - Input Limits: prevent input beyond max length or show error
78
+ - Normalization: case-insensitive matching, handles Vietnamese accents
79
+
80
+ **Logic**
81
+ - Matching: partial/exact match returns correct results, no 500 errors
82
+ - Multi-keyword: results based on AND/OR logic
83
+ - Performance: debounce ~300ms before API call
84
+
85
+ **Security**
86
+ - Injection: XSS/SQL encoded as plain text, never executed
87
+ - Wildcards: `%, _, *` treated as normal text (escaped)
88
+
89
+ ---
90
+
91
+ ## 4. Filter
92
+
93
+ **UI/UX**
94
+ - Feedback: selected filters displayed as tags/badges
95
+ - Persistence: collapse/expand retains selected values
96
+ - Conflicts: conflicting conditions show "No data" message, header layout intact
97
+
98
+ **Data & Validate**
99
+ - Range Validation: start > end or min > max shows field error, Apply button disabled
100
+ - Dropdown Integrity: options match 100% of actual data, hide unauthorized values
101
+
102
+ **Logic**
103
+ - Logic AND/OR: results satisfy correct filter logic, Total Count updated
104
+ - Dependent Filters: selecting Filter A updates Filter B options
105
+ - Reset & Navigation: reset returns original data or preserves state depending on action
106
+
107
+ **Security**
108
+ - URL Manipulation: erroneous URL params ignored, defaults assigned, no 500 error
109
+
110
+ ---
111
+
112
+ ## 5. Pagination
113
+
114
+ **UI/UX**
115
+ - Boundary States: Previous/First disabled on page 1, Next/Last disabled on last page
116
+ - Active & Loading: active page highlighted, loading effect during page transition
117
+ - Hidden State: pagination bar hidden when data fits one page
118
+
119
+ **Data & Validate**
120
+ - Label Consistency: "Viewing X of Y" matches actual data
121
+ - Zero Records: pagination hidden, empty state displayed
122
+
123
+ **Logic**
124
+ - Navigation: loads correct dataset for page (page 2, limit 10 = records 11-20)
125
+ - Change Page Size: shows correct quantity, resets to page 1
126
+ - Interaction Resets: new search/filter resets to page 1
127
+ - Delete Fallback: deleting all records on last page pushes to previous page
128
+
129
+ **Security**
130
+ - URL Manipulation: invalid page/size in URL fallbacks to defaults, no server crash
131
+
132
+ ---
133
+
134
+ ## 6. Modal / Dialog
135
+
136
+ **UI/UX**
137
+ - Overlay & Backdrop: centered modal, backdrop blur, background scroll locked
138
+ - Focus Trapping: Tab key cycles only within modal elements
139
+ - Responsive: modal resizes, action buttons always visible or scrollable
140
+
141
+ **Data & Validate**
142
+ - Dismiss Actions: close via X, Cancel, Escape, backdrop click. Resets data on reopen
143
+
144
+ **Logic**
145
+ - Submissions: action button shows loading, modal closes on success, background data updated
146
+ - Failure: modal stays open on API error, shows error message, retains entered data
147
+ - Stacked Modals: Modal B over A has higher z-index, closing B keeps A intact
148
+
149
+ **Security**
150
+ - Reload & Security: handles deep linking if present, removes HTML from DOM on close (protect sensitive data)
151
+
152
+ ---
153
+
154
+ ## 7. List / Card
155
+
156
+ **UI/UX**
157
+ - Visual States: empty state when empty, skeleton when loading, hover effect (shadow/scale) on card
158
+ - Content: text truncation without breaking card height, placeholder image on broken image
159
+
160
+ **Data & Validate**
161
+ - Integrity: data fields (price, status, tag) 100% accurate vs system
162
+ - Total Count: matches actual database count after filtering
163
+
164
+ **Logic**
165
+ - Navigation: clicking card navigates to correct detail page
166
+ - Direct Actions: Like/Add to Cart updates immediately without reloading list
167
+ - Loading Flows: Load More / Infinite Scroll appends records, maintains scroll position
168
+ - Layout Toggle: Grid/List view switch changes UI but preserves data
169
+
170
+ **Security**
171
+ - RBAC & Resilience: hide sensitive data/privileged buttons from DOM. Network loss shows error + "Try again" button
172
+
173
+ ---
174
+
175
+ ## Security Tag Rules
176
+
177
+ For VP-SEC scenarios testing **unauthorized access** (no login, wrong role, direct URL access):
178
+ - Use **`@no-auth`** tag — this runs the test without authentication, which is exactly what you want to verify.
179
+ - Do NOT use `@manual` for these — they are automatable with `@no-auth`.
180
+
181
+ ```gherkin
182
+ @no-auth
183
+ Scenario: VP-SEC-001 Unauthenticated user cannot access admin page
184
+ Given User is on [Admin] page
185
+ Then User see [Login] page
186
+ ```
187
+
188
+ Use `@manual` only when the environment truly cannot be set up automatically (e.g., third-party OAuth, physical device).
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: sungen-add-screen
3
- description: 'Add a new Sungen screen — scaffolds directories and delegates to /sungen-make-tc for test case creation'
3
+ description: 'Add a new Sungen screen — scaffolds directories and delegates to /sungen-create-test for test case creation'
4
4
  argument-hint: '[screen-name] [url-path]'
5
5
  agent: 'agent'
6
6
  tools: [vscode, execute, read, agent, edit, search, web, browser, todo]
@@ -36,11 +36,11 @@ Ask the user: "Would you like to fill in `requirements/spec.md` now? This helps
36
36
 
37
37
  Ask the user: "Would you like to create test cases now?"
38
38
 
39
- If yes → **tell the user to run `/sungen-make-tc ${input:screen}` as a separate command.** Do NOT attempt to generate test cases yourself in this session — the `make-tc` command auto-loads the `sungen-gherkin-syntax` and `sungen-tc-generation` skills which contain the full Gherkin syntax rules, pattern shapes, viewpoint checklists, and output format.
39
+ If yes → **tell the user to run `/sungen-create-test ${input:screen}` as a separate command.** Do NOT attempt to generate test cases yourself in this session — the `create-test` command auto-loads the `sungen-gherkin-syntax` and `sungen-tc-generation` skills which contain the full Gherkin syntax rules, pattern shapes, viewpoint checklists, and output format.
40
40
 
41
41
  ### 4. Confirm
42
42
 
43
43
  If the user declined test case creation, tell them next steps:
44
44
  - Fill `requirements/spec.md` with screen specs (if not done)
45
- - Run `/sungen-make-tc` to create test cases
46
- - Run `/sungen-make-test` to generate selectors, compile, and run tests
45
+ - Run `/sungen-create-test` to create test cases
46
+ - Run `/sungen-run-test` to generate selectors, compile, and run tests