@sun-asterisk/sungen 2.1.1 → 2.2.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 (155) hide show
  1. package/README.md +78 -51
  2. package/dist/cli/index.js +1 -1
  3. package/dist/generators/test-generator/adapters/playwright/templates/imports.hbs +1 -1
  4. package/dist/generators/test-generator/adapters/playwright/templates/steps/actions/fill-action.hbs +1 -1
  5. package/dist/generators/test-generator/adapters/playwright/templates/steps/actions/fill-editor-action.hbs +1 -1
  6. package/dist/generators/test-generator/adapters/playwright/templates/steps/assertions/checked-assertion.hbs +0 -1
  7. package/dist/generators/test-generator/adapters/playwright/templates/steps/assertions/column-cell-assertion.hbs +0 -1
  8. package/dist/generators/test-generator/adapters/playwright/templates/steps/assertions/contain-text-assertion.hbs +0 -1
  9. package/dist/generators/test-generator/adapters/playwright/templates/steps/assertions/count-assertion.hbs +0 -1
  10. package/dist/generators/test-generator/adapters/playwright/templates/steps/assertions/disabled-assertion.hbs +0 -1
  11. package/dist/generators/test-generator/adapters/playwright/templates/steps/assertions/disabled-with-filter-assertion.hbs +0 -1
  12. package/dist/generators/test-generator/adapters/playwright/templates/steps/assertions/disabled-with-role-variable-assertion.hbs +0 -1
  13. package/dist/generators/test-generator/adapters/playwright/templates/steps/assertions/disabled-with-variable-assertion.hbs +0 -1
  14. package/dist/generators/test-generator/adapters/playwright/templates/steps/assertions/empty-assertion.hbs +0 -1
  15. package/dist/generators/test-generator/adapters/playwright/templates/steps/assertions/enabled-assertion.hbs +0 -1
  16. package/dist/generators/test-generator/adapters/playwright/templates/steps/assertions/focused-assertion.hbs +0 -1
  17. package/dist/generators/test-generator/adapters/playwright/templates/steps/assertions/have-text-assertion.hbs +0 -1
  18. package/dist/generators/test-generator/adapters/playwright/templates/steps/assertions/hidden-dialog-heading-assertion.hbs +0 -1
  19. package/dist/generators/test-generator/adapters/playwright/templates/steps/assertions/hidden-with-filter-assertion.hbs +0 -1
  20. package/dist/generators/test-generator/adapters/playwright/templates/steps/assertions/hidden-with-role-variable-assertion.hbs +0 -1
  21. package/dist/generators/test-generator/adapters/playwright/templates/steps/assertions/hidden-with-variable-assertion.hbs +0 -1
  22. package/dist/generators/test-generator/adapters/playwright/templates/steps/assertions/is-hidden-assertion.hbs +0 -1
  23. package/dist/generators/test-generator/adapters/playwright/templates/steps/assertions/label-value-assertion.hbs +0 -1
  24. package/dist/generators/test-generator/adapters/playwright/templates/steps/assertions/list-item-count-assertion.hbs +0 -1
  25. package/dist/generators/test-generator/adapters/playwright/templates/steps/assertions/loading-assertion.hbs +0 -1
  26. package/dist/generators/test-generator/adapters/playwright/templates/steps/assertions/not-checked-assertion.hbs +0 -1
  27. package/dist/generators/test-generator/adapters/playwright/templates/steps/assertions/page-assertion.hbs +0 -1
  28. package/dist/generators/test-generator/adapters/playwright/templates/steps/assertions/selected-assertion.hbs +0 -1
  29. package/dist/generators/test-generator/adapters/playwright/templates/steps/assertions/sorted-assertion.hbs +0 -1
  30. package/dist/generators/test-generator/adapters/playwright/templates/steps/assertions/table-cell-by-filter.hbs +0 -1
  31. package/dist/generators/test-generator/adapters/playwright/templates/steps/assertions/table-cell-by-index.hbs +0 -1
  32. package/dist/generators/test-generator/adapters/playwright/templates/steps/assertions/table-column-exists.hbs +0 -1
  33. package/dist/generators/test-generator/adapters/playwright/templates/steps/assertions/table-empty.hbs +0 -1
  34. package/dist/generators/test-generator/adapters/playwright/templates/steps/assertions/table-row-count.hbs +0 -1
  35. package/dist/generators/test-generator/adapters/playwright/templates/steps/assertions/table-row-exists.hbs +0 -1
  36. package/dist/generators/test-generator/adapters/playwright/templates/steps/assertions/table-row-not-exists.hbs +0 -1
  37. package/dist/generators/test-generator/adapters/playwright/templates/steps/assertions/visible-assertion.hbs +0 -1
  38. package/dist/generators/test-generator/adapters/playwright/templates/steps/assertions/visible-dialog-heading-assertion.hbs +0 -1
  39. package/dist/generators/test-generator/adapters/playwright/templates/steps/assertions/visible-with-locator-variable-assertion.hbs +0 -1
  40. package/dist/generators/test-generator/adapters/playwright/templates/steps/assertions/visible-with-role-variable-assertion.hbs +0 -1
  41. package/dist/generators/test-generator/adapters/playwright/templates/steps/assertions/visible-with-value-assertion.hbs +0 -1
  42. package/dist/generators/test-generator/adapters/playwright/templates/steps/assertions/visible-with-variable-assertion.hbs +0 -1
  43. package/dist/generators/test-generator/adapters/playwright/templates/steps/navigation/navigation.hbs +1 -1
  44. package/dist/generators/test-generator/code-generator.d.ts +4 -0
  45. package/dist/generators/test-generator/code-generator.d.ts.map +1 -1
  46. package/dist/generators/test-generator/code-generator.js +19 -0
  47. package/dist/generators/test-generator/code-generator.js.map +1 -1
  48. package/dist/generators/test-generator/patterns/navigation-patterns.js +2 -2
  49. package/dist/generators/test-generator/patterns/navigation-patterns.js.map +1 -1
  50. package/dist/generators/test-generator/utils/selector-resolver.d.ts +15 -8
  51. package/dist/generators/test-generator/utils/selector-resolver.d.ts.map +1 -1
  52. package/dist/generators/test-generator/utils/selector-resolver.js +26 -197
  53. package/dist/generators/test-generator/utils/selector-resolver.js.map +1 -1
  54. package/dist/orchestrator/project-initializer.d.ts +8 -0
  55. package/dist/orchestrator/project-initializer.d.ts.map +1 -1
  56. package/dist/orchestrator/project-initializer.js +68 -4
  57. package/dist/orchestrator/project-initializer.js.map +1 -1
  58. package/dist/orchestrator/templates/ai-instructions/claude-cmd-add-screen.md +4 -3
  59. package/dist/orchestrator/templates/ai-instructions/claude-cmd-make-tc.md +11 -46
  60. package/dist/orchestrator/templates/ai-instructions/claude-cmd-make-test.md +11 -46
  61. package/dist/orchestrator/templates/ai-instructions/claude-config.md +9 -8
  62. package/dist/orchestrator/templates/ai-instructions/claude-skill-error-mapping.md +29 -0
  63. package/dist/orchestrator/templates/ai-instructions/claude-skill-gherkin-syntax.md +2 -2
  64. package/dist/orchestrator/templates/ai-instructions/claude-skill-selector-fix.md +206 -0
  65. package/dist/orchestrator/templates/ai-instructions/claude-skill-selector-keys.md +19 -21
  66. package/dist/orchestrator/templates/ai-instructions/claude-skill-tc-generation.md +256 -0
  67. package/dist/orchestrator/templates/ai-instructions/copilot-cmd-add-screen.md +14 -17
  68. package/dist/orchestrator/templates/ai-instructions/copilot-cmd-make-tc.md +16 -47
  69. package/dist/orchestrator/templates/ai-instructions/copilot-cmd-make-test.md +16 -47
  70. package/dist/orchestrator/templates/ai-instructions/copilot-config.md +8 -7
  71. package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-error-mapping.md +56 -0
  72. package/{src/orchestrator/templates/ai-instructions/copilot-skill-gherkin-syntax.md → dist/orchestrator/templates/ai-instructions/github-skill-sungen-gherkin-syntax.md} +5 -5
  73. package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-selector-fix.md +206 -0
  74. package/dist/orchestrator/templates/ai-instructions/{copilot-skill-selector-keys.md → github-skill-sungen-selector-keys.md} +22 -24
  75. package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-tc-generation.md +257 -0
  76. package/dist/orchestrator/templates/playwright.config.d.ts.map +1 -1
  77. package/dist/orchestrator/templates/playwright.config.js +3 -1
  78. package/dist/orchestrator/templates/playwright.config.js.map +1 -1
  79. package/dist/orchestrator/templates/playwright.config.ts +3 -1
  80. package/dist/orchestrator/templates/readme.md +78 -101
  81. package/dist/orchestrator/templates/specs-base.d.ts +4 -0
  82. package/dist/orchestrator/templates/specs-base.d.ts.map +1 -0
  83. package/dist/orchestrator/templates/specs-base.js +70 -0
  84. package/dist/orchestrator/templates/specs-base.js.map +1 -0
  85. package/dist/orchestrator/templates/specs-base.ts +73 -0
  86. package/package.json +1 -1
  87. package/src/cli/index.ts +1 -1
  88. package/src/generators/test-generator/adapters/playwright/templates/imports.hbs +1 -1
  89. package/src/generators/test-generator/adapters/playwright/templates/steps/actions/fill-action.hbs +1 -1
  90. package/src/generators/test-generator/adapters/playwright/templates/steps/actions/fill-editor-action.hbs +1 -1
  91. package/src/generators/test-generator/adapters/playwright/templates/steps/assertions/checked-assertion.hbs +0 -1
  92. package/src/generators/test-generator/adapters/playwright/templates/steps/assertions/column-cell-assertion.hbs +0 -1
  93. package/src/generators/test-generator/adapters/playwright/templates/steps/assertions/contain-text-assertion.hbs +0 -1
  94. package/src/generators/test-generator/adapters/playwright/templates/steps/assertions/count-assertion.hbs +0 -1
  95. package/src/generators/test-generator/adapters/playwright/templates/steps/assertions/disabled-assertion.hbs +0 -1
  96. package/src/generators/test-generator/adapters/playwright/templates/steps/assertions/disabled-with-filter-assertion.hbs +0 -1
  97. package/src/generators/test-generator/adapters/playwright/templates/steps/assertions/disabled-with-role-variable-assertion.hbs +0 -1
  98. package/src/generators/test-generator/adapters/playwright/templates/steps/assertions/disabled-with-variable-assertion.hbs +0 -1
  99. package/src/generators/test-generator/adapters/playwright/templates/steps/assertions/empty-assertion.hbs +0 -1
  100. package/src/generators/test-generator/adapters/playwright/templates/steps/assertions/enabled-assertion.hbs +0 -1
  101. package/src/generators/test-generator/adapters/playwright/templates/steps/assertions/focused-assertion.hbs +0 -1
  102. package/src/generators/test-generator/adapters/playwright/templates/steps/assertions/have-text-assertion.hbs +0 -1
  103. package/src/generators/test-generator/adapters/playwright/templates/steps/assertions/hidden-dialog-heading-assertion.hbs +0 -1
  104. package/src/generators/test-generator/adapters/playwright/templates/steps/assertions/hidden-with-filter-assertion.hbs +0 -1
  105. package/src/generators/test-generator/adapters/playwright/templates/steps/assertions/hidden-with-role-variable-assertion.hbs +0 -1
  106. package/src/generators/test-generator/adapters/playwright/templates/steps/assertions/hidden-with-variable-assertion.hbs +0 -1
  107. package/src/generators/test-generator/adapters/playwright/templates/steps/assertions/is-hidden-assertion.hbs +0 -1
  108. package/src/generators/test-generator/adapters/playwright/templates/steps/assertions/label-value-assertion.hbs +0 -1
  109. package/src/generators/test-generator/adapters/playwright/templates/steps/assertions/list-item-count-assertion.hbs +0 -1
  110. package/src/generators/test-generator/adapters/playwright/templates/steps/assertions/loading-assertion.hbs +0 -1
  111. package/src/generators/test-generator/adapters/playwright/templates/steps/assertions/not-checked-assertion.hbs +0 -1
  112. package/src/generators/test-generator/adapters/playwright/templates/steps/assertions/page-assertion.hbs +0 -1
  113. package/src/generators/test-generator/adapters/playwright/templates/steps/assertions/selected-assertion.hbs +0 -1
  114. package/src/generators/test-generator/adapters/playwright/templates/steps/assertions/sorted-assertion.hbs +0 -1
  115. package/src/generators/test-generator/adapters/playwright/templates/steps/assertions/table-cell-by-filter.hbs +0 -1
  116. package/src/generators/test-generator/adapters/playwright/templates/steps/assertions/table-cell-by-index.hbs +0 -1
  117. package/src/generators/test-generator/adapters/playwright/templates/steps/assertions/table-column-exists.hbs +0 -1
  118. package/src/generators/test-generator/adapters/playwright/templates/steps/assertions/table-empty.hbs +0 -1
  119. package/src/generators/test-generator/adapters/playwright/templates/steps/assertions/table-row-count.hbs +0 -1
  120. package/src/generators/test-generator/adapters/playwright/templates/steps/assertions/table-row-exists.hbs +0 -1
  121. package/src/generators/test-generator/adapters/playwright/templates/steps/assertions/table-row-not-exists.hbs +0 -1
  122. package/src/generators/test-generator/adapters/playwright/templates/steps/assertions/visible-assertion.hbs +0 -1
  123. package/src/generators/test-generator/adapters/playwright/templates/steps/assertions/visible-dialog-heading-assertion.hbs +0 -1
  124. package/src/generators/test-generator/adapters/playwright/templates/steps/assertions/visible-with-locator-variable-assertion.hbs +0 -1
  125. package/src/generators/test-generator/adapters/playwright/templates/steps/assertions/visible-with-role-variable-assertion.hbs +0 -1
  126. package/src/generators/test-generator/adapters/playwright/templates/steps/assertions/visible-with-value-assertion.hbs +0 -1
  127. package/src/generators/test-generator/adapters/playwright/templates/steps/assertions/visible-with-variable-assertion.hbs +0 -1
  128. package/src/generators/test-generator/adapters/playwright/templates/steps/navigation/navigation.hbs +1 -1
  129. package/src/generators/test-generator/code-generator.ts +21 -0
  130. package/src/generators/test-generator/patterns/navigation-patterns.ts +2 -2
  131. package/src/generators/test-generator/utils/selector-resolver.ts +27 -204
  132. package/src/orchestrator/project-initializer.ts +84 -5
  133. package/src/orchestrator/templates/ai-instructions/claude-cmd-add-screen.md +4 -3
  134. package/src/orchestrator/templates/ai-instructions/claude-cmd-make-tc.md +11 -46
  135. package/src/orchestrator/templates/ai-instructions/claude-cmd-make-test.md +11 -46
  136. package/src/orchestrator/templates/ai-instructions/claude-config.md +9 -8
  137. package/src/orchestrator/templates/ai-instructions/claude-skill-error-mapping.md +29 -0
  138. package/src/orchestrator/templates/ai-instructions/claude-skill-gherkin-syntax.md +2 -2
  139. package/src/orchestrator/templates/ai-instructions/claude-skill-selector-fix.md +206 -0
  140. package/src/orchestrator/templates/ai-instructions/claude-skill-selector-keys.md +19 -21
  141. package/src/orchestrator/templates/ai-instructions/claude-skill-tc-generation.md +256 -0
  142. package/src/orchestrator/templates/ai-instructions/copilot-cmd-add-screen.md +14 -17
  143. package/src/orchestrator/templates/ai-instructions/copilot-cmd-make-tc.md +16 -47
  144. package/src/orchestrator/templates/ai-instructions/copilot-cmd-make-test.md +16 -47
  145. package/src/orchestrator/templates/ai-instructions/copilot-config.md +8 -7
  146. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-error-mapping.md +56 -0
  147. package/{dist/orchestrator/templates/ai-instructions/copilot-skill-gherkin-syntax.md → src/orchestrator/templates/ai-instructions/github-skill-sungen-gherkin-syntax.md} +5 -5
  148. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-selector-fix.md +206 -0
  149. package/src/orchestrator/templates/ai-instructions/{copilot-skill-selector-keys.md → github-skill-sungen-selector-keys.md} +22 -24
  150. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-tc-generation.md +257 -0
  151. package/src/orchestrator/templates/playwright.config.ts +3 -1
  152. package/src/orchestrator/templates/readme.md +78 -101
  153. package/src/orchestrator/templates/specs-base.ts +73 -0
  154. package/dist/orchestrator/templates/ai-instructions/copilot-skill-error-mapping.md +0 -27
  155. package/src/orchestrator/templates/ai-instructions/copilot-skill-error-mapping.md +0 -27
@@ -0,0 +1,256 @@
1
+ ---
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.'
4
+ user-invocable: false
5
+ ---
6
+
7
+ ## Test Case Generation Strategy
8
+
9
+ ### Goal
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`.
12
+
13
+ ### Update Mode (existing test cases)
14
+
15
+ When the `.feature` file already has scenarios, read it first and summarize what exists:
16
+
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
26
+
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
32
+
33
+ For option 3:
34
+ - Overwrite both `.feature` and `test-data.yaml` completely
35
+
36
+ ### Page Exploration & Auth
37
+
38
+ Use Playwright MCP to explore the live page. If the page requires authentication:
39
+ 1. `browser_navigate` to `baseURL` (from `playwright.config.ts`)
40
+ 2. If redirected to login, ask the user to log in manually:
41
+ > "This page requires login. Please log in using the browser. Confirm when you're done."
42
+ 3. Once confirmed, `browser_navigate` to the target page and take `browser_snapshot`
43
+
44
+ **Never use `sungen makeauth`.** Always let the user log in manually via the MCP browser.
45
+
46
+ ### Single Screen Focus
47
+
48
+ **One screen = one URL path.** Only generate test cases for elements visible on the target page.
49
+
50
+ - Navigate to the target screen path — do NOT explore sibling paths (e.g., testing `/admin/users` should not scan `/admin/review`)
51
+ - Take ONE snapshot of the target page — do not click links to navigate away
52
+ - If a link goes to a different path, test only that the link is visible and clickable — the destination page is a SEPARATE screen
53
+ - If a modal/dialog opens on the same page, that IS part of this screen
54
+ - Each screen gets its own `qa/screens/<name>/` directory — never mix screens
55
+
56
+ #### Detail screens with dynamic IDs
57
+
58
+ For screens like `/admin/users/:id` or `/products/:slug`:
59
+ 1. Navigate to the **list page** first via MCP browser to find a real record ID
60
+ 2. Use that ID in the page selector value
61
+ 3. Use `User is on [X] page` — sungen resolves the path from the selector
62
+
63
+ ```yaml
64
+ # selectors.yaml — full path with real ID (generated during make-test)
65
+ user detail:
66
+ type: 'page'
67
+ value: '/admin/users/de42d800-0f5a-490e-9dcf-344fedbd34a5'
68
+ ```
69
+
70
+ ```gherkin
71
+ Scenario: VP-UI-001 User detail displays name
72
+ Given User is on [User Detail] page
73
+ And User wait for [User Name] heading is visible
74
+ Then User see [User Name] heading with {{user_name}}
75
+ ```
76
+
77
+ Note: the selector uses a hardcoded ID from the live page. If the record is deleted, update the ID in `selectors.yaml`.
78
+
79
+ ### Section-Focused Approach
80
+
81
+ 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.
82
+
83
+ #### Common Section Patterns
84
+
85
+ Identify which patterns exist on the screen:
86
+
87
+ | Pattern | Elements to look for |
88
+ |---|---|
89
+ | **Header / Navigation** | Logo, nav links, breadcrumbs, user menu, notifications, language selector |
90
+ | **Form** | Input fields, dropdowns, checkboxes, radio buttons, date pickers, file uploads, submit/cancel buttons |
91
+ | **Data Table** | Column headers, sortable columns, row data, row actions, bulk actions, column filters |
92
+ | **Search & Filters** | Search input, filter dropdowns, clear/reset, active filter tags |
93
+ | **Card Grid / List** | Cards with title/image/description, load more, infinite scroll |
94
+ | **Pagination** | Previous/next buttons, page numbers, page size selector, total count |
95
+ | **Tabs / Accordion** | Tab headers, tab panels, expand/collapse |
96
+ | **Modal / Dialog** | Open trigger, close button, form inside modal, confirmation dialog |
97
+ | **Sidebar** | Stats, quick actions, related links, mini widgets |
98
+ | **File Upload** | Drop zone, file picker, progress bar, file list, delete |
99
+ | **Rich Text Editor** | Toolbar, content area, formatting buttons, preview |
100
+ | **Carousel / Slider** | Prev/next arrows, dots/indicators, auto-play, swipe |
101
+
102
+ Example output:
103
+
104
+ > This screen has the following sections:
105
+ > 1. Header (logo, navigation tabs, user menu)
106
+ > 2. Create Form (name, email, role dropdown, department, submit)
107
+ > 3. User Table (columns: name, email, status, actions; sortable, filterable)
108
+ > 4. Pagination (previous/next, page indicator)
109
+ >
110
+ > Which sections do you want to create test cases for? (e.g., "2, 3" or "all")
111
+
112
+ For each selected section, generate **20+ scenarios per applicable viewpoint**. Skip viewpoint categories that don't apply.
113
+
114
+ Present a test plan summary and wait for user confirmation before generating files.
115
+
116
+ ### Viewpoint Categories
117
+
118
+ | VP Category | Description |
119
+ |---|---|
120
+ | **UI/UX** | Default appearance, element visibility, default states |
121
+ | **Validation** | Input validation, error messages, edge cases. **Must explore live page via MCP to capture actual error messages before writing tests. Use `User see {{error_var}}` pattern — never assert just "is visible".** |
122
+ | **Logic** | Business logic, interactions, state changes |
123
+ | **Security** | Auth guards, injection, permission checks |
124
+
125
+ ### Coverage Checklist per Section Pattern
126
+
127
+ Apply the relevant checklist based on the section pattern:
128
+
129
+ #### Form sections
130
+ - **UI/UX**: All fields visible, labels correct, default values, placeholder text, required indicators
131
+ - **Validation**: Empty submit, each required field empty, invalid format (email, phone, URL), min/max length, special chars, unicode, XSS, SQL injection, whitespace-only, boundary values — **assert exact error messages via `User see {{error_var}}`**, store texts in test-data.yaml
132
+ - **Logic**: Successful submit, submit with all optional fields, edit existing record, cancel resets form, field dependencies (show/hide), auto-complete, date range validation
133
+ - **Security**: CSRF protection, unauthorized submit, role-based field visibility, input sanitization
134
+
135
+ #### Data Table sections
136
+ - **UI/UX**: All columns visible, column headers, row data displays correctly, empty state, loading state, action buttons visible
137
+ - **Validation**: N/A (read-only) or inline edit validation
138
+ - **Logic**: Sort ascending/descending per sortable column, filter by each column, search within table, row action menu (edit/delete/view), bulk select, bulk action, row click navigation, column resize
139
+ - **Security**: Cannot access other users' data, action permissions per role, data not exposed in DOM
140
+
141
+ #### Search & Filter sections
142
+ - **UI/UX**: Search field visible, filter buttons visible, clear button state
143
+ - **Validation**: Empty search, special chars, SQL injection, XSS, very long text, unicode/emoji, whitespace, partial match, case insensitive
144
+ - **Logic**: Apply single filter, combine multiple filters, clear single filter, clear all filters, search + filter combined, filter persists across pagination, no results state
145
+ - **Security**: Injection via search, injection via filter params
146
+
147
+ #### Pagination sections
148
+ - **UI/UX**: Page indicator visible, previous disabled on page 1, next enabled
149
+ - **Logic**: Next page, previous page, navigate to last page, boundary (first/last), page indicator updates, data refreshes on navigation
150
+ - **Security**: Filters persist across pages, search persists, cannot access page beyond max
151
+
152
+ #### Modal / Dialog sections
153
+ - **UI/UX**: Modal opens, close button visible, overlay visible, form fields inside modal
154
+ - **Validation**: Submit empty form in modal, field validation inside modal
155
+ - **Logic**: Open modal, close with X, close with Escape, close with overlay click, submit success closes modal, submit error keeps modal open
156
+ - **Security**: Cannot open unauthorized modals, CSRF on modal submit
157
+
158
+ #### Card Grid / List sections
159
+ - **UI/UX**: Cards display all expected fields (title, image, description, metadata), empty state, loading state
160
+ - **Logic**: Click card navigates to detail, load more / infinite scroll, card action buttons (like, share, delete), responsive layout
161
+ - **Security**: User-generated content sanitized, cannot access other users' cards
162
+
163
+ #### Carousel / Slider sections
164
+ - **UI/UX**: Arrows visible, indicators visible, current slide highlighted
165
+ - **Logic**: Next slide, previous slide, wrap at end, auto-play, indicator click navigates, swipe gesture
166
+ - **Security**: N/A
167
+
168
+ #### Tabs / Accordion sections
169
+ - **UI/UX**: All tabs visible, active tab highlighted, default tab selected
170
+ - **Logic**: Switch tabs, content updates per tab, deep link to tab, accordion expand/collapse, only one accordion open at a time
171
+ - **Security**: Tab content respects permissions
172
+
173
+ ### General Coverage Dimensions (aim for 20+ total per viewpoint)
174
+
175
+ **Happy paths (3-5):** Standard flow, all optional fields, minimum required
176
+ **Edge cases (5-8):** Empty, max length, special chars, unicode/CJK/emoji, whitespace, leading/trailing spaces, overflow
177
+ **Boundary values (3-5):** At min/max limit, one above/below, zero/null
178
+ **Negative cases (3-5):** Invalid format, missing required, wrong type, injection attempts
179
+ **State transitions (2-4):** Before/after action, undo, cancel mid-flow
180
+ **Combinatorial (2-4):** Multiple invalid fields, valid+invalid combos, different roles
181
+
182
+ ### SPA Wait-For Steps
183
+
184
+ If the page is an SPA (Next.js, Nuxt, React Router, etc.), add a `wait for` step after navigation:
185
+
186
+ ```gherkin
187
+ Given User is on [Screen] page
188
+ And User wait for [Page Title] heading is visible
189
+ ```
190
+
191
+ For scenarios needing dynamic data, add a second wait:
192
+
193
+ ```gherkin
194
+ And User wait for [Data Element] button is visible
195
+ ```
196
+
197
+ ### Output Files
198
+
199
+ **1. Feature file** — `qa/screens/<screen>/features/<screen>.feature`
200
+
201
+ Group by section, then by viewpoint within each section:
202
+
203
+ ```gherkin
204
+ @auth:role
205
+ Feature: <Screen> Screen
206
+
207
+ # ============================================================
208
+ # Section: Create User Form
209
+ # ============================================================
210
+
211
+ # --- UI/UX (20+) ---
212
+
213
+ Scenario: VP-UI-001 Name field is visible
214
+ ...
215
+
216
+ # --- Validation (20+) ---
217
+
218
+ Scenario: VP-VAL-001 Submit with empty name
219
+ ...
220
+
221
+ # ============================================================
222
+ # Section: User Table
223
+ # ============================================================
224
+
225
+ # --- UI/UX (20+) ---
226
+
227
+ Scenario: VP-UI-025 Table displays all columns
228
+ ...
229
+ ```
230
+
231
+ **Naming convention:** `VP-<CATEGORY>-<NNN>` prefix in Scenario name.
232
+
233
+ **2. Test data file** — `qa/screens/<screen>/test-data/<screen>.yaml`
234
+
235
+ Group variables by section:
236
+
237
+ ```yaml
238
+ # ============================================================
239
+ # Create User Form
240
+ # ============================================================
241
+ valid_name: 'John Doe'
242
+ valid_email: 'john@example.com'
243
+ empty_input: ''
244
+ special_chars: '!@#$%^&*()'
245
+
246
+ # ============================================================
247
+ # User Table
248
+ # ============================================================
249
+ sort_column: 'Name'
250
+ search_term: 'John'
251
+ ```
252
+
253
+ ### Do NOT Generate
254
+
255
+ - `selectors.yaml` — this is created during `/sungen:make-test`
256
+ - Playwright code — sungen compiles Gherkin to Playwright
@@ -1,41 +1,38 @@
1
1
  ---
2
- description: 'Add a new Sungen screen — scaffolds directories and delegates to make-tc for test case creation'
3
- mode: 'agent'
2
+ name: sungen-add-screen
3
+ description: 'Add a new Sungen screen — scaffolds directories and delegates to /sungen-make-tc for test case creation'
4
+ argument-hint: '[screen-name] [url-path]'
5
+ agent: 'agent'
4
6
  tools: ['terminal']
5
7
  ---
6
8
 
9
+ **Input**: Screen name and URL path (e.g., `/sungen-add-screen login /login`).
10
+
7
11
  You are adding a new Sungen screen for test generation.
8
12
 
9
13
  ## Parameters
10
14
 
11
- Parse from user input:
12
- - **screen** — screen name (e.g., `login`, `dashboard`, `settings`)
13
- - **path** — URL path (e.g., `/login`, `/dashboard`, `/settings`)
14
-
15
- If **screen** is missing, ask: "What is the screen name? (e.g., `login`, `dashboard`)"
16
- If **path** is missing, ask: "What is the URL path? (e.g., `/login`, `/dashboard`)"
15
+ - **screen** ${input:screen:screen name (e.g., login, dashboard)}
16
+ - **path** — ${input:path:URL path (e.g., /login, /dashboard)}
17
17
 
18
18
  ## Steps
19
19
 
20
20
  ### 1. Scaffold the screen
21
21
 
22
- Run in terminal:
22
+ Run with #tool:terminal:
23
23
  ```bash
24
- sungen add --screen <screen> --path <path>
24
+ sungen add --screen ${input:screen} --path ${input:path}
25
25
  ```
26
26
 
27
27
  ### 2. Create test cases
28
28
 
29
29
  Ask the user: "Would you like to create test cases now?"
30
30
 
31
- If yes, delegate to the `sungen-make-tc` prompt to handle:
32
- - Exploring the live page or analyzing static designs
33
- - Gathering test viewpoints (UI/UX, Validation, Logic, Security)
34
- - Generating the 3 files (feature, selectors, test-data)
31
+ If yes, tell the user to run `/sungen-make-tc ${input:screen}`.
35
32
 
36
33
  ### 3. Confirm
37
34
 
38
35
  Tell the user what was created and next steps:
39
- - If the page requires authentication before exploring via browser, read `baseURL` from `playwright.config.ts` and tell the user to manually run: `sungen makeauth <role> --url <baseURL>` (e.g., `sungen makeauth admin --url http://localhost:3000`). **Do NOT execute this command yourself.**
40
- - Edit the generated files as needed
41
- - Run `sungen generate --screen <screen>` to compile to Playwright `.spec.ts`
36
+ - If the page requires authentication, the user will be asked to log in via the MCP browser during `/sungen-make-tc`
37
+ - Run `/sungen-make-tc` to create test cases
38
+ - Run `/sungen-make-test` to generate selectors, compile, and run tests
@@ -1,59 +1,28 @@
1
1
  ---
2
- description: 'Create test cases for a Sungen screen — gathers viewpoints, explores live page or static designs, generates feature/selectors/test-data files'
3
- mode: 'agent'
4
- tools: ['terminal', 'playwright']
2
+ name: sungen-make-tc
3
+ description: 'Create or update test cases for a Sungen screen — generates feature + test-data files (20+ scenarios per viewpoint). Uses sungen-gherkin-syntax and sungen-tc-generation skills.'
4
+ argument-hint: '[screen-name]'
5
+ agent: 'agent'
6
+ tools: ['terminal', 'playwright/*']
5
7
  ---
6
8
 
9
+ **Input**: Screen name (e.g., `/sungen-make-tc admin-users`).
10
+
7
11
  ## Role
8
12
 
9
- You are a **Senior QA Engineer** specialized in test case design. You structure test cases by viewpoint categories and translate UI into Gherkin test cases following the `sungen-gherkin-syntax` and `sungen-selector-keys` prompt rules.
13
+ You are a **Senior QA Engineer**. You structure test cases by viewpoint categories and translate UI into Gherkin test cases following the `sungen-gherkin-syntax` and `sungen-tc-generation` skills. **Gherkin scenarios and test data only** — selectors are handled during `/sungen-make-test`.
10
14
 
11
15
  ## Parameters
12
16
 
13
- Parse from user input:
14
- - **screen** — screen name (e.g., `login`, `dashboard`)
15
-
16
- If missing, ask the user.
17
+ - **screen** ${input:screen:screen name (e.g., login, dashboard)}
17
18
 
18
19
  ## Steps
19
20
 
20
- ### 1. Verify screen exists
21
-
22
- Check `qa/screens/<screen>/` exists. If not, tell user to run `sungen add --screen <screen> --path <path>` first.
23
-
24
- ### 2. Determine source mode
25
-
26
- Ask: "Do you have a **live page** or **static designs** (screenshots, Figma, images)?"
27
-
28
- **Live page →** explore via browser (see `.github/copilot-instructions.md` for Playwright MCP rules). If auth needed, check `specs/.auth/<role>.json` exists — if not, read `baseURL` from `playwright.config.ts` and tell the user to manually run: `sungen makeauth <role> --url <baseURL>` (e.g., `sungen makeauth admin --url http://localhost:3000`). **Do NOT execute `sungen makeauth` yourself.** Wait for the user to confirm auth is ready before proceeding.
29
-
30
- **Static designs →** ask user to provide screenshot paths, Figma exports, or UI descriptions. Note: selectors will be best-guess until live page is available.
31
-
32
- Present discovered elements to user, then proceed.
33
-
34
- ### 3. Gather test viewpoints
35
-
36
- | VP Category | Description |
37
- |---|---|
38
- | **UI/UX** | Default screen appearance, static elements, default states |
39
- | **Validation** | Field/form validation, error messages |
40
- | **Logic** | Business logic, happy paths, redirects |
41
- | **Security** | Auth guards, permission checks |
42
-
43
- For each viewpoint, gather: **UI Target**, **Test Viewpoint**, **Expected Result**.
44
-
45
- User can provide all at once as a table:
46
- ```
47
- | VP Category | UI Target | Test Viewpoint | Expected Result |
48
- ```
49
-
50
- ### 4. Generate files
51
-
52
- Generate the 3 files following `sungen-gherkin-syntax` and `sungen-selector-keys` prompt rules:
53
- - `qa/screens/<screen>/features/<screen>.feature` — one Scenario per viewpoint
54
- - `qa/screens/<screen>/selectors/<screen>.yaml`
55
- - `qa/screens/<screen>/test-data/<screen>.yaml`
56
-
57
- ### 5. Confirm
21
+ 1. Verify `qa/screens/${input:screen}/` exists. If not → run `/sungen-add-screen` first.
22
+ 2. Check if `.feature` already has scenarios. If yes → summarize existing coverage and ask: **1) Add new sections**, **2) Add viewpoints to existing sections**, or **3) Replace all**. See `sungen-tc-generation` skill for update mode details.
23
+ 3. Ask the user: "How should I explore the page? **1) Live page** (via Playwright MCP) or **2) Static designs** (screenshots, Figma)?". If live page, explore via #tool:playwright (see [copilot-instructions.md](../../copilot-instructions.md) for MCP rules). If auth needed, ask user to log in manually.
24
+ 4. Identify screen sections → ask user which to focus on (per `sungen-tc-generation` skill). Present sections as a numbered list and let user pick.
25
+ 5. Generate or update `.feature` + `test-data.yaml` following `sungen-gherkin-syntax` and `sungen-tc-generation` skills.
26
+ 6. Show summary → next: `/sungen-make-test ${input:screen}`
58
27
 
59
- Show what was generated. Next: `sungen generate --screen <screen>`
28
+ **No selectors.yaml** selectors are generated during `/sungen-make-test`.
@@ -1,58 +1,27 @@
1
1
  ---
2
- description: 'Compile and run Playwright tests for a Sungen screen — auto-fixes selectors on failure, falls back to AI .spec.ts fix after 5 attempts'
3
- mode: 'agent'
4
- tools: ['terminal']
2
+ name: sungen-make-test
3
+ description: 'Generate selectors, compile, and run Playwright tests — auto-fixes selectors on failure. Uses sungen-selector-fix, sungen-selector-keys, and sungen-error-mapping skills.'
4
+ argument-hint: '[screen-name]'
5
+ agent: 'agent'
6
+ tools: ['terminal', 'playwright/*']
5
7
  ---
6
8
 
9
+ **Input**: Screen name (e.g., `/sungen-make-test admin-users`).
10
+
7
11
  ## Role
8
12
 
9
- You are a **Senior Developer** specialized in Playwright test debugging. You diagnose test failures, fix selectors/test-data, and patch `.spec.ts` when needed. Use the `sungen-error-mapping` and `sungen-selector-keys` prompts for error diagnosis and key fixes.
13
+ You are a **Senior Developer** specialized in Playwright test debugging. You generate selectors from live pages, diagnose test failures, and fix selectors/test-data using the `sungen-selector-fix`, `sungen-selector-keys`, and `sungen-error-mapping` skills.
10
14
 
11
15
  ## Parameters
12
16
 
13
- Parse from user input:
14
- - **screen** — screen name (e.g., `login`, `dashboard`)
15
-
16
- If missing, ask the user.
17
+ - **screen** ${input:screen:screen name (e.g., login, dashboard)}
17
18
 
18
19
  ## Steps
19
20
 
20
- ### 1. Verify screen exists
21
-
22
- Check `qa/screens/<screen>/` has all 3 source files. If not, tell user to run `sungen-add-screen` and `sungen-make-tc` prompts first.
23
-
24
- ### 2. Compile
25
-
26
- ```bash
27
- sungen generate --screen <screen>
28
- ```
29
-
30
- If fails, fix source files per `sungen-error-mapping` prompt and retry.
31
-
32
- ### 3. Run tests
33
-
34
- ```bash
35
- npx playwright test specs/screens/<screen>/<screen>.spec.ts
36
- ```
37
-
38
- If pass → Step 5. If fail → Step 4.
39
-
40
- ### 4. Fix and retry (max 5 attempts)
41
-
42
- Per attempt:
43
- 1. Read Playwright error output
44
- 2. Map error to fix using `sungen-error-mapping` prompt
45
- 3. Fix `selectors.yaml` or `test-data.yaml`
46
- 4. Recompile: `sungen generate --screen <screen>`
47
- 5. Retest
48
-
49
- ### 5. Fallback — AI fix .spec.ts
50
-
51
- After 5 failed attempts, ask user:
52
- > Tests still failing. Would you like me to directly fix the `.spec.ts` file?
53
-
54
- If yes: read `.spec.ts`, fix locators/assertions, mark with `// AI-fixed: <reason>`
55
-
56
- ### 6. Confirm
57
-
58
- Show: pass/fail, attempt count, files changed.
21
+ 1. Verify `qa/screens/${input:screen}/` has `.feature` + `test-data.yaml`. If not → run `/sungen-make-tc` first.
22
+ 2. Explore live page via #tool:playwright to generate `selectors.yaml` (per `sungen-selector-fix` skill).
23
+ 3. Compile with #tool:terminal: `sungen generate --screen ${input:screen}`
24
+ 4. Run with #tool:terminal: `npx playwright test specs/generated/${input:screen}/*.spec.ts`
25
+ 5. If fail → fix selectors/test-data per `sungen-selector-fix` + `sungen-error-mapping` skills, retry (max 5).
26
+ 6. After 5 fails → ask user about direct `.spec.ts` fix.
27
+ 7. Show: pass/fail, attempt count, files changed.
@@ -73,12 +73,14 @@ When exploring a page to generate test files:
73
73
  Only use: `browser_navigate`, `browser_snapshot`, `browser_click`, `browser_fill_form`, `browser_evaluate`.
74
74
 
75
75
  To browse authenticated pages via MCP:
76
- 1. Check if `specs/.auth/<role>.json` exists
77
- 2. If not, read `baseURL` from `playwright.config.ts` and tell the user to manually run: `sungen makeauth <role> --url <baseURL>`. **Do NOT execute `sungen makeauth` yourself.** Wait for user confirmation.
78
- 3. Read `specs/.auth/<role>.json`
79
- 4. `browser_navigate` to the page
80
- 5. `browser_evaluate` to inject localStorage and cookies from the JSON
81
- 6. `browser_navigate` again to reload with auth
76
+ 1. `browser_navigate` to `baseURL`
77
+ 2. If redirected to login, ask the user to log in manually:
78
+ > "This page requires login. Please log in using the browser. Confirm when you're done."
79
+ 3. Once confirmed, `browser_navigate` to the target page and take `browser_snapshot`
80
+
81
+ **Never use `sungen makeauth`.** Always let the user log in manually via the MCP browser.
82
+ **NEVER use `browser_evaluate` to inject cookies or localStorage.** It causes size limit issues and server 500 errors.
83
+ **Minimize navigations** — take one snapshot per page, do not navigate repeatedly.
82
84
 
83
85
  ## Commands
84
86
 
@@ -86,5 +88,4 @@ To browse authenticated pages via MCP:
86
88
  sungen add --screen <name> --path <url-path> # Create screen
87
89
  sungen generate --screen <name> # Compile to .spec.ts
88
90
  sungen generate --all # Compile all
89
- sungen makeauth <role> # Capture auth state
90
91
  ```
@@ -0,0 +1,56 @@
1
+ ---
2
+ name: sungen-error-mapping
3
+ description: 'Playwright and Sungen error to fix mapping. Use this when running Playwright tests or debugging test failures.'
4
+ user-invocable: false
5
+ ---
6
+
7
+ ## Playwright Errors → Fix
8
+
9
+ | Error | Fix in `selectors.yaml` |
10
+ |---|---|
11
+ | strict mode violation | add `nth`, `exact: true`, or specific `name` |
12
+ | Element is not an input | change `type` or `value` |
13
+ | Timeout waiting for selector | fix `type`/`value`/`name` to match element |
14
+ | toBeVisible Timeout | verify accessible name or use `testid` |
15
+ | toHaveText mismatch | fix in `test-data.yaml` |
16
+ | Navigation failed | fix page `value` path |
17
+ | not a select | set `variant: 'custom'` |
18
+ | Frame not found | fix `frame` value |
19
+
20
+ ## Auth Errors → Fix
21
+
22
+ | Symptom | Fix |
23
+ |---|---|
24
+ | Tests redirect to login page | `specs/.auth/<role>.json` missing or expired. Tell user: `sungen makeauth <role> --url <baseURL>` |
25
+ | `storageState` file not found | Run `sungen makeauth <role> --url <baseURL>` to create auth state |
26
+ | Most tests timeout on first step | Auth expired — re-run `sungen makeauth <role> --url <baseURL>` |
27
+ | Page shows home/login instead of target | SPA routing + expired auth. Re-run `sungen makeauth`, add `wait for` step after navigation |
28
+
29
+ **Never run `sungen makeauth` yourself.** Always tell the user to run it manually.
30
+
31
+ ## Performance Errors → Fix (specs/base.ts)
32
+
33
+ All generated `.spec.ts` files import from `specs/base.ts`. This shared file handles context caching, navigation skip, and overlay cleanup.
34
+
35
+ | Symptom | Fix in `specs/base.ts` |
36
+ |---|---|
37
+ | Server returns 429 (rate limited) | Context caching broken — check `contextCache` Map reuses sessions per `storageState` |
38
+ | Tests slow even with `--workers=1` | Navigation skip not working — check `goto` patch compares `currentPath === url` |
39
+ | Previous test's modal blocks next test | Overlay cleanup insufficient — improve Escape/click dismiss logic |
40
+ | All tests fail on first navigation | `page.url()` is `about:blank` — check try/catch in goto patch |
41
+ | Multiple session invalidation errors | Too many contexts created — ensure `contextCache.get(cacheKey)` returns existing context |
42
+
43
+ **Rules:**
44
+ - `base.ts` changes affect ALL tests — edit carefully
45
+ - Small project-specific tweaks are OK (e.g., custom overlay dismiss, timeout tuning, extra wait logic)
46
+ - Do NOT move individual selector/data fixes into `base.ts` — those belong in `selectors.yaml` / `test-data.yaml`
47
+ - If unsure whether a fix belongs in `base.ts` or selectors, ask the user
48
+
49
+ ## Sungen Errors → Fix
50
+
51
+ | Error | Fix |
52
+ |---|---|
53
+ | Unknown step pattern | rewrite `.feature` step to match supported pattern |
54
+ | Missing selector | add key to `selectors.yaml` |
55
+ | Missing variable | add key to `test-data.yaml` |
56
+ | Invalid selector type | use: role/testid/placeholder/label/text/locator/page/upload/frame |
@@ -1,7 +1,7 @@
1
1
  ---
2
- description: 'Sungen Gherkin patterns, selector types, and YAML key rules. Referenced by other sungen prompts.'
3
- mode: 'agent'
4
- tools: []
2
+ name: sungen-gherkin-syntax
3
+ description: 'Sungen Gherkin patterns, selector types, and YAML key rules. Use this when writing or editing .feature, selectors.yaml, or test-data.yaml files.'
4
+ user-invocable: false
5
5
  ---
6
6
 
7
7
  ## Step Patterns (65 patterns)
@@ -10,7 +10,7 @@ tools: []
10
10
 
11
11
  ```
12
12
  User is on [T] page # navigate to page
13
- User navigate to [T] page with {{v}} # navigate with data
13
+ User is on [T] page with {{v}} # navigate with data (e.g., detail page with ID)
14
14
  User is logged in | is not logged in # auth state
15
15
  ```
16
16
 
@@ -98,7 +98,7 @@ User click [Act] in [Table] table row with {{f}} # action in row
98
98
 
99
99
  ## YAML Keys
100
100
 
101
- `[Reference]` → **lowercase, spaces→dots**: `[Search Content]` → `search.content:`
101
+ `[Reference]` → **lowercase, keep Unicode**: `[Search Content]` → `search content:`, `[Thời gian]` → `thời gian:`
102
102
 
103
103
  ## Selectors (priority order)
104
104