@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,479 @@
1
+ ---
2
+ name: execute-flow
3
+ description: Executing Flow — 4 gates độc lập để thực thi Playwright từ testcase có sẵn. Gate 1 load TC file và sinh work plan. Gate 2 sync scripts (hash-based). Gate 3 chạy playwright và thu thập evidence. Gate 4 sinh report và hỏi log bug lên Jira. Không cần đi qua workflow.md Gate 1-2.
4
+ allowed-tools: Read, Write, Edit, Glob, Grep, Bash, mcp__playwright__browser_navigate, mcp__playwright__browser_snapshot, mcp__playwright__browser_generate_locator, mcp__playwright__browser_close
5
+ ---
6
+
7
+ # Executing Flow
8
+
9
+ Flow độc lập để tester thực thi test từ TC file có sẵn, không cần chạy lại phân tích (workflow.md Gate 1-2).
10
+
11
+ ## Entry Points
12
+
13
+ | Nguồn | Trigger | Cách AI xử lý |
14
+ |-------|---------|---------------|
15
+ | Ticket | `ak execute PROJ-33` | Tìm TC file trong `.aiflow/context/current.json` |
16
+ | File | `ak execute ./testcases/AD10.md` | Đọc trực tiếp file path |
17
+ | Manual | `ak execute` (không argument) | Hỏi tester: "TC file của bạn ở đâu?" |
18
+
19
+ ---
20
+
21
+ ## ⛩️ GATE 1 — Context & Work Plan
22
+
23
+ ### Pre-flight checks (auto, không hỏi tester)
24
+
25
+ Kiểm tra trước khi làm gì:
26
+
27
+ 0. **MCP Playwright** có được cấu hình không?
28
+ - Kiểm tra **`~/.claude/settings.json`** (global user-level, áp dụng cho mọi project): có key `playwright` trong `mcpServers` không?
29
+ - Nếu thiếu → dừng, hỏi tester:
30
+ > "⚠️ MCP Playwright chưa được cấu hình. Đây là yêu cầu bắt buộc để chạy browser automation.
31
+ > Sẽ cài vào **global settings** (`~/.claude/settings.json`) — chỉ cần làm một lần, dùng được cho mọi repo.
32
+ > → Tự động cài đặt? [Y/n]"
33
+ - Nếu tester chọn **Y** (hoặc Enter):
34
+ - Đọc `~/.claude/settings.json`
35
+ - Thêm key `playwright` vào `mcpServers` (giữ nguyên các key khác):
36
+ ```json
37
+ "playwright": {
38
+ "command": "npx",
39
+ "args": ["-y", "@playwright/mcp@latest", "--isolated", "--browser", "chromium", "--headless"]
40
+ }
41
+ ```
42
+ - Ghi lại file `~/.claude/settings.json`
43
+ - Thông báo:
44
+ > "✅ Đã cài MCP Playwright vào global settings. **Vui lòng restart Claude Code** để load MCP server, sau đó chạy lại lệnh `ak execute`."
45
+ - Dừng. Không proceed cho đến khi tester restart và chạy lại.
46
+ - Nếu tester chọn **n** → dừng, hướng dẫn:
47
+ > "Để cài thủ công: mở `~/.claude/settings.json`, thêm `playwright` vào `mcpServers`, rồi restart Claude Code."
48
+
49
+ 1. TC file có parse được không? (file tồn tại, có Section 3 — Danh sách Test Cases)
50
+ 2. `ak-test/` folder có tồn tại không? Nếu không → hướng dẫn tester tạo: `mkdir ak-test`
51
+ 3. `BASE_URL` env var có set không? Nếu không → hỏi: "BASE_URL chưa set. App đang chạy ở URL nào?"
52
+
53
+ Items 1–3 chạy ngay khi entry. Item 4 chạy sau khi repo được xác định từ Bước 1 (parse TC file):
54
+
55
+ 4. `playwright.config.ts` có tồn tại trong `ak-test/{repo}/` không? Nếu không → dừng, hướng dẫn tester: "Chưa có playwright.config.ts cho repo {repo}. Tạo file từ template tại `ak-test/{repo}/playwright.config.ts` (xem skill execute-flow templates)."
56
+
57
+ Nếu bất kỳ check nào fail → dừng, hướng dẫn fix. Không proceed.
58
+
59
+ ### Bước 1: Parse TC file
60
+
61
+ Đọc TC file, extract từ Section 1 — Thông tin chung:
62
+ - `Screen_ID`: từ "Mã màn hình - Tên màn hình" (vd `AD10_Create Product` → ScreenID = `AD10`)
63
+ - `Screen_Name`: phần sau `_` (vd `Create Product`)
64
+ - `Repo`: từ dòng "Repo" (vd `repo-fe`)
65
+
66
+ Nếu thiếu `Repo` field → hỏi tester:
67
+ > "TC file của màn hình `{ScreenID}` chưa có thông tin Repo. Repo này nằm trong repository nào?
68
+ > (vd: repo-fe, repo-be)"
69
+
70
+ Chờ tester trả lời rồi mới tiếp tục.
71
+
72
+ Nếu nhiều màn hình khác repo → hỏi từng màn hình một.
73
+
74
+ ### Bước 2: Extract TCs từ Section 3
75
+
76
+ Đọc tất cả rows trong các bảng Section 3.x, extract:
77
+ - TC_ID, Test Case Name, Severity
78
+
79
+ Phân loại sơ bộ:
80
+ - **Manual TC**: Steps đề cập "kiểm tra DB", "kiểm tra file", "Quan sát giao diện tổng quan", "Kiểm tra layout/màu sắc"
81
+ - **Automation TC**: còn lại
82
+
83
+ ### Bước 3: Scan scripts hiện tại
84
+
85
+ Tìm `ak-test/{repo}/scripts/{screenId}/{ScreenID}.spec.ts`:
86
+ - Nếu tồn tại: đọc `@tc-id` comments → xác định TCs đã có script
87
+ - Tính hash cho từng TC → so với `@tc-hash` trong file → xác định `updated` vs `skipped`
88
+ - Nếu không tồn tại: tất cả automation TCs đều là `new`
89
+
90
+ ### Bước 4: Hiển thị Work Plan
91
+
92
+ ```
93
+ 📋 WORK PLAN — {ticket hoặc tên TC file}
94
+
95
+ Requirement Overview:
96
+ - Màn hình: {ScreenID}_{Screen Name} ({repo})
97
+ - Tổng TC: {N} | Automation: {N} | Manual/Untest: {N}
98
+
99
+ Script Sync Plan:
100
+ | Screen | TC_ID | Script hiện tại | Trạng thái |
101
+ |--------|----------|---------------------------|---------------|
102
+ | AD10 | AD10_001 | - | 🆕 Gen mới |
103
+ | AD10 | AD10_002 | AD10.spec.ts (hash match) | ⏭️ Skip |
104
+ | AD10 | AD10_005 | AD10.spec.ts (hash diff) | 🔄 Update |
105
+ | AD10 | AD10_023 | - | ⚠️ Manual TC |
106
+
107
+ → Cần gen mới: {N} | Update: {N} | Skip: {N} | Manual (Untest): {N}
108
+ ```
109
+
110
+ ```
111
+ ⏸️ GATE 1: WORK PLAN READY
112
+
113
+ Screens: {N} | Total TC: {N} ({N} automation / {N} manual)
114
+ Scripts: {N} gen mới | {N} update | {N} skip
115
+ Repo mapping: {ScreenID} → {repo}
116
+
117
+ → Type APPROVED to proceed to Gate 2 (Script Sync)
118
+ → Type REPO: {ScreenID}={repo} để cập nhật repo mapping
119
+ ```
120
+
121
+ Dừng. Chờ APPROVED.
122
+
123
+ ---
124
+
125
+ ## ⛩️ GATE 2 — Script Sync
126
+
127
+ Chỉ chạy sau Gate 1 APPROVED.
128
+
129
+ ### Invoke script-sync skill
130
+
131
+ Gọi `script-sync` skill với context:
132
+ - `tcFile`: path TC file
133
+ - `repo`: từ Gate 1
134
+ - `screenId`: always lowercase ScreenID (vd `ad10`, not `AD10`) — directory path uses lowercase
135
+ - `screenUrl`: hỏi tester nếu chưa biết: "URL path của màn hình {ScreenID} là gì? (vd `/admin/products/create`)"
136
+ - `baseUrl`: từ `BASE_URL` env var
137
+
138
+ Nhận về: danh sách kết quả per TC.
139
+
140
+ ### Hiển thị kết quả
141
+
142
+ ```
143
+ ⏸️ GATE 2: SCRIPT SYNC COMPLETE
144
+
145
+ Gen mới: {N} | Updated: {N} | Skipped: {N}
146
+ Manual (Untest): {N} TCs
147
+ Blocked: {N} TCs — xem lý do bên trên
148
+
149
+ → Review: ak-test/{repo}/scripts/{screenId}/{ScreenID}.spec.ts
150
+ → Type APPROVED to run tests
151
+ → Type SKIP: {TC_ID} để đánh dấu Pending và tiếp tục
152
+ → Or provide feedback to fix scripts
153
+ ```
154
+
155
+ Dừng. Chờ APPROVED.
156
+
157
+ Khi tester gõ `SKIP: AD10_019`: đánh dấu TC đó là Pending, loại khỏi danh sách sẽ chạy.
158
+
159
+ ---
160
+
161
+ ## ⛩️ GATE 3 — Execute & Evidence
162
+
163
+ Chỉ chạy sau Gate 2 APPROVED.
164
+
165
+ ### Bước 1: Xác định run number
166
+
167
+ Scan `ak-test/{repo}/results/{screenId}/` để tìm run folder hiện có:
168
+ - Nếu không có folder nào → `run-1`
169
+ - Nếu có `run-1`, `run-2` → `run-3`
170
+
171
+ Tạo folder: `ak-test/{repo}/results/{screenId}/run-{N}/`
172
+
173
+ ### Bước 2: Chạy Playwright
174
+
175
+ ```bash
176
+ cd ak-test/{repo}
177
+ BASE_URL={baseUrl} npx playwright test scripts/{screenId}/{ScreenID}.spec.ts
178
+ ```
179
+
180
+ Note: Reporters are already configured in `playwright.config.ts` (json → `test-results/results.json`, html, list). The CLI `--reporter` flag would override these settings, so it is omitted here.
181
+
182
+ ### Bước 3: Parse kết quả
183
+
184
+ Đọc `ak-test/{repo}/test-results/results.json` (Playwright JSON output).
185
+
186
+ Với mỗi test:
187
+ - Extract TC_ID từ test title (format: `AD10_001 - {name}` hoặc `[AD10_001] {name}`)
188
+ - Map: TC_ID → `{status: 'passed'|'failed', duration, attachments, errors}`
189
+
190
+ ### Bước 4: Tổ chức Evidence
191
+
192
+ Với mỗi TC:
193
+
194
+ **Tạo folder:** `ak-test/{repo}/results/{screenId}/run-{N}/{TC_ID}-{kebab-scenario}/`
195
+
196
+ Với `kebab-scenario` = Test Case Name lowercase, dấu cách thành `-`, bỏ ký tự đặc biệt.
197
+
198
+ **Copy files từ Playwright output:**
199
+ - Screenshots → `step-NN-{desc}.png`
200
+ - Trace file → `trace.zip`
201
+
202
+ **Tạo `result.md`:**
203
+
204
+ Khi PASS:
205
+ ```markdown
206
+ # Result: {TC_ID} — {Test Case Name}
207
+
208
+ **Status:** ✅ PASS
209
+ **Duration:** {X}s
210
+ **Run:** run-{N} | {YYYY-MM-DD HH:MM}
211
+
212
+ ## Evidence
213
+ | Step | Screenshot |
214
+ |------|-----------|
215
+ | {step 1} | step-01-{desc}.png |
216
+ | {step 2} | step-02-{desc}.png |
217
+ ```
218
+
219
+ Khi FAIL:
220
+ ```markdown
221
+ # Result: {TC_ID} — {Test Case Name}
222
+
223
+ **Status:** ❌ FAIL
224
+ **Duration:** {X}s
225
+ **Run:** run-{N} | {YYYY-MM-DD HH:MM}
226
+
227
+ ## Failure Details
228
+ **Error:** {error message từ Playwright}
229
+
230
+ ## Evidence
231
+ | File | Mô tả |
232
+ |------|-------|
233
+ | failure-screenshot.png | Trạng thái lúc fail |
234
+ | trace.zip | Playwright trace |
235
+
236
+ ## Bug Reference
237
+ → Xem: bugs/BUG-{NNN}-{slug}.md
238
+ ```
239
+
240
+ Với Manual TCs (Untest): không tạo evidence folder.
241
+
242
+ ### Bước 5: Auto-draft Bug Reports
243
+
244
+ Với mỗi TC failed, tạo `ak-test/{repo}/results/{screenId}/run-{N}/bugs/BUG-{NNN}-{slug}.md`:
245
+
246
+ ```markdown
247
+ # BUG-{NNN} — {Test Case Name}
248
+
249
+ **TC_ID:** {TC_ID}
250
+ **Severity:** {severity từ TC file}
251
+ **Status:** 🔴 Open
252
+ **Found at:** Gate 3 Execution | {YYYY-MM-DD}
253
+ **Environment:** {baseUrl} | Chrome | Windows
254
+
255
+ ---
256
+
257
+ ## Steps to Reproduce
258
+
259
+ {Steps từ TC file, numbered}
260
+
261
+ ## Expected Result
262
+
263
+ {Expected Result từ TC file}
264
+
265
+ ## Actual Result
266
+
267
+ {Actual behavior từ Playwright error}
268
+
269
+ ## Evidence
270
+
271
+ - Screenshot: `{TC_ID}-{scenario}/failure-screenshot.png`
272
+ - Playwright trace: `{TC_ID}-{scenario}/trace.zip`
273
+
274
+ ## Technical Notes
275
+
276
+ ```
277
+ {Playwright error message}
278
+ ```
279
+
280
+ ---
281
+
282
+ ## Resolution
283
+
284
+ - [ ] Dev fix
285
+ - [ ] Retest: `RETEST: {TC_ID}`
286
+ ```
287
+
288
+ BUG số: đếm file trong `bugs/` folder, +1. Format: `001`, `002`,...
289
+
290
+ ### Bước 6: Cập nhật TC file gốc
291
+
292
+ Ghi kết quả vào các cột R1/R2 trong TC file:
293
+
294
+ - R1 = lần chạy đầu tiên (run-1). Nếu R1 đã có giá trị → ghi vào R2.
295
+ - R1 Tester = `AI-R1`, R2 Tester = `AI-R2`
296
+
297
+ ```markdown
298
+ | AD10_001 | ... | ✅ Pass | {YYYY-MM-DD} | AI-R1 | | | |
299
+ | AD10_005 | ... | ❌ Fail | {YYYY-MM-DD} | AI-R1 | | | |
300
+ | AD10_023 | ... | ⏭️ Untest | - | - | | | |
301
+ ```
302
+
303
+ Cập nhật Section 2 — Test Execution Summary table:
304
+
305
+ ```markdown
306
+ | Round {N} | {passed} | {failed} | {untest} | {pending} | {total} | {passed/total*100}% |
307
+ ```
308
+
309
+ ### Bước 7: Hiển thị Gate 3
310
+
311
+ ```
312
+ ⏸️ GATE 3: EXECUTION COMPLETE
313
+
314
+ Results (run-{N}):
315
+ - Passed: {N} / {total automation}
316
+ - Failed: {N} / {total automation}
317
+ - Untest: {N} (manual TCs)
318
+ - Pending: {N} (blocked/skipped)
319
+
320
+ Bugs drafted: {N} ({N} Critical, {N} High, {N} Medium, {N} Low)
321
+ Unresolved critical: {N}
322
+
323
+ → Evidence: ak-test/{repo}/results/{screenId}/run-{N}/
324
+ → Type APPROVED when all critical/high bugs resolved
325
+ → Type RETEST: {TC_ID} to re-execute
326
+ → Type PENDING: {TC_ID} để đánh dấu TC không chạy được
327
+ ```
328
+
329
+ Dừng. Chờ APPROVED.
330
+
331
+ ### RETEST loop
332
+
333
+ Khi tester gõ `RETEST: AD10_005, AD10_008`:
334
+
335
+ 1. **Re-run Dev Artifacts Check**: invoke `pr-impact-analysis` skill nếu PR đã khai báo.
336
+ - Nếu phát hiện commit mới → đề xuất TC bổ sung, tester approve delta trước
337
+ 2. **Chạy selective test:**
338
+ ```bash
339
+ cd ak-test/{repo}
340
+ BASE_URL={baseUrl} npx playwright test --grep "AD10_005|AD10_008"
341
+ ```
342
+ 3. Xác định run number mới (run-{N+1})
343
+ 4. Tổ chức evidence vào `run-{N+1}/` (không xóa run cũ)
344
+ 5. Cập nhật R2 columns trong TC file
345
+ 6. Cập nhật bug status:
346
+ - TC pass sau retest → ghi `RESOLVED` vào bug file: `**Status:** ✅ Resolved`
347
+ - TC vẫn fail → ghi `**Retest {N}:** Still OPEN` vào bug file
348
+
349
+ Khi tester gõ `PENDING: AD10_025`: cập nhật TC row với `⏳ Pending`.
350
+
351
+ ---
352
+
353
+ ## ⛩️ GATE 4 — Report & Bug Logging
354
+
355
+ Chỉ chạy sau Gate 3 APPROVED.
356
+
357
+ ### Bước 1: Tổng hợp kết quả
358
+
359
+ Đọc tất cả `result.md` trong `run-{N}/`:
360
+ - Count passed/failed/untest/pending per run
361
+ - Identify last run number (run-{max})
362
+
363
+ Đọc `bugs/BUG-*.md` trong run folder: phân loại severity + status (Open/Resolved).
364
+
365
+ ### Bước 2: Cập nhật Section 2 trong TC file
366
+
367
+ Cập nhật bảng Test Execution Summary với số liệu từ R1 và R2.
368
+
369
+ ### Bước 3: Sinh testreport.md
370
+
371
+ Tạo `ak-test/{repo}/results/{screenId}/run-{N}/testreport.md` theo template chuẩn:
372
+
373
+ ```markdown
374
+ # SUMMARY TEST REPORT
375
+
376
+ ## Project Information
377
+ | Property | Value | Property | Value |
378
+ |:---|:---|:---|:---|
379
+ | Project Name | {tên dự án từ TC file hoặc hỏi tester} | Author | AI |
380
+ | Project Code | {ScreenID} | Reviewer | {tên tester} |
381
+ | Created At | {ngày chạy R1} | Report Date | {hôm nay} |
382
+ | Last updated at | {hôm nay} | | |
383
+
384
+ ## Test Execution Summary
385
+ | No | Module code | Written By | Created Date | R1 Passed | R1 Failed | R1 UnTest | R1 Pending | R2 Passed | R2 Failed | R2 UnTest | R2 Pending | Blocked | Total test cases | Tổng passed | % hoàn thành | Created Date | Updated Date | Sprint | Creator | Reviewer / Approver |
386
+ |---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
387
+ | 1 | {ScreenID} | AI | {date} | {r1p} | {r1f} | {r1u} | {r1pe} | {r2p} | {r2f} | {r2u} | {r2pe} | {blocked} | {total} | {tổng passed} | {%} | {date} | {date} | {sprint nếu có} | AI | {tester} |
388
+
389
+ ## Bug Summary
390
+ | Bug ID | Severity | Title | Status | Jira Ticket |
391
+ |--------|----------|-------|--------|-------------|
392
+ {rows từ bugs/}
393
+
394
+ ## Sign-off
395
+ - **Recommendation:** {Go nếu 0 Critical+High Open / No-go nếu còn / Conditional go nếu chỉ Medium còn open}
396
+ - **Conditions:** {liệt kê nếu Conditional}
397
+ ```
398
+
399
+ **Exit criteria:**
400
+ - 0 Critical bugs Open → Go (kể cả còn Medium/Low)
401
+ - 0 High bugs Open → Go (nếu không có Critical)
402
+ - Còn Critical hoặc High Open → No-go
403
+ - Chỉ còn Medium/Low Open → Conditional go
404
+
405
+ ### Bước 4: Bug logging flow
406
+
407
+ Hỏi từng bug theo thứ tự severity (Critical → High → Medium → Low):
408
+
409
+ ```
410
+ 🐛 BUG-{NNN} [{Severity}] — {Title}
411
+ TC: {TC_ID} | Evidence: run-{N}/bugs/BUG-{NNN}...
412
+ Steps: {steps tóm tắt}
413
+ Expected: {expected}
414
+ Actual: {actual}
415
+
416
+ → Log lên Jira? [Y/n] (hoặc gõ SKIP-BUG để bỏ qua)
417
+ ```
418
+
419
+ Nếu tester gõ `Y`:
420
+ - Gọi `ak bug-log` (nếu adapter có) hoặc hướng dẫn tester copy nội dung
421
+ - Ghi ticket ID vào bug file: `**Jira Ticket:** {ticket-id}`
422
+ - Ghi ticket ID vào cột Ticket ID của TC trong TC file
423
+
424
+ Nếu `n` hoặc `SKIP-BUG`: ghi `Not logged` trong testreport.md Bug Summary.
425
+
426
+ ### Bước 5: Hiển thị Gate 4
427
+
428
+ ```
429
+ ⏸️ GATE 4: REPORT READY
430
+
431
+ Overall: {Pass / Fail / Conditional}
432
+ Passed: {N}/{total} | % hoàn thành: {N}%
433
+ Bugs logged to Jira: {N}/{total bugs}
434
+ Recommendation: {Go / No-go / Conditional go}
435
+
436
+ → Review: ak-test/{repo}/results/{screenId}/run-{N}/testreport.md
437
+ → Type APPROVED to sign off
438
+ → Type NO-GO: {reason} to reject release
439
+ ```
440
+
441
+ Dừng. Chờ APPROVED hoặc NO-GO.
442
+
443
+ ---
444
+
445
+ ## Commands Reference
446
+
447
+ ```
448
+ # Entry points
449
+ ak execute PROJ-33 # từ ticket
450
+ ak execute ./testcases/AD10.md # từ file
451
+ ak execute # manual
452
+
453
+ # Gate 1
454
+ REPO: AD10=repo-fe, API01=repo-be # cập nhật repo mapping
455
+
456
+ # Gate 2
457
+ SKIP: {TC_ID} # đánh dấu Pending, bỏ qua script
458
+
459
+ # Gate 3
460
+ RETEST: {TC_ID} # re-execute 1 TC
461
+ RETEST: {TC_ID1}, {TC_ID2} # re-execute nhiều TCs
462
+ PENDING: {TC_ID} # đánh dấu không chạy được
463
+
464
+ # Gate approval
465
+ APPROVED # chuyển gate tiếp theo
466
+ NO-GO: {reason} # reject (chỉ Gate 4)
467
+ SKIP-BUG: BUG-{NNN} # bỏ qua không log bug này
468
+ ```
469
+
470
+ ---
471
+
472
+ ## Mandatory Rules
473
+
474
+ - ✅ Dừng ở mỗi gate, chờ APPROVED trước khi proceed
475
+ - ✅ `run-{N}` không bao giờ bị xóa hay overwrite — luôn tạo folder mới
476
+ - ✅ R1/R2 trong TC file gốc được cập nhật sau mỗi lần chạy
477
+ - ✅ Hỏi từng bug một — không auto-log toàn bộ
478
+ - ❌ Không lấy expected result từ PR/code — chỉ từ TC file
479
+ - ❌ Không skip gate kể cả khi "chỉ có 1 TC"
@@ -0,0 +1,39 @@
1
+ import { defineConfig, devices } from '@playwright/test'
2
+ import path from 'path'
3
+
4
+ const LOGGED_OUT = { storageState: undefined }
5
+
6
+ export default defineConfig({
7
+ testDir: './scripts',
8
+ outputDir: './test-results',
9
+ fullyParallel: false,
10
+ forbidOnly: !!process.env.CI,
11
+ retries: process.env.CI ? 1 : 0,
12
+ workers: 1,
13
+ reporter: [
14
+ ['json', { outputFile: 'test-results/results.json' }],
15
+ ['html', { outputFolder: 'playwright-report', open: 'never' }],
16
+ ['list'],
17
+ ],
18
+ use: {
19
+ baseURL: process.env.BASE_URL || 'http://localhost:3000',
20
+ trace: 'on-first-retry',
21
+ screenshot: 'on',
22
+ video: 'on-first-retry',
23
+ headless: !process.env.HEADED,
24
+ },
25
+ projects: [
26
+ // Uncomment nếu cần auth setup:
27
+ // { name: 'setup', testMatch: /auth\.setup\.ts/ },
28
+ {
29
+ name: 'chromium',
30
+ use: {
31
+ ...devices['Desktop Chrome'],
32
+ // storageState: '.auth/user.json', // uncomment nếu cần auth
33
+ },
34
+ // dependencies: ['setup'], // uncomment nếu cần auth
35
+ },
36
+ ],
37
+ })
38
+
39
+ export { LOGGED_OUT }
@@ -0,0 +1,99 @@
1
+ ---
2
+ name: generate-test-report
3
+ description: Use when TESTER needs to generate the final test summary report at Gate 4 after all test execution is complete. Aggregates results from evidence/ and bugs/ directories, verifies acceptance criteria coverage, and produces a Go/No-Go recommendation.
4
+ keywords: test report, summary, sign-off, go no-go, gate 4, evidence, bug summary, coverage
5
+ ---
6
+
7
+ # Generate Test Report — Gate 4
8
+
9
+ > **Phạm vi:** Gate 4 — Báo cáo & Sign-off trong workflow 4-gate (`docs/workflow.md`)
10
+ > **Chỉ chạy sau khi Gate 3 đã được TESTER gõ `APPROVED`.**
11
+
12
+ ---
13
+
14
+ ## Điều kiện vào Gate 4
15
+
16
+ - ✅ Gate 3 APPROVED — tất cả critical/high bugs đã resolved và re-tested
17
+ - ✅ Đã có đầy đủ: `evidence/`, `bugs/`, `test-plan/test-cases/`, `test-plan/checklist.md`
18
+ - ✅ `test-plan/impact-analysis.md` tồn tại (kể cả khi không có PR — file ghi "chưa có dev artifacts")
19
+
20
+ ---
21
+
22
+ ## Quy trình tạo Test Report
23
+
24
+ ### Bước 1 — Thu thập kết quả
25
+
26
+ Đọc toàn bộ:
27
+ - `evidence/*/result.md` → đếm Pass / Fail / Blocked per TC
28
+ - `bugs/BUG-*.md` → đếm bugs theo severity, trạng thái resolved/unresolved
29
+ - `test-plan/test-cases/*.md` → danh sách TC ID và module
30
+
31
+ Tổng hợp per module theo format template (R1/R2 tracking từ testcase files).
32
+
33
+ ### Bước 2 — Kiểm tra coverage
34
+
35
+ - So sánh TC đã thực thi với checklist `test-plan/checklist.md`
36
+ - Verify acceptance criteria từ `test-plan/test-analysis.md` (Gate 1) — từng item đã cover chưa?
37
+ - Tính % hoàn thành: `(Tổng passed / Total test cases) × 100`
38
+ - **Verify regression scope từ `test-plan/impact-analysis.md`**: đọc "Đề xuất Regression TCs" — những regression TCs đó đã được execute chưa? Nếu chưa → flag trong report (không block Go/No-Go nhưng phải ghi nhận rõ).
39
+
40
+ ### Bước 3 — Đánh giá Exit Criteria & Go/No-Go
41
+
42
+ | Điều kiện | Go | No-Go |
43
+ |---|---|---|
44
+ | Critical bugs | 0 unresolved | Còn ≥ 1 |
45
+ | High bugs | 0 unresolved hoặc có deferred plan | Còn unresolved không có plan |
46
+ | Coverage | ≥ 100% acceptance criteria covered | Còn AC chưa test |
47
+ | Pass rate | Đạt ngưỡng exit criteria | Dưới ngưỡng |
48
+
49
+ **Conditional Go:** Pass nhưng còn Medium/Low bugs chưa fix — ghi rõ điều kiện deferred.
50
+
51
+ ### Bước 4 — Viết Test Report
52
+
53
+ **Dùng template:** `templates/test-report.md`
54
+
55
+ Điền đầy đủ:
56
+ - **Project Information:** lấy từ ticket context
57
+ - **Test Execution Summary:** per module, R1/R2 stats, % hoàn thành
58
+ - **Bug Summary:** tổng hợp từ `bugs/`
59
+ - **Coverage:** acceptance criteria đã cover
60
+ - **Sign-off Decision:** Go / No-Go / Conditional Go + lý do cụ thể
61
+
62
+ Output: `test-plan/test-report.md`
63
+
64
+ ---
65
+
66
+ ## Gate 4 Display
67
+
68
+ ```
69
+ ⏸️ GATE 4: TEST REPORT READY
70
+
71
+ Overall: [Pass / Fail / Conditional]
72
+ Passed: [N/total] | Bugs unresolved: [N Critical / N High / N Medium / N Low]
73
+ Coverage: [N]% acceptance criteria covered
74
+
75
+ Recommendation: [Go / No-Go / Conditional go]
76
+ [Nếu Conditional: điều kiện cụ thể]
77
+
78
+ → Review: test-plan/test-report.md
79
+ → Type APPROVED to sign off and submit to Backlog/Jira
80
+ → Type NO-GO: [reason] to reject release
81
+ ```
82
+
83
+ ---
84
+
85
+ ## Xử lý phản hồi của TESTER
86
+
87
+ **`APPROVED`** → Done. Hướng dẫn TESTER copy nội dung lên Backlog/Jira ticket.
88
+
89
+ **`NO-GO: [reason]`** → Ghi nhận lý do vào test-report.md. List những gì cần fix trước khi release.
90
+
91
+ ---
92
+
93
+ ## Mandatory Rules
94
+
95
+ - ❌ KHÔNG generate report khi còn critical bug chưa resolved
96
+ - ❌ KHÔNG tự quyết Go/No-Go thay TESTER — chỉ đưa ra recommendation
97
+ - ✅ PHẢI verify từng acceptance criteria từ Gate 1 trước khi kết luận coverage
98
+ - ✅ PHẢI trích dẫn TC ID cụ thể khi claim "requirement X đã covered"
99
+ - ✅ Bugs deferred PHẢI có justification rõ ràng trong report
@@ -0,0 +1,58 @@
1
+ # SUMMARY TEST REPORT
2
+
3
+ ## Project Information
4
+
5
+ | Property | Value | Property | Value |
6
+ | :--- | :--- | :--- | :--- |
7
+ | **Project Name** | [Project Name] | **Author/Created By** | [Author Name] |
8
+ | **Project Code** | [Project Code] | **Reviewer** | [Reviewer Name] |
9
+ | **Created At** | [Creation Date] | **Report Date** | [Report Date] |
10
+ | **Last updated at** | [Update Date] | | |
11
+
12
+ ---
13
+
14
+ ## Test Execution Summary
15
+
16
+ | No | Module Code | Written By | Created Date | R1 Passed | R1 Failed | R1 UnTest | R1 Pending | R2 Passed | R2 Failed | R2 UnTest | R2 Pending | Blocked | Total Test Cases | Tổng Passed | % Hoàn thành | Updated Date | Sprint | Creator | Reviewer / Approver |
17
+ |---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
18
+ | 1 | [Module Code] | [Author] | [Date] | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0% | [Date] | [Sprint] | [Creator] | [Reviewer] |
19
+ | 2 | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
20
+
21
+ ---
22
+
23
+ ## Bug Summary
24
+
25
+ | Severity | Total | Resolved | Unresolved | Deferred |
26
+ |---|---|---|---|---|
27
+ | Critical | 0 | 0 | 0 | 0 |
28
+ | High | 0 | 0 | 0 | 0 |
29
+ | Medium | 0 | 0 | 0 | 0 |
30
+ | Low | 0 | 0 | 0 | 0 |
31
+ | **Total** | **0** | **0** | **0** | **0** |
32
+
33
+ **Deferred bugs justification:**
34
+ - [BUG-ID]: [Lý do defer và sprint xử lý]
35
+
36
+ ---
37
+
38
+ ## Acceptance Criteria Coverage
39
+
40
+ | # | Acceptance Criteria | TC IDs | Status |
41
+ |---|---|---|---|
42
+ | 1 | [AC từ Gate 1] | [TC_001, TC_002] | ✅ Covered |
43
+ | 2 | [AC từ Gate 1] | [TC_003] | ✅ Covered |
44
+ | 3 | [AC từ Gate 1] | - | ❌ Not covered |
45
+
46
+ **Coverage:** [N/N] acceptance criteria covered ([N]%)
47
+
48
+ ---
49
+
50
+ ## Sign-off Decision
51
+
52
+ | Item | Value |
53
+ |---|---|
54
+ | **Overall Result** | Pass / Fail / Conditional |
55
+ | **Recommendation** | Go / No-Go / Conditional Go |
56
+ | **Conditions** (nếu Conditional) | [Mô tả điều kiện cụ thể] |
57
+ | **Sign-off By** | [TESTER Name] |
58
+ | **Sign-off Date** | [Date] |