@relipa/ai-flow-kit 0.1.2 → 0.1.3

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 (41) hide show
  1. package/README.md +26 -0
  2. package/bin/aiflow.js +40 -1
  3. package/custom/harness/playwright/.env.example +10 -0
  4. package/custom/harness/playwright/playwright.config.ts +34 -0
  5. package/custom/harness/playwright/tests/e2e/auth.setup.ts +25 -0
  6. package/custom/harness/playwright/tests/e2e/fixtures/test.ts +6 -0
  7. package/custom/harness/playwright/tests/e2e/pages/BasePage.ts +9 -0
  8. package/custom/harness/playwright/tests/e2e/support/auth.ts +5 -0
  9. package/custom/mcp-presets/playwright.json +8 -0
  10. package/custom/rules/test-patterns.md +70 -0
  11. package/custom/skills/automation-testing/SKILL.md +239 -0
  12. package/custom/skills/automation-testing/templates/BasePage.ts +29 -0
  13. package/custom/skills/automation-testing/templates/PageObject.example.ts +29 -0
  14. package/custom/skills/automation-testing/templates/playwright.config.ts +39 -0
  15. package/custom/skills/automation-testing/templates/spec.example.ts +29 -0
  16. package/custom/skills/coverage-check/SKILL.md +202 -0
  17. package/custom/skills/evidence-aggregation/SKILL.md +246 -0
  18. package/custom/skills/execute-flow/SKILL.md +479 -0
  19. package/custom/skills/execute-flow/templates/playwright.config.ts +39 -0
  20. package/custom/skills/generate-test-report/SKILL.md +99 -0
  21. package/custom/skills/generate-test-report/templates/test-report.md +58 -0
  22. package/custom/skills/generate-testcase/SKILL.md +303 -0
  23. package/custom/skills/generate-testcase/templates/testcase.md +88 -0
  24. package/custom/skills/log-bug/SKILL.md +131 -0
  25. package/custom/skills/pr-impact-analysis/SKILL.md +180 -0
  26. package/custom/skills/retest-orchestration/SKILL.md +191 -0
  27. package/custom/skills/script-sync/SKILL.md +208 -0
  28. package/custom/skills/test-analysis/SKILL.md +262 -0
  29. package/custom/templates/shared/gate-workflow.md +306 -2
  30. package/docs/common/CHANGELOG.md +52 -0
  31. package/docs/common/QUICK_START.md +30 -0
  32. package/docs/common/cli-reference.md +48 -7
  33. package/package.json +1 -1
  34. package/scripts/create-score-excel.js +20 -7
  35. package/scripts/detect.js +10 -0
  36. package/scripts/guide.js +9 -0
  37. package/scripts/prompt.js +36 -0
  38. package/scripts/scaffold-playwright.js +106 -0
  39. package/scripts/task.js +21 -7
  40. package/scripts/update.js +124 -124
  41. package/scripts/use.js +30 -12
@@ -0,0 +1,202 @@
1
+ ---
2
+ name: coverage-check
3
+ description: Gate 2 Phase 2d — Apply action items từ review-report (Phase 2c), generate coverage matrix (requirement→TC mapping), tạo final testcase set hoàn chỉnh, và trigger automation-testing để sinh Playwright scripts. Chạy sau Phase 2c APPROVED.
4
+ keywords: gate2, phase2d, coverage, matrix, final testcase, playwright, scripts, traceability
5
+ ---
6
+
7
+ # Coverage Check & Final Output — Gate 2 Phase 2d
8
+
9
+ > **GATE 2 PHASE 2d: Chỉ chạy sau Phase 2c (Review & Optimize) đã được APPROVED.**
10
+ >
11
+ > Phase này là giai đoạn cuối của Gate 2: apply tất cả sửa đổi, generate coverage matrix, xuất final TC set, và sinh Playwright scripts.
12
+
13
+ ---
14
+
15
+ ## Conditions to Enter Phase 2d
16
+
17
+ - ✅ Phase 2c APPROVED — `test-plan/review-report.md` đã được TESTER approve
18
+ - ✅ Files tồn tại: `test-plan/test-cases/`, `test-plan/review-report.md`, `test-plan/test-analysis.md`
19
+
20
+ ---
21
+
22
+ ## Checklist trước khi output (bắt buộc)
23
+
24
+ Trước khi xuất final TC set, kiểm tra:
25
+
26
+ - [ ] Đã xóa duplicate TCs (từ review-report.md Section 1)
27
+ - [ ] Đã sửa TC có vấn đề (từ review-report.md Section 2)
28
+ - [ ] Đã tách/gộp TCs cần optimize (từ review-report.md Section 3)
29
+ - [ ] Đã thêm TC còn thiếu (từ review-report.md Section 4)
30
+ - [ ] Đã bổ sung Accessibility/Compatibility cases (từ review-report.md Section 6)
31
+ - [ ] 100% requirements trong scope được cover bởi ít nhất 1 TC
32
+
33
+ ---
34
+
35
+ ## Step 1: Apply Action Items từ Phase 2c
36
+
37
+ Đọc `test-plan/review-report.md` và apply từng action item từ **Section 7 — Danh sách cần sửa**:
38
+
39
+ | Loại action | Cách thực hiện |
40
+ |-------------|---------------|
41
+ | Xóa duplicate | Remove TC file hoặc xóa row khỏi testcase table |
42
+ | Sửa TC có vấn đề | Edit cột Scenario/Steps/Expected Result/Preconditions cụ thể |
43
+ | Tách TC dài | Split thành 2 TC riêng với TC_ID mới |
44
+ | Gộp TC | Merge nội dung, giữ TC_ID của TC đầu tiên |
45
+ | Thêm TC mới | Tạo TC mới với TC_ID tiếp theo trong chuỗi |
46
+
47
+ Ghi lại những gì đã apply:
48
+
49
+ ```markdown
50
+ ## Action Items Applied
51
+
52
+ | # | Action | TC_ID | Vấn đề | Priority | Status |
53
+ |---|--------|-------|--------|---------|--------|
54
+ | 1 | Sửa Expected Result | AD10_005 | Expected Result mơ hồ | High | ✅ Done |
55
+ | 2 | Thêm Precondition | AD10_007 | Thiếu precondition | High | ✅ Done |
56
+ | 3 | Thêm TC mới | AD10_012 | Thiếu screen reader case | Medium | ✅ Done |
57
+ | 4 | Xóa duplicate | AD10_003 | Duplicate với AD10_001 | High | ✅ Done |
58
+ ```
59
+
60
+ ---
61
+
62
+ ## Step 2: Generate Coverage Matrix
63
+
64
+ So sánh requirements từ `test-plan/test-analysis.md` với TC set hiện tại:
65
+
66
+ **Format coverage matrix:**
67
+
68
+ ```markdown
69
+ ## Coverage Matrix — [Feature Name]
70
+
71
+ | # | Requirement/Acceptance Criteria | Có TC cover? | TC IDs | % |
72
+ |---|--------------------------------|-------------|--------|---|
73
+ | AC1 | User đăng nhập thành công với credentials hợp lệ | ✅ | AD10_001 | 100% |
74
+ | AC2 | Hiển thị error khi credentials sai | ✅ | AD10_002 | 100% |
75
+ | AC3 | Validate required fields | ✅ | AD10_003, AD10_004 | 100% |
76
+ | BR1 | Account bị lock sau 5 lần sai | ✅ | AD10_008 | 100% |
77
+ | WCAG | Keyboard navigation qua form | ✅ | AD10_006 | 100% |
78
+ | COMPAT | Hoạt động trên Firefox | ⚠️ | AD10_013 (pending) | 0% |
79
+
80
+ **Summary:**
81
+ - Total requirements/AC: [N]
82
+ - Covered: [N] ([N]%)
83
+ - Not covered: [N] ([N]%)
84
+ ```
85
+
86
+ **Nếu coverage < 100%** → tạo TC mới để cover trước khi tiếp tục.
87
+
88
+ ---
89
+
90
+ ## Step 3: Export Final Testcase Set
91
+
92
+ Consolidate toàn bộ TCs (sau khi apply actions) vào **1 file duy nhất**:
93
+
94
+ Lưu `test-plan/test-cases/final-testcases.md`:
95
+
96
+ ```markdown
97
+ # Final Test Cases — [Feature Name]
98
+
99
+ **Version:** 2.0 (after Phase 2d) | **Date:** [YYYY-MM-DD] | **Status:** Final
100
+
101
+ | TC_ID | Scenario | Preconditions | Test Steps | Test Data | Expected Result | Severity | Type |
102
+ |-------|----------|---------------|------------|-----------|----------------|----------|------|
103
+ | AD10_001 | Đăng nhập thành công | App chạy. User tồn tại. | 1. Mở /login 2. Nhập email hợp lệ 3. Nhập password hợp lệ 4. Click "Đăng nhập" | user@example.com / Password123! | Redirect tới /dashboard. Hiển thị "Chào [Tên user]" ở header. | Critical | Auto |
104
+ | AD10_002 | Error khi sai password | App chạy. User tồn tại. | 1. Mở /login 2. Nhập email hợp lệ 3. Nhập password SAI 4. Click "Đăng nhập" | user@example.com / WrongPass | Error "Sai email hoặc mật khẩu" hiển thị. URL vẫn /login. | High | Auto |
105
+ | ... | ... | ... | ... | ... | ... | ... | ... |
106
+ ```
107
+
108
+ **Cột Type:**
109
+ - `Auto` — test case này sẽ có Playwright script
110
+ - `Manual` — test case này cần TESTER test thủ công (UI phức tạp, OTP, physical device)
111
+
112
+ ---
113
+
114
+ ## Step 4: Generate Playwright Scripts (Incremental)
115
+
116
+ Với tất cả TCs có `Type = Auto` trong `final-testcases.md`:
117
+
118
+ **Bước 4a — Kiểm tra scripts hiện có:**
119
+ ```
120
+ Glob: test-plan/test-scripts/*.spec.ts
121
+ ```
122
+ Phân loại mỗi TC_ID:
123
+ - `[NEW]` — chưa có `.spec.ts` tương ứng → cần sinh
124
+ - `[UPDATED]` — đã có `.spec.ts` nhưng TC nằm trong danh sách thay đổi (từ Section 7 review-report.md) → cần regenerate
125
+ - `[SKIP]` — đã có `.spec.ts` và TC không thay đổi → giữ nguyên
126
+
127
+ **Bước 4b — Invoke `automation-testing` skill** chỉ cho TCs `[NEW]` và `[UPDATED]`:
128
+
129
+ ```
130
+ Sinh Playwright scripts cho:
131
+ [NEW] AD10_005 — Scenario: ...
132
+ [UPDATED] AD10_002 — Scenario: ... (TC content changed: Expected Result đã sửa)
133
+ Output path: test-plan/test-scripts/
134
+ ```
135
+
136
+ Scripts được lưu tại `test-plan/test-scripts/[TC_ID].spec.ts`:
137
+
138
+ ```
139
+ test-plan/test-scripts/
140
+ ├── AD10_001.spec.ts ← [SKIP] unchanged
141
+ ├── AD10_002.spec.ts ← [UPDATED] regenerated
142
+ ├── AD10_003.spec.ts ← [SKIP] unchanged
143
+ ├── AD10_004.spec.ts ← [SKIP] unchanged
144
+ ├── AD10_005.spec.ts ← [NEW] created
145
+ └── ...
146
+ ```
147
+
148
+ **Traceability mapping:**
149
+
150
+ ```markdown
151
+ ## Script Traceability
152
+
153
+ | TC_ID | Script File | Status | Ghi chú |
154
+ |-------|-------------|--------|---------|
155
+ | AD10_001 | test-plan/test-scripts/AD10_001.spec.ts | ✅ SKIP — unchanged | |
156
+ | AD10_002 | test-plan/test-scripts/AD10_002.spec.ts | ✅ UPDATED | Expected Result sửa |
157
+ | AD10_005 | test-plan/test-scripts/AD10_005.spec.ts | ✅ NEW | |
158
+ | AD10_011 | — | 🔧 Manual (OTP required) | |
159
+ ```
160
+
161
+ ---
162
+
163
+ ## Gate 2d Display (Final)
164
+
165
+ ```
166
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
167
+ ⏸️ GATE 2: TEST PLAN READY
168
+
169
+ Test cases: [N] total ([N] Auto / [N] Manual)
170
+ Coverage: [N/N] requirements covered ([N]%)
171
+ Scripts: [N] Playwright specs ([N] new / [N] updated / [N] skipped unchanged)
172
+
173
+ Issues resolved:
174
+ Duplicates removed: [N]
175
+ TCs fixed: [N]
176
+ TCs added: [N]
177
+ TCs split/merged: [N]
178
+
179
+ → Review: test-plan/
180
+ │ ├── test-analysis.md (Gate 1)
181
+ │ ├── checklist.md (Phase 2a)
182
+ │ ├── test-plan.md (Phase 2b)
183
+ │ ├── review-report.md (Phase 2c)
184
+ │ ├── test-cases/final-testcases.md (Phase 2d final)
185
+ │ └── test-scripts/*.spec.ts (Playwright)
186
+ → Type APPROVED to proceed to Gate 3 (Execution)
187
+ → Or provide feedback to update
188
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
189
+ ```
190
+
191
+ Sau APPROVED → **tiến sang Gate 3**.
192
+
193
+ ---
194
+
195
+ ## Mandatory Rules
196
+
197
+ - ❌ **KHÔNG** generate scripts trước khi coverage = 100%
198
+ - ❌ **KHÔNG** bỏ qua bất kỳ action item nào từ review-report.md
199
+ - ✅ **PHẢI** apply TẤT CẢ changes từ Phase 2c trước khi generate coverage matrix
200
+ - ✅ **PHẢI** đạt 100% AC coverage trước khi phase kết thúc
201
+ - ✅ **PHẢI** có traceability mapping (TC_ID → script file)
202
+ - ✅ Scripts **PHẢI** dùng selector từ DOM thật (thông qua automation-testing skill Phase 3)
@@ -0,0 +1,246 @@
1
+ ---
2
+ name: evidence-aggregation
3
+ description: Gate 3 — Sau khi Playwright chạy xong, tổ chức screenshots/traces/logs vào thư mục evidence/ theo từng TC, generate result.md per TC, auto-draft bug report cho TCs failed.
4
+ keywords: gate3, evidence, screenshots, playwright, test results, bugs, bug report, pass fail
5
+ ---
6
+
7
+ # Evidence Aggregation — Gate 3
8
+
9
+ > **Mục đích:** Tổ chức evidence từ Playwright test run vào cấu trúc `evidence/` theo từng TC,
10
+ > và auto-generate draft bug reports cho TCs bị fail.
11
+ >
12
+ > **Khi nào chạy:** Sau `npx playwright test` hoàn thành trong Gate 3.
13
+
14
+ ---
15
+
16
+ ## Input
17
+
18
+ 1. `test-results/results.json` — Playwright JSON report (từ config `reporter: ['json']`)
19
+ 2. `test-results/` — thư mục chứa screenshots/traces của Playwright
20
+ 3. `playwright-report/` — HTML report
21
+ 4. `test-plan/test-cases/final-testcases.md` — danh sách TCs gốc (để lấy metadata)
22
+
23
+ ---
24
+
25
+ ## Step 1: Parse Playwright Results
26
+
27
+ Đọc `test-results/results.json` và extract:
28
+
29
+ ```json
30
+ {
31
+ "suites": [
32
+ {
33
+ "tests": [
34
+ {
35
+ "title": "[AD10_001] Đăng nhập thành công với email và password hợp lệ",
36
+ "status": "passed",
37
+ "duration": 1234,
38
+ "attachments": [
39
+ { "name": "screenshot", "path": "test-results/..." }
40
+ ],
41
+ "errors": []
42
+ }
43
+ ]
44
+ }
45
+ ]
46
+ }
47
+ ```
48
+
49
+ Từ `title` field: extract TC_ID (format: `[ScreenID]_[NNN]` ở đầu title, trong dấu `[]`).
50
+
51
+ **Mapping rule:** `"[AD10_001] Đăng nhập thành công với email và password hợp lệ"` → `TC_ID = "AD10_001"`.
52
+
53
+ ---
54
+
55
+ ## Step 2: Tổ chức Evidence theo TC
56
+
57
+ Với mỗi TC, tạo folder và copy files:
58
+
59
+ ```
60
+ evidence/
61
+ ├── AD10_001-dang-nhap-thanh-cong/
62
+ │ ├── step-01-mo-trang-login.png ← screenshot (nếu có)
63
+ │ ├── step-02-nhap-credentials.png
64
+ │ ├── step-03-ket-qua.png
65
+ │ └── result.md ← summary (xem Step 3)
66
+ ├── AD10_002-error-sai-password/
67
+ │ ├── failure-screenshot.png
68
+ │ ├── trace.zip ← Playwright trace (nếu có)
69
+ │ └── result.md
70
+ └── ...
71
+ ```
72
+
73
+ **Đặt tên folder:** `TC_[ID]-[kebab-case-scenario]` (lowercase, dấu cách thành `-`).
74
+
75
+ **Copy files từ `test-results/`:**
76
+ - Screenshots: tìm theo TC_ID trong filename hoặc theo test title match
77
+ - Traces: `.zip` files trong `test-results/`
78
+ - Nếu không tìm thấy attachment theo TC_ID → ghi chú "no screenshot" trong result.md
79
+
80
+ ---
81
+
82
+ ## Step 3: Generate result.md per TC
83
+
84
+ Với mỗi TC, tạo `evidence/TC_[ID]-[scenario]/result.md`:
85
+
86
+ **Template khi PASS:**
87
+
88
+ ```markdown
89
+ # Result: AD10_001 — Đăng nhập thành công
90
+
91
+ **Status:** ✅ PASS
92
+ **Duration:** 1.23s
93
+ **Run date:** [YYYY-MM-DD HH:MM]
94
+
95
+ ## Evidence
96
+
97
+ | Step | Screenshot |
98
+ |------|-----------|
99
+ | 1. Mở trang /login | step-01-mo-trang-login.png |
100
+ | 2. Nhập email + password | step-02-nhap-credentials.png |
101
+ | 3. Redirect về /dashboard | step-03-ket-qua.png |
102
+
103
+ ## Notes
104
+
105
+ _Test passed. No issues found._
106
+ ```
107
+
108
+ **Template khi FAIL:**
109
+
110
+ ```markdown
111
+ # Result: AD10_002 — Error khi sai password
112
+
113
+ **Status:** ❌ FAIL
114
+ **Duration:** 2.45s
115
+ **Run date:** [YYYY-MM-DD HH:MM]
116
+
117
+ ## Failure Details
118
+
119
+ **Error message:**
120
+ ```
121
+ Error: expect(received).toBeVisible()
122
+ Expected: visible
123
+ Received: not visible (element not found)
124
+ Locator: page.getByText('Sai email hoặc mật khẩu')
125
+ ```
126
+
127
+ **Steps executed:**
128
+ 1. ✅ Mở trang /login
129
+ 2. ✅ Nhập email hợp lệ
130
+ 3. ✅ Nhập password SAI
131
+ 4. ✅ Click "Đăng nhập"
132
+ 5. ❌ Error message không xuất hiện → FAIL
133
+
134
+ ## Evidence
135
+
136
+ | File | Mô tả |
137
+ |------|-------|
138
+ | failure-screenshot.png | Trạng thái màn hình lúc fail |
139
+ | trace.zip | Playwright trace (mở bằng `npx playwright show-trace`) |
140
+
141
+ ## Bug Reference
142
+
143
+ → Xem: bugs/BUG-001-error-message-khong-hien.md
144
+ ```
145
+
146
+ ---
147
+
148
+ ## Step 4: Auto-generate Bug Draft cho TCs Failed
149
+
150
+ Với mỗi TC có status `failed`, tạo draft bug report:
151
+
152
+ **Lưu `bugs/BUG-[NNN]-[slug-title].md`** (số tăng dần, bắt đầu từ 001):
153
+
154
+ ```markdown
155
+ # BUG-001 — Error message không hiển thị khi sai password
156
+
157
+ **TC_ID:** AD10_002
158
+ **Severity:** [High] ← dựa trên Severity của TC trong final-testcases.md
159
+ **Status:** 🔴 Open
160
+ **Found at:** Gate 3 Execution | [YYYY-MM-DD]
161
+ **Environment:** [baseUrl] | Chrome Latest | Windows
162
+
163
+ ---
164
+
165
+ ## Steps to Reproduce
166
+
167
+ 1. Mở trang /login tại [baseUrl/login]
168
+ 2. Nhập email hợp lệ: `user@example.com`
169
+ 3. Nhập password SAI: `WrongPassword`
170
+ 4. Click button "Đăng nhập"
171
+
172
+ ## Expected Result
173
+
174
+ Error message "Sai email hoặc mật khẩu" hiển thị ngay dưới form.
175
+
176
+ ## Actual Result
177
+
178
+ Error message KHÔNG hiển thị. Trang vẫn load bình thường, không có feedback cho user.
179
+
180
+ ## Evidence
181
+
182
+ - Screenshot: `evidence/AD10_002-error-sai-password/failure-screenshot.png`
183
+ - Playwright trace: `evidence/AD10_002-error-sai-password/trace.zip`
184
+
185
+ ## Technical Notes
186
+
187
+ ```
188
+ Playwright assertion failed:
189
+ expect(page.getByText('Sai email hoặc mật khẩu')).toBeVisible()
190
+ Element not found in DOM after 5000ms timeout.
191
+ ```
192
+
193
+ _Dev có thể reproduce bằng cách mở trace: `npx playwright show-trace evidence/AD10_002.../trace.zip`_
194
+
195
+ ---
196
+
197
+ ## Resolution
198
+
199
+ - [ ] Dev fix
200
+ - [ ] Retest: `RETEST: AD10_002`
201
+ ```
202
+
203
+ **Severity từ TC metadata:**
204
+ - TC Severity = Critical → Bug Severity = Critical
205
+ - TC Severity = High → Bug Severity = High
206
+ - TC Severity = Medium → Bug Severity = Medium
207
+ - TC Severity = Low → Bug Severity = Low
208
+
209
+ ---
210
+
211
+ ## Step 5: Display Gate 3 Summary
212
+
213
+ ```
214
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
215
+ ⏸️ GATE 3: EXECUTION COMPLETE
216
+
217
+ Results:
218
+ ✅ Passed: [N] / [total]
219
+ ❌ Failed: [N] / [total]
220
+ 🚫 Blocked: [N] / [total]
221
+ 🔧 Manual: [N] (chưa execute)
222
+
223
+ Bugs logged:
224
+ 🔴 Critical: [N]
225
+ 🟠 High: [N]
226
+ 🟡 Medium: [N]
227
+ 🟢 Low: [N]
228
+
229
+ → Review evidence: evidence/
230
+ → Review bugs: bugs/
231
+ → Type APPROVED when all critical/high bugs resolved
232
+ → Type RETEST: [TC_ID] to re-execute a specific test case
233
+ → Type PR: [url] to declare new dev PRs (triggers Dev Artifacts Check)
234
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
235
+ ```
236
+
237
+ ---
238
+
239
+ ## Mandatory Rules
240
+
241
+ - ✅ **PHẢI** tạo đúng 1 folder per TC (kể cả TC pass)
242
+ - ✅ **PHẢI** tạo `result.md` trong mỗi folder
243
+ - ✅ **PHẢI** tạo bug draft cho mọi TC failed, không bỏ sót
244
+ - ✅ Bug severity phải map từ TC severity trong final-testcases.md
245
+ - ❌ **KHÔNG** overwrite evidence của previous run — tạo subfolder với timestamp nếu re-run
246
+ - ✅ Nếu `test-results/results.json` không tồn tại → hướng dẫn TESTER chạy `npx playwright test --reporter=json` trước