@sun-asterisk/sungen 2.6.15 → 2.7.0-beta.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 (90) hide show
  1. package/dist/cli/index.js +3 -1
  2. package/dist/cli/index.js.map +1 -1
  3. package/dist/exporters/feature-parser.d.ts +9 -2
  4. package/dist/exporters/feature-parser.d.ts.map +1 -1
  5. package/dist/exporters/feature-parser.js +12 -4
  6. package/dist/exporters/feature-parser.js.map +1 -1
  7. package/dist/orchestrator/ai-rules-updater.d.ts.map +1 -1
  8. package/dist/orchestrator/ai-rules-updater.js +10 -0
  9. package/dist/orchestrator/ai-rules-updater.js.map +1 -1
  10. package/dist/orchestrator/project-initializer.d.ts +5 -0
  11. package/dist/orchestrator/project-initializer.d.ts.map +1 -1
  12. package/dist/orchestrator/project-initializer.js +16 -0
  13. package/dist/orchestrator/project-initializer.js.map +1 -1
  14. package/dist/orchestrator/templates/ai-instructions/claude-cmd-create-test.md +9 -1
  15. package/dist/orchestrator/templates/ai-instructions/claude-cmd-review.md +13 -12
  16. package/dist/orchestrator/templates/ai-instructions/claude-cmd-run-test.md +4 -2
  17. package/dist/orchestrator/templates/ai-instructions/claude-config.md +1 -1
  18. package/dist/orchestrator/templates/ai-instructions/claude-skill-delivery.md +1 -1
  19. package/dist/orchestrator/templates/ai-instructions/claude-skill-gherkin-syntax.md +14 -0
  20. package/dist/orchestrator/templates/ai-instructions/claude-skill-selector-fix.md +57 -11
  21. package/dist/orchestrator/templates/ai-instructions/claude-skill-selector-keys.md +41 -31
  22. package/dist/orchestrator/templates/ai-instructions/claude-skill-tc-generation.md +386 -326
  23. package/dist/orchestrator/templates/ai-instructions/claude-skill-tc-review.md +268 -90
  24. package/dist/orchestrator/templates/ai-instructions/claude-skill-test-design-techniques.md +23 -49
  25. package/dist/orchestrator/templates/ai-instructions/claude-skill-viewpoint-group-a-data-entry.md +203 -0
  26. package/dist/orchestrator/templates/ai-instructions/claude-skill-viewpoint-group-b-data-ops.md +179 -0
  27. package/dist/orchestrator/templates/ai-instructions/claude-skill-viewpoint-group-c-data-explore.md +233 -0
  28. package/dist/orchestrator/templates/ai-instructions/claude-skill-viewpoint-group-d-display.md +226 -0
  29. package/dist/orchestrator/templates/ai-instructions/claude-skill-viewpoint-group-e-identity.md +177 -0
  30. package/dist/orchestrator/templates/ai-instructions/claude-skill-viewpoint.md +69 -240
  31. package/dist/orchestrator/templates/ai-instructions/copilot-cmd-create-test.md +9 -1
  32. package/dist/orchestrator/templates/ai-instructions/copilot-cmd-review.md +13 -12
  33. package/dist/orchestrator/templates/ai-instructions/copilot-cmd-run-test.md +4 -2
  34. package/dist/orchestrator/templates/ai-instructions/copilot-config.md +1 -1
  35. package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-delivery.md +1 -1
  36. package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-gherkin-syntax.md +15 -21
  37. package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-selector-fix.md +61 -15
  38. package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-selector-keys.md +41 -31
  39. package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-tc-generation.md +371 -324
  40. package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-tc-review.md +262 -102
  41. package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-test-design-techniques.md +23 -49
  42. package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-viewpoint-group-a-data-entry.md +203 -0
  43. package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-viewpoint-group-b-data-ops.md +179 -0
  44. package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-viewpoint-group-c-data-explore.md +233 -0
  45. package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-viewpoint-group-d-display.md +226 -0
  46. package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-viewpoint-group-e-identity.md +177 -0
  47. package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-viewpoint.md +69 -240
  48. package/dist/orchestrator/templates/qa-context.md +90 -0
  49. package/dist/orchestrator/templates/readme.md +16 -13
  50. package/package.json +9 -1
  51. package/src/cli/index.ts +4 -1
  52. package/src/exporters/feature-parser.ts +12 -4
  53. package/src/orchestrator/ai-rules-updater.ts +10 -0
  54. package/src/orchestrator/project-initializer.ts +20 -0
  55. package/src/orchestrator/templates/ai-instructions/claude-cmd-create-test.md +9 -1
  56. package/src/orchestrator/templates/ai-instructions/claude-cmd-review.md +13 -12
  57. package/src/orchestrator/templates/ai-instructions/claude-cmd-run-test.md +4 -2
  58. package/src/orchestrator/templates/ai-instructions/claude-config.md +1 -1
  59. package/src/orchestrator/templates/ai-instructions/claude-skill-delivery.md +1 -1
  60. package/src/orchestrator/templates/ai-instructions/claude-skill-gherkin-syntax.md +14 -0
  61. package/src/orchestrator/templates/ai-instructions/claude-skill-selector-fix.md +57 -11
  62. package/src/orchestrator/templates/ai-instructions/claude-skill-selector-keys.md +41 -31
  63. package/src/orchestrator/templates/ai-instructions/claude-skill-tc-generation.md +386 -326
  64. package/src/orchestrator/templates/ai-instructions/claude-skill-tc-review.md +268 -90
  65. package/src/orchestrator/templates/ai-instructions/claude-skill-test-design-techniques.md +23 -49
  66. package/src/orchestrator/templates/ai-instructions/claude-skill-viewpoint-group-a-data-entry.md +203 -0
  67. package/src/orchestrator/templates/ai-instructions/claude-skill-viewpoint-group-b-data-ops.md +179 -0
  68. package/src/orchestrator/templates/ai-instructions/claude-skill-viewpoint-group-c-data-explore.md +233 -0
  69. package/src/orchestrator/templates/ai-instructions/claude-skill-viewpoint-group-d-display.md +226 -0
  70. package/src/orchestrator/templates/ai-instructions/claude-skill-viewpoint-group-e-identity.md +177 -0
  71. package/src/orchestrator/templates/ai-instructions/claude-skill-viewpoint.md +69 -240
  72. package/src/orchestrator/templates/ai-instructions/copilot-cmd-create-test.md +9 -1
  73. package/src/orchestrator/templates/ai-instructions/copilot-cmd-review.md +13 -12
  74. package/src/orchestrator/templates/ai-instructions/copilot-cmd-run-test.md +4 -2
  75. package/src/orchestrator/templates/ai-instructions/copilot-config.md +1 -1
  76. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-delivery.md +1 -1
  77. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-gherkin-syntax.md +15 -21
  78. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-selector-fix.md +61 -15
  79. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-selector-keys.md +41 -31
  80. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-tc-generation.md +371 -324
  81. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-tc-review.md +262 -102
  82. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-test-design-techniques.md +23 -49
  83. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-viewpoint-group-a-data-entry.md +203 -0
  84. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-viewpoint-group-b-data-ops.md +179 -0
  85. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-viewpoint-group-c-data-explore.md +233 -0
  86. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-viewpoint-group-d-display.md +226 -0
  87. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-viewpoint-group-e-identity.md +177 -0
  88. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-viewpoint.md +69 -240
  89. package/src/orchestrator/templates/qa-context.md +90 -0
  90. package/src/orchestrator/templates/readme.md +16 -13
@@ -1,417 +1,483 @@
1
1
  ---
2
2
  name: sungen-tc-generation
3
- description: 'Test case generation strategy section-focused, viewpoint-driven, Gherkin + test-data only. Auto-loaded by create-test command.'
3
+ description: 'Use when create-test needs to translate spec.md/Figma/UI into .feature + test-data.yaml. Invoke after requirements are read, before any selectors.yaml work.'
4
4
  user-invocable: false
5
5
  ---
6
6
 
7
- ## Goal
7
+ ## ⚠️ Gotchas — read before generating
8
8
 
9
- Generate **focused test cases per screen section** using a **tier-based approach** for faster results. Output `.feature` + `test-data.yaml` only — selectors are deferred to `/sungen:run-test`.
9
+ - `spec_figma.md` exists read file only, **NEVER** call `mcp__figma__*`
10
+ → PAT auth flow already done by `sungen-figma-source`; re-calling fails or duplicates work.
10
11
 
11
- ### Tier System
12
+ - `selectors.yaml` → do **NOT** generate — handled by `run-test`
13
+ → Selectors need live DOM inspection via Playwright MCP, only `run-test` triggers it.
12
14
 
13
- | Tier | Priority | What to generate | When |
14
- |---|---|---|---|
15
- | **Tier 1** (default) | `@high` | Happy paths, required validation, core business rules, security basics | First run of `create-test` |
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 |
15
+ - `@steps:` scenarios **NO** priority tag (setup blocks, not test cases)
16
+ → Priority tags filter test runs; setup blocks must always run via `@extend:`, never be filtered out.
19
17
 
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).
18
+ - Hardcode exact error messages in test-data.yamlnever leave `{{error}}` vague
19
+ → Assertions are string-equal; vague placeholders produce false-positive passes.
21
20
 
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
+ - `@parallel` required when mixing `@auth:X` + `@no-auth` in the same feature
22
+ → Playwright shares browser context per worker; auth state leaks across scenarios without isolation.
23
23
 
24
- ## Update Mode
24
+ - XSS ≠ SQL injection — generate as **2 separate scenarios**, never merge
25
+ → Different attack vectors (client render vs DB query) and different observable failures (alert popup vs DB error).
25
26
 
26
- When `.feature` already has scenarios, detect which tiers exist by scanning section comments, then ask the appropriate update mode.
27
+ - **SQL injection has 2 layers generate both when field reaches a backend query:**
28
+ - Layer 1 → field UI: special chars blocked by input field → `@high` automated scenario
29
+ - Layer 2 → API server: field accepts alphanumeric (e.g. LIKE/search field) → send payload like `1 OR 1=1` directly to API (curl/Postman, bypass UI) → verify server uses parameterized query, not string concat → `@high @manual`
30
+ → Skipping Layer 2 = missing real attack vector even when field validation is correct.
31
+ → Trigger: any free-text field whose value reaches a LIKE, partial-match, or dynamic WHERE clause.
27
32
 
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**
33
+ - **Concurrent / race conditions generate `@manual` when spec or viewpoint mentions multi-tab, multi-user, or simultaneous actions:**
34
+ Examples: two browser tabs same search with different conditions must not contaminate each other; double-click submit must not create duplicates.
35
+ `@normal @manual` by default unless data integrity at risk `@high @manual`.
36
+ Do NOT skip because "hard to automate" — document as `@manual` so it appears in the test plan.
32
37
 
33
- **If Tier 1 only:**
34
- 1. **Add new sections**append new sections with Tier 2 (`@normal` + `@low`) scenarios, continue numbering
35
- 2. **Add viewpoints** expand existing sections with Tier 2 (`@normal` + `@low`) scenarios
38
+ - Spec mentions outcomes on a **different user-facing surface** (another URL, mobile app, user portal, widget)
39
+ "Single screen focus" means don't test other screens' UI patterns it does NOT exempt you from documenting business outcomes on other surfaces.
40
+ **Always generate `@manual` scenarios for the output surface** at minimum one `@high @manual` per cross-surface business rule.
41
+ → If the output surface is reachable with a different auth role in the same test run, use `@auth:role` + `@extend` setup instead of `@manual`.
42
+ → Skipping these entirely = zero test can catch "admin creates record correctly but user never sees it" — the most silent failure class.
43
+ → Add `Display surfaces` + `Cross-surface rules` to the Coverage Map (see Step 2).
36
44
 
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
45
+ - Spec uses **inclusive boundary operators** (`<=`, `>=`, `≤`, `≥`, "at least N", "no more than N", "up to and including")
46
+ The boundary point itself **must** be a test case not just "inside" and "outside" regions.
47
+ Generate: `boundary - 1` (must fail/not-display), `boundary` (must pass/display), `boundary + 1` (must pass or fail depending on direction).
48
+ → Example: `end_at >= now` → test `end_at = now` (inclusive: display), `end_at = now - 1s` (exclusive: no display).
49
+ → Off-by-one at inclusive boundaries is the most common display-logic bug.
40
50
 
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.
45
-
46
- For append: read highest `VP-<CAT>-<NNN>`, continue from next number. Never modify existing scenarios.
51
+ - **AND condition in business rule test each branch failing independently:**
52
+ When spec defines "A AND B AND C must all be true", generate:
53
+ (1) A fails while B/C pass, (2) B fails while A/C pass, (3) C fails while A/B pass.
54
+ OR condition: generate 1 scenario per branch where that branch alone triggers the outcome.
55
+ → Happy-path only = missing the most common multi-condition implementation bug.
47
56
 
48
- ## Requirements-Driven Generation
57
+ ---
49
58
 
50
- When `qa/screens/<screen>/requirements/` exists:
51
- - **`spec.md`** — primary: sections, field constraints, validation messages, business rules, states
52
- - **`ui/`** — supplementary: screenshots for layout/visual context
53
- - **`test-viewpoint.md`** — supplementary: edge cases, known issues
59
+ ## Tier System
54
60
 
55
- Requirements improve every viewpoint: exact error messages for VAL, business rules for LOGIC, role permissions for SEC.
61
+ | Tier | Priority | What to generate | When |
62
+ |---|---|---|---|
63
+ | **Tier 1** (default) | `@high` | Happy paths, required validation, core business rules, security basics | First run of `create-test` |
64
+ | **Tier 2** (expand) | `@normal` + `@low` | UI presence, optional validation, edge cases, cosmetic checks | User runs `create-test` with "Add viewpoints" mode |
56
65
 
57
- If also exploring live page: verify spec vs actual, flag mismatches, capture exact text.
66
+ **Tier 1 stops when:**
67
+ - Every core user task has a happy-path scenario
68
+ - Every validation rule has at least one negative case (required, format, boundary)
69
+ - Every business rule has at least one scenario
70
+ - Security basics covered (auth redirect, permission blocked, injection)
58
71
 
59
- ### Tier 1 Lightweight Guard
72
+ **Tier 2** only when the user explicitly chooses "Add viewpoints" or "Add new sections".
60
73
 
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:
74
+ **Fast-path** display-only screens (no form, no state machine, ≤2 sections):
75
+ skip Coverage Map (Step 2) entirely. Go straight to Output Format with Tier 1 VP-UI presence checks
76
+ and any obvious VP-SEC (auth redirect). Spec drives nothing here — viewpoint covers it.
62
77
 
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
-
111
- ### Figma supplement (`spec_figma.md`)
112
-
113
- When `requirements/spec_figma.md` is present alongside `spec.md`, treat it as a **secondary input** with these rules:
114
-
115
- - **Never override `spec.md`**: `spec.md` is authoritative for all business rules, field constraints, and behavior. `spec_figma.md` only supplements with visual/text data that `spec.md` may lack.
116
- - **`## Text Inventory` → literal strings**: use text label values from this section verbatim in `test-data.yaml` (button labels, input placeholders, error messages shown in Figma). Do not paraphrase or invent alternatives.
117
- - **`## Interaction States` → state coverage checkpoints**: use the listed variants (e.g., empty, loading, error, success) as a checklist for state-coverage scenarios. Only generate scenarios for states that are either (a) confirmed in both `spec.md` and `spec_figma.md`, or (b) explicitly documented in one source without contradiction from the other.
118
- - **Flag disagreements**: if a field name, label, or behavior in `spec_figma.md` contradicts `spec.md`, insert an HTML comment at the top of the `.feature` file:
119
- ```gherkin
120
- <!-- FIGMA-SPEC CONFLICT: <brief description> — using spec.md value -->
121
- ```
122
- Then proceed using the `spec.md` value.
123
-
124
- ## Screen Input Sources
125
-
126
- **Auto-detect** — the parent command (`create-test`) resolves visual sources before invoking this skill. By the time generation starts, the available sources are already determined:
127
- - `spec.md` — primary, always read if present
128
- - `spec_figma.md` — Figma supplement, read if present (PAT flow already completed)
129
- - `ui/*.png` — visual context, read if present
130
- - `test-viewpoint.md` — edge cases and known issues, read if present
78
+ ## Update Mode
131
79
 
132
- **IMPORTANT:** If `spec_figma.md` exists, do NOT call any `mcp__figma__*` tool. The PAT flow is complete — just read the file.
80
+ When `.feature` already has scenarios, summarize and ask:
81
+ 1. **Add new sections** — append Tier 1 scenarios, continue numbering
82
+ 2. **Add viewpoints** — expand existing sections with Tier 2 scenarios
83
+ 3. **Replace all** — overwrite with fresh Tier 1 generation
133
84
 
134
- **Single screen focus**: one URL = one screen. Don't explore sibling paths. Modals on same page = part of this screen.
85
+ For append: read highest `VP-<CAT>-<NNN>`, continue from next number. Never modify existing scenarios.
135
86
 
136
- ### Capture Real Data
87
+ > **IDs are immutable & append-only.** The dashboard tracks each test case by its ID (namespaced at export as `<SCREEN>-<CAT>-<NNN>`, e.g. `LOGIN-SEC-001`). When updating a `.feature`:
88
+ > - **Never renumber** existing scenarios — even when earlier ones were deleted. Renumbering changes the dashboard key and loses that test's pass/fail history.
89
+ > - **New scenarios** take the next unused number per `VP-<CAT>` group (continue from the highest; do NOT fill gaps left by deletions).
90
+ > - **Deleting** a scenario retires its number permanently — never reuse it.
91
+ > - Editing a scenario's title text or steps is fine — the ID stays the same.
137
92
 
138
- When exploring live page or reading Figma designs, actively collect to hardcode in `test-data.yaml`:
139
- - User names, option labels, card content, error messages, counter keywords
140
- - **Hardcode first, @manual last** — stale data that fails fast > @manual that never runs
93
+ ---
141
94
 
142
- ## Section Identification
95
+ ## Input Sources
143
96
 
144
- Identify sections from page patterns. Use `sungen-viewpoint` skill for the 10 pattern types (Form & Inputs, Data Table, Create/Add, Update/Edit, Delete, Search, Filter, Pagination, Modal/Dialog, List/Card). Present sections and ask user which to focus on.
97
+ Auto-detected by `create-test` before invoking this skill:
98
+ - `spec.md` — primary, always read if present
99
+ - `spec_figma.md` — Figma supplement (PAT flow already done — just read the file)
100
+ - `ui/*.png` — visual context
101
+ - `test-viewpoint.md` — test conditions checklist; scan entirely regardless of format.
102
+ Format varies across projects: hierarchical table (Level 1–4 columns), flat checklist,
103
+ prose, or mixed. Regardless of format:
104
+ 1. Scan entire file top to bottom.
105
+ 2. Each row / bullet / item = 1 viewpoint → add to `Viewpoint items` in Coverage Map.
106
+ 3. Do NOT pre-classify into buckets before scanning — classify only when
107
+ writing the scenario.
108
+ - `qa/context.md` — project-wide context set by the QA lead. Read ONCE before building the Coverage Map; apply to every screen. Extraction rules:
109
+ - **Roles** → for each role in the table: add to the `@auth:X` tag pool; generate a VP-SEC blocked-access scenario for every role boundary relevant to this screen.
110
+ - **Testing strategy → Focus areas** → if `security` listed: VP-SEC is mandatory Tier 1 for every free-text input regardless of spec risk level; if `ui` not listed: all VP-UI scenarios move to Tier 2 minimum.
111
+ - **Testing strategy → Mandatory coverage** → each line is a hard override applied to this screen regardless of spec risk; document in `Context constraints` of the Coverage Map.
112
+ - **Testing strategy → Deprioritize/skip** → record in `Context constraints`; suppress those VP categories from Tier 1 generation.
113
+ - **Global business rules** → add each to the `Business rules` section tagged `[G]` (e.g. `[G1 – soft-delete only]`); treat as `HIGH` risk unless stated otherwise.
114
+ - **Error patterns** → use as fallback only when `spec.md` does not give exact error text; never override spec-specified messages.
115
+ - If `qa/context.md` is absent: proceed without it — no impact on the generation flow.
116
+
117
+ **Single screen focus**: one URL = one screen. Modals on same page = part of this screen.
118
+ This means: do not test other screens' UI layout or navigation. It does NOT mean skip documenting business outcomes that your screen's actions cause on other surfaces. Those cross-surface outcomes must appear in the Coverage Map and be covered by at least `@manual` scenarios.
119
+
120
+ **Capture real data** from live page or Figma: option labels, error messages, counter keywords. Hardcode in `test-data.yaml` — stale data that fails fast beats `@manual` that never runs.
145
121
 
146
- ## Test Generation Strategy
122
+ ---
147
123
 
148
- ### Step 1 — Spec-first extraction (always do this first)
124
+ ## Generation Workflow
149
125
 
150
- Before applying any checklist, extract test conditions from `spec.md` (and `test-viewpoint.md` if present):
151
- - **Validation rules**: field constraints, error messages, required/optional
152
- - **Business rules**: eligibility, calculation logic, permission-based behavior
153
- - **State lifecycle**: allowed transitions, blocked transitions
154
- - **Edge cases**: boundary values, empty states, concurrent conditions
126
+ ### Step 1 Orient: patterns + risk
155
127
 
156
- These spec-extracted conditions drive **which scenarios exist** `sungen-viewpoint` only supplements with generic web UI coverage that spec doesn't explicitly state.
128
+ Identify core user tasks. Categorize page sections by UI pattern group using `sungen-viewpoint`:
129
+ data entry (A), data manipulation (B), data exploration (C), display/feedback (D), identity (E).
157
130
 
158
- ### Step 2 Apply test design techniques
131
+ Proceed directly to Step 2. Pause to ask the user only when section priority is genuinely ambiguous from spec (e.g. multiple top-level forms without business context).
159
132
 
160
- Apply `sungen-test-design-techniques` to spec-extracted conditions:
133
+ ### Step 2 Build Coverage Map
161
134
 
162
- | Technique | Apply when spec mentions |
163
- |---|---|
164
- | EP | Valid/invalid ranges, categories → **one** scenario per class, not per value |
165
- | BVA | Numeric range, string length → `min-1`, `min`, `max`, `max+1` (compact 4-point default) |
166
- | Decision Table | 2+ dependent conditions → one scenario per combination (cap at distinct outcomes if >3 conditions) |
167
- | State Transition | Entity lifecycle → one scenario per valid transition + key invalid transitions |
135
+ Read `spec.md` fully, then extract into a Coverage Map **before writing any scenario**. Nothing is skipped at this stage — risk only affects depth in Step 3.
168
136
 
169
- ### Step 3 Fill coverage gaps with viewpoint checklists
137
+ **Risk tags:** HIGH = complex business rules, cascading fields, multi-step state changes, auth/integration. LOW = display-only, static labels, read-only fields.
170
138
 
171
- Use `sungen-viewpoint` skill for per-pattern checklists across 4 viewpoints: UI/UX, Data & Validate, Logic, Security.
139
+ ```
140
+ Context constraints: [populated from qa/context.md before writing any scenario]
141
+ roles: [list roles, e.g. admin / manager / staff]
142
+ strategy: [active overrides, e.g. "VP-SEC mandatory T1", "VP-UI → T2 only"]
143
+ global rules: [G1 – ...] → also appear in Business rules below tagged [G]
144
+ → leave empty if qa/context.md is absent or has no entries applicable to this screen
145
+ User journeys: [J1 – ...], [J2 – ...]
146
+ Validation rules: [V1 – field → "exact error text"], [V2 – ...]
147
+ Business rules: [B1 HIGH – ...], [B2 LOW – ...]
148
+ Secondary behaviors: [SB1 – tiebreaker: when X identical → sort by Y DESC]
149
+ [SB2 – default state when no condition applies: ...]
150
+ → capture "otherwise", "when tied", "secondary sort", "fallback" rules here
151
+ States: [StateA → StateB], [blocked: StateC → StateA]
152
+ Security: [S1 HIGH – OAuth/SSO flow], [S2 HIGH – free-text inputs → XSS + SQL injection]
153
+ Concurrency risks: [C1 – spec/viewpoint mentions multi-tab, concurrent edit, or simultaneous action]
154
+ → leave empty if neither spec nor viewpoint mentions concurrency
155
+ Display surfaces: [Surface1 – /url, auth:role], [Surface2 – /url, auth:user] ← list every surface spec mentions as output
156
+ Cross-surface rules: [B1 – action on /admin → outcome on /user (3-condition AND logic)] ← mandatory if Display surfaces exist
157
+ Inclusive bounds: [start_at <= now → boundary: start_at=now must display], [end_at >= now → boundary: end_at=now must display]
158
+ Viewpoint items: [TV-01 – <exact wording from test-viewpoint row 1>]
159
+ [TV-02 – <exact wording from test-viewpoint row 2>]
160
+ → one entry per row/bullet in test-viewpoint.md, regardless of format
161
+ → leave empty if no test-viewpoint.md present
162
+ Spec gaps: [G1 – behavior undocumented → verify with dev]
163
+ ```
172
164
 
173
- **Tier-aware gap filling:**
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.
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.
165
+ **Example login screen (2 sections, 5 validation rules):**
166
+ ```
167
+ User journeys: [J1 account login with valid credentials]
168
+ Validation rules: [V1 empty email "Invalid email address"],
169
+ [V2 short password "Password must be at least 6 characters"],
170
+ [V3 invalid format "Invalid email address"],
171
+ [V4 wrong credentials "Invalid email or password"]
172
+ Business rules: [B1 HIGH toggle is same-page state, not route change]
173
+ States: [Default Account form], [Account form Google login],
174
+ [Account form Loading Success/Error]
175
+ Security: [S1 HIGH – free-text email/password → XSS + SQL injection]
176
+ Display surfaces: [Login page – /login, no-auth] ← same surface, no cross-surface rules needed
177
+ Cross-surface rules: (none)
178
+ Inclusive bounds: (none)
179
+ Spec gaps: [G1 – auth error on 401 unconfirmed on live]
180
+
181
+ Tier 1 output: VP-LOGIC-001 (toggle reveals form), VP-LOGIC-002 (restore Google state),
182
+ VP-LOGIC-003 (login success → redirect), VP-VAL-001 (empty fields),
183
+ VP-VAL-002 (invalid format), VP-VAL-003 (short password),
184
+ VP-VAL-004 (wrong credentials), VP-SEC-001 (XSS), VP-SEC-002 (SQL injection)
185
+ ```
183
186
 
184
- **Validation rule**: capture actual error messages from live page or spec.md. Use `User see {{error_var}}` — never assert just "is visible".
187
+ **Example admin notice management screen (cross-surface + inclusive bounds):**
188
+ ```
189
+ User journeys: [J1 – create notice], [J2 – edit notice], [J3 – toggle active], [J4 – delete notice]
190
+ Validation rules: [V1 – title empty → "必須項目です"], [V2 – end_at <= start_at → "終了日時は開始日時より後に…"],
191
+ [V3 – title > 255 chars → "255文字以内で入力してください"]
192
+ Business rules: [B1 CRITICAL – notice displays on user-facing portal only when: is_active=ON AND start_at<=now AND end_at>=now],
193
+ [B2 HIGH – is_active=ON by default on create; not on form],
194
+ [B3 HIGH – toggle not blocked by date range]
195
+ States: [Scheduled → Live → Expired], [any → OFF via toggle]
196
+ Security: [S1 HIGH – free-text title/content → XSS + SQL injection], [S2 HIGH – admin-only, non-admin blocked]
197
+ Display surfaces: [Admin panel – /admin/notices, auth:admin], [User portal – /user-facing-url, auth:user] ← TWO surfaces
198
+ Cross-surface rules: [B1 – admin creates/toggles → user portal shows/hides banner; 8-combination decision table]
199
+ Inclusive bounds: [start_at <= now → boundary: start_at=now must display], [end_at >= now → boundary: end_at=now must display]
200
+ Spec gaps: [G1 – exact content max length unconfirmed]
201
+
202
+ Tier 1 output (admin surface): VP-LOGIC-001 to VP-LOGIC-013, VP-VAL-001 to VP-VAL-007, VP-SEC-001 to VP-SEC-003
203
+ Cross-surface output (user portal): VP-LOGIC-CS-001 @manual (M-01: all 3 ON → display),
204
+ VP-LOGIC-CS-002 @manual (M-05: is_active=OFF → no display),
205
+ VP-LOGIC-CS-003 @manual (M-03: start_at future → no display),
206
+ VP-LOGIC-CS-004 @manual (M-02: end_at past → no display),
207
+ VP-LOGIC-CS-005 @manual (boundary: start_at=now → display),
208
+ VP-LOGIC-CS-006 @manual (boundary: end_at=now → display)
209
+ ```
185
210
 
186
- ## Priority Tags (auto-assign)
211
+ **❌ Bad Coverage Map — silently misses validation rules AND cross-surface outcomes:**
212
+ ```
213
+ User journeys: [J1 – create notice], [J2 – edit notice]
214
+ Business rules: [B1 – display logic: is_active + date range]
215
+ Security: [S1 – admin only]
216
+ ```
217
+ → Output misses VP-VAL-* entirely (validation rules not listed with exact messages).
218
+ → Output misses user portal scenarios entirely (no `Display surfaces` or `Cross-surface rules` field).
219
+ → Output misses boundary tests for `start_at <= now`, `end_at >= now` (no `Inclusive bounds` field).
220
+ → Root cause: Coverage Map only captured admin CRUD journeys; spec section on "display flow" and "user-facing surface" was not scanned into the map.
187
221
 
188
- Every scenario **MUST** have exactly one priority tag. Add it before the scenario line (after `@extend:` if present).
222
+ **✅ Good** see admin notice example above: `Display surfaces` lists every URL spec mentions as output, `Cross-surface rules` maps each admin action to its user-facing outcome, `Inclusive bounds` flags every `<=`/`>=` for BVA. Every item maps to a VP-ID in `Tier 1 output`.
189
223
 
190
- **Rule: look at what the WHEN step does and what THEN asserts that determines the tag.**
224
+ #### Tier 1 guardminimum before writing scenarios
191
225
 
192
- | Tag | Scenario type | Examples |
226
+ | Spec section | Minimum requirement | Tag |
193
227
  |---|---|---|
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 |
228
+ | Required field | 1 required-error TC per field | `@high` |
229
+ | Validation rule | 1 exact-message TC per rule | `@high` |
230
+ | Business rule | 1 behavioral TC per rule | `@high` |
231
+ | **Secondary behavior / tiebreaker** | **1 TC per tiebreaker or fallback rule in `Secondary behaviors`** | **`@high`** |
232
+ | Auth / OAuth / permissions | 1 VP-SEC TC | `@high` |
233
+ | Free-text input | 1 XSS TC **and** 1 SQL injection TC (separate) | `@high` |
234
+ | **Free-text LIKE / partial-match field** | **1 field-level SQL TC + 1 API-level SQL `@manual` TC** | **`@high`** |
235
+ | Lifecycle states | 1 key state transition TC | `@high` |
236
+ | Public page | 1 accessible-without-auth TC | `@high` |
237
+ | **Cross-surface business rule** | **1 `@high @manual` TC per affected surface per rule** even if not automated today | **`@high`** |
238
+ | **Inclusive boundary condition** (`<=`, `>=`) | **4 TCs per range: `min-1` (fail), `min` (pass), `max` (pass), `max+1` (fail)** — never skip the exact boundary point | **`@high`** |
239
+ | **Concurrency risk (from `Concurrency risks`)** | **1 `@manual` TC per risk — `@normal` unless data integrity at risk → `@high`** | **`@normal`** |
240
+ | States row (Default / Loading / Error / Success) | 1 visual state TC per named state — separate from lifecycle transition TC | `@normal` |
241
+ | Actions secondary (cancel, reset, export) | 1 behavior TC per secondary action | `@normal` |
205
242
 
206
- **`@steps:` scenarios** do NOT get a priority tag (they are setup blocks, not test cases).
243
+ > **Completeness check** after generating all scenarios, scan Coverage Map line by line.
244
+ > Every spec item must map to at least one scenario. Every `Viewpoint items` entry must be mapped to a VP-ID or marked `[covered: VP-ID]`. Do NOT silently skip either source.
245
+ > Specifically verify: `Display surfaces` each have ≥1 scenario; `Inclusive bounds` each have a boundary-point TC.
207
246
 
208
- ### Priority assignment — disambiguation tie-breaker
247
+ #### Tier 2 strategy
209
248
 
210
- When in doubt between `@low` and `@normal`, apply this rule:
249
+ Walk `spec.md` top-to-bottom and apply `sungen-viewpoint` Tier 2 checklist for each identified pattern. Depth by risk: high-risk section → all items; low-risk → presence checks only. Skip items already covered by Tier 1.
250
+ For HIGH-tagged sections: use the same depth as Step 3 (full BVA + Decision Table) when generating new Tier 2 VP-VAL items not already covered by Step 3. For LOW-tagged sections: EP valid + EP invalid only — skip BVA and Decision Table. Do NOT re-generate scenarios already created in Step 3.
211
251
 
212
- | Pattern | Tag |
213
- |---|---|
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 |
219
-
220
- **Example:** `Then User see [Email] field` (no When) → `@low`. `When User fill ... And User click ... Then User see [Error]` → `@normal`.
252
+ **When `test-viewpoint.md` is present — mandatory line-by-line scan:**
253
+ Every item in `test-viewpoint.md` must appear in `Viewpoint items` of the Coverage Map (done in Step 2). In Tier 2, walk `Viewpoint items` line by line:
254
+ - Item already covered by Tier 1 mark `[covered: VP-ID]`, skip.
255
+ - Item automatable generate `@normal` scenario.
256
+ - Item requires DB setup / network manipulation `@normal @manual`.
257
+ - Item marked as known bug `@manual` with comment `# Known issue: <ID>`.
221
258
 
222
- ## SPA Wait-For Steps
259
+ > **Viewpoint completeness check** — after Tier 2, every `Viewpoint items`
260
+ > entry must be mapped to a VP-ID or marked `[covered: VP-ID]`.
261
+ > If any item has neither → generate missing scenario before finishing.
262
+ > Do NOT silently skip viewpoint items because they seem redundant or
263
+ > hard to automate.
223
264
 
224
- ```gherkin
225
- Given User is on [Screen] page
226
- And User wait for [Page Title] heading is visible
227
- ```
265
+ ### Step 3 — Apply test design techniques
228
266
 
229
- ## Cleanup & Hooks
267
+ Delegate to `sungen-test-design-techniques` for technique selection and depth.
268
+ Risk level from Coverage Map drives depth: HIGH section → full BVA / Decision Table; LOW section → EP valid+invalid only.
230
269
 
231
- ### Auto-assign `@cleanup:*` tags based on screen sections
270
+ **BVA constraint:** Use compact 4-point mode only (min-1, min, max, max+1). Do not apply Full 6-point mode.
232
271
 
233
- After identifying screen sections, add appropriate `@cleanup:*` feature-level tags. These activate base.ts fixtures that auto-clean state between tests.
272
+ ### Step 4 Supplement with viewpoint checklists
234
273
 
235
- | Screen has | Add tag | Why |
236
- |---|---|---|
237
- | Modal / Dialog / Drawer | `@cleanup:overlay` | Dismiss leftover overlays between tests |
238
- | Form & Inputs / Search / Filter | `@cleanup:forms` | Clear form fields, reset selects |
239
- | Long scrollable content | `@cleanup:scroll` | Scroll to top for consistent assertions |
240
- | Auth tokens / session data in tests | `@cleanup:storage` | Clear sessionStorage |
241
- | CI/CD or debug-heavy screens | `@screenshot:on-failure` | Auto-capture screenshot on test failure |
274
+ Use `sungen-viewpoint` for defect-prone patterns spec never documents. Skip items already covered by spec-driven scenarios.
242
275
 
243
- **Always add `@cleanup:overlay`** if ANY section opens a dialog (Create/Add, Update/Edit, Delete confirmation). Most CRUD screens need it.
276
+ > **XSS and SQL injection** are generated at Tier 1 guard (Step 2). Skip them when applying `sungen-viewpoint` Shared Checks — do not generate again.
244
277
 
245
- **Always add `@cleanup:forms`** if the screen has inline search, filter dropdowns, or editable forms that persist between tests.
278
+ #### 4a. Shared Checks generate ONCE per screen
246
279
 
247
- ### When to add `@afterEach` hook scenario
280
+ Apply the **Shared Checks table in `sungen-viewpoint`** (single source). Generate each at most once per screen, not per pattern. Since XSS and SQL injection are already covered at the Tier 1 guard (Step 2, above), at this step generate only the remaining ones that fit the screen: **Loading State** (any async fetch), **Empty State** (any list/table/card that can return 0 records), **URL Manipulation** (URL params affecting displayed data).
248
281
 
249
- Only when `@cleanup:*` tags aren't enough feature-specific cleanup logic:
250
- - Reset a dropdown filter to default value (not just clear)
251
- - Navigate away from a sub-tab back to the main tab
252
- - Close a specific sidebar panel
282
+ #### 4b. Pattern Tier 1 / Tier 2
253
283
 
254
- ```gherkin
255
- @afterEach
256
- Scenario: Reset filters to default
257
- When User select [Status Filter] dropdown with {{default_status}}
258
- ```
284
+ **Gap check rule — Step 4b fills gaps from Step 3, not a new generation source:**
285
+ - **VP-VAL BVA/EP items**: skip if Step 3 already generated scenarios for that field. Generate only if Step 3 missed the field entirely.
286
+ - **VP-LOGIC, VP-UI, VP-SEC items**: generate normally — Step 3 does not cover these.
259
287
 
260
- ### `@beforeAll` / `@afterAll`optional, low priority
288
+ - **Tier 1**: all items from `#### Tier 1 @high` → VP-LOGIC, VP-VAL, VP-SEC
289
+ - **Tier 2**: items from `#### Tier 2 — @normal + @low` → VP-UI
261
290
 
262
- For one-time setup/teardown. Most screens don't need these.
291
+ Risk weighting: high-risk section → all Tier 1 items. Low-risk (e.g. read-only table) → only clearly applicable items.
263
292
 
264
- ### `@parallel` when tests need independent browser state
293
+ #### 4c. Cross-pattern interactions where spec-invisible bugs live
265
294
 
266
- Add `@parallel` at feature level when:
295
+ For every pair of patterns present on the screen, walk the **⚡ Cross-pattern interactions** list in each `sungen-viewpoint` group file (single source). Never-miss pairs:
296
+ - **Create / Update / Delete × Data Table** — new record missing or count not updated; row shows stale data; last-record delete → blank page.
297
+ - **Search / Filter × Pagination** — results don't reset to page 1.
298
+ - **Form × Modal/Dialog** — modal stays open on success / data wiped on failure.
299
+ - **Import × Data Table** — table not refreshed / count wrong after import.
300
+ - **Sort × Data Table** — all cells in a row must reorder together (data must not shift to wrong columns).
301
+ - **Filter (≥2 active)** — generate 1 scenario with all filters active simultaneously to verify AND logic.
267
302
 
268
- 1. **Multiple auth groups** (required) — e.g., `@auth:user` + `@no-auth` scenarios. Serial mode uses one shared context and cannot mix auth roles. Compiler will error without this tag.
269
- 2. **Validation-heavy features** (recommended) — each scenario fills forms with different invalid data and needs a clean form. Serial shared page keeps previous test's input.
303
+ Cross-pattern: `@high` by default.
270
304
 
271
- Serial (default) is best for: CRUD flows, sequential user journeys, UI checks on the same page.
305
+ **Assert values, not existence.** Never bare "is visible". Capture exact error messages into test-data.yaml.
272
306
 
273
- ```gherkin
274
- @parallel @auth:user
275
- @cleanup:forms
276
- Feature: kudos Screen
307
+ ---
277
308
 
278
- @high
279
- Scenario: Send kudos
280
- ...
309
+ ## Priority Tags
281
310
 
282
- @high @no-auth
283
- Scenario: Unauthenticated user is redirected
284
- ...
285
- ```
311
+ Every scenario **MUST** have exactly one priority tag. Assign by user impact per the **"Assign priority by user impact"** table in `sungen-gherkin-syntax`; override only when context differs.
286
312
 
287
- ## Output Format
313
+ Quick fallback: auth / CRUD / security / required-field / unique-constraint → `@high`; format validation / standard-range boundary / search / filter / sort → `@normal`; presence / label / placeholder / cosmetic → `@low`. (Inclusive-operator or critical boundary → `@high`.)
288
314
 
289
- **Feature file** — `qa/screens/<screen>/features/<screen>.feature`
315
+ ---
290
316
 
291
- `Background` is valid for simple shared setup (navigate to page). Use `@steps`/`@extend` for complex flows with scope (dialog, frame).
317
+ ## SPA Wait-For Steps
292
318
 
293
319
  ```gherkin
294
- @auth:role
295
- @cleanup:overlay
296
- @cleanup:forms
297
- Feature: <Screen> Screen
320
+ Given User is on [Screen] page
321
+ And User wait for [Page Title] heading is visible
322
+ ```
298
323
 
299
- Background:
300
- Given User is on [Screen] page
324
+ ---
301
325
 
302
- # Shared setup — NO priority tag on @steps
303
- @steps:open_form
304
- Scenario: Open form
305
- When User click [Create] button
306
- Then User see [Form] dialog
326
+ ## Cleanup & Hooks
307
327
 
308
- # --- Section: Create User Form (Tier 1: @high) ---
328
+ Add cleanup tags per the `sungen-gherkin-syntax` Cleanup table. Key rules:
329
+ - **Always `@cleanup:overlay`** if ANY section opens a dialog; **always `@cleanup:forms`** if the screen has inline search, filter, or editable forms.
330
+ - **`@parallel`** is required when mixing auth groups (`@auth:X` + `@no-auth`); recommended for validation-heavy features needing a clean form state per scenario.
331
+ - **`@afterEach`** hook only when `@cleanup:*` tags aren't enough (feature-specific reset logic).
309
332
 
310
- @high @extend:open_form
311
- Scenario: VP-LOGIC-001 Submit form with valid data creates record
312
- Given User is on [Form] dialog
313
- When User fill [Name] field with {{valid_name}}
314
- And User click [Submit] button
315
- Then User see {{success_message}} message
333
+ ---
316
334
 
317
- @high @extend:open_form
318
- Scenario: VP-VAL-001 Submit with all empty fields shows errors
319
- Given User is on [Form] dialog
320
- When User click [Submit] button
321
- Then User see [Name error] message with {{name_required_error}}
335
+ ## Output Format
322
336
 
323
- # --- Section: User Table (Tier 1: @high) ---
337
+ **Files:** `qa/screens/<screen>/features/<screen>.feature` + `qa/screens/<screen>/test-data/<screen>.yaml`
324
338
 
325
- @high
326
- Scenario: VP-VAL-010 Table displays correct data
327
- Then User see [Users] table match data:
328
- | Name | Email |
329
- | {{name_1}} | {{email_1}} |
339
+ Use step patterns and element types from `sungen-gherkin-syntax`.
340
+ **Naming**: `VP-<CATEGORY>-<NNN>`. Scenario name must use the **same element type** as the steps.
330
341
 
331
- @high
332
- Scenario: VP-SEC-010 Unauthorized user cannot access page
333
- Given User is not logged in
334
- When User navigate to [Screen] page
335
- Then User is on [Login] page
336
- ```
342
+ **Test data** — grouped by section, loaded at runtime:
337
343
 
338
- **Tier 2 (expand run)** appends sections with `# --- Section: X (Tier 2: @normal + @low) ---` comments. Adds UI field presence, hover states, tooltips, empty states.
344
+ ```yaml
345
+ # login.yaml (base)
346
+ valid_email: admin@dev.example.com
347
+ valid_password: DevPass123
339
348
 
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.
349
+ # login.staging.yaml (override)
350
+ valid_email: admin@staging.example.com
351
+ valid_password: StagingPass456
352
+ ```
341
353
 
342
- ### When to use DataTable vs Row Scope
354
+ **DataTable vs Row Scope:**
343
355
 
344
356
  | Pattern | Use when |
345
357
  |---|---|
346
358
  | `table match data:` + DataTable | Verifying **multiple rows** exist with expected values |
347
- | `row in [Table] table with {{v}}` + `column with {{v}}` | Checking **single row** details or **acting** on a row (click, edit) |
359
+ | `row in [Table] table with {{v}}` + `column with {{v}}` | Single row detail or action on a row |
348
360
 
349
- **Naming**: `VP-<CATEGORY>-<NNN>` prefix. Scenario name must use the **same element type** as the steps — e.g., if the step uses `dialog`, write "dialog opens" not "modal opens".
350
-
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.
352
-
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.
361
+ ---
354
362
 
355
- **i18n / multilingual**: use the same `SUNGEN_ENV` overlay for locale variants e.g., `login.vi.yaml`, `login.staging-ja.yaml`. Include `lbl_*` / `msg_*` keys for selector `{{variable}}` references (see `sungen-selector-keys` § i18n). One feature file + one selector file works across all locales.
363
+ ## Worked Examplespec Coverage Map output
356
364
 
357
- ## Flow Test Generation
365
+ A minimal end-to-end pass. Use this to calibrate output: every Coverage Map line below maps to exactly one scenario, and every `{{var}}` exists in the YAML.
358
366
 
359
- When generating tests for a **flow** (`qa/flows/<name>/`), adapt the strategy:
367
+ **① Input `spec.md` (excerpt):**
368
+ ```
369
+ ## Coupon Form
370
+ - Code: required, free text, max 20 chars, must be unique.
371
+ - Discount %: required, integer 1–100 inclusive.
372
+ - Submit creates a coupon; it appears at the top of the Coupon List.
373
+ - Only authenticated admins can create coupons.
374
+ ```
360
375
 
361
- ### Structure
376
+ **② Coverage Map (Step 2 output):**
377
+ ```
378
+ User journeys: [J1 – admin creates coupon → appears top of list]
379
+ Validation rules: [V1 – code empty → "Code is required"],
380
+ [V2 – code > 20 chars → "Code must be 20 characters or less"],
381
+ [V3 – duplicate code → "Code already exists"],
382
+ [V4 – discount empty → "Discount is required"]
383
+ Business rules: [B1 HIGH – new coupon sorts to top of list]
384
+ States: (none — no lifecycle)
385
+ Security: [S1 HIGH – free-text code → XSS + SQL injection], [S2 HIGH – admin-only]
386
+ Display surfaces: [Coupon admin – /admin/coupons, auth:admin] ← single surface
387
+ Cross-surface rules: (none)
388
+ Inclusive bounds: [discount 1–100 inclusive → BVA: 0, 1, 100, 101]
389
+ Spec gaps: (none)
390
+
391
+ Tier 1 output: VP-LOGIC-001 (create → top of list), VP-VAL-001 (code empty),
392
+ VP-VAL-002 (code > 20), VP-VAL-003 (duplicate code), VP-VAL-004 (discount empty),
393
+ VP-VAL-005 (discount=0 reject), VP-VAL-006 (discount=1 accept),
394
+ VP-VAL-007 (discount=100 accept), VP-VAL-008 (discount=101 reject),
395
+ VP-SEC-001 (XSS), VP-SEC-002 (SQL injection), VP-SEC-003 (non-admin blocked)
396
+ ```
397
+ > Note how `Inclusive bounds` line forces 4 BVA scenarios (0/1/100/101), not just "valid + invalid".
362
398
 
363
- - **Background**starting page only: `Given User is on [Login] page`
364
- - **Scenarios** — each phase of the E2E journey as a separate scenario
365
- - **Selector refs** — use `[Screen:Element]` namespace format (see `sungen-gherkin-syntax`)
366
- - **Test data** — namespace by phase: `login.email`, `submission.nominee`
367
- - **Feature tag** — `@flow` required at feature level
399
+ **③ Output — `coupons.feature` (excerpt, 4 of 12 scenarios):**
400
+ ```gherkin
401
+ @parallel @auth:admin
402
+ @cleanup:overlay
403
+ @cleanup:forms
404
+ Feature: Coupons Screen
368
405
 
369
- ### Flow vs Screen Differences
406
+ Background:
407
+ Given User is on [Coupons] page
408
+
409
+ @steps:open_create_form
410
+ Scenario: Open create form
411
+ When User click [Create Coupon] button
412
+ Then User see [Create Coupon] dialog
413
+
414
+ # --- Section: Create Coupon (Tier 1) ---
415
+
416
+ @high @extend:open_create_form
417
+ Scenario: VP-LOGIC-001 Submit valid coupon adds it to top of list
418
+ Given User is on [Create Coupon] dialog
419
+ When User fill [Code] field with {{valid_coupon.code}}
420
+ And User fill [Discount] field with {{valid_coupon.discount}}
421
+ And User click [Save] button
422
+ Then User see [Create Coupon] dialog is hidden
423
+ And User see [Coupon List] row in [Coupon List] table with {{valid_coupon.code}}
424
+
425
+ @high @extend:open_create_form
426
+ Scenario: VP-VAL-005 Discount of 0 is rejected (boundary min-1)
427
+ Given User is on [Create Coupon] dialog
428
+ When User fill [Code] field with {{valid_coupon.code}}
429
+ And User fill [Discount] field with {{discount_zero}}
430
+ And User click [Save] button
431
+ Then User see [Discount Error] message with {{error.discount_range}}
432
+
433
+ @high @extend:open_create_form
434
+ Scenario: VP-VAL-006 Discount of 1 is accepted (boundary min)
435
+ Given User is on [Create Coupon] dialog
436
+ When User fill [Code] field with {{valid_coupon.code}}
437
+ And User fill [Discount] field with {{discount_min}}
438
+ And User click [Save] button
439
+ Then User see [Create Coupon] dialog is hidden
370
440
 
371
- | Aspect | Screen | Flow |
372
- |---|---|---|
373
- | Section focus | UI patterns per section | Journey phases across screens |
374
- | Viewpoints | VP-UI, VP-VAL, VP-LOGIC, VP-SEC per section | VP-LOGIC (flow transitions), VP-SEC (auth persistence), VP-VAL (cross-screen data) |
375
- | Tier 1 focus | Happy path + required validation per section | Happy path through entire flow + auth + key error recovery |
376
- | Background | Navigate to screen | Navigate to starting page |
441
+ @high @no-auth
442
+ Scenario: VP-SEC-003 Unauthenticated user is redirected to login
443
+ Then User see [Login] page
444
+ ```
377
445
 
378
- ### Flow-specific scenarios by tier
446
+ **④ Output `coupons.yaml` (excerpt):**
447
+ ```yaml
448
+ valid_coupon:
449
+ code: "SAVE-{{$uuid}}"
450
+ discount: "20"
451
+ discount_zero: "0" # boundary min-1 (reject)
452
+ discount_min: "1" # boundary min (accept)
453
+ discount_max: "100" # boundary max (accept)
454
+ discount_over: "101" # boundary max+1 (reject)
455
+ error:
456
+ discount_range: "Discount must be between 1 and 100"
457
+ ```
379
458
 
380
- | Category | Tier | Examples |
381
- |---|---|---|
382
- | **Happy path** | T1 | Complete flow end-to-end with valid data |
383
- | **Auth persistence** | T1 | Auth state maintained across screen transitions |
384
- | **Error recovery** | T1 | Invalid input mid-flow → fix → continue |
385
- | **Incomplete flow** | T2 | User abandons at each phase → state cleanup |
386
- | **Cross-screen data** | T2 | Data entered on screen A visible on screen B |
387
- | **Screen transition edges** | T2 | Back button, refresh, deep link mid-flow |
388
- | **UI state across screens** | T2 | Breadcrumb, progress indicator, nav state |
389
- | **Negative inputs mid-flow** | T3 | XSS/SQL in cross-screen fields, special chars |
390
- | **Concurrent flow** | T3 | Two tabs same flow, session expiry mid-flow |
391
- | **Cross-screen validation** | T3 | Field dependency across screens, cascading errors |
392
-
393
- ### Flow Lightweight Guard (Tier 1)
394
-
395
- > After generating Tier 1 flow scenarios, verify these checks — if any are missing, add them:
396
-
397
- | Flow requirement | Minimum TC | Tag |
398
- |---|---|---|
399
- | Complete flow end-to-end with valid data | At least 1 happy path scenario | `@high` |
400
- | Auth state across screen transitions | At least 1 auth persistence check (if flow crosses auth) | `@high` |
401
- | Invalid input mid-flow → fix → continue | At least 1 error recovery scenario | `@high` |
459
+ ---
402
460
 
403
- ### Flow Section Comments
461
+ ## Flow Test Generation
404
462
 
405
- Flow features use the same `# --- Section:` comment format, with phase names instead of UI sections:
463
+ > **Auto-detect**: if path is `qa/flows/<name>/` use this section. Skip Steps 1–4 above.
406
464
 
407
- ```gherkin
408
- # --- Section: Login Phase (Tier 1: @high) ---
409
- # --- Section: Submission Phase (Tier 2: @normal + @low) ---
410
- ```
465
+ | Aspect | Screen | Flow |
466
+ |---|---|---|
467
+ | Section focus | UI patterns per section | Journey phases across screens |
468
+ | Selector format | `[Element]` | `[Screen:Element]` (namespaced) |
469
+ | Test data keys | `{{variable}}` | `{{phase.variable}}` |
470
+ | Feature tag | `@auto` / `@smoke` etc. | `@flow` (required) |
471
+ | Viewpoints | VP-UI/VAL/LOGIC/SEC per section | VP-LOGIC (transitions), VP-SEC (auth persistence), VP-VAL (cross-screen data) |
411
472
 
412
- Update Mode tier detection works identically — scan for tier markers in these comments.
473
+ **Scenarios to generate:**
413
474
 
414
- ### Output Format (Flow)
475
+ | Category | What to test |
476
+ |---|---|
477
+ | Happy path | Complete flow end-to-end with valid data |
478
+ | Auth persistence | Auth state maintained across screen transitions |
479
+ | Error recovery | Invalid input mid-flow → fix → continue |
480
+ | Cross-screen data | Data entered on screen A visible on screen B |
415
481
 
416
482
  ```gherkin
417
483
  @flow @auth:user
@@ -420,36 +486,30 @@ Feature: Award Submission Flow
420
486
  Background:
421
487
  Given User is on [Login] page
422
488
 
423
- # --- Section: Login Phase (Tier 1: @high) ---
424
-
425
489
  @high
426
- Scenario: User login successfully
490
+ Scenario: User logs in successfully
427
491
  When User fill [Login:Email] field with {{login.email}}
428
492
  And User fill [Login:Password] field with {{login.password}}
429
493
  And User click [Login:Submit] button
430
494
  Then User see [Dashboard] page
431
495
 
432
- # --- Section: Submission Phase (Tier 1: @high) ---
433
-
434
496
  @high
435
- Scenario: User navigates to awards and submits
436
- Given User is on [Awards] page
497
+ Scenario: User submits nomination
498
+ When User click [Dashboard:Awards] link
499
+ Then User see [Awards] page
437
500
  When User fill [Awards:Nominee] field with {{submission.nominee}}
438
- And User fill [Awards:Reason] field with {{submission.reason}}
439
501
  And User click [Awards:Submit] button
440
- Then User see [Awards:Success Message] text with {{submission.success_message}}
502
+ Then User see {{success_message}} message
441
503
  ```
442
504
 
443
505
  ```yaml
444
- # test-data — namespaced by phase
506
+ # flows/<name>/test-data/<name>.yaml
445
507
  login:
446
- email: "user@example.com"
447
- password: "Password123"
448
-
508
+ email: "admin@example.com"
509
+ password: "secret123"
449
510
  submission:
450
511
  nominee: "John Doe"
451
- reason: "Outstanding contribution to the team"
452
- success_message: "Award submitted successfully"
512
+ success_message: "Award submitted successfully"
453
513
  ```
454
514
 
455
- **Do NOT generate**: `selectors.yaml` (created during run-test), Playwright code (sungen compiles).
515
+ **Do NOT generate**: `selectors.yaml` (created during `run-test`), Playwright code (sungen compiles).