@sun-asterisk/sungen 2.6.6 → 2.6.8

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.
@@ -14,17 +14,34 @@ Generate **focused test cases per screen section** using a **tier-based approach
14
14
  |---|---|---|---|
15
15
  | **Tier 1** (default) | `@high` | Happy paths, required validation, core business rules, security basics | First run of `create-test` |
16
16
  | **Tier 2** (expand) | `@normal` + `@low` | UI presence, optional validation, edge cases, cosmetic checks | User runs `create-test` again with "Add viewpoints" mode |
17
+ | **Tier 3** (deep) | `@high` + `@normal` + `@low` | Extra BVA combinations, cross-field validation, negative/destructive inputs, concurrent/race conditions, complex state transitions | Recommended after Tier 2 completes |
18
+ | **Full** (all-at-once) | All | Tier 1 + 2 + 3 combined in one run | Option at first run, **not recommended** — large output |
17
19
 
18
- **Round 1 (Tier 1)** targets **~10-15 scenarios per section** — enough to cover critical flows and catch real bugs. This is the default behavior.
20
+ **Round 1 (Tier 1)** targets **~10-15 scenarios per section** — enough to cover critical flows and catch real bugs. This is the default behavior. A **Full** option is available but not recommended — it generates all tiers at once, producing very large output (~40-60 scenarios/section).
19
21
 
20
- **Round 2 (Tier 2)** expands to full coverage when the user explicitly chooses "Add viewpoints" or "Add new sections" update mode. Only then generate `@normal` + `@low` scenarios to fill coverage gaps.
22
+ **Round 2 (Tier 2)** expands coverage when the user explicitly chooses "Add viewpoints" or "Add new sections" update mode. Only then generate `@normal` + `@low` scenarios to fill coverage gaps.
21
23
 
22
24
  ## Update Mode
23
25
 
24
- When `.feature` already has scenarios, summarize and ask:
26
+ When `.feature` already has scenarios, detect which tiers exist by scanning section comments, then ask the appropriate update mode.
27
+
28
+ **Tier detection** — scan for `# --- Section:` comments:
29
+ - Only `(Tier 1: @high)` comments → **Tier 1 only**
30
+ - Has `(Tier 2: @normal + @low)` comments → **Tier 1 + 2**
31
+ - Has `(Tier 3: deep)` comments → **Tier 1 + 2 + 3**
32
+
33
+ **If Tier 1 only:**
25
34
  1. **Add new sections** — append new sections with Tier 2 (`@normal` + `@low`) scenarios, continue numbering
26
35
  2. **Add viewpoints** — expand existing sections with Tier 2 (`@normal` + `@low`) scenarios
27
- 3. **Replace all** — overwrite with fresh Tier 1 (`@high`) generation
36
+
37
+ **If Tier 1 + 2:**
38
+ 1. **Deep coverage (Tier 3)** — add advanced scenarios: extra BVA, cross-field validation, negative inputs, race conditions **(Recommended)**
39
+ 2. **Add new sections** — append new sections with Tier 2 scenarios, continue numbering
40
+
41
+ **If Tier 1 + 2 + 3** (full coverage):
42
+ 1. **Add new sections** — append new sections if screen has changed
43
+
44
+ > **Replace all** (available in all modes) — overwrite with fresh Tier 1 (`@high`) generation. Use when spec has changed significantly.
28
45
 
29
46
  For append: read highest `VP-<CAT>-<NNN>`, continue from next number. Never modify existing scenarios.
30
47
 
@@ -39,6 +56,58 @@ Requirements improve every viewpoint: exact error messages for VAL, business rul
39
56
 
40
57
  If also exploring live page: verify spec vs actual, flag mismatches, capture exact text.
41
58
 
59
+ ### Tier 1 — Lightweight Guard
60
+
61
+ > Tier 1 uses the quick 3-step strategy (Step 1–3) without full section walking. After generation, verify these checks against `spec.md` — if any are missing, add them before finalizing:
62
+
63
+ | Spec section | Minimum TC requirement | Tag |
64
+ |---|---|---|
65
+ | Fields row, `Required=yes` | At least 1 required-error TC per required field | `@high` |
66
+ | Validation Rules row | At least 1 exact-message TC per validation rule | `@high` |
67
+ | Business Rule bullet | At least 1 behavioral TC per business rule | `@high` |
68
+ | Security-sensitive actions (auth, permissions) | At least 1 security check (VP-SEC) | `@high` |
69
+ | Entity with lifecycle states | At least 1 key state transition (VP-LOGIC) | `@high` |
70
+
71
+ Other spec sections (Section header, Default, Accessibility, Notes) are deferred to Tier 2.
72
+
73
+ ### Mapping Contract (Tier 2+ — MANDATORY)
74
+
75
+ > **Full contract applies from Tier 2 onwards.** Walk `spec.md` top-to-bottom. For every section listed below, you **MUST** produce the indicated TCs. If a section is missing or empty, note it explicitly — do **NOT** silently skip.
76
+
77
+ #### Table 1 — `spec.md` → TC Mapping Contract
78
+
79
+ | Spec section | TC requirement | Tier | Tag | Viewpoint |
80
+ |---|---|---|---|---|
81
+ | Section header | 1 presence TC | T2 | `@low` | VP-UI |
82
+ | Fields row, `Required=yes` | 1 per-field required-error TC (individual, not bulk) | T2 | `@normal` | VP-VAL |
83
+ | Fields `Constraints` cell (non-empty, non-`—`) | 4 BVA for numeric range; 1 EP for format | T2 | `@normal` | VP-VAL |
84
+ | Fields `Constraints` cell (numeric) | 2 extra BVA (`min+1`, `max-1`) + mid-range → total 7-point with T2 | T3 | `@normal` | VP-VAL |
85
+ | Fields `Default` cell (non-empty, non-`—`) | 1 default-state TC | T2 | `@low` | VP-UI |
86
+ | Fields with dependencies (conditional required, cascading) | 1 cross-field TC per dependency | T3 | `@normal` | VP-VAL |
87
+ | Fields accepting free text input | 1 negative input TC (XSS/SQL injection/special chars) | T3 | `@high` | VP-SEC |
88
+ | Actions row (primary: submit, create, delete) | 1 edge/alternate behavior TC | T2 | `@normal` | VP-LOGIC |
89
+ | Actions row (secondary: cancel, reset, export) | 1 behavior TC | T2 | `@normal` | VP-LOGIC |
90
+ | Actions with submit/save | 1 race condition TC (double-submit, back after POST) | T3 | `@normal` | VP-LOGIC |
91
+ | Validation Rules row | 1 exact-message TC | T2 | `@normal` | VP-VAL |
92
+ | States row (Default/Loading/Error/Success) | 1 visual state TC | T2 | `@normal` | VP-UI / VP-LOGIC |
93
+ | States row (other states) | 1 visual TC | T2 | `@low` | VP-UI |
94
+ | Business Rule bullet | 1 edge-case behavioral TC; `@manual` if unautomatable | T2 | `@normal` | VP-LOGIC |
95
+ | Accessibility tab order | 1 tab-walking TC | T2 | `@low` | VP-UI |
96
+ | Notes bullet | classify per content (page title→VP-UI, env→`@manual`, edge→relevant section) | T2 | `@low` | varies |
97
+
98
+ #### Table 2 — `test-viewpoint.md` → TC Mapping Contract
99
+
100
+ | Section / format | TC requirement |
101
+ |---|---|
102
+ | `## Edge Cases` (bulleted) | classify per spec Notes |
103
+ | `## Known Issues` (bulleted) | `@manual` TCs with bug ID comment |
104
+ | `## Design Decisions` | behavioral TCs |
105
+ | `## UI Patterns Identified` | confirm `sungen-viewpoint` pattern checklists |
106
+ | `## Priority Viewpoints` | adjust Tier-2 emphasis |
107
+ | `## Element Overview` (table) | 1 presence/state TC per row (T2, `@low`) |
108
+ | `## State Transitions` (table) | 1 TC per valid transition + key blocked |
109
+ | Free-form notes | re-read with heading as context |
110
+
42
111
  ### Figma supplement (`spec_figma.md`)
43
112
 
44
113
  When `requirements/spec_figma.md` is present alongside `spec.md`, treat it as a **secondary input** with these rules:
@@ -102,8 +171,15 @@ Apply `sungen-test-design-techniques` to spec-extracted conditions:
102
171
  Use `sungen-viewpoint` skill for per-pattern checklists across 4 viewpoints: UI/UX, Data & Validate, Logic, Security.
103
172
 
104
173
  **Tier-aware gap filling:**
105
- - **Tier 1 (first run)**: only add `@high` items from the checklists — core security checks (VP-SEC), required field validation (VP-VAL), key state transitions (VP-LOGIC). Skip `@normal`/`@low` items like hover states, empty states, tooltips.
174
+ - **Tier 1 (first run)**: only add `@high` items from the checklists. Skip `@normal`/`@low` items. After generation, apply the **Lightweight Guard** to verify coverage.
106
175
  - **Tier 2 (expand run)**: add `@normal` + `@low` scenarios — UI presence, optional validation, edge cases, cosmetic checks, keyboard nav, hover effects.
176
+ - **Tier 3 (deep run)**: do NOT use viewpoint checklists. Instead, re-apply test design techniques with deeper analysis:
177
+ - **BVA**: expand from 4-point to 6-point (`min-1`, `min`, `min+1`, `max-1`, `max`, `max+1`) + typical mid-range value
178
+ - **Decision Table**: enumerate combinations previously capped — cover remaining outcome rows
179
+ - **Cross-field**: identify field dependencies from spec, generate one scenario per dependency
180
+ - **Negative inputs**: add security-oriented inputs (SQL `' OR 1=1`, XSS `<script>`, special chars `<>&"'`, max+100 length)
181
+ - **Race conditions**: double-click submit, browser back after POST, concurrent edit by two users
182
+ - **Full (all-at-once)**: apply Tier 1 + 2 + 3 rules in a single pass. Use all viewpoint checklists and all test design technique depths. Mark sections with all three tier comments.
107
183
 
108
184
  **Validation rule**: capture actual error messages from live page or spec.md. Use `User see {{error_var}}` — never assert just "is visible".
109
185
 
@@ -113,29 +189,35 @@ Every scenario **MUST** have exactly one priority tag. Add it before the scenari
113
189
 
114
190
  **Rule: look at what the WHEN step does and what THEN asserts — that determines the tag.**
115
191
 
116
- | Tag | When to use |
117
- |---|---|
118
- | `@high` | WHEN performs: login/logout, submit happy path, auth-check, primary CRUD action. THEN asserts: success state, redirect, or security gate |
119
- | `@normal` | WHEN provides invalid/empty input, OR scenario tests search/filter/notification/secondary flow. THEN asserts: error message, secondary feature result |
120
- | `@low` | THEN only asserts: element visible, text label, placeholder, tooltip, icon, layout. WHEN (if any) is navigation only |
192
+ | Tag | Scenario type | Examples |
193
+ |---|---|---|
194
+ | `@high` | Auth actions | login, logout, protected page redirect |
195
+ | `@high` | CRUD happy path | create / update / delete success message or redirect |
196
+ | `@high` | Security gate | unauthenticated access redirected to login |
197
+ | `@high` | Primary business flow | core flow step completes successfully |
198
+ | `@normal` | Input validation | invalid / empty input → error message shown |
199
+ | `@normal` | Boundary / format | email format, length limit, numeric range |
200
+ | `@normal` | Secondary features | search, filter, sort, pagination, notification |
201
+ | `@normal` | Non-primary state transition | cancel, undo, back |
202
+ | `@low` | Element presence | component / section is visible |
203
+ | `@low` | Text content | label, placeholder, tooltip, warning text |
204
+ | `@low` | Visual / cosmetic | alignment, icon, empty state, hover style |
205
+
206
+ **`@steps:` scenarios** do NOT get a priority tag (they are setup blocks, not test cases).
207
+
208
+ ### Priority assignment — disambiguation tie-breaker
121
209
 
122
- ### Auto-assign heuristics
210
+ When in doubt between `@low` and `@normal`, apply this rule:
123
211
 
124
- | Scenario type (by WHEN + THEN structure) | Tag |
212
+ | Pattern | Tag |
125
213
  |---|---|
126
- | Auth: login / logout / protected page redirect | `@high` |
127
- | CRUD happy path: create / update / delete success message or redirect | `@high` |
128
- | Security: unauthenticated access redirected to login | `@high` |
129
- | Primary business flow step completes successfully | `@high` |
130
- | Validation: invalid / empty input error message shown | `@normal` |
131
- | Boundary / format validation (email, length, range) | `@normal` |
132
- | Secondary features: search, filter, sort, pagination, notification | `@normal` |
133
- | State transition not on primary success path (cancel, undo, back) | `@normal` |
134
- | Element / component presence check (is it visible?) | `@low` |
135
- | Text content: label, placeholder, tooltip, warning message text | `@low` |
136
- | Visual / cosmetic: alignment, icon, empty state, hover style | `@low` |
214
+ | 0 When steps + Then asserts only `User see [T] type` (presence) | `@low` (always) |
215
+ | 0 When steps + Then asserts `User see [T] type with {{value}}` (content) | `@low` (label/text) |
216
+ | When steps but no state change (e.g., navigation only) | `@low` |
217
+ | When provides invalid input + Then asserts validation error | `@normal` |
218
+ | When triggers business logic + Then asserts state change | `@high` or `@normal` per heuristics |
137
219
 
138
- **`@steps:` scenarios** do NOT get a priority tag (they are setup blocks, not test cases).
220
+ **Example:** `Then User see [Email] field` (no When) `@low`. `When User fill ... And User click ... Then User see [Error]` → `@normal`.
139
221
 
140
222
  ## SPA Wait-For Steps
141
223
 
@@ -253,7 +335,9 @@ Feature: <Screen> Screen
253
335
  Then User is on [Login] page
254
336
  ```
255
337
 
256
- **Tier 2 (expand run)** adds `@normal` + `@low` scenarios like UI field presence, hover states, tooltips, empty states.
338
+ **Tier 2 (expand run)** appends sections with `# --- Section: X (Tier 2: @normal + @low) ---` comments. Adds UI field presence, hover states, tooltips, empty states.
339
+
340
+ **Tier 3 (deep run)** appends sections with `# --- Section: X (Tier 3: deep) ---` comments. Adds extra BVA boundaries, cross-field validation, negative/destructive inputs, concurrent/race conditions.
257
341
 
258
342
  ### When to use DataTable vs Row Scope
259
343
 
@@ -266,21 +350,7 @@ Feature: <Screen> Screen
266
350
 
267
351
  **Test data** — `qa/screens/<screen>/test-data/<screen>.yaml`, grouped by section. Data is loaded **at runtime** — keys become runtime lookups, not hardcoded strings. The same compiled test works across environments.
268
352
 
269
- **Environment-specific data**: For values that differ per environment (credentials, URLs, test users), create `<screen>.<env>.yaml` alongside the base file. Users run `SUNGEN_ENV=staging npx playwright test` to merge overrides. Structure env YAML with the same keys, only including values that change:
270
-
271
- ```yaml
272
- # login.yaml (base)
273
- valid_email: admin@dev.example.com
274
- valid_password: DevPass123
275
-
276
- # login.staging.yaml (override for staging)
277
- valid_email: admin@staging.example.com
278
- valid_password: StagingPass456
279
- ```
280
-
281
- **Do NOT generate**: `selectors.yaml` (created during run-test), Playwright code (sungen compiles).
282
-
283
- ---
353
+ **Environment-specific data**: create `<screen>.<env>.yaml` alongside the base file with only the keys that change. Users run `SUNGEN_ENV=staging npx playwright test` to merge overrides.
284
354
 
285
355
  ## Flow Test Generation
286
356
 
@@ -303,15 +373,41 @@ When generating tests for a **flow** (`qa/flows/<name>/`), adapt the strategy:
303
373
  | Tier 1 focus | Happy path + required validation per section | Happy path through entire flow + auth + key error recovery |
304
374
  | Background | Navigate to screen | Navigate to starting page |
305
375
 
306
- ### Flow-specific scenarios to generate
376
+ ### Flow-specific scenarios by tier
307
377
 
308
- | Category | Examples |
309
- |---|---|
310
- | **Happy path** | Complete flow end-to-end with valid data |
311
- | **Auth persistence** | Auth state maintained across screen transitions |
312
- | **Error recovery** | Invalid input mid-flow → fix → continue |
313
- | **Incomplete flow** | User abandons at each phase → state cleanup |
314
- | **Cross-screen data** | Data entered on screen A visible on screen B |
378
+ | Category | Tier | Examples |
379
+ |---|---|---|
380
+ | **Happy path** | T1 | Complete flow end-to-end with valid data |
381
+ | **Auth persistence** | T1 | Auth state maintained across screen transitions |
382
+ | **Error recovery** | T1 | Invalid input mid-flow → fix → continue |
383
+ | **Incomplete flow** | T2 | User abandons at each phase → state cleanup |
384
+ | **Cross-screen data** | T2 | Data entered on screen A visible on screen B |
385
+ | **Screen transition edges** | T2 | Back button, refresh, deep link mid-flow |
386
+ | **UI state across screens** | T2 | Breadcrumb, progress indicator, nav state |
387
+ | **Negative inputs mid-flow** | T3 | XSS/SQL in cross-screen fields, special chars |
388
+ | **Concurrent flow** | T3 | Two tabs same flow, session expiry mid-flow |
389
+ | **Cross-screen validation** | T3 | Field dependency across screens, cascading errors |
390
+
391
+ ### Flow Lightweight Guard (Tier 1)
392
+
393
+ > After generating Tier 1 flow scenarios, verify these checks — if any are missing, add them:
394
+
395
+ | Flow requirement | Minimum TC | Tag |
396
+ |---|---|---|
397
+ | Complete flow end-to-end with valid data | At least 1 happy path scenario | `@high` |
398
+ | Auth state across screen transitions | At least 1 auth persistence check (if flow crosses auth) | `@high` |
399
+ | Invalid input mid-flow → fix → continue | At least 1 error recovery scenario | `@high` |
400
+
401
+ ### Flow Section Comments
402
+
403
+ Flow features use the same `# --- Section:` comment format, with phase names instead of UI sections:
404
+
405
+ ```gherkin
406
+ # --- Section: Login Phase (Tier 1: @high) ---
407
+ # --- Section: Submission Phase (Tier 2: @normal + @low) ---
408
+ ```
409
+
410
+ Update Mode tier detection works identically — scan for tier markers in these comments.
315
411
 
316
412
  ### Output Format (Flow)
317
413
 
@@ -322,6 +418,8 @@ Feature: Award Submission Flow
322
418
  Background:
323
419
  Given User is on [Login] page
324
420
 
421
+ # --- Section: Login Phase (Tier 1: @high) ---
422
+
325
423
  @high
326
424
  Scenario: User login successfully
327
425
  When User fill [Login:Email] field with {{login.email}}
@@ -329,6 +427,8 @@ Feature: Award Submission Flow
329
427
  And User click [Login:Submit] button
330
428
  Then User see [Dashboard] page
331
429
 
430
+ # --- Section: Submission Phase (Tier 1: @high) ---
431
+
332
432
  @high
333
433
  Scenario: User navigates to awards and submits
334
434
  Given User is on [Awards] page
@@ -349,3 +449,5 @@ submission:
349
449
  reason: "Outstanding contribution to the team"
350
450
  success_message: "Award submitted successfully"
351
451
  ```
452
+
453
+ **Do NOT generate**: `selectors.yaml` (created during run-test), Playwright code (sungen compiles).
@@ -68,6 +68,45 @@ Scenario: VP-VAL-003 Above maximum is rejected # value = 101
68
68
  - `@high VP-VAL-012 Maximum boundary (10) is accepted`
69
69
  - `@high VP-VAL-013 Above maximum (11) is rejected`
70
70
 
71
+ ### Expected outcome contract (MANDATORY)
72
+
73
+ When generating BVA scenarios, the **Then** assertion **MUST** match the scenario name's outcome verb:
74
+
75
+ | Name verb | Expected `Then` assertion |
76
+ |---|---|
77
+ | "is accepted" / "passes validation" | NO validation error visible. Form proceeds OR field is in normal state. Use `User see [Field Error] message is hidden` if uncertain. |
78
+ | "is rejected" / "fails validation" / "shows error" | Specific validation error visible with exact message text from spec. |
79
+
80
+ **Anti-pattern (do NOT generate):**
81
+
82
+ ```gherkin
83
+ # BAD: name says "passes validation" but asserts auth error
84
+ Scenario: VP-VAL-005 Email at maximum boundary (254 chars) passes validation
85
+ When User fill [Email] field with {{email_max_254}}
86
+ And User fill [Password] field with {{valid_password}}
87
+ And User click [Login] button
88
+ Then User see [Auth Error] message with {{auth_error_message}}
89
+ ```
90
+
91
+ **Correct pattern:**
92
+
93
+ ```gherkin
94
+ # GOOD: name and assertion aligned
95
+ @normal
96
+ Scenario: VP-VAL-005 Email at maximum boundary (254 chars) passes validation
97
+ When User fill [Email] field with {{email_max_254}}
98
+ And User fill [Password] field with {{valid_password}}
99
+ And User click [Login] button
100
+ Then User see [Email Error] message is hidden
101
+
102
+ @normal
103
+ Scenario: VP-VAL-006 Email at maximum+1 (255 chars) fails validation
104
+ When User fill [Email] field with {{email_over_max_255}}
105
+ And User fill [Password] field with {{valid_password}}
106
+ And User click [Login] button
107
+ Then User see [Email Error] message with {{email_too_long_error}}
108
+ ```
109
+
71
110
  ---
72
111
 
73
112
  ## 3. Decision Table