@sun-asterisk/sungen 2.6.7 → 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,37 +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` | Extra BVA combinations, cross-field validation, negative/destructive inputs, concurrent/race conditions, complex state transitions | Recommended after Tier 2 completes |
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
18
  | **Full** (all-at-once) | All | Tier 1 + 2 + 3 combined in one run | Option at first run, **not recommended** — large output |
19
19
 
20
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).
21
21
 
22
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.
23
23
 
24
- **Round 3 (Tier 3)** deepens coverage with advanced test design techniques after Tier 2 is complete. This tier focuses on scenarios that Tier 1+2 didn't cover:
25
- - **Extra BVA combinations**: additional boundary points not covered in Tier 1 (e.g., `min+1`, `max-1`, typical values between boundaries)
26
- - **Cross-field validation**: field A value affects field B behavior (dependent fields, conditional required, cascading dropdowns)
27
- - **Negative/destructive inputs**: SQL injection, XSS payloads, special characters, excessively long strings, unicode edge cases
28
- - **Concurrent/race conditions**: double submit, back button after submit, multiple tabs, session expiry mid-action
29
- - **Complex state transitions**: multi-step state changes, undo/redo, conflicting state updates, transition from every non-obvious state
30
-
31
24
  ## Update Mode
32
25
 
33
- When `.feature` already has scenarios, summarize existing coverage 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**
34
32
 
35
- **If only Tier 1 exists** (only `@high` scenarios):
33
+ **If Tier 1 only:**
36
34
  1. **Add new sections** — append new sections with Tier 2 (`@normal` + `@low`) scenarios, continue numbering
37
35
  2. **Add viewpoints** — expand existing sections with Tier 2 (`@normal` + `@low`) scenarios
38
- 3. **Replace all** — overwrite with fresh Tier 1 (`@high`) generation
39
36
 
40
- **If Tier 1 + 2 exist** (`@high` + `@normal` + `@low` scenarios):
37
+ **If Tier 1 + 2:**
41
38
  1. **Deep coverage (Tier 3)** — add advanced scenarios: extra BVA, cross-field validation, negative inputs, race conditions **(Recommended)**
42
39
  2. **Add new sections** — append new sections with Tier 2 scenarios, continue numbering
43
- 3. **Replace all** — overwrite with fresh Tier 1 (`@high`) generation
44
40
 
45
- **If Tier 1 + 2 + 3 exist** (full coverage already):
41
+ **If Tier 1 + 2 + 3** (full coverage):
46
42
  1. **Add new sections** — append new sections if screen has changed
47
- 2. **Replace all** — overwrite with fresh Tier 1 (`@high`) generation
43
+
44
+ > **Replace all** (available in all modes) — overwrite with fresh Tier 1 (`@high`) generation. Use when spec has changed significantly.
48
45
 
49
46
  For append: read highest `VP-<CAT>-<NNN>`, continue from next number. Never modify existing scenarios.
50
47
 
@@ -59,6 +56,58 @@ Requirements improve every viewpoint: exact error messages for VAL, business rul
59
56
 
60
57
  If also exploring live page: verify spec vs actual, flag mismatches, capture exact text.
61
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
+
62
111
  ### Figma supplement (`spec_figma.md`)
63
112
 
64
113
  When `requirements/spec_figma.md` is present alongside `spec.md`, treat it as a **secondary input** with these rules:
@@ -122,7 +171,7 @@ Apply `sungen-test-design-techniques` to spec-extracted conditions:
122
171
  Use `sungen-viewpoint` skill for per-pattern checklists across 4 viewpoints: UI/UX, Data & Validate, Logic, Security.
123
172
 
124
173
  **Tier-aware gap filling:**
125
- - **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.
126
175
  - **Tier 2 (expand run)**: add `@normal` + `@low` scenarios — UI presence, optional validation, edge cases, cosmetic checks, keyboard nav, hover effects.
127
176
  - **Tier 3 (deep run)**: do NOT use viewpoint checklists. Instead, re-apply test design techniques with deeper analysis:
128
177
  - **BVA**: expand from 4-point to 6-point (`min-1`, `min`, `min+1`, `max-1`, `max`, `max+1`) + typical mid-range value
@@ -130,7 +179,7 @@ Use `sungen-viewpoint` skill for per-pattern checklists across 4 viewpoints: UI/
130
179
  - **Cross-field**: identify field dependencies from spec, generate one scenario per dependency
131
180
  - **Negative inputs**: add security-oriented inputs (SQL `' OR 1=1`, XSS `<script>`, special chars `<>&"'`, max+100 length)
132
181
  - **Race conditions**: double-click submit, browser back after POST, concurrent edit by two users
133
- - **Full (all-at-once)**: apply Tier 1 + 2 + 3 rules in a single generation pass. Use all techniques at maximum depth.
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.
134
183
 
135
184
  **Validation rule**: capture actual error messages from live page or spec.md. Use `User see {{error_var}}` — never assert just "is visible".
136
185
 
@@ -140,29 +189,35 @@ Every scenario **MUST** have exactly one priority tag. Add it before the scenari
140
189
 
141
190
  **Rule: look at what the WHEN step does and what THEN asserts — that determines the tag.**
142
191
 
143
- | Tag | When to use |
144
- |---|---|
145
- | `@high` | WHEN performs: login/logout, submit happy path, auth-check, primary CRUD action. THEN asserts: success state, redirect, or security gate |
146
- | `@normal` | WHEN provides invalid/empty input, OR scenario tests search/filter/notification/secondary flow. THEN asserts: error message, secondary feature result |
147
- | `@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).
148
207
 
149
- ### Auto-assign heuristics
208
+ ### Priority assignment — disambiguation tie-breaker
150
209
 
151
- | Scenario type (by WHEN + THEN structure) | Tag |
210
+ When in doubt between `@low` and `@normal`, apply this rule:
211
+
212
+ | Pattern | Tag |
152
213
  |---|---|
153
- | Auth: login / logout / protected page redirect | `@high` |
154
- | CRUD happy path: create / update / delete success message or redirect | `@high` |
155
- | Security: unauthenticated access redirected to login | `@high` |
156
- | Primary business flow step completes successfully | `@high` |
157
- | Validation: invalid / empty input error message shown | `@normal` |
158
- | Boundary / format validation (email, length, range) | `@normal` |
159
- | Secondary features: search, filter, sort, pagination, notification | `@normal` |
160
- | State transition not on primary success path (cancel, undo, back) | `@normal` |
161
- | Element / component presence check (is it visible?) | `@low` |
162
- | Text content: label, placeholder, tooltip, warning message text | `@low` |
163
- | 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 |
164
219
 
165
- **`@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`.
166
221
 
167
222
  ## SPA Wait-For Steps
168
223
 
@@ -280,9 +335,9 @@ Feature: <Screen> Screen
280
335
  Then User is on [Login] page
281
336
  ```
282
337
 
283
- **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.
284
339
 
285
- **Tier 3 (deep run)** adds advanced `@high` + `@normal` scenarios: extra BVA boundaries, cross-field validation, negative/destructive inputs, concurrent/race conditions.
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.
286
341
 
287
342
  ### When to use DataTable vs Row Scope
288
343
 
@@ -295,21 +350,7 @@ Feature: <Screen> Screen
295
350
 
296
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.
297
352
 
298
- **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:
299
-
300
- ```yaml
301
- # login.yaml (base)
302
- valid_email: admin@dev.example.com
303
- valid_password: DevPass123
304
-
305
- # login.staging.yaml (override for staging)
306
- valid_email: admin@staging.example.com
307
- valid_password: StagingPass456
308
- ```
309
-
310
- **Do NOT generate**: `selectors.yaml` (created during run-test), Playwright code (sungen compiles).
311
-
312
- ---
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.
313
354
 
314
355
  ## Flow Test Generation
315
356
 
@@ -332,15 +373,41 @@ When generating tests for a **flow** (`qa/flows/<name>/`), adapt the strategy:
332
373
  | Tier 1 focus | Happy path + required validation per section | Happy path through entire flow + auth + key error recovery |
333
374
  | Background | Navigate to screen | Navigate to starting page |
334
375
 
335
- ### Flow-specific scenarios to generate
376
+ ### Flow-specific scenarios by tier
336
377
 
337
- | Category | Examples |
338
- |---|---|
339
- | **Happy path** | Complete flow end-to-end with valid data |
340
- | **Auth persistence** | Auth state maintained across screen transitions |
341
- | **Error recovery** | Invalid input mid-flow → fix → continue |
342
- | **Incomplete flow** | User abandons at each phase → state cleanup |
343
- | **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.
344
411
 
345
412
  ### Output Format (Flow)
346
413
 
@@ -351,6 +418,8 @@ Feature: Award Submission Flow
351
418
  Background:
352
419
  Given User is on [Login] page
353
420
 
421
+ # --- Section: Login Phase (Tier 1: @high) ---
422
+
354
423
  @high
355
424
  Scenario: User login successfully
356
425
  When User fill [Login:Email] field with {{login.email}}
@@ -358,6 +427,8 @@ Feature: Award Submission Flow
358
427
  And User click [Login:Submit] button
359
428
  Then User see [Dashboard] page
360
429
 
430
+ # --- Section: Submission Phase (Tier 1: @high) ---
431
+
361
432
  @high
362
433
  Scenario: User navigates to awards and submits
363
434
  Given User is on [Awards] page
@@ -378,3 +449,5 @@ submission:
378
449
  reason: "Outstanding contribution to the team"
379
450
  success_message: "Award submitted successfully"
380
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