@sun-asterisk/sungen 2.5.2 → 2.6.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 (187) hide show
  1. package/dist/cli/commands/add-flow.d.ts +3 -0
  2. package/dist/cli/commands/add-flow.d.ts.map +1 -0
  3. package/dist/cli/commands/add-flow.js +27 -0
  4. package/dist/cli/commands/add-flow.js.map +1 -0
  5. package/dist/cli/commands/delivery.d.ts.map +1 -1
  6. package/dist/cli/commands/delivery.js +95 -60
  7. package/dist/cli/commands/delivery.js.map +1 -1
  8. package/dist/cli/commands/generate.d.ts.map +1 -1
  9. package/dist/cli/commands/generate.js +38 -6
  10. package/dist/cli/commands/generate.js.map +1 -1
  11. package/dist/cli/index.js +3 -1
  12. package/dist/cli/index.js.map +1 -1
  13. package/dist/generators/test-generator/adapters/adapter-interface.d.ts +16 -0
  14. package/dist/generators/test-generator/adapters/adapter-interface.d.ts.map +1 -1
  15. package/dist/generators/test-generator/adapters/playwright/playwright-adapter.d.ts +3 -0
  16. package/dist/generators/test-generator/adapters/playwright/playwright-adapter.d.ts.map +1 -1
  17. package/dist/generators/test-generator/adapters/playwright/playwright-adapter.js.map +1 -1
  18. package/dist/generators/test-generator/adapters/playwright/templates/imports.hbs +3 -2
  19. package/dist/generators/test-generator/adapters/playwright/templates/scenario.hbs +20 -1
  20. package/dist/generators/test-generator/adapters/playwright/templates/steps/actions/alert-accept-action.hbs +1 -1
  21. package/dist/generators/test-generator/adapters/playwright/templates/steps/actions/alert-dismiss-action.hbs +1 -1
  22. package/dist/generators/test-generator/adapters/playwright/templates/steps/actions/alert-fill-action.hbs +1 -1
  23. package/dist/generators/test-generator/adapters/playwright/templates/steps/assertions/alert-text-assertion.hbs +2 -2
  24. package/dist/generators/test-generator/adapters/playwright/templates/steps/assertions/column-cell-assertion.hbs +1 -0
  25. package/dist/generators/test-generator/adapters/playwright/templates/steps/navigation/navigation.hbs +2 -1
  26. package/dist/generators/test-generator/adapters/playwright/templates/steps/navigation/route-assertion.hbs +1 -2
  27. package/dist/generators/test-generator/adapters/playwright/templates/steps/navigation/wait-timeout.hbs +1 -1
  28. package/dist/generators/test-generator/adapters/playwright/templates/test-file.hbs +84 -4
  29. package/dist/generators/test-generator/code-generator.d.ts +2 -0
  30. package/dist/generators/test-generator/code-generator.d.ts.map +1 -1
  31. package/dist/generators/test-generator/code-generator.js +105 -17
  32. package/dist/generators/test-generator/code-generator.js.map +1 -1
  33. package/dist/generators/test-generator/patterns/interaction-patterns.d.ts.map +1 -1
  34. package/dist/generators/test-generator/patterns/interaction-patterns.js +22 -3
  35. package/dist/generators/test-generator/patterns/interaction-patterns.js.map +1 -1
  36. package/dist/generators/test-generator/patterns/navigation-patterns.d.ts.map +1 -1
  37. package/dist/generators/test-generator/patterns/navigation-patterns.js +8 -3
  38. package/dist/generators/test-generator/patterns/navigation-patterns.js.map +1 -1
  39. package/dist/generators/test-generator/step-mapper.d.ts +4 -0
  40. package/dist/generators/test-generator/step-mapper.d.ts.map +1 -1
  41. package/dist/generators/test-generator/step-mapper.js +7 -0
  42. package/dist/generators/test-generator/step-mapper.js.map +1 -1
  43. package/dist/generators/test-generator/template-engine.d.ts +14 -0
  44. package/dist/generators/test-generator/template-engine.d.ts.map +1 -1
  45. package/dist/generators/test-generator/template-engine.js +1 -1
  46. package/dist/generators/test-generator/template-engine.js.map +1 -1
  47. package/dist/generators/test-generator/utils/data-resolver.d.ts +3 -20
  48. package/dist/generators/test-generator/utils/data-resolver.d.ts.map +1 -1
  49. package/dist/generators/test-generator/utils/data-resolver.js +23 -66
  50. package/dist/generators/test-generator/utils/data-resolver.js.map +1 -1
  51. package/dist/generators/test-generator/utils/selector-resolver.d.ts +2 -6
  52. package/dist/generators/test-generator/utils/selector-resolver.d.ts.map +1 -1
  53. package/dist/generators/test-generator/utils/selector-resolver.js +18 -80
  54. package/dist/generators/test-generator/utils/selector-resolver.js.map +1 -1
  55. package/dist/orchestrator/ai-rules-updater.d.ts.map +1 -1
  56. package/dist/orchestrator/ai-rules-updater.js +4 -0
  57. package/dist/orchestrator/ai-rules-updater.js.map +1 -1
  58. package/dist/orchestrator/flow-manager.d.ts +22 -0
  59. package/dist/orchestrator/flow-manager.d.ts.map +1 -0
  60. package/dist/orchestrator/flow-manager.js +251 -0
  61. package/dist/orchestrator/flow-manager.js.map +1 -0
  62. package/dist/orchestrator/project-initializer.d.ts.map +1 -1
  63. package/dist/orchestrator/project-initializer.js +1 -0
  64. package/dist/orchestrator/project-initializer.js.map +1 -1
  65. package/dist/orchestrator/screen-manager.d.ts.map +1 -1
  66. package/dist/orchestrator/screen-manager.js +3 -1
  67. package/dist/orchestrator/screen-manager.js.map +1 -1
  68. package/dist/orchestrator/templates/ai-instructions/claude-cmd-add-flow.md +88 -0
  69. package/dist/orchestrator/templates/ai-instructions/claude-cmd-create-test.md +11 -8
  70. package/dist/orchestrator/templates/ai-instructions/claude-cmd-review.md +8 -6
  71. package/dist/orchestrator/templates/ai-instructions/claude-cmd-run-test.md +15 -11
  72. package/dist/orchestrator/templates/ai-instructions/claude-config.md +41 -10
  73. package/dist/orchestrator/templates/ai-instructions/claude-skill-capture-live.md +12 -0
  74. package/dist/orchestrator/templates/ai-instructions/claude-skill-delivery.md +19 -18
  75. package/dist/orchestrator/templates/ai-instructions/claude-skill-error-mapping.md +12 -0
  76. package/dist/orchestrator/templates/ai-instructions/claude-skill-gherkin-syntax.md +122 -10
  77. package/dist/orchestrator/templates/ai-instructions/claude-skill-selector-fix.md +31 -3
  78. package/dist/orchestrator/templates/ai-instructions/claude-skill-selector-keys.md +45 -0
  79. package/dist/orchestrator/templates/ai-instructions/claude-skill-tc-generation.md +92 -0
  80. package/dist/orchestrator/templates/ai-instructions/claude-skill-tc-review.md +30 -0
  81. package/dist/orchestrator/templates/ai-instructions/copilot-cmd-add-flow.md +86 -0
  82. package/dist/orchestrator/templates/ai-instructions/copilot-cmd-create-test.md +13 -10
  83. package/dist/orchestrator/templates/ai-instructions/copilot-cmd-delivery.md +16 -15
  84. package/dist/orchestrator/templates/ai-instructions/copilot-cmd-review.md +9 -7
  85. package/dist/orchestrator/templates/ai-instructions/copilot-cmd-run-test.md +21 -17
  86. package/dist/orchestrator/templates/ai-instructions/copilot-config.md +40 -9
  87. package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-capture-live.md +12 -0
  88. package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-delivery.md +19 -18
  89. package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-error-mapping.md +12 -0
  90. package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-gherkin-syntax.md +122 -10
  91. package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-selector-fix.md +31 -3
  92. package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-selector-keys.md +45 -0
  93. package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-tc-generation.md +93 -0
  94. package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-tc-review.md +30 -0
  95. package/dist/orchestrator/templates/playwright.config.d.ts.map +1 -1
  96. package/dist/orchestrator/templates/playwright.config.js +3 -1
  97. package/dist/orchestrator/templates/playwright.config.js.map +1 -1
  98. package/dist/orchestrator/templates/playwright.config.ts +4 -1
  99. package/dist/orchestrator/templates/specs-base.d.ts +3 -4
  100. package/dist/orchestrator/templates/specs-base.d.ts.map +1 -1
  101. package/dist/orchestrator/templates/specs-base.js +60 -91
  102. package/dist/orchestrator/templates/specs-base.js.map +1 -1
  103. package/dist/orchestrator/templates/specs-base.ts +61 -101
  104. package/dist/orchestrator/templates/specs-test-data.d.ts +3 -1
  105. package/dist/orchestrator/templates/specs-test-data.d.ts.map +1 -1
  106. package/dist/orchestrator/templates/specs-test-data.js +53 -2
  107. package/dist/orchestrator/templates/specs-test-data.js.map +1 -1
  108. package/dist/orchestrator/templates/specs-test-data.ts +56 -2
  109. package/package.json +1 -1
  110. package/src/cli/commands/add-flow.ts +25 -0
  111. package/src/cli/commands/delivery.ts +109 -58
  112. package/src/cli/commands/generate.ts +43 -6
  113. package/src/cli/index.ts +3 -1
  114. package/src/generators/test-generator/adapters/adapter-interface.ts +6 -1
  115. package/src/generators/test-generator/adapters/playwright/playwright-adapter.ts +1 -1
  116. package/src/generators/test-generator/adapters/playwright/templates/imports.hbs +3 -2
  117. package/src/generators/test-generator/adapters/playwright/templates/scenario.hbs +20 -1
  118. package/src/generators/test-generator/adapters/playwright/templates/steps/actions/alert-accept-action.hbs +1 -1
  119. package/src/generators/test-generator/adapters/playwright/templates/steps/actions/alert-dismiss-action.hbs +1 -1
  120. package/src/generators/test-generator/adapters/playwright/templates/steps/actions/alert-fill-action.hbs +1 -1
  121. package/src/generators/test-generator/adapters/playwright/templates/steps/assertions/alert-text-assertion.hbs +2 -2
  122. package/src/generators/test-generator/adapters/playwright/templates/steps/assertions/column-cell-assertion.hbs +1 -0
  123. package/src/generators/test-generator/adapters/playwright/templates/steps/navigation/navigation.hbs +2 -1
  124. package/src/generators/test-generator/adapters/playwright/templates/steps/navigation/route-assertion.hbs +1 -2
  125. package/src/generators/test-generator/adapters/playwright/templates/steps/navigation/wait-timeout.hbs +1 -1
  126. package/src/generators/test-generator/adapters/playwright/templates/test-file.hbs +84 -4
  127. package/src/generators/test-generator/code-generator.ts +119 -20
  128. package/src/generators/test-generator/patterns/interaction-patterns.ts +25 -3
  129. package/src/generators/test-generator/patterns/navigation-patterns.ts +8 -3
  130. package/src/generators/test-generator/step-mapper.ts +8 -0
  131. package/src/generators/test-generator/template-engine.ts +5 -2
  132. package/src/generators/test-generator/utils/data-resolver.ts +25 -77
  133. package/src/generators/test-generator/utils/selector-resolver.ts +23 -109
  134. package/src/orchestrator/ai-rules-updater.ts +5 -0
  135. package/src/orchestrator/flow-manager.ts +243 -0
  136. package/src/orchestrator/project-initializer.ts +1 -0
  137. package/src/orchestrator/screen-manager.ts +3 -1
  138. package/src/orchestrator/templates/ai-instructions/claude-cmd-add-flow.md +88 -0
  139. package/src/orchestrator/templates/ai-instructions/claude-cmd-create-test.md +11 -8
  140. package/src/orchestrator/templates/ai-instructions/claude-cmd-review.md +8 -6
  141. package/src/orchestrator/templates/ai-instructions/claude-cmd-run-test.md +15 -11
  142. package/src/orchestrator/templates/ai-instructions/claude-config.md +41 -10
  143. package/src/orchestrator/templates/ai-instructions/claude-skill-capture-live.md +12 -0
  144. package/src/orchestrator/templates/ai-instructions/claude-skill-delivery.md +19 -18
  145. package/src/orchestrator/templates/ai-instructions/claude-skill-error-mapping.md +12 -0
  146. package/src/orchestrator/templates/ai-instructions/claude-skill-gherkin-syntax.md +122 -10
  147. package/src/orchestrator/templates/ai-instructions/claude-skill-selector-fix.md +31 -3
  148. package/src/orchestrator/templates/ai-instructions/claude-skill-selector-keys.md +45 -0
  149. package/src/orchestrator/templates/ai-instructions/claude-skill-tc-generation.md +92 -0
  150. package/src/orchestrator/templates/ai-instructions/claude-skill-tc-review.md +30 -0
  151. package/src/orchestrator/templates/ai-instructions/copilot-cmd-add-flow.md +86 -0
  152. package/src/orchestrator/templates/ai-instructions/copilot-cmd-create-test.md +13 -10
  153. package/src/orchestrator/templates/ai-instructions/copilot-cmd-delivery.md +16 -15
  154. package/src/orchestrator/templates/ai-instructions/copilot-cmd-review.md +9 -7
  155. package/src/orchestrator/templates/ai-instructions/copilot-cmd-run-test.md +21 -17
  156. package/src/orchestrator/templates/ai-instructions/copilot-config.md +40 -9
  157. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-capture-live.md +12 -0
  158. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-delivery.md +19 -18
  159. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-error-mapping.md +12 -0
  160. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-gherkin-syntax.md +122 -10
  161. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-selector-fix.md +31 -3
  162. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-selector-keys.md +45 -0
  163. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-tc-generation.md +93 -0
  164. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-tc-review.md +30 -0
  165. package/src/orchestrator/templates/playwright.config.ts +4 -1
  166. package/src/orchestrator/templates/specs-base.ts +61 -101
  167. package/src/orchestrator/templates/specs-test-data.ts +56 -2
  168. package/dist/utils/feature-finder.d.ts +0 -9
  169. package/dist/utils/feature-finder.d.ts.map +0 -1
  170. package/dist/utils/feature-finder.js +0 -67
  171. package/dist/utils/feature-finder.js.map +0 -1
  172. package/dist/utils/screen-paths.d.ts +0 -10
  173. package/dist/utils/screen-paths.d.ts.map +0 -1
  174. package/dist/utils/screen-paths.js +0 -73
  175. package/dist/utils/screen-paths.js.map +0 -1
  176. package/dist/utils/selector-loader.d.ts +0 -6
  177. package/dist/utils/selector-loader.d.ts.map +0 -1
  178. package/dist/utils/selector-loader.js +0 -20
  179. package/dist/utils/selector-loader.js.map +0 -1
  180. package/dist/utils/test-data-loader.d.ts +0 -6
  181. package/dist/utils/test-data-loader.d.ts.map +0 -1
  182. package/dist/utils/test-data-loader.js +0 -20
  183. package/dist/utils/test-data-loader.js.map +0 -1
  184. package/src/utils/feature-finder.ts +0 -33
  185. package/src/utils/screen-paths.ts +0 -37
  186. package/src/utils/selector-loader.ts +0 -23
  187. package/src/utils/test-data-loader.ts +0 -23
@@ -0,0 +1,88 @@
1
+ ---
2
+ name: add-flow
3
+ description: 'Add a new Sungen flow — scaffolds directories for E2E cross-screen testing, helps fill spec.md, and can capture visuals via the capture skills'
4
+ argument-hint: [flow-name] [--path <start-url>]
5
+ allowed-tools: Read, Grep, Bash, Glob, Edit, Write, AskUserQuestion, mcp__playwright__browser_navigate, mcp__playwright__browser_take_screenshot, mcp__playwright__browser_snapshot, mcp__figma__get_design_context, mcp__figma__get_variable_defs, mcp__figma__get_screenshot
6
+ ---
7
+
8
+ You are adding a new Sungen flow for E2E cross-screen test generation.
9
+
10
+ ## Parameters
11
+
12
+ Parse from `$ARGUMENTS`:
13
+ - **flow** — flow name (e.g., `award-submission`, `user-onboarding`)
14
+ - **--path \<url\>** — starting page URL path (default: `/login`)
15
+ - **--description \<text\>** — flow description (optional)
16
+
17
+ If **flow** is missing, ask: "What is the flow name? (e.g., `award-submission`, `user-onboarding`)"
18
+ If **path** is missing, ask: "What is the starting URL path? (e.g., `/login`)"
19
+
20
+ ## Steps
21
+
22
+ ### 1. Scaffold the flow
23
+
24
+ ```bash
25
+ sungen add-flow --flow <name> --path <path>
26
+ ```
27
+
28
+ This creates:
29
+ ```
30
+ qa/flows/<name>/
31
+ ├── features/<name>.feature # Gherkin with @flow tag, Background, sample scenarios
32
+ ├── selectors/<name>.yaml # Namespaced keys: "login:submit", "awards:submit"
33
+ ├── test-data/<name>.yaml # Namespaced data: login.email, submission.nominee
34
+ └── requirements/
35
+ ├── spec.md # Flow specification
36
+ └── ui/ # Screenshots, mockups
37
+ ```
38
+
39
+ ### 1a. Identify the screens in the flow
40
+
41
+ Ask the user: "Which screens does this flow visit, in order? (e.g., login → dashboard → award-form → confirmation)"
42
+
43
+ Record the screen list — you will need it for:
44
+ - Filling `spec.md` (Step 3)
45
+ - Suggesting `[Screen:Element]` namespace prefixes
46
+ - Capturing visuals per screen (Step 2)
47
+
48
+ ### 2. Capture visual source
49
+
50
+ Use `AskUserQuestion`: *"Pick a visual source for this flow's screens:"*
51
+ - **Figma designs** (Recommended for pre-launch) — invoke `sungen-capture-figma` skill for each screen
52
+ - **Live page scan** (dev/staging is up) — invoke `sungen-capture-live` skill for each screen URL
53
+ - **Local images** — invoke `sungen-capture-local` skill to load from `requirements/ui/`
54
+ - **Skip** — user will drop images manually into `requirements/ui/` later
55
+
56
+ Each capture skill writes outputs into `qa/flows/<name>/requirements/ui/` and reports back a summary. Do not inline capture logic here — always delegate to the skill so behavior stays consistent with `/sungen:create-test`.
57
+
58
+ ### 3. Fill spec.md
59
+
60
+ Use `AskUserQuestion`: *"Fill `spec.md` now? (You can reference the captured visuals)"* — offer **Yes, fill now (Recommended)** / **Skip, fill later**.
61
+
62
+ If yes → open `qa/flows/<name>/requirements/spec.md` and help the user fill:
63
+ - **Screens list** — ordered list of screens with URL paths
64
+ - **Flow steps** — what the user does at each screen
65
+ - **Transitions** — what triggers navigation between screens
66
+ - **Business rules** — cross-screen validation, state that persists
67
+ - **Test data** — what data is entered at each screen
68
+
69
+ Reference the captured visuals from Step 2 to suggest field names, form elements, and UI states.
70
+
71
+ ### 4. Next steps
72
+
73
+ Tell the user what was created, then use `AskUserQuestion` to offer next steps:
74
+
75
+ - **`/sungen:create-test <name>`** — Create test scenarios for the flow (Recommended)
76
+ - **Done for now** — I'll come back later
77
+
78
+ If user picks `/sungen:create-test`, **you MUST use the Skill tool** to invoke it. Do NOT generate test cases yourself — the skill auto-loads `sungen-gherkin-syntax` and `sungen-tc-generation`.
79
+
80
+ ## Key Rules
81
+
82
+ - Flows are **independent** from screens — own selectors, own test-data
83
+ - Selectors use `[Screen:Element]` namespace format with colon
84
+ - YAML keys must be **quoted** due to colon: `"login:submit":`
85
+ - Test data namespaced by phase: `login.email`, `submission.nominee`
86
+ - `@flow` tag required at feature level
87
+ - `Background:` should only contain the starting page navigation
88
+ - Each scenario = one phase of the journey
@@ -19,13 +19,16 @@ You are a **Senior QA Engineer** specialized in test case design. You structure
19
19
 
20
20
  ## Parameters
21
21
 
22
- Parse **screen** from `$ARGUMENTS`. If missing, ask the user.
22
+ Parse **name** from `$ARGUMENTS`. If missing, ask the user.
23
+
24
+ **Auto-detect context**: check if `qa/flows/<name>/` exists → flow mode. Else check `qa/screens/<name>/` → screen mode. This determines paths, generation strategy, and CLI commands.
23
25
 
24
26
  ## Steps
25
27
 
26
- 1. Verify `qa/screens/<screen>/` exists. If not → `/sungen:add-screen` first.
28
+ 1. **Flow**: Verify `qa/flows/<name>/` exists. If not → `/sungen:add-flow` first.
29
+ **Screen**: Verify `qa/screens/<name>/` exists. If not → `/sungen:add-screen` first.
27
30
  2. Check if `.feature` file already has scenarios. If yes → use `AskUserQuestion` to ask the update mode (see `sungen-tc-generation` skill for details). If no → fresh creation.
28
- 3. **Read requirements & resolve visual source** — check `qa/screens/<screen>/requirements/`:
31
+ 3. **Read requirements & resolve visual source** — check `qa/<screens|flows>/<name>/requirements/`:
29
32
  - If `spec.md` exists → read it as PRIMARY source (sections, fields, validation rules, business rules, states).
30
33
  - If `test-viewpoint.md` exists → read it. If it only contains HTML comments (scaffold template), use `AskUserQuestion` to ask:
31
34
  - **Fill test-viewpoint.md first** — I'll help you identify edge cases, known issues, and design decisions for this screen before generating tests
@@ -44,13 +47,13 @@ Parse **screen** from `$ARGUMENTS`. If missing, ask the user.
44
47
 
45
48
  Summarize what you found in requirements and present to the user.
46
49
 
47
- 4. Follow the `sungen-tc-generation` skill for section identification, viewpoint generation, and output format. When requirements exist, use the "Requirements-Driven Generation" strategy.
48
- 5. Generate or update `.feature` + `test-data.yaml` following `sungen-gherkin-syntax` and `sungen-tc-generation` skills.
50
+ 4. Follow the `sungen-tc-generation` skill for section identification, viewpoint generation, and output format. **For flows**, use the "Flow Test Generation" section in the skill. When requirements exist, use the "Requirements-Driven Generation" strategy.
51
+ 5. Generate or update `.feature` + `test-data.yaml` following `sungen-gherkin-syntax` and `sungen-tc-generation` skills. **For flows**: use `[Screen:Element]` namespace format, namespace test-data by phase, add `@flow` tag.
49
52
  6. Show summary, then use `AskUserQuestion` to offer next steps:
50
53
 
51
- - **`/sungen:review <screen>`** — Review syntax, coverage, viewpoint quality (Recommended)
52
- - **`/sungen:run-test <screen>`** — Skip review, generate selectors and run tests now
53
- - **`/sungen:create-test <screen>`** — Expand coverage: add @normal + @low scenarios
54
+ - **`/sungen:review <name>`** — Review syntax, coverage, viewpoint quality (Recommended)
55
+ - **`/sungen:run-test <name>`** — Skip review, generate selectors and run tests now
56
+ - **`/sungen:create-test <name>`** — Expand coverage: add @normal + @low scenarios
54
57
  - **Done for now** — I'll come back later
55
58
 
56
59
  **No selectors.yaml** — selectors are generated during `/sungen:run-test`.
@@ -11,17 +11,19 @@ You are a **Senior QA Reviewer**. You evaluate Gherkin test cases using the `sun
11
11
 
12
12
  ## Parameters
13
13
 
14
- Parse **screen** from `$ARGUMENTS`. If missing, ask the user.
14
+ Parse **name** from `$ARGUMENTS`. If missing, ask the user.
15
+
16
+ **Auto-detect context**: check if `qa/flows/<name>/` exists → flow mode (base path: `qa/flows/<name>/`). Else check `qa/screens/<name>/` → screen mode (base path: `qa/screens/<name>/`).
15
17
 
16
18
  ## Steps
17
19
 
18
- 1. Read `qa/screens/<screen>/features/<screen>.feature` and `qa/screens/<screen>/test-data/<screen>.yaml`. If missing → `/sungen:create-test` first.
19
- 2. Follow the `sungen-tc-review` skill — score 3 dimensions: Syntax (30pts), Coverage (40pts), Viewpoint (30pts). Use `sungen-viewpoint` for pattern checklists.
20
- 3. **Unverified Selectors check** — if `qa/screens/<screen>/selectors/<screen>.yaml` exists, count lines matching `@needs-live-verify`. Include in the review report as a non-scoring metric (see `sungen-tc-review` skill for report format). Does NOT affect the 60% threshold.
20
+ 1. Read `<base>/<name>/features/<name>.feature` and `<base>/<name>/test-data/<name>.yaml`. If missing → `/sungen:create-test` first.
21
+ 2. Follow the `sungen-tc-review` skill — score 3 dimensions: Syntax (30pts), Coverage (40pts), Viewpoint (30pts). **For flows**, also apply the "Flow Review Additions" section. Use `sungen-viewpoint` for pattern checklists.
22
+ 3. **Unverified Selectors check** — if `<base>/<name>/selectors/<name>.yaml` exists, count lines matching `@needs-live-verify`. Include in the review report as a non-scoring metric. Does NOT affect the 60% threshold.
21
23
  4. Output review report per `sungen-tc-review` format. **>= 60%**: PASS. **< 60%**: FAIL with recommendations.
22
24
  5. If FAIL and user confirms → update test cases following `sungen-gherkin-syntax` and `sungen-tc-generation` skills, then re-review.
23
25
  6. After PASS (or user decides to proceed), use `AskUserQuestion` to offer next steps:
24
26
 
25
- - **`/sungen:run-test <screen>`** — Generate selectors, compile, and run tests (Recommended)
26
- - **`/sungen:create-test <screen>`** — Add more test cases before running
27
+ - **`/sungen:run-test <name>`** — Generate selectors, compile, and run tests (Recommended)
28
+ - **`/sungen:create-test <name>`** — Add more test cases before running
27
29
  - **Done for now** — I'll come back later
@@ -11,11 +11,13 @@ You are a **Senior Developer**. Use `sungen-selector-fix`, `sungen-selector-keys
11
11
 
12
12
  ## Parameters
13
13
 
14
- Parse **screen** from `$ARGUMENTS`. If missing, ask the user.
14
+ Parse **name** from `$ARGUMENTS`. If missing, ask the user.
15
+
16
+ **Auto-detect context**: check if `qa/flows/<name>/` exists → flow mode (base path: `qa/flows/<name>/`). Else check `qa/screens/<name>/` → screen mode (base path: `qa/screens/<name>/`).
15
17
 
16
18
  ## Pre-run (phased — per `sungen-selector-fix` skill)
17
19
 
18
- 1. Verify `qa/screens/<screen>/` has `.feature` + `test-data.yaml`.
20
+ 1. Verify `<base>/<name>/` has `.feature` + `test-data.yaml`.
19
21
  2. **Phase 0 — Selector Pre-gen**: if `selectors.yaml` is missing/empty or doesn't cover the feature file's `[Reference]`s, apply the following decision tree before running Phase 0 from `sungen-selector-fix`:
20
22
 
21
23
  ```
@@ -29,14 +31,14 @@ Parse **screen** from `$ARGUMENTS`. If missing, ask the user.
29
31
  2. Apply selector heuristics from sungen-figma-source skill (testid > role+name > placeholder > label > locator > text)
30
32
  3. Write selectors.yaml — every provisional entry gets this comment on the line above:
31
33
  # @needs-live-verify source=figma node_id=<id>
32
- 4. Compile: sungen generate --screen <screen> — must succeed
34
+ 4. Compile: Screen: sungen generate --screen <name>. Flow: sungen generate --flow <name> — must succeed
33
35
  5. Phase 1 smoke check runs; tests using unverified selectors may fail
34
36
  → auto-fix triggers on next run-test invocation when a live page is available
35
37
  NO → hard stop: print the following message and stop:
36
38
  "Cannot generate selectors: no live page URL and no spec_figma.md found.
37
39
  Options:
38
40
  • Provide the live URL so Playwright MCP can snapshot the page, OR
39
- • Run: sungen add --screen <screen> --figma <figma-url> to generate spec_figma.md first"
41
+ • Run: sungen add --screen <name> --figma <figma-url> to generate spec_figma.md first"
40
42
  ```
41
43
 
42
44
  **Auto-fix on subsequent runs**: when `run-test` is invoked again with a reachable live page, Phase 0 compares the DOM snapshot against existing `selectors.yaml` entries. Entries tagged `# @needs-live-verify` are treated as candidates — if the actual selector differs, the entry is replaced and the comment removed (entry becomes verified). Entries that already match are also promoted to verified (comment removed).
@@ -50,7 +52,7 @@ Parse **screen** from `$ARGUMENTS`. If missing, ask the user.
50
52
  name: "Submit"
51
53
  ```
52
54
  3. **Phase 0.5 — Auth Persistence**: if the feature has `@auth:<role>` tags and `specs/.auth/<role>.json` is missing/expired, run Phase 0.5 from `sungen-selector-fix` — user logs in manually in MCP browser → `browser_storage_state` → `specs/.auth/<role>.json`. Offer `sungen makeauth <role>` as CLI fallback only if `browser_storage_state` isn't available in this MCP version.
53
- 4. Compile: `sungen generate --screen <screen>` (default: runtime data loading from YAML). Use `--inline-data` only if user requests compile-time hardcoded values.
55
+ 4. Compile: **Screen**: `sungen generate --screen <name>`. **Flow**: `sungen generate --flow <name>`. Default: runtime data loading from YAML. Use `--inline-data` only if user requests compile-time hardcoded values.
54
56
 
55
57
  ## Run & Fix (phased — per `sungen-selector-fix` skill)
56
58
 
@@ -61,15 +63,17 @@ Parse **screen** from `$ARGUMENTS`. If missing, ask the user.
61
63
 
62
64
  ## Playwright command guidelines
63
65
 
64
- **Per-screen JSON results** — each run must write its JSON report to a dedicated path co-located with the `.spec.ts`, so `sungen delivery` can read the correct results per screen:
66
+ **Per-screen/flow JSON results** — each run must write its JSON report to a dedicated path co-located with the `.spec.ts`, so `sungen delivery` can read the correct results:
65
67
 
66
68
  ```bash
67
- # ✅ Correct — per-screen output file via env var
68
- PLAYWRIGHT_JSON_OUTPUT_NAME=specs/generated/<screen>/<screen>-test-result.json \
69
- npx playwright test specs/generated/<screen>/<screen>.spec.ts
70
- ```
69
+ # ✅ Screen
70
+ PLAYWRIGHT_JSON_OUTPUT_NAME=specs/generated/<name>/<name>-test-result.json \
71
+ npx playwright test specs/generated/<name>/<name>.spec.ts
71
72
 
72
- Output: `specs/generated/<screen>/<screen>-test-result.json`
73
+ # ✅ Flow
74
+ PLAYWRIGHT_JSON_OUTPUT_NAME=specs/generated/flows/<name>/<name>-test-result.json \
75
+ npx playwright test specs/generated/flows/<name>/<name>.spec.ts
76
+ ```
73
77
 
74
78
  **DO NOT** pass `--reporter=...` flag — it overrides the reporters from `playwright.config.ts` and disables the JSON reporter that `sungen delivery` depends on.
75
79
 
@@ -21,22 +21,28 @@ You generate 3 files for sungen — a Gherkin compiler that produces Playwright
21
21
  | `sungen-capture-live` | Capture a live running page via Playwright MCP (snapshot + screenshot) |
22
22
  | `sungen-figma-source` | Figma URL → spec_figma.md + ui/*.png + provisional selectors |
23
23
 
24
- ## Workflow (5 AI commands)
24
+ ## Workflow (6 AI commands)
25
25
 
26
26
  | Command | What it does |
27
27
  |---|---|
28
28
  | `/sungen:add-screen <name> <path>` | Scaffold `qa/screens/<name>/` directories |
29
- | `/sungen:create-test <name>` | Generate `.feature` + `test-data.yaml` (no selectors) |
30
- | `/sungen:review <name>` | Score syntax, coverage, viewpoint quality (60% threshold) |
31
- | `/sungen:run-test <name>` | Generate `selectors.yaml` from live page, compile, run, auto-fix |
29
+ | `/sungen:add-flow <name> [--path <url>]` | Scaffold `qa/flows/<name>/` directories for E2E cross-screen testing |
30
+ | `/sungen:create-test <name>` | Generate `.feature` + `test-data.yaml` (auto-detects screen or flow) |
31
+ | `/sungen:review <name>` | Score syntax, coverage, viewpoint quality (auto-detects screen or flow) |
32
+ | `/sungen:run-test <name>` | Generate `selectors.yaml`, compile, run, auto-fix (auto-detects screen or flow) |
32
33
  | `/sungen:delivery [name...]` | Export test cases → CSV for QA delivery (all screens if no arg) |
33
34
 
34
- **Order:** add-screen → create-test → review → run-test → delivery.
35
+ **Screen path:** add-screen → create-test → review → run-test → delivery.
36
+ **Flow path:** add-flow → create-test → review → run-test → delivery.
37
+
38
+ `create-test`, `review`, and `run-test` auto-detect context: if `qa/flows/<name>/` exists → flow mode, else `qa/screens/<name>/` → screen mode.
35
39
 
36
40
  After each command completes, use `AskUserQuestion` to present the next actions as selectable options. Never just print text — always give clickable choices so the user can continue the workflow seamlessly.
37
41
 
38
42
  ## File Structure
39
43
 
44
+ ### Screen (single-screen testing)
45
+
40
46
  ```
41
47
  qa/screens/<screen-name>/
42
48
  ├── features/<screen>.feature # Gherkin scenarios
@@ -47,9 +53,27 @@ qa/screens/<screen-name>/
47
53
  └── requirements/
48
54
  ├── spec.md # Screen specification (primary source)
49
55
  └── ui/ # Screenshots, mockups
56
+ ```
57
+
58
+ ### Flow (E2E cross-screen testing)
50
59
 
51
- qa/deliverables/<screen>-testcases.csv # Exported test cases (from /sungen:delivery)
52
- qa/deliverables/<screen>-testcases.xlsx # Styled workbook for client hand-off
60
+ ```
61
+ qa/flows/<flow-name>/
62
+ ├── features/<flow>.feature # Gherkin with @flow tag, [Screen:Element] refs
63
+ ├── selectors/<flow>.yaml # Namespaced keys: "login:submit", "awards:title"
64
+ ├── test-data/<flow>.yaml # Namespaced data: login.email, submission.nominee
65
+ ├── test-data/<flow>.staging.yaml # Environment override (optional)
66
+ ├── test-data/<flow>.production.yaml # Environment override (optional)
67
+ └── requirements/
68
+ ├── spec.md # Flow specification (screens, steps, transitions)
69
+ └── ui/ # Screenshots, mockups
70
+ ```
71
+
72
+ Flows are **independent** from screens — own selectors, own test-data. Selectors use colon-namespaced keys (`"login:submit":`) to avoid duplicate element names across screens.
73
+
74
+ ```
75
+ qa/deliverables/<name>-testcases.csv # Exported test cases (from /sungen:delivery)
76
+ qa/deliverables/<name>-testcases.xlsx # Styled workbook for client hand-off
53
77
  ```
54
78
 
55
79
  ## Test Data
@@ -61,11 +85,18 @@ qa/deliverables/<screen>-testcases.xlsx # Styled workbook for client hand-off
61
85
  ## CLI Commands
62
86
 
63
87
  ```bash
88
+ # Screen
64
89
  sungen add --screen <name> --path <url-path> # Scaffold screen directories
65
90
  sungen add --screen <name> --path <path> --feature <name> # Scaffold with sub-feature
66
91
  sungen generate --screen <name> # Compile .feature → .spec.ts (runtime data)
67
92
  sungen generate --screen <name> --inline-data # Compile with hardcoded data (legacy)
68
- sungen generate --all # Compile all screens
69
- sungen delivery # Export all screens → CSV + XLSX
70
- sungen delivery <screen> # Export a single screen
93
+
94
+ # Flow
95
+ sungen add-flow --flow <name> --path <start-url> # Scaffold flow directories
96
+ sungen generate --flow <name> # Compile flow .feature → .spec.ts
97
+
98
+ # All
99
+ sungen generate --all # Compile all screens and flows
100
+ sungen delivery # Export all → CSV + XLSX
101
+ sungen delivery <name> # Export a single screen or flow
71
102
  ```
@@ -61,6 +61,18 @@ Where `<timestamp>` is `YYYYMMDD-HHMM` in local time (e.g. `live-20260421-1430.p
61
61
 
62
62
  This gives users a visual record they can reference later without re-scanning.
63
63
 
64
+ ### 6a. Verify unauthenticated redirect target (flow capture only)
65
+
66
+ When capturing for a **flow** that includes security scenarios (e.g., "unauthenticated user cannot access X"):
67
+
68
+ 1. Open a **fresh incognito/unauthenticated** browser context (no storage state).
69
+ 2. `browser_navigate` to the protected route (e.g., `/dashboard`).
70
+ 3. Record the **actual redirect URL** — do NOT assume it goes to `/login`. The app may redirect to `/register`, `/`, or any other route.
71
+ 4. Report the redirect target to the caller: *"Unauthenticated access to `/dashboard` redirects to `/register`"*.
72
+ 5. The caller must use the **actual redirect URL** in Gherkin assertions (e.g., `Then User is on [Register] page`), never an assumed one.
73
+
74
+ Skip this step if the flow has no security scenarios or the user explicitly says to skip.
75
+
64
76
  ### 6. Detect discrepancies vs spec
65
77
 
66
78
  If `spec.md` exists, briefly cross-check the snapshot against spec sections:
@@ -6,7 +6,7 @@ user-invocable: false
6
6
 
7
7
  ## Purpose
8
8
 
9
- Export test cases from Sungen screens to a standardized CSV file (format BM-2-901-13) for QA delivery.
9
+ Export test cases from Sungen screens and flows to a standardized CSV file (format BM-2-901-13) for QA delivery.
10
10
 
11
11
  **This skill delegates all heavy work to the `sungen delivery` CLI.** The CLI is the single source of truth for parsing logic — do NOT re-parse files in AI. Your role is only to:
12
12
 
@@ -19,18 +19,19 @@ Export test cases from Sungen screens to a standardized CSV file (format BM-2-90
19
19
  ## Architecture
20
20
 
21
21
  ```
22
- User → /sungen:delivery [screen...]
22
+ User → /sungen:delivery [name...]
23
23
 
24
24
 
25
25
  sungen delivery CLI (deterministic — no AI tokens)
26
- ├─ Scope detection (no-arg = all screens)
27
- ├─ Pre-flight source checks per screen
26
+ ├─ Scope detection (no-arg = all screens + flows)
27
+ ├─ Auto-detect: qa/flows/<name>/ flow, qa/screens/<name>/ → screen
28
+ ├─ Pre-flight source checks per target
28
29
  ├─ Parse .feature (metadata)
29
30
  ├─ Parse .spec.ts (resolved Playwright code — source of truth)
30
31
  ├─ Parse test-data.yaml (resolve {{vars}})
31
32
  ├─ Parse test-results/results.json (match test titles)
32
33
  ├─ Merge sources + generate CSV rows
33
- └─ Write qa/deliverables/<screen>-testcases.csv
34
+ └─ Write qa/deliverables/<name>-testcases.csv
34
35
  ```
35
36
 
36
37
  Source modules: `src/exporters/*.ts`
@@ -39,18 +40,18 @@ Source modules: `src/exporters/*.ts`
39
40
 
40
41
  ## Required sources (CLI pre-flight checks these)
41
42
 
42
- | # | Source | Path | Created by |
43
- |---|--------|------|------------|
44
- | 1 | Feature file | `qa/screens/<screen>/features/<screen>.feature` | `/sungen:add-screen` + `/sungen:create-test` |
45
- | 2 | Test data | `qa/screens/<screen>/test-data/<screen>.yaml` | `/sungen:create-test` |
46
- | 3 | Selectors | `qa/screens/<screen>/selectors/<screen>.yaml` | `/sungen:run-test` |
47
- | 4 | Compiled spec | `specs/generated/<screen>/<screen>.spec.ts` | `sungen generate` (during `/sungen:run-test`) |
48
- | 5 | Test results | `specs/generated/<screen>/<screen>-test-result.json` (per-screen) or `test-results/results.json` (global fallback) | `/sungen:run-test` |
43
+ | # | Source | Screen path | Flow path | Created by |
44
+ |---|--------|-------------|-----------|------------|
45
+ | 1 | Feature file | `qa/screens/<name>/features/<name>.feature` | `qa/flows/<name>/features/<name>.feature` | `add-screen`/`add-flow` + `create-test` |
46
+ | 2 | Test data | `qa/screens/<name>/test-data/<name>.yaml` | `qa/flows/<name>/test-data/<name>.yaml` | `create-test` |
47
+ | 3 | Selectors | `qa/screens/<name>/selectors/<name>.yaml` | `qa/flows/<name>/selectors/<name>.yaml` | `run-test` |
48
+ | 4 | Compiled spec | `specs/generated/<name>/<name>.spec.ts` | `specs/generated/flows/<name>/<name>.spec.ts` | `sungen generate` |
49
+ | 5 | Test results | `specs/generated/<name>/<name>-test-result.json` or `test-results/results.json` | `specs/generated/flows/<name>/<name>-test-result.json` or global fallback | `run-test` |
49
50
 
50
51
  **Sources 1-4 are blocking** — CLI aborts if any is missing.
51
52
  **Source 5 is optional** — CSV is still generated but Test Result/Date/Executor/Env columns are empty (all tests show as Pending).
52
53
 
53
- The CLI reads the **per-screen result file first** (co-located with `.spec.ts`), then falls back to the global `test-results/results.json`. Per-screen is preferred because the global file gets OVERWRITTEN each time Playwright runs, losing results from earlier screens.
54
+ The CLI reads the **per-target result file first** (co-located with `.spec.ts`), then falls back to the global `test-results/results.json`. Per-target is preferred because the global file gets OVERWRITTEN each time Playwright runs, losing results from earlier targets.
54
55
 
55
56
  ---
56
57
 
@@ -87,17 +88,17 @@ The CLI reads the **per-screen result file first** (co-located with `.spec.ts`),
87
88
  ## CLI command reference
88
89
 
89
90
  ```bash
90
- # Export all screens
91
+ # Export all screens and flows
91
92
  sungen delivery
92
93
 
93
- # Export specific screens
94
- sungen delivery kudos awards
94
+ # Export specific targets (auto-detects screen vs flow)
95
+ sungen delivery kudos awards nomination-flow
95
96
 
96
97
  # Skip pre-flight (CI only)
97
98
  sungen delivery --skip-preflight
98
99
 
99
- # Skip screens with blocking misses
100
+ # Skip targets with blocking misses
100
101
  sungen delivery --continue-on-missing
101
102
  ```
102
103
 
103
- Output: `qa/deliverables/<screen>-testcases.csv` (UTF-8 with BOM)
104
+ Output: `qa/deliverables/<name>-testcases.csv` (UTF-8 with BOM)
@@ -101,6 +101,18 @@ If `toHaveText` fails on an input → the Gherkin step has wrong target type. Fi
101
101
 
102
102
  ---
103
103
 
104
+ ## Flow-Specific Errors
105
+
106
+ | Error | Diagnosis | Fix |
107
+ |---|---|---|
108
+ | Navigation timeout between screens | Cross-screen transition takes too long or URL mismatch | Add explicit `wait for page` step between screen transitions in `.feature`. Verify target URL path |
109
+ | Selector `"screen:element"` not found | Namespace key missing or wrong format | Ensure colon-namespaced key in `selectors.yaml` is **quoted**: `"login:submit":`. Check screen prefix matches `[Screen:Element]` ref in Gherkin |
110
+ | Test data `screen.key` undefined | Phase namespace mismatch | Verify `test-data.yaml` uses dot-namespaced keys: `login.email`, `submission.nominee`. Keys must match `{{screen.key}}` refs in `.feature` |
111
+ | State lost between screens | Auth/session expired during multi-screen flow | Ensure all screens in the flow share the same `@auth:role` tag. Check if the app invalidates sessions on navigation |
112
+ | Duplicate selector key across screens | Two screens use same element name without namespace | Always use `[Screen:Element]` format in flow `.feature`. Selectors must use `"screen:element":` quoted keys |
113
+
114
+ ---
115
+
104
116
  ## Performance & Infrastructure Errors → Fix in `specs/base.ts`
105
117
 
106
118
  All generated `.spec.ts` import from `specs/base.ts` — shared context caching, navigation, overlay cleanup. AI **can and should** tune `base.ts` to match the project.
@@ -120,6 +120,32 @@ Most elements auto-infer from `[Label] type` → `getByRole(type, { name: 'Label
120
120
  - Same label, nth occurrence → add `--N` suffix
121
121
  - Target Name > 30 chars → shorten to 1–3 meaningful words
122
122
 
123
+ ## Dynamic Variables (test-data YAML)
124
+
125
+ Use `{{$var}}` in test-data YAML for values that must be unique per test run. Resolved at **runtime** by `TestDataLoader` — the compiler passes them through unchanged.
126
+
127
+ | Variable | Example | Output |
128
+ |---|---|---|
129
+ | `{{$timestamp}}` | `"User-{{$timestamp}}"` | `"User-1714000000"` |
130
+ | `{{$uuid}}` | `"{{$uuid}}"` | `"a1b2c3d4-..."` |
131
+ | `{{$random:min:max}}` | `"{{$random:1:100}}"` | `"42"` |
132
+ | `{{$date}}` | `"{{$date}}"` | `"2026-04-24"` |
133
+ | `{{$datetime}}` | `"{{$datetime}}"` | `"2026-04-24T10:30:00.000Z"` |
134
+
135
+ **Rules:**
136
+ - `$timestamp` and `$uuid` → same value across all keys in one `load()` call (stable within a test file)
137
+ - `$random` → unique per occurrence (each key gets a different random)
138
+ - Resolved once at load time → every `get()` returns the same resolved value
139
+ - Use for CRUD flows to avoid data collision between parallel runs
140
+
141
+ ```yaml
142
+ # test-data/crud-award.yaml
143
+ award:
144
+ name: "Award-{{$timestamp}}"
145
+ email: "test+{{$uuid}}@example.com"
146
+ score: "{{$random:1:100}}"
147
+ ```
148
+
123
149
  ## Selectors (priority order)
124
150
 
125
151
  | type | value | name | use |
@@ -138,27 +164,112 @@ Options: `nth` `exact` `scope` `match` `variant` `frame` `contenteditable` `colu
138
164
 
139
165
  ## Tags
140
166
 
167
+ ### Functional tags (affect code generation)
168
+
141
169
  | Tag | Effect |
142
170
  |---|---|
143
- | `@auto` | Standard scenario, ready for automation |
144
171
  | `@manual` | Skip in generation |
145
- | `@smoke` / `@regression` | Test suite grouping |
146
- | `@critical` | Priority: system unusable if fails (login, auth, core CRUD) |
147
- | `@high` | Priority: major feature broken (required validation, key business rules) |
148
- | `@normal` | Priority: degraded experience (UI layout, secondary flows) |
149
- | `@low` | Priority: minor/cosmetic (tooltips, hover states, empty states) |
150
172
  | `@auth:role` | Use auth storage state for role |
151
173
  | `@no-auth` | Disable inherited auth |
152
174
  | `@steps:name` | Define reusable step block (base scenario) |
153
175
  | `@extend:name` | Prepend Given→When from @steps block (skip Then) |
154
- | `@cleanup:overlay` | Auto-cleanup: dismiss dialogs/overlays after each test (base.ts fixture) |
155
- | `@cleanup:forms` | Auto-cleanup: clear form fields after each test (base.ts fixture) |
156
- | `@cleanup:scroll` | Auto-cleanup: scroll to top after each test (base.ts fixture) |
157
- | `@cleanup:storage` | Auto-cleanup: clear sessionStorage after each test (base.ts fixture) |
176
+ | `@cleanup:overlay` | Auto-cleanup: dismiss dialogs/overlays after each test (cleanupPage) |
177
+ | `@cleanup:forms` | Auto-cleanup: clear form fields after each test (cleanupPage) |
178
+ | `@cleanup:scroll` | Auto-cleanup: scroll to top after each test (cleanupPage) |
179
+ | `@cleanup:storage` | Auto-cleanup: clear sessionStorage after each test (cleanupPage) |
158
180
  | `@screenshot:on-failure` | Auto-capture screenshot when test fails (base.ts fixture) |
181
+ | `@parallel` | Opt-out: fresh page per test instead of serial default (for independent scenarios) |
159
182
  | `@beforeAll` | Hook: runs once before all tests → `test.beforeAll()` |
160
183
  | `@afterEach` | Hook: runs after each test → `test.afterEach()` (custom cleanup) |
161
184
  | `@afterAll` | Hook: runs once after all tests → `test.afterAll()` |
185
+ | `@flow` | Mark feature as E2E flow (cross-screen testing) |
186
+
187
+ ### Pass-through tags (filter at runtime via Playwright --grep)
188
+
189
+ Any tag not listed above passes through to Playwright `{ tag: [...] }`. Feature-level tags inherit to all scenarios.
190
+
191
+ | Tag | Purpose |
192
+ |---|---|
193
+ | `@smoke` | Quick sanity check — run after every deploy |
194
+ | `@regression` | Full test suite — run nightly or before release |
195
+ | `@critical` | Priority: system unusable if fails (login, auth, core CRUD) |
196
+ | `@high` | Priority: major feature broken (required validation, key business rules) |
197
+ | `@normal` | Priority: degraded experience (UI layout, secondary flows) |
198
+ | `@low` | Priority: minor/cosmetic (tooltips, hover states, empty states) |
199
+ | `@auto` | Standard scenario, ready for automation |
200
+ | Any custom | e.g., `@sprint-42`, `@team-payment` — any tag works |
201
+
202
+ **Run filtered:**
203
+ ```bash
204
+ npx playwright test --grep "@smoke" # only smoke tests
205
+ npx playwright test --grep "@critical" # only critical priority
206
+ npx playwright test --grep "@smoke|@critical" # smoke OR critical
207
+ ```
208
+
209
+ ### Serial vs Parallel (test execution mode)
210
+
211
+ **Default: serial** — `test.describe.serial()` with shared page. Background runs once in `beforeAll`. Fail → skip remaining.
212
+
213
+ **`@parallel` opt-out** — `test.describe()` with fresh page per test. Background runs as `beforeEach`. Use when scenarios are truly independent (validation rules, permission tests).
214
+
215
+ | Mode | Generated | Page | Background | On fail |
216
+ |---|---|---|---|---|
217
+ | Serial (default) | `test.describe.serial()` | Shared | `beforeAll` (1 goto) | Skip remaining |
218
+ | `@parallel` | `test.describe()` | Fresh per test | `beforeEach` (N goto) | Continue |
219
+
220
+ **`@parallel` is required** when a feature has multiple auth groups (e.g., `@auth:user` + `@no-auth` scenarios). Serial mode uses one shared browser context and cannot mix auth roles. The compiler will error if `@parallel` is missing in this case.
221
+
222
+ ### `@flow` tag (E2E cross-screen testing)
223
+
224
+ `@flow` marks a feature as a **flow** — an E2E journey spanning multiple screens. Flows live in `qa/flows/<name>/` with their own selectors, test-data, and requirements.
225
+
226
+ **Key differences from screen tests:**
227
+
228
+ | Aspect | Screen (`qa/screens/`) | Flow (`qa/flows/`) |
229
+ |---|---|---|
230
+ | Scope | Single page | Multiple pages |
231
+ | Selectors | `[Element]` → own YAML | `[Screen:Element]` → own YAML (namespaced) |
232
+ | Test data | `{{variable}}` | `{{phase.variable}}` (namespaced by phase) |
233
+ | Tag | `@auto` / `@smoke` etc. | `@flow` (required at feature level) |
234
+ | Multi-domain | N/A | Absolute URL in selector `path:` skips baseURL |
235
+
236
+ **Selector namespace format:** `[Screen:Element]` where colon separates screen prefix from element name. The YAML key is `"screen:element"` (quoted, lowercase).
237
+
238
+ ```gherkin
239
+ # Feature file
240
+ When User fill [Login:Email] field with {{login.email}}
241
+ And User click [Login:Submit] button
242
+ Then User see [Dashboard] page
243
+ When User click [Dashboard:Awards] link
244
+ ```
245
+
246
+ ```yaml
247
+ # selectors.yaml — keys are namespaced, quoted due to colon
248
+ "login:email":
249
+ type: 'testid'
250
+ value: 'email-input'
251
+
252
+ "login:submit":
253
+ type: 'role'
254
+ value: 'button'
255
+ name: 'Login'
256
+
257
+ dashboard:
258
+ type: 'page'
259
+ value: '/dashboard'
260
+
261
+ "dashboard:awards":
262
+ type: 'role'
263
+ value: 'link'
264
+ name: 'Awards'
265
+ ```
266
+
267
+ **Flow structure:**
268
+ - `Background:` — set starting page only (e.g., `Given User is on [Login] page`)
269
+ - Each `Scenario:` — one phase/step of the flow (login, navigate, submit, etc.)
270
+ - Page navigation between scenarios uses `[Screen] page` references
271
+
272
+ **CLI:** `sungen add-flow --flow <name>`, `sungen generate --flow <name>`, `sungen generate --all` (includes flows)
162
273
 
163
274
  ### @extend behavior
164
275
 
@@ -185,6 +296,7 @@ Options: `nth` `exact` `scope` `match` `variant` `frame` `contenteditable` `colu
185
296
  | Missing target type | `fill [email] with {{v}}` | `fill [email] field with {{v}}` |
186
297
  | Background with scope | `Background: ... And User is on [X] dialog` | Use `@steps` + `@extend` for scope-dependent flows |
187
298
  | `is on` after When | `When ... And User is on [X] dialog` | `And User see [X] dialog` or separate Given |
299
+ | Literal URL navigate | `User navigate to "/dashboard"` | `User is on [Dashboard] page` (add page selector in `selectors.yaml`) |
188
300
 
189
301
  ## Background vs @steps/@extend
190
302