@sun-asterisk/sungen 2.4.3 → 2.4.6

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 (138) hide show
  1. package/dist/cli/commands/add.d.ts.map +1 -1
  2. package/dist/cli/commands/add.js +8 -2
  3. package/dist/cli/commands/add.js.map +1 -1
  4. package/dist/cli/commands/delivery.d.ts +7 -0
  5. package/dist/cli/commands/delivery.d.ts.map +1 -0
  6. package/dist/cli/commands/delivery.js +348 -0
  7. package/dist/cli/commands/delivery.js.map +1 -0
  8. package/dist/cli/commands/update.d.ts.map +1 -1
  9. package/dist/cli/commands/update.js +64 -1
  10. package/dist/cli/commands/update.js.map +1 -1
  11. package/dist/cli/index.js +4 -2
  12. package/dist/cli/index.js.map +1 -1
  13. package/dist/exporters/csv-exporter.d.ts +32 -0
  14. package/dist/exporters/csv-exporter.d.ts.map +1 -0
  15. package/dist/exporters/csv-exporter.js +311 -0
  16. package/dist/exporters/csv-exporter.js.map +1 -0
  17. package/dist/exporters/feature-parser.d.ts +48 -0
  18. package/dist/exporters/feature-parser.d.ts.map +1 -0
  19. package/dist/exporters/feature-parser.js +178 -0
  20. package/dist/exporters/feature-parser.js.map +1 -0
  21. package/dist/exporters/package-info.d.ts +9 -0
  22. package/dist/exporters/package-info.d.ts.map +1 -0
  23. package/dist/exporters/package-info.js +73 -0
  24. package/dist/exporters/package-info.js.map +1 -0
  25. package/dist/exporters/playwright-report-parser.d.ts +21 -0
  26. package/dist/exporters/playwright-report-parser.d.ts.map +1 -0
  27. package/dist/exporters/playwright-report-parser.js +184 -0
  28. package/dist/exporters/playwright-report-parser.js.map +1 -0
  29. package/dist/exporters/scenario-merger.d.ts +21 -0
  30. package/dist/exporters/scenario-merger.d.ts.map +1 -0
  31. package/dist/exporters/scenario-merger.js +51 -0
  32. package/dist/exporters/scenario-merger.js.map +1 -0
  33. package/dist/exporters/spec-parser.d.ts +20 -0
  34. package/dist/exporters/spec-parser.d.ts.map +1 -0
  35. package/dist/exporters/spec-parser.js +259 -0
  36. package/dist/exporters/spec-parser.js.map +1 -0
  37. package/dist/exporters/step-formatter.d.ts +32 -0
  38. package/dist/exporters/step-formatter.d.ts.map +1 -0
  39. package/dist/exporters/step-formatter.js +76 -0
  40. package/dist/exporters/step-formatter.js.map +1 -0
  41. package/dist/exporters/test-data-resolver.d.ts +20 -0
  42. package/dist/exporters/test-data-resolver.d.ts.map +1 -0
  43. package/dist/exporters/test-data-resolver.js +96 -0
  44. package/dist/exporters/test-data-resolver.js.map +1 -0
  45. package/dist/exporters/types.d.ts +104 -0
  46. package/dist/exporters/types.d.ts.map +1 -0
  47. package/dist/exporters/types.js +6 -0
  48. package/dist/exporters/types.js.map +1 -0
  49. package/dist/exporters/xlsx-exporter.d.ts +19 -0
  50. package/dist/exporters/xlsx-exporter.d.ts.map +1 -0
  51. package/dist/exporters/xlsx-exporter.js +309 -0
  52. package/dist/exporters/xlsx-exporter.js.map +1 -0
  53. package/dist/generators/test-generator/utils/selector-resolver.d.ts.map +1 -1
  54. package/dist/generators/test-generator/utils/selector-resolver.js +26 -0
  55. package/dist/generators/test-generator/utils/selector-resolver.js.map +1 -1
  56. package/dist/orchestrator/ai-rules-updater.d.ts.map +1 -1
  57. package/dist/orchestrator/ai-rules-updater.js +12 -0
  58. package/dist/orchestrator/ai-rules-updater.js.map +1 -1
  59. package/dist/orchestrator/project-initializer.d.ts +12 -1
  60. package/dist/orchestrator/project-initializer.d.ts.map +1 -1
  61. package/dist/orchestrator/project-initializer.js +84 -64
  62. package/dist/orchestrator/project-initializer.js.map +1 -1
  63. package/dist/orchestrator/screen-manager.d.ts +1 -0
  64. package/dist/orchestrator/screen-manager.d.ts.map +1 -1
  65. package/dist/orchestrator/screen-manager.js +4 -2
  66. package/dist/orchestrator/screen-manager.js.map +1 -1
  67. package/dist/orchestrator/templates/ai-instructions/claude-cmd-add-screen.md +18 -9
  68. package/dist/orchestrator/templates/ai-instructions/claude-cmd-create-test.md +7 -5
  69. package/dist/orchestrator/templates/ai-instructions/claude-cmd-delivery.md +71 -0
  70. package/dist/orchestrator/templates/ai-instructions/claude-cmd-run-test.md +38 -10
  71. package/dist/orchestrator/templates/ai-instructions/claude-config.md +12 -2
  72. package/dist/orchestrator/templates/ai-instructions/claude-skill-capture-figma.md +142 -0
  73. package/dist/orchestrator/templates/ai-instructions/claude-skill-capture-live.md +100 -0
  74. package/dist/orchestrator/templates/ai-instructions/claude-skill-capture-local.md +73 -0
  75. package/dist/orchestrator/templates/ai-instructions/claude-skill-delivery.md +103 -0
  76. package/dist/orchestrator/templates/ai-instructions/claude-skill-gherkin-syntax.md +2 -0
  77. package/dist/orchestrator/templates/ai-instructions/claude-skill-selector-fix.md +87 -4
  78. package/dist/orchestrator/templates/ai-instructions/claude-skill-selector-keys.md +22 -0
  79. package/dist/orchestrator/templates/ai-instructions/copilot-cmd-add-screen.md +18 -9
  80. package/dist/orchestrator/templates/ai-instructions/copilot-cmd-create-test.md +6 -4
  81. package/dist/orchestrator/templates/ai-instructions/copilot-cmd-delivery.md +71 -0
  82. package/dist/orchestrator/templates/ai-instructions/copilot-cmd-run-test.md +45 -20
  83. package/dist/orchestrator/templates/ai-instructions/copilot-config.md +12 -2
  84. package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-capture-figma.md +142 -0
  85. package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-capture-live.md +100 -0
  86. package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-capture-local.md +73 -0
  87. package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-delivery.md +103 -0
  88. package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-gherkin-syntax.md +2 -0
  89. package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-selector-fix.md +87 -4
  90. package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-selector-keys.md +22 -0
  91. package/dist/orchestrator/templates/playwright.config.d.ts.map +1 -1
  92. package/dist/orchestrator/templates/playwright.config.js +6 -1
  93. package/dist/orchestrator/templates/playwright.config.js.map +1 -1
  94. package/dist/orchestrator/templates/playwright.config.ts +6 -1
  95. package/package.json +2 -1
  96. package/src/cli/commands/add.ts +9 -2
  97. package/src/cli/commands/delivery.ts +348 -0
  98. package/src/cli/commands/update.ts +84 -2
  99. package/src/cli/index.ts +4 -2
  100. package/src/exporters/csv-exporter.ts +304 -0
  101. package/src/exporters/feature-parser.ts +168 -0
  102. package/src/exporters/package-info.ts +35 -0
  103. package/src/exporters/playwright-report-parser.ts +168 -0
  104. package/src/exporters/scenario-merger.ts +63 -0
  105. package/src/exporters/spec-parser.ts +247 -0
  106. package/src/exporters/step-formatter.ts +80 -0
  107. package/src/exporters/test-data-resolver.ts +59 -0
  108. package/src/exporters/types.ts +112 -0
  109. package/src/exporters/xlsx-exporter.ts +301 -0
  110. package/src/generators/test-generator/utils/selector-resolver.ts +26 -0
  111. package/src/orchestrator/ai-rules-updater.ts +12 -0
  112. package/src/orchestrator/project-initializer.ts +103 -70
  113. package/src/orchestrator/screen-manager.ts +5 -2
  114. package/src/orchestrator/templates/ai-instructions/claude-cmd-add-screen.md +18 -9
  115. package/src/orchestrator/templates/ai-instructions/claude-cmd-create-test.md +7 -5
  116. package/src/orchestrator/templates/ai-instructions/claude-cmd-delivery.md +71 -0
  117. package/src/orchestrator/templates/ai-instructions/claude-cmd-run-test.md +38 -10
  118. package/src/orchestrator/templates/ai-instructions/claude-config.md +12 -2
  119. package/src/orchestrator/templates/ai-instructions/claude-skill-capture-figma.md +142 -0
  120. package/src/orchestrator/templates/ai-instructions/claude-skill-capture-live.md +100 -0
  121. package/src/orchestrator/templates/ai-instructions/claude-skill-capture-local.md +73 -0
  122. package/src/orchestrator/templates/ai-instructions/claude-skill-delivery.md +103 -0
  123. package/src/orchestrator/templates/ai-instructions/claude-skill-gherkin-syntax.md +2 -0
  124. package/src/orchestrator/templates/ai-instructions/claude-skill-selector-fix.md +87 -4
  125. package/src/orchestrator/templates/ai-instructions/claude-skill-selector-keys.md +22 -0
  126. package/src/orchestrator/templates/ai-instructions/copilot-cmd-add-screen.md +18 -9
  127. package/src/orchestrator/templates/ai-instructions/copilot-cmd-create-test.md +6 -4
  128. package/src/orchestrator/templates/ai-instructions/copilot-cmd-delivery.md +71 -0
  129. package/src/orchestrator/templates/ai-instructions/copilot-cmd-run-test.md +45 -20
  130. package/src/orchestrator/templates/ai-instructions/copilot-config.md +12 -2
  131. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-capture-figma.md +142 -0
  132. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-capture-live.md +100 -0
  133. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-capture-local.md +73 -0
  134. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-delivery.md +103 -0
  135. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-gherkin-syntax.md +2 -0
  136. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-selector-fix.md +87 -4
  137. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-selector-keys.md +22 -0
  138. package/src/orchestrator/templates/playwright.config.ts +6 -1
@@ -0,0 +1,103 @@
1
+ ---
2
+ name: sungen-delivery
3
+ description: 'Export Gherkin scenarios + Playwright results → CSV test case deliverable. Auto-loaded by delivery command.'
4
+ user-invocable: false
5
+ ---
6
+
7
+ ## Purpose
8
+
9
+ Export test cases from Sungen screens to a standardized CSV file (format BM-2-901-13) for QA delivery.
10
+
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
+
13
+ 1. Invoke the CLI
14
+ 2. Show its output verbatim
15
+ 3. Help the user react to pre-flight failures
16
+
17
+ ---
18
+
19
+ ## Architecture
20
+
21
+ ```
22
+ User → /sungen:delivery [screen...]
23
+
24
+
25
+ sungen delivery CLI (deterministic — no AI tokens)
26
+ ├─ Scope detection (no-arg = all screens)
27
+ ├─ Pre-flight source checks per screen
28
+ ├─ Parse .feature (metadata)
29
+ ├─ Parse .spec.ts (resolved Playwright code — source of truth)
30
+ ├─ Parse test-data.yaml (resolve {{vars}})
31
+ ├─ Parse test-results/results.json (match test titles)
32
+ ├─ Merge sources + generate CSV rows
33
+ └─ Write qa/deliverables/<screen>-testcases.csv
34
+ ```
35
+
36
+ Source modules: `src/exporters/*.ts`
37
+
38
+ ---
39
+
40
+ ## Required sources (CLI pre-flight checks these)
41
+
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` |
49
+
50
+ **Sources 1-4 are blocking** — CLI aborts if any is missing.
51
+ **Source 5 is optional** — CSV is still generated but Test Result/Date/Executor/Env columns are empty (all tests show as Pending).
52
+
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
+
55
+ ---
56
+
57
+ ## Column mapping (handled by CLI)
58
+
59
+ | CSV Column | Source |
60
+ |------------|--------|
61
+ | TC ID | Generated: `<SCREEN_UPPER>-<VP>-<NNN>` |
62
+ | Category 1 | Scenario name with VP prefix stripped |
63
+ | Category 2 | VP group: `VP-SEC`→Accessing, `VP-UI`→GUI, `VP-VAL`/`VP-LOGIC`→Function |
64
+ | Category 3 | Feature name (first line of `.feature`) |
65
+ | Category 4 | Screen name |
66
+ | Pre-condition | Auth tag → "Logged in as X" / "Not authenticated" + Given steps (natural language) |
67
+ | Test Data | `{{vars}}` from scenario resolved via test-data.yaml → `key: value; key2: value2` |
68
+ | Steps | `.spec.ts` code comments for interactions (numbered) |
69
+ | Expected results | `.spec.ts` `expect(...)` comments (numbered) |
70
+ | Priority | Tag: `@critical`/`@high`/`@normal`/`@low` (default: Normal) |
71
+ | Testcase type | `@manual` → Manual, else Auto. Not compiled → "Not compiled" |
72
+ | Test Result | results.json status: passed→Passed, failed/timedOut→Failed, skipped→N/A, else Pending |
73
+ | Executed Date | results.json startTime formatted as `dd/mm/yyyy` |
74
+ | Test Executor | `git config user.name` |
75
+ | Test Environment | `playwright.config.ts` baseURL + project name |
76
+ | Note | Error message + trace path (for failed tests) |
77
+
78
+ ---
79
+
80
+ ## Excluded from CSV
81
+
82
+ - `@steps:<name>` **base** scenarios — these are setup-only, inlined into `@extend:...` scenarios at compile time
83
+ - Default scaffold `Sample scenario for <screen>` — not a real test
84
+
85
+ ---
86
+
87
+ ## CLI command reference
88
+
89
+ ```bash
90
+ # Export all screens
91
+ sungen delivery
92
+
93
+ # Export specific screens
94
+ sungen delivery kudos awards
95
+
96
+ # Skip pre-flight (CI only)
97
+ sungen delivery --skip-preflight
98
+
99
+ # Skip screens with blocking misses
100
+ sungen delivery --continue-on-missing
101
+ ```
102
+
103
+ Output: `qa/deliverables/<screen>-testcases.csv` (UTF-8 with BOM)
@@ -109,6 +109,8 @@ Row scope: `see [Ref] row in [Table] table with {{v}}` enters scope. Subsequent
109
109
 
110
110
  Most elements auto-infer from `[Label] type` → `getByRole(type, { name: 'Label' })`. Only add YAML when the accessible name differs, needs `nth`, or needs `testid`. Full auto-infer table → see `sungen-selector-keys` skill.
111
111
 
112
+ **Types requiring YAML entry:** `date-picker`, `uploader`, `overlay`, `frame`, `step` - these have no standard ARIA role and need explicit selectors.
113
+
112
114
  ## YAML Keys
113
115
 
114
116
  `[Reference]` → **lowercase, keep Unicode**: `[Search Content]` → `search content:`, `[Thời gian]` → `thời gian:`
@@ -8,7 +8,88 @@ user-invocable: false
8
8
 
9
9
  Run tests in priority waves — catch fundamental issues early, fix critical paths first, let shared fixes cascade to lower-priority tests.
10
10
 
11
- **Never run all tests blindly.** Always start with a smoke check.
11
+ **Never run all tests blindly.** Always start with selector pre-generation, then a smoke check.
12
+
13
+ ---
14
+
15
+ ## Phase 0: Pre-run Selector Generation (Playwright MCP)
16
+
17
+ **Before any `sungen generate` or test run**, populate `selectors.yaml` from the live page so tests don't fail on missing keys in Phase 1.
18
+
19
+ ### When to run Phase 0
20
+
21
+ - `selectors.yaml` missing, empty, or contains only the page selector
22
+ - The `.feature` file has `[Reference]` keys without corresponding YAML entries and the referenced element can't be auto-inferred (see `sungen-selector-keys` § Auto-Infer)
23
+ - User explicitly re-scans after UI changes
24
+
25
+ If existing selectors already cover the feature file, **skip Phase 0** and go straight to compile + Phase 1.
26
+
27
+ ### Steps
28
+
29
+ 1. **Confirm with the user** via `AskUserQuestion`: *"Generate selectors from the live page via Playwright MCP now?"* — offer **Yes, scan live page** / **Skip (use existing selectors.yaml)** / **Cancel**.
30
+ 2. **Collect references**: parse the `.feature` file for every `[Reference]` element + its type (e.g. `[Submit] button`, `[Email] field`). Deduplicate.
31
+ 3. **Ensure page selector**: if missing, ask user for URL path and write it first.
32
+ 4. **Navigate**:
33
+ - Read `baseURL` from `playwright.config.ts`.
34
+ - `browser_navigate` to the page URL.
35
+ - If redirected to login → run **Phase 0.5: Auth Persistence** first (see below), then re-navigate to the target page.
36
+ 5. **Snapshot**: take **ONE** `browser_snapshot`. All Phase 0 selectors come from this single snapshot.
37
+ 6. **Generate YAML entries**:
38
+ - Keys: follow `sungen-selector-keys` (lowercase, Unicode preserved, `--type` / `--N` suffixes).
39
+ - Selector priority: follow the table in **Diagnosis & Fix § Step 3** (`testid` > `role`+name > `placeholder` > `label` > `locator` > `text`).
40
+ - Copy names **character-for-character** from the snapshot. Never infer from the Gherkin label.
41
+ - If an element is auto-inferable per `sungen-selector-keys` § Auto-Infer, **omit it** from YAML — keep the file minimal.
42
+ 7. **Merge, don't overwrite**: preserve the page selector and any user-authored entries in `selectors.yaml`. Only add missing keys.
43
+ 8. **Show summary + confirm**: list the keys that will be added, ask the user to approve, then write the file.
44
+ 9. **Compile**: `sungen generate --screen <screen>` — then proceed to Phase 1.
45
+
46
+ ### Common Phase 0 pitfalls
47
+
48
+ - Writing keys inferred from the Gherkin label instead of the snapshot name → Phase 1 will fail with "no element found".
49
+ - Skipping Phase 0.5 when an auth redirect happened → snapshot captures the login page, all selectors wrong.
50
+ - Using `browser_evaluate` alone to scrape cookies → misses httpOnly session cookies. Always use `browser_storage_state` (or the `browser_run_code` fallback).
51
+ - Overwriting user-authored selectors → always merge.
52
+
53
+ ---
54
+
55
+ ## Phase 0.5: Auth Persistence (MCP alternative to `sungen makeauth`)
56
+
57
+ Capture an authenticated session from the MCP browser into `specs/.auth/<role>.json` — the same path `sungen makeauth` writes to, which compiled tests already reference via `test.use({ storageState })` based on `@auth:<role>` tags. No `playwright.config.ts` edits needed. Run once per auth lifetime, not on every selector fix.
58
+
59
+ ### When to run Phase 0.5
60
+
61
+ - Phase 0 navigation hit a login redirect and `specs/.auth/<role>.json` is missing or expired
62
+ - A scenario tagged `@auth:<role>` is about to run and its auth file is absent
63
+ - User asks to refresh auth
64
+
65
+ Skip if `specs/.auth/<role>.json` already exists and a probe navigation reaches an authenticated page without redirecting to login.
66
+
67
+ ### Steps
68
+
69
+ 1. **Resolve the role**:
70
+ - Look at the `.feature` file for `@auth:<role>` tags (feature-level or scenario-level). Pick the role for the scenario being run. If no tag exists, default to `user`.
71
+ - Target file: `specs/.auth/<role>.json`. Create `specs/.auth/` if missing.
72
+ - If the file already exists → use `AskUserQuestion` to confirm overwrite (mirrors the `(y/N)` prompt in `sungen makeauth`).
73
+ 2. **Navigate to login**:
74
+ - Read `baseURL` from `playwright.config.ts` (fall back to `APP_BASE_URL` env, then `http://localhost:3000` — same resolution order as `sungen makeauth`).
75
+ - `browser_navigate` to `<baseURL>/login`. If the app uses a different login path, ask the user.
76
+ - If the URL doesn't stay on `/login` after load → user is already signed in. Skip step 3.
77
+ 3. **Ask the user to log in manually** in the MCP browser (username, password, MFA, SSO — whatever the app needs). Never type credentials via `browser_type` or script the login. Wait for the user to confirm in chat that they're signed in.
78
+ 4. **Verify login** — check the current URL or take a `browser_snapshot`; confirm the page is no longer on `/login`.
79
+ 5. **Export storage state** (preferred → fallback):
80
+ - **Preferred** — `browser_storage_state` with `filename: "specs/.auth/<role>.json"` (native Playwright MCP tool; captures cookies including httpOnly + localStorage + sessionStorage via the Playwright context — same output format as `context.storageState({ path })` used by `sungen makeauth`).
81
+ - **Fallback** — if `browser_storage_state` isn't available in this MCP version, use `browser_run_code` to execute `await context.storageState({ path: 'specs/.auth/<role>.json' })`.
82
+ - **Do NOT** use `browser_evaluate` for auth export — it misses httpOnly cookies and session auth will fail silently.
83
+ 6. **Gitignore** — ensure `specs/.auth/` (or `specs/.auth/*.json`) is in `.gitignore`. Add it if missing.
84
+ 7. **Return to Phase 0 step 4** — re-`browser_navigate` to the target page; the session is now active.
85
+
86
+ ### Phase 0.5 pitfalls
87
+
88
+ - Writing to a path other than `specs/.auth/<role>.json` → compiled tests won't find the file. Always match `sungen makeauth`'s convention.
89
+ - Committing `specs/.auth/*.json` → leaks a live session. Always gitignore.
90
+ - Scripting the login with `browser_type` → bypasses MFA/CAPTCHA and risks account lockout. Always manual.
91
+ - Running Phase 0.5 on every `run-test` invocation → unnecessary; reuse the file until tests start redirecting to login.
92
+ - Mismatch between `<role>` in the auth file and `@auth:<role>` tag → compiled tests reference a nonexistent file.
12
93
 
13
94
  ---
14
95
 
@@ -94,10 +175,10 @@ Only when `test-results/` screenshots are insufficient:
94
175
 
95
176
  1. Read `baseURL` from `playwright.config.ts`
96
177
  2. `browser_navigate` to target page
97
- 3. If redirected to login → ask user to log in manually via MCP browser
178
+ 3. If redirected to login → run **Phase 0.5: Auth Persistence**, then re-navigate
98
179
  4. Take **ONE** `browser_snapshot` — fix all broken selectors from this single snapshot
99
180
 
100
- **Never use `sungen makeauth`.** Never use `browser_evaluate` to inject cookies.
181
+ Never use `browser_evaluate` to inject or read cookies (misses httpOnly). For auth, use Phase 0.5 or `sungen makeauth`.
101
182
 
102
183
  ### Step 3: Fix Broken Selectors
103
184
 
@@ -181,9 +262,11 @@ user detail:
181
262
 
182
263
  | Phase | What runs | Max fix attempts | On failure after max |
183
264
  |---|---|---|---|
265
+ | 0. Pre-gen | Playwright MCP snapshot → write selectors.yaml | 1 snapshot | Ask user — skip or retry navigation |
266
+ | 0.5. Auth | Manual login in MCP browser → `browser_storage_state` → `specs/.auth/<role>.json` | 1 login | Ask user — retry login or fall back to `sungen makeauth` |
184
267
  | 1. Smoke | First 5 @critical/@high | 2 | Ask user — fundamentals broken |
185
268
  | 2. Priority | All @critical + @high | 2 | Report failures, continue to Phase 3 |
186
269
  | 3. Full | All tests | 1 | Report @low/@normal failures, continue |
187
270
  | 4. Regression | All tests | 0 | Report final results |
188
271
 
189
- **Total worst case: 5 fix attempts** (2+2+1), not unbounded loops.
272
+ **Total worst case: 5 fix attempts** (2+2+1), not unbounded loops. Phases 0 and 0.5 don't count toward fix budget.
@@ -102,5 +102,27 @@ If no YAML key exists, the resolver infers from the Gherkin element type:
102
102
  | `[X] list` | `getByRole('list', { name: 'X' })` |
103
103
  | `[X] column` | `getByRole('columnheader', { name: 'X' })` |
104
104
  | `[X] dialog` / `modal` / `drawer` | `getByRole('dialog', { name: 'X' })` |
105
+ | `[X] dropdown` / `select` | `getByRole('combobox', { name: 'X' })` |
106
+ | `[X] menuitem` | `getByRole('menuitem', { name: 'X' })` |
107
+ | `[X] progressbar` | `getByRole('progressbar', { name: 'X' })` |
108
+ | `[X] section` | `getByRole('region', { name: 'X' })` |
109
+ | `[X] card` | `getByRole('article', { name: 'X' })` |
110
+ | `[X] item` | `getByRole('listitem', { name: 'X' })` |
111
+ | `[X] cell` | `getByRole('cell', { name: 'X' })` |
112
+ | `[X] spinner` | `getByRole('status', { name: 'X' })` |
113
+ | `[X] breadcrumb` | `getByRole('navigation', { name: 'X' })` |
114
+ | `[X] badge` / `tooltip` / `tag` | `getByText('X')` |
105
115
 
106
116
  **Only add a YAML entry when** the auto-inferred locator won't work (wrong name, need testid, need nth, etc.).
117
+
118
+ ### Types requiring YAML entry (no auto-infer)
119
+
120
+ These types need explicit `selectors.yaml` entries:
121
+
122
+ | Type | Reason |
123
+ |------|--------|
124
+ | `date-picker` | Custom component, needs testid or CSS |
125
+ | `uploader` | File input, needs upload type selector |
126
+ | `overlay` | No standard ARIA role, needs CSS/testid |
127
+ | `frame` | Needs iframe selector |
128
+ | `step` | Custom stepper component, needs testid |
@@ -1,9 +1,9 @@
1
1
  ---
2
2
  name: sungen-add-screen
3
- description: 'Add a new Sungen screen — scaffolds directories and delegates to /sungen-create-test for test case creation'
3
+ description: 'Add a new Sungen screen — scaffolds directories, helps fill spec.md, and can auto-capture a live-page screenshot via Playwright MCP'
4
4
  argument-hint: '[screen-name] [url-path]'
5
5
  agent: 'agent'
6
- tools: [vscode, execute, read, agent, edit, search, web, browser, todo]
6
+ tools: [vscode, execute, read, agent, edit, search, web, browser, todo, 'playwright/*']
7
7
  ---
8
8
 
9
9
  **Input**: Screen name and URL path (e.g., `/sungen-add-screen login /login`).
@@ -24,18 +24,27 @@ Run with #tool:terminal:
24
24
  sungen add --screen ${input:screen} --path ${input:path}
25
25
  ```
26
26
 
27
- ### 2. Fill requirements (recommended)
27
+ ### 2. Fill spec.md
28
28
 
29
- Ask the user: "Would you like to fill in `requirements/spec.md` now? This helps generate higher quality test cases."
29
+ Ask: *"Fill `spec.md` now?"* offer **1) Yes, fill now (Recommended)** / **2) Skip, fill later**.
30
30
 
31
- - If yes → open `qa/screens/${input:screen}/requirements/spec.md` and help the user fill sections, fields, validation rules, business rules, and states.
32
- - If they have UI designs (screenshots, Figma exports, mockups) → suggest copying them to `requirements/ui/`.
33
- - If no → proceed to step 3.
31
+ If yes → open `qa/screens/${input:screen}/requirements/spec.md` and help the user fill sections, fields, validation rules, business rules, and states. Especially prompt for the optional **Figma URL** and **Live URL** fields in Overview — those unlock auto-capture without re-asking next run.
34
32
 
35
- ### 3. Next steps
33
+ ### 3. Capture visual source
34
+
35
+ Ask the user to pick a visual source. Always offer all three so pre-launch projects work:
36
+
37
+ - **1) Figma design** (Recommended for pre-launch) — invoke `sungen-capture-figma` skill
38
+ - **2) Live page scan** (dev/staging is up) — invoke `sungen-capture-live` skill
39
+ - **3) Skip** — user will drop images manually into `requirements/ui/` later, or rely on `/sungen-create-test` to prompt again
40
+
41
+ Each capture skill writes outputs into `qa/screens/${input:screen}/requirements/ui/` and reports back. Do not inline capture logic here — delegate to the skill so behavior stays consistent with `/sungen-create-test`.
42
+
43
+ If the user has additional UI designs (mockups, hand-drawn sketches), suggest copying them to `requirements/ui/` — `sungen-capture-local` will pick them up during `/sungen-create-test`.
44
+
45
+ ### 4. Next steps
36
46
 
37
47
  Tell the user what was created and offer next steps:
38
48
 
39
49
  - **`/sungen-create-test ${input:screen}`** — Create test cases from requirements/designs (Recommended)
40
- - **Fill `requirements/spec.md`** — Write screen specs first for better test quality
41
50
  - **Done for now** — I'll come back later
@@ -28,10 +28,12 @@ You are a **Senior QA Engineer**. You structure test cases by viewpoint categori
28
28
  - **2) Continue without it** — generate tests from spec and other sources only
29
29
  - Summarize what you found in requirements and present to the user.
30
30
  4. **Screen input** (supplements requirements, or is primary source if no requirements):
31
- - Ask: "How should I get the screen design? **1) Figma design** (provide Figma URL recommended), **2) UI images** (screenshots/mockups in `requirements/ui/`), or **3) Live page scan** (optional, via Playwright MCP)?"
32
- - Recommend Figma or UI images first. Live page scan is optional useful to verify specs vs actual UI or capture real data.
33
- - If live page: `browser_navigate` ONE `browser_snapshot`. If auth redirect → ask user to log in manually. Never use `browser_run_code` or `browser_evaluate` to inject cookies.
34
- - If exploring, verify and supplement requirementsflag any discrepancies found.
31
+ - Ask the user to pick a visual source. Always offer all three so pre-launch projects work:
32
+ - **1) Figma design** (Recommended for pre-launch)invoke `sungen-capture-figma` skill
33
+ - **2) UI images** (existing screenshots/mockups in `requirements/ui/`) invoke `sungen-capture-local` skill
34
+ - **3) Live page scan** (dev/staging is up) invoke `sungen-capture-live` skill
35
+ - Each capture skill writes outputs into `qa/screens/${input:screen}/requirements/ui/` and reports back. Do not inline capture logic here — delegate to the skill so behavior stays consistent.
36
+ - After the capture skill returns, cross-check its output against `spec.md` and flag any discrepancies before moving on.
35
37
  5. Identify screen sections → ask user which to focus on (per `sungen-tc-generation` skill). When requirements exist, use the "Requirements-Driven Generation" strategy. Present sections as a numbered list and let user pick.
36
38
  6. Generate or update `.feature` + `test-data.yaml` following `sungen-gherkin-syntax` and `sungen-tc-generation` skills.
37
39
  7. Show summary and offer next steps:
@@ -0,0 +1,71 @@
1
+ ---
2
+ name: delivery
3
+ description: 'Export Gherkin scenarios + Playwright results to CSV test case file for QA delivery.'
4
+ argument-hint: "[screen-name...] (omit for all screens)"
5
+ allowed-tools: Bash, Read, AskUserQuestion
6
+ ---
7
+
8
+ ## Role
9
+
10
+ You are a **QA Test Delivery Engineer**. Your job is to invoke the deterministic `sungen delivery` CLI that performs all parsing and CSV export. Your role is minimal — just run the CLI and help the user if pre-flight checks fail.
11
+
12
+ ## Parameters
13
+
14
+ Parse **screens** from `$ARGUMENTS`:
15
+ - If empty → CLI will process **all** screens in `qa/screens/`
16
+ - If provided → pass them through to the CLI
17
+
18
+ ## Steps
19
+
20
+ ### 1. Invoke the CLI
21
+
22
+ Run via Bash (single command, no extra parsing):
23
+
24
+ ```bash
25
+ npx sungen delivery <screens>
26
+ ```
27
+
28
+ - If no screen args → just run `npx sungen delivery`
29
+ - If screen args → pass them as positional arguments
30
+
31
+ The CLI handles:
32
+ - Scope detection (all screens vs specific)
33
+ - Pre-flight source checks with colorful output
34
+ - Parsing `.feature`, `.spec.ts`, `test-data.yaml`, `test-results/results.json`
35
+ - Generating CSV at `qa/deliverables/<screen>-testcases.csv`
36
+ - Printing summary table
37
+
38
+ ### 2. Handle pre-flight failures (if CLI exits non-zero)
39
+
40
+ If the CLI exits with blocking issues, it will have already printed a clear table showing exactly what's missing per screen.
41
+
42
+ Use `AskUserQuestion` to offer next steps:
43
+
44
+ **Options:**
45
+ - **Fix missing sources** (Recommended) — Print the suggested commands from CLI output and stop. User will run those commands manually, then re-invoke `/sungen:delivery`.
46
+ - **Continue with available screens** — Re-run as `npx sungen delivery <screens> --continue-on-missing` to skip screens with blocking issues.
47
+ - **Cancel** — Exit.
48
+
49
+ ### 3. Show summary + offer next steps (on success)
50
+
51
+ Forward the CLI's summary table to the user verbatim. Then use `AskUserQuestion`:
52
+
53
+ - **Open a specific CSV** — Help user inspect one of the exported files with Read tool.
54
+ - **Run tests to refresh results** — Suggest `/sungen:run-test <screen>` to update `test-results/results.json`, then re-run delivery.
55
+ - **Export another screen** — User can run `/sungen:delivery <other-screen>`.
56
+ - **Done** — Exit.
57
+
58
+ ## Important notes
59
+
60
+ - **Do NOT parse files yourself** — the CLI is the source of truth for parsing logic. Your job is orchestration + user interaction.
61
+ - **Do NOT modify feature/spec.ts/test-data files** — the delivery is read-only.
62
+ - **The CLI already respects `@manual` tags, skips `@steps:` base scenarios, groups by Category 2, and generates UTF-8 BOM CSV for Excel compatibility with Vietnamese.**
63
+ - **Pre-flight check is built into the CLI** — use `--skip-preflight` only in CI/automated pipelines where checks are done externally.
64
+
65
+ ## CLI Reference
66
+
67
+ ```
68
+ sungen delivery [screens...]
69
+ [--skip-preflight] Skip pre-flight checks (not recommended)
70
+ [--continue-on-missing] Skip screens with blocking misses
71
+ ```
@@ -1,43 +1,68 @@
1
1
  ---
2
- name: sungen-run-test
3
- description: 'Compile and run Playwright tests — auto-fixes selectors on failure. Uses sungen-selector-fix, sungen-selector-keys, and sungen-error-mapping skills.'
4
- argument-hint: '[screen-name]'
5
- agent: 'agent'
6
- tools: [vscode, execute, read, agent, edit, search, web, browser, todo, 'playwright/*']
2
+ name: run-test
3
+ description: 'Generate selectors + auth state via Playwright MCP, compile, and run Playwright tests — auto-fixes selectors on failure'
4
+ argument-hint: [screen-name]
5
+ allowed-tools: Read, Grep, Bash, Glob, Edit, Write, AskUserQuestion, mcp__playwright__browser_navigate, mcp__playwright__browser_snapshot, mcp__playwright__browser_take_screenshot, mcp__playwright__browser_wait_for, mcp__playwright__browser_evaluate, mcp__playwright__browser_run_code, mcp__playwright__browser_storage_state, mcp__playwright__browser_set_storage_state
7
6
  ---
8
7
 
9
- **Input**: Screen name (e.g., `/sungen-run-test admin-users`).
10
-
11
8
  ## Role
12
9
 
13
10
  You are a **Senior Developer**. Use `sungen-selector-fix`, `sungen-selector-keys`, and `sungen-error-mapping` skills.
14
11
 
15
12
  ## Parameters
16
13
 
17
- - **screen** ${input:screen:screen name (e.g., login, dashboard)}
14
+ Parse **screen** from `$ARGUMENTS`. If missing, ask the user.
18
15
 
19
- ## Compile
16
+ ## Pre-run (phased — per `sungen-selector-fix` skill)
20
17
 
21
- 1. Verify `qa/screens/${input:screen}/` has `.feature` + `test-data.yaml`
22
- 2. Ensure `selectors.yaml` has page selector. If missing, ask user for URL path
23
- 3. `sungen generate --screen ${input:screen}`
18
+ 1. Verify `qa/screens/<screen>/` has `.feature` + `test-data.yaml`.
19
+ 2. **Phase 0 — Selector Pre-gen**: if `selectors.yaml` is missing/empty or doesn't cover the feature file's `[Reference]`s, run Phase 0 from `sungen-selector-fix` — confirm with user, `browser_navigate` one `browser_snapshot` → merge YAML entries.
20
+ 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.
21
+ 4. Compile: `sungen generate --screen <screen>`.
24
22
 
25
23
  ## Run & Fix (phased — per `sungen-selector-fix` skill)
26
24
 
27
- 4. **Phase 1 — Smoke Check**: Run first 5 `@critical`/`@high` scenarios only. If failures → diagnose, fix fundamentals (page selector, auth, base @steps), re-run. Max 2 attempts. If still broken → ask user.
28
- 5. **Phase 2 — Priority Wave**: Run all `@critical` + `@high` scenarios. Fix only failures from this wave. Max 2 attempts. Shared selectors fixed here cascade to later phases.
29
- 6. **Phase 3 — Full Run**: Run all tests. Fix only **new** failures (elements unique to `@normal`/`@low`). Max 1 attempt. Don't loop on low-priority failures.
30
- 7. **Phase 4 — Regression**: One final full run. Report results. No more fix loops.
25
+ 5. **Phase 1 — Smoke Check**: Run first 5 `@critical`/`@high` scenarios only. If failures → diagnose, fix fundamentals (page selector, auth, base @steps), re-run. Max 2 attempts. If still broken → ask user.
26
+ 6. **Phase 2 — Priority Wave**: Run all `@critical` + `@high` scenarios. Fix only failures from this wave. Max 2 attempts. Shared selectors fixed here cascade to later phases.
27
+ 7. **Phase 3 — Full Run**: Run all tests. Fix only **new** failures (elements unique to `@normal`/`@low`). Max 1 attempt. Don't loop on low-priority failures.
28
+ 8. **Phase 4 — Regression**: One final full run. Report results. No more fix loops.
29
+
30
+ ## Playwright command guidelines
31
+
32
+ **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:
33
+
34
+ ```bash
35
+ # ✅ Correct — per-screen output file via env var
36
+ PLAYWRIGHT_JSON_OUTPUT_NAME=specs/generated/<screen>/<screen>-test-result.json \
37
+ npx playwright test specs/generated/<screen>/<screen>.spec.ts
38
+ ```
39
+
40
+ Output: `specs/generated/<screen>/<screen>-test-result.json`
41
+
42
+ **DO NOT** pass `--reporter=...` flag — it overrides the reporters from `playwright.config.ts` and disables the JSON reporter that `sungen delivery` depends on.
43
+
44
+ ```bash
45
+ # ❌ Wrong — --reporter flag disables the config's JSON reporter
46
+ npx playwright test specs/generated/<screen>/<screen>.spec.ts --reporter=list
47
+
48
+ # ❌ Wrong — no env var → writes to default test-results/results.json
49
+ # (overwritten on every screen run, loses per-screen tracking)
50
+ npx playwright test specs/generated/<screen>/<screen>.spec.ts
51
+ ```
52
+
53
+ If you want to filter scenarios, use `-g "<pattern>"` instead of a reporter override.
54
+
55
+ `sungen delivery` reads the per-screen file first, falls back to the global `test-results/results.json` if missing.
31
56
 
32
57
  ## Next steps
33
58
 
34
- After showing results, offer next steps:
59
+ After showing results, use `AskUserQuestion` to offer next steps:
35
60
 
36
61
  If all tests **passed**:
37
- - **`/sungen-create-test ${input:screen}`** — Add more test cases (Recommended)
62
+ - **`/sungen:create-test <screen>`** — Add more test cases (Recommended)
38
63
  - **Done** — All tests passed, I'm finished
39
64
 
40
65
  If tests **failed** (after retries):
41
- - **`/sungen-run-test ${input:screen}`** — Re-run after manual fixes
42
- - **`/sungen-create-test ${input:screen}`** — Revise test cases
66
+ - **`/sungen:run-test <screen>`** — Re-run after manual fixes
67
+ - **`/sungen:create-test <screen>`** — Revise test cases
43
68
  - **Done for now** — I'll fix manually later
@@ -15,8 +15,12 @@ You generate 3 files for sungen — a Gherkin compiler that produces Playwright
15
15
  | `sungen-viewpoint` | 10 UI patterns x 4 viewpoints — coverage checklists |
16
16
  | `sungen-selector-keys` | YAML key generation from `[Reference]` names, suffixes, lookup priority |
17
17
  | `sungen-selector-fix` | Selector generation from live page, auto-fix strategy |
18
+ | `sungen-delivery` | Export Gherkin + Playwright results → CSV test case deliverable |
19
+ | `sungen-capture-figma` | Fetch design context + PNG from a Figma frame URL via Figma Dev Mode MCP |
20
+ | `sungen-capture-local` | Load existing UI assets (screenshots, mockups, Figma exports) from `requirements/ui/` |
21
+ | `sungen-capture-live` | Capture a live running page via Playwright MCP (snapshot + screenshot) |
18
22
 
19
- ## Workflow (4 AI commands)
23
+ ## Workflow (5 AI commands)
20
24
 
21
25
  | Command | What it does |
22
26
  |---|---|
@@ -24,8 +28,9 @@ You generate 3 files for sungen — a Gherkin compiler that produces Playwright
24
28
  | `/sungen-create-test <name>` | Generate `.feature` + `test-data.yaml` (no selectors) |
25
29
  | `/sungen-review <name>` | Score syntax, coverage, viewpoint quality (60% threshold) |
26
30
  | `/sungen-run-test <name>` | Generate `selectors.yaml` from live page, compile, run, auto-fix |
31
+ | `/sungen-delivery [name...]` | Export test cases → CSV for QA delivery (all screens if no arg) |
27
32
 
28
- **Order:** add-screen → create-test → review → run-test.
33
+ **Order:** add-screen → create-test → review → run-test → delivery.
29
34
 
30
35
  After each command completes, present the next actions as selectable options. Never just print text — always give clickable choices so the user can continue the workflow seamlessly.
31
36
 
@@ -39,6 +44,9 @@ qa/screens/<screen-name>/
39
44
  └── requirements/
40
45
  ├── spec.md # Screen specification (primary source)
41
46
  └── ui/ # Screenshots, mockups
47
+
48
+ qa/deliverables/<screen>-testcases.csv # Exported test cases (from /sungen-delivery)
49
+ qa/deliverables/<screen>-testcases.xlsx # Styled workbook for client hand-off
42
50
  ```
43
51
 
44
52
  ## CLI Commands
@@ -48,4 +56,6 @@ sungen add --screen <name> --path <url-path> # Scaffold screen dir
48
56
  sungen add --screen <name> --path <path> --feature <name> # Scaffold with sub-feature
49
57
  sungen generate --screen <name> # Compile .feature → .spec.ts
50
58
  sungen generate --all # Compile all screens
59
+ sungen delivery # Export all screens → CSV + XLSX
60
+ sungen delivery <screen> # Export a single screen
51
61
  ```