@relipa/ai-flow-kit 0.2.1 → 0.2.2-beta.0

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.
@@ -18,7 +18,9 @@ Sync test cases (từ TC file `.md`) với Playwright spec files, sử dụng **
18
18
  - `tcFile`: path đến TC file markdown (vd `testcases/AD10.md`)
19
19
  - `repo`: tên repo (vd `repo-fe`)
20
20
  - `screenId`: mã màn hình, always lowercase (vd `ad10`, not `AD10`) — directory paths use lowercase; spec file name `{ScreenID}.spec.ts` remains uppercase
21
+ - `featureDir`: `{ScreenID}_{Screen-Name-kebab-case}` (vd `AD10_create-product`)
21
22
  - `baseUrl`: URL của app để Playwright MCP snapshot
23
+ - `scriptsRoot`: `AK-Docs/03.Testing/05.Scripts/{repo}/` — script + Page Object sinh ra nằm ở đây, `Shared/evidence-helper.ts` nằm ở `AK-Docs/03.Testing/05.Scripts/Shared/`
22
24
 
23
25
  ---
24
26
 
@@ -39,7 +41,7 @@ Không tính vào hash: `Severity`, `Pre-condition`, `Data Test`, `Ticket ID`, `
39
41
 
40
42
  ## Spec File Structure
41
43
 
42
- Mỗi TC trong spec file có metadata comment ngay trước `test()`:
44
+ Mỗi TC trong spec file có metadata comment ngay trước `test()`. File nằm ở `AK-Docs/03.Testing/05.Scripts/{repo}/{featureDir}/{ScreenID}.spec.ts`:
43
45
 
44
46
  ```typescript
45
47
  // @screen-id: AD10
@@ -48,20 +50,25 @@ Mỗi TC trong spec file có metadata comment ngay trước `test()`:
48
50
  // @screen-url: /admin/products/create
49
51
  // @generated: YYYY-MM-DD
50
52
 
51
- import { test, expect } from '../../shared/fixtures/test'
53
+ import { test, expect } from '../../Shared/fixtures/test'
54
+ import { captureStepEvidence } from '../../Shared/evidence-helper'
52
55
  import { AD10Page } from '../pages/AD10Page'
53
56
 
54
57
  test.describe('AD10 - Create Product', () => {
55
58
 
56
59
  // @tc-hash: a3f9b2c1
57
60
  // @tc-id: AD10_001
58
- test('AD10_001 - Truy cập trực tiếp qua URL khi chưa đăng nhập', async ({ page }) => {
61
+ test('AD10_001 - Truy cập trực tiếp qua URL khi chưa đăng nhập', async ({ page }, testInfo) => {
62
+ const pageObj = new AD10Page(page)
59
63
  // ...
64
+ // xem "Assertion Rules" + "Evidence Capture per Step" bên dưới — mỗi step UI trong TC
65
+ // phải gọi captureStepEvidence(page, testInfo, N, 'desc', {...}) và assertion phải khẳng
66
+ // định đúng nội dung Expected Result, không chỉ kiểm tra element tồn tại.
60
67
  })
61
68
 
62
69
  // @tc-hash: d7e2f4a9
63
70
  // @tc-id: AD10_002
64
- test('AD10_002 - Truy cập trực tiếp qua URL khi đã đăng nhập', async ({ page }) => {
71
+ test('AD10_002 - Truy cập trực tiếp qua URL khi đã đăng nhập', async ({ page }, testInfo) => {
65
72
  // ...
66
73
  })
67
74
 
@@ -84,7 +91,7 @@ Nhận diện **Manual TCs** — các TC không thể automation:
84
91
 
85
92
  ### Bước 2: Scan spec file hiện tại
86
93
 
87
- Tìm `ak-test/{repo}/scripts/{screenId}/{ScreenID}.spec.ts`.
94
+ Tìm `AK-Docs/03.Testing/05.Scripts/{repo}/{featureDir}/{ScreenID}.spec.ts` (`scriptsRoot` từ input + `{featureDir}/{ScreenID}.spec.ts`).
88
95
 
89
96
  Nếu tồn tại: đọc file, extract tất cả cặp `@tc-hash` + `@tc-id` bằng regex:
90
97
  ```
@@ -114,25 +121,40 @@ Với mỗi TC cần gen mới:
114
121
  - `mcp__playwright__browser_navigate` → `baseUrl + screenUrl`
115
122
  - `mcp__playwright__browser_snapshot` → lấy accessibility tree
116
123
  - Với từng element trong Steps: `mcp__playwright__browser_generate_locator`
117
- 3. Sinh test block với metadata comments:
124
+ - Nếu locator match **nhiều hơn 1 element** trên snapshot → không dùng locator đó, tìm locator scope hẹp hơn (trong đúng container/row/modal) hoặc dùng `data-testid` cụ thể. Xem "Assertion Rules" — locator mơ hồ là nguyên nhân chính gây false pass/fail.
125
+ 3. Sinh test block với metadata comments — **mỗi Step trong TC file map 1:1 với 1 action + 1 evidence capture**, assertion cuối phải khẳng định đúng nội dung Expected Result:
118
126
 
119
127
  ```typescript
120
128
  // @tc-hash: {hash}
121
129
  // @tc-id: {TC_ID}
122
- test('{TC_ID} - {Test Case Name}', async ({ page }) => {
130
+ test('{TC_ID} - {Test Case Name}', async ({ page }, testInfo) => {
123
131
  const pageObj = new {ScreenID}Page(page)
124
- // Step 1: {step text}
132
+
133
+ // Step 1: {step text — vd "Trên màn hình danh sách, click item A để mở A1"}
125
134
  await pageObj.{action}()
126
- // Step 2: {step text}
135
+ await captureStepEvidence(page, testInfo, 1, '{step-1-desc}', { highlightSelector: pageObj.itemALocator })
136
+
137
+ // Step 2: {step text — vd "Trên A1, click button B để mở modal B1"}
127
138
  await pageObj.{action}()
128
- // Expected: {expected result}
129
- await expect(page.{locator}).{assertion}
139
+ await captureStepEvidence(page, testInfo, 2, '{step-2-desc}', { highlightSelector: pageObj.buttonBLocator })
140
+
141
+ // Step 3 (nếu step mở popup/modal): chờ modal hiện + settle rồi mới chụp + assert
142
+ await expect(pageObj.modalB1Locator).toBeVisible()
143
+ await captureStepEvidence(page, testInfo, 3, '{step-3-desc}', {
144
+ highlightSelector: pageObj.confirmFieldLocator, // đúng vùng cần confirm theo Expected Result
145
+ scrollSelector: pageObj.confirmFieldLocator, // nếu modal có scroll
146
+ })
147
+
148
+ // Expected: {expected result — assertion PHẢI check đúng nội dung, không chỉ tồn tại}
149
+ await expect(pageObj.confirmFieldLocator).toHaveText('{expected text từ TC file}')
130
150
  })
131
151
  ```
132
152
 
153
+ > Nếu TC chỉ có 1 step / không mở modal mới, vẫn gọi `captureStepEvidence` ít nhất 1 lần ở trạng thái cuối (sau khi `waitForUiSettled`) — không bỏ qua evidence.
154
+
133
155
  4. Nếu spec file chưa tồn tại: tạo file mới với file header + describe wrapper + test block.
134
156
  5. Nếu spec file đã tồn tại: append test block vào trước closing `})` của `test.describe`.
135
- 6. Nếu `{ScreenID}Page.ts` chưa tồn tại: tạo Page Object với locators cho các elements đã snapshot.
157
+ 6. Nếu `{ScreenID}Page.ts` chưa tồn tại: tạo Page Object với locators cho các elements đã snapshot — **đặt tên locator theo đúng item được mô tả trong Step** (vd `itemALocator`, `buttonBLocator`) để dùng lại cho `highlightSelector` ở bước capture evidence.
136
158
 
137
159
  **File header khi tạo spec mới:**
138
160
  ```typescript
@@ -142,7 +164,8 @@ Với mỗi TC cần gen mới:
142
164
  // @screen-url: {url path}
143
165
  // @generated: {YYYY-MM-DD}
144
166
 
145
- import { test, expect } from '../../shared/fixtures/test'
167
+ import { test, expect } from '../../Shared/fixtures/test'
168
+ import { captureStepEvidence } from '../../Shared/evidence-helper'
146
169
  import { {ScreenID}Page } from '../pages/{ScreenID}Page'
147
170
 
148
171
  test.describe('{ScreenID} - {Screen Name}', () => {
@@ -188,8 +211,8 @@ mcp__playwright__browser_close
188
211
  ⚠️ Manual: {N} TCs → {TC_IDs} (lý do)
189
212
  ❌ Blocked: {N} TCs → {TC_IDs} (lý do)
190
213
 
191
- → Script: ak-test/{repo}/scripts/{screenId}/{ScreenID}.spec.ts
192
- → Page Object: ak-test/{repo}/scripts/pages/{ScreenID}Page.ts
214
+ → Script: AK-Docs/03.Testing/05.Scripts/{repo}/{featureDir}/{ScreenID}.spec.ts
215
+ → Page Object: AK-Docs/03.Testing/05.Scripts/{repo}/pages/{ScreenID}Page.ts
193
216
  ```
194
217
 
195
218
  Trả về danh sách kết quả cho `execute-flow`:
@@ -199,10 +222,25 @@ Trả về danh sách kết quả cho `execute-flow`:
199
222
 
200
223
  ---
201
224
 
225
+ ## Assertion Rules (bắt buộc — tránh false pass/fail)
226
+
227
+ - ❌ **Không** dùng locator match nhiều hơn 1 element làm căn cứ assertion — verify qua `browser_snapshot` rằng locator chỉ trúng đúng 1 node trước khi dùng. Nếu snapshot cho thấy nhiều node giống nhau (list item, nhiều modal ẩn/hiện cùng lúc) → scope locator trong đúng container (`getByRole('dialog').getByText(...)`, `row.getByTestId(...)`) hoặc thêm `.filter({ hasText: ... })`.
228
+ - ❌ **Không** dùng `toBeVisible()`/`toBeAttached()` làm assertion duy nhất khi Expected Result mô tả **nội dung cụ thể** (text, giá trị, số lượng, trạng thái field) — phải dùng `toHaveText`/`toContainText`/`toHaveValue`/`toBeDisabled`/`toHaveCount` tương ứng.
229
+ - ❌ **Không** wrap action trong `try/catch` rồi để pass nếu catch nuốt lỗi mà không có assertion thay thế khẳng định behavior đúng.
230
+ - ✅ Với negative/validation TC (kỳ vọng lỗi, kỳ vọng bị chặn) → assertion phải khẳng định đúng **hành vi chặn** đó xảy ra (message lỗi đúng text, hoặc action bị disable, hoặc điều hướng không xảy ra) — không chỉ assert "trang không crash".
231
+ - ✅ Mỗi step có mô tả thay đổi UI trong TC Steps → phải có 1 lệnh gọi `captureStepEvidence(...)` tương ứng, đặt **ngay sau** `waitForUiSettled` implicit trong helper — xem "Evidence Capture per Step" dưới.
232
+
233
+ ## Evidence Capture per Step
234
+
235
+ - Import `captureStepEvidence`, `waitForUiSettled`, `highlightElement` từ `Shared/evidence-helper.ts` (không viết lại logic này trong từng spec).
236
+ - Nếu Step yêu cầu click để mở popup/modal → thực hiện click **trước**, chờ modal `toBeVisible()`, rồi mới `captureStepEvidence` cho step đó — không chụp step trước khi hành động mở modal xảy ra.
237
+ - Nếu vùng cần confirm nằm ngoài viewport (modal dài, table nhiều dòng) → truyền `scrollSelector` để helper tự `scrollIntoViewIfNeeded()` trước khi chụp.
238
+ - Truyền `highlightSelector` = đúng locator của item/nội dung mà Expected Result yêu cầu tester xác nhận — helper tự khoanh viền đỏ rồi remove sau khi chụp.
239
+
202
240
  ## Mandatory Rules
203
241
 
204
242
  - ❌ **Không bao giờ bịa selector** — phải dùng Playwright MCP snapshot
205
243
  - ❌ **Không overwrite** test block có hash match — skip hoàn toàn
206
244
  - ✅ Ưu tiên locator: `getByRole` > `getByLabel` > `getByPlaceholder` > `getByText` > `getByTestId` > CSS
207
- - ✅ Không tạo lại `BasePage.ts` / `fixtures/test.ts` nếu đã tồn tại
245
+ - ✅ Không tạo lại `BasePage.ts` / `fixtures/test.ts` / `evidence-helper.ts` nếu đã tồn tại
208
246
  - ✅ Test names/comments theo ngôn ngữ của TC input (xem `custom/rules/output-language.md`) — TC tiếng Việt → tiếng Việt, TC tiếng Anh → tiếng Anh
@@ -475,9 +475,10 @@ Pre-flight checks (stop and report if any fail):
475
475
  - If Y: read and update `~/.claude/settings.json` by merging the playwright entry into `mcpServers`, then instruct TESTER to **restart Claude Code** before retrying. Stop here.
476
476
  - If n: show manual install instructions (add `playwright` to `mcpServers` in `~/.claude/settings.json`). Stop here.
477
477
  1. TC file is parseable — Section 3 has at least one TC row
478
- 2. `ak-test/{repo}/` directory exists (or offer to scaffold it)
478
+ 2. `AK-Docs/03.Testing/` subfolders exist (`04.Evidence/`, `05.Scripts/`, `02.Reports/`, `06.Bugs/` — auto-create if missing)
479
479
  3. `BASE_URL` env var is set
480
- 4. `ak-test/{repo}/playwright.config.ts` exists (or offer to create from template)
480
+ 4. `AK-Docs/03.Testing/05.Scripts/{repo}/playwright.config.ts` exists (or auto-scaffold the Playwright project inside AK-Docs — package.json, node_modules gitignored — see `execute-flow` SKILL.md "Scaffold Playwright Project")
481
+ 5. `.gitignore` (repo root containing AK-Docs) ignores `03.Testing/04.Evidence/` (binary evidence, never committed even though it lives inside AK-Docs) and `03.Testing/05.Scripts/**/{node_modules,test-results,playwright-report,blob-report}/` — auto-append if missing
481
482
 
482
483
  Then display work plan:
483
484
 
@@ -516,7 +517,7 @@ Hash-based TC↔script sync — for each TC in the file:
516
517
  - **Unchanged TC** (hash matches): skip — do not touch.
517
518
  - **Manual/Blocked TC**: mark `⏭️ Untest` / `⏳ Pending` — no script generated.
518
519
 
519
- Output: `ak-test/{repo}/scripts/{screenId}/{ScreenID}.spec.ts` (1 file per screen, all TCs inside)
520
+ Output: `AK-Docs/03.Testing/05.Scripts/{repo}/{featureDir}/{ScreenID}.spec.ts` (1 file per screen, all TCs inside). Every TC Step that changes UI must call `captureStepEvidence()` from `Shared/evidence-helper.ts` (waits for loading to finish, opens popups/modals via click before capturing, scrolls to the confirm area, red-outline highlights the item to confirm) and every assertion must check the actual Expected Result content — not just element presence. See `script-sync` SKILL.md "Assertion Rules" / "Evidence Capture per Step".
520
521
 
521
522
  - **INVOKE** `gate-review` skill (generate mode) — write `.aiflow/review/gate-2-[ticket-id].md`
522
523
  - Display gate pause message from `gate-review` skill — wait for **APPROVED**
@@ -544,17 +545,22 @@ Chạy [Pre-flight — Đồng bộ Source & Docs](#pre-flight-bắt-buộc--đ
544
545
 
545
546
  **Step 3.1 — Determine run number**
546
547
 
547
- Check `ak-test/{repo}/results/{screenId}/` — next run is `run-{N+1}`.
548
+ Check `AK-Docs/03.Testing/04.Evidence/{repo}/{featureDir}/` — next run is `run-{N+1}`.
548
549
 
549
- **Step 3.2 — Execute Playwright**
550
+ **Step 3.2 — Execute Playwright** (script and evidence both live inside AK-Docs; evidence stays out of Git via `.gitignore`, not via a separate working dir):
550
551
 
551
552
  ```bash
552
- BASE_URL=<url> npx playwright test scripts/{screenId}/{ScreenID}.spec.ts
553
+ cd AK-Docs/03.Testing/05.Scripts
554
+ EVIDENCE_DIR="$(pwd)/../04.Evidence/{repo}/{featureDir}/run-{N}" \
555
+ BASE_URL=<url> \
556
+ npx playwright test --config={repo}/playwright.config.ts {repo}/{featureDir}/{ScreenID}.spec.ts
553
557
  ```
554
558
 
555
- **Step 3.3 — Organize evidence** into `ak-test/{repo}/results/{screenId}/run-{N}/`:
556
- - Per-TC folder `{TC_ID}-{scenario}/` with `step-NN-{desc}.png`, `trace.zip`, `result.md`
557
- - Auto-draft `bugs/BUG-NNN-{slug}.md` for failed TCs
559
+ **Step 3.3 — Organize evidence + report:**
560
+ - Evidence (already written directly to `AK-Docs/03.Testing/04.Evidence/{repo}/{featureDir}/run-{N}/{TC_ID}-{scenario}/`, gitignored): `step-NN-{desc}.png` per Step, `trace.zip`
561
+ - Report (`AK-Docs/03.Testing/02.Reports/{repo}/{featureDir}/run-{N}/{TC_ID}-{scenario}/result.md`) text only, links back to the `04.Evidence/` path
562
+ - Before recording PASS/FAIL, re-check that the assertion actually matches the TC's Expected Result content (not just "did not throw") — see `execute-flow` SKILL.md "DOM Verification Rules"
563
+ - Auto-draft `AK-Docs/03.Testing/06.Bugs/{repo}/{featureDir}/run-{N}/BUG-NNN-{slug}.md` for failed TCs
558
564
 
559
565
  **Step 3.4 — Update TC file** R1/R2 columns:
560
566
  - `✅ Pass` · `❌ Fail` · `⏭️ Untest` · `⏳ Pending`
@@ -593,7 +599,7 @@ Only runs after Gate 3 APPROVED.
593
599
 
594
600
  Chạy [Pre-flight — Đồng bộ Source & Docs](#pre-flight-bắt-buộc--đồng-bộ-source--docs-đầu-mỗi-gate) ở đầu file. Lỗi → hiển thị ⚠️ cảnh báo, không dừng gate.
595
601
 
596
- **Step 4.1** — Generate `ak-test/{repo}/results/{screenId}/run-{N}/testreport.md`:
602
+ **Step 4.1** — Generate `AK-Docs/03.Testing/02.Reports/{repo}/{featureDir}/run-{N}/testreport.md`:
597
603
  - Per-module rows with Pass/Fail/Untest/Pending counts, R1/R2 columns, % completion
598
604
  - Go/No-Go: 0 unresolved Critical = Go
599
605
 
@@ -609,7 +615,7 @@ Wait for reply before moving to next bug.
609
615
  ⏸️ GATE 4: REPORT READY
610
616
  Decision: [GO / NO-GO]
611
617
  Bugs logged: [N] | Skipped: [N]
612
- → Review: [ak-test/{repo}/results/{screenId}/run-{N}/testreport.md](ak-test/{repo}/results/{screenId}/run-{N}/testreport.md)
618
+ → Review: [AK-Docs/03.Testing/02.Reports/{repo}/{featureDir}/run-{N}/testreport.md](AK-Docs/03.Testing/02.Reports/{repo}/{featureDir}/run-{N}/testreport.md)
613
619
  → Type APPROVED to sign off
614
620
  ```
615
621
 
@@ -9,6 +9,14 @@ Versioning follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
9
9
 
10
10
  ## [Unreleased]
11
11
 
12
+ ## [0.2.2] - 2026-08-24
13
+
14
+ ### Changed
15
+
16
+ - **`execute-test` flow (`execute-flow` + `script-sync` skills) no longer uses an `ak-test/` working dir at all — everything, including binary evidence, now lives inside `AK-Docs/03.Testing/`.** Previously the whole flow (Playwright scripts, per-TC `result.md`, bug drafts, `testreport.md`, and evidence) lived under `ak-test/{repo}/`, outside the project's docs tree — reports/bugs/scripts had no place in version control alongside the rest of `AK-Docs/03.Testing/` (Testcases, Reports, Bugs). New mapping: `05.Scripts/{repo}/{featureDir}/{ScreenID}.spec.ts` (Gate 2), `04.Evidence/{repo}/{featureDir}/run-{N}/` (Gate 3, screenshots/video/`trace.zip`/raw `results.json`), `02.Reports/{repo}/{featureDir}/run-{N}/{result.md, testreport.md}` (Gate 3/4), `06.Bugs/{repo}/{featureDir}/run-{N}/BUG-NNN-*.md` (Gate 3) — this restores `docs/common/Testing-Structure.md`'s original Gate 3 → `04.Evidence/` mapping instead of diverging from it (an earlier iteration of this change had evidence live in `ak-test/` to keep binaries out of AK-Docs entirely; superseded before release in favor of `.gitignore`). `05.Scripts/` is a self-contained, runnable Playwright project (`package.json`/`node_modules`/`tsconfig.json`) living inside AK-Docs — Gate 1 auto-scaffolds it and appends `03.Testing/04.Evidence/` plus `03.Testing/05.Scripts/**/{node_modules,test-results,playwright-report,blob-report}` to `.gitignore` if missing, so the binary evidence and Playwright build artifacts never get committed even though they're colocated with the rest of the docs tree. `playwright.config.ts`'s `outputDir`/JSON reporter path read `EVIDENCE_DIR` (set by the AI per run to the `04.Evidence/` path, a simple 1-level-up relative path from `05.Scripts/` since both now live under the same `03.Testing/` parent) so each run gets its own evidence folder.
17
+
18
+ - **`execute-flow`/`script-sync` gained explicit DOM-assertion and evidence-quality rules** to fix reported false pass/fail results and low-quality screenshots: locators that match more than one element are now called out as the primary root cause of mis-graded TCs (fix: scope to the right container or use `data-testid`, not `.first()`/broad CSS); assertions must check the actual Expected Result content (`toHaveText`/`toBeDisabled`/etc.), not just element presence; negative/validation TCs need an assertion on the actual blocking behavior, not "page didn't crash." New shared helper `custom/skills/execute-flow/templates/evidence-helper.ts` (copied once to `AK-Docs/03.Testing/05.Scripts/Shared/`) provides `waitForUiSettled()` (networkidle + no loading indicator + fonts ready — fixes screenshots taken mid-spinner), `highlightElement()`/`removeHighlight()` (red 3px outline around the item to confirm), and `captureStepEvidence()`/`openAndCapture()` (per-TC-Step screenshot, click-to-open-modal before capturing, `scrollIntoViewIfNeeded()` for scrollable content) — every generated spec must use these instead of ad-hoc screenshot calls. `playwright.config.ts` template gained `deviceScaleFactor: 2` and a configurable `locale` (default `ja-JP`) for sharper, correctly-rendered Kanji/Katakana text in evidence, plus 1 retry to absorb timing flakes before a TC is reported FAIL.
19
+
12
20
  ## [0.2.1] - 2026-08-17
13
21
 
14
22
  ### Added
@@ -29,6 +29,7 @@
29
29
  | `99.Memory/` Project Brain — full design, scoring model, mem-id scheme, role/PM permissions | [Memory-Architecture-v1.0.md](./Memory-Architecture-v1.0.md) | v1.1 — Phase 1 (`draft/list/submit/remove`) is what's implemented today; later phases in this doc are roadmap, not shipped yet |
30
30
  | How updates to `AK-Docs`/`Shared-Docs` get reviewed — branch/Merge Request flow, who can merge to `main` | [Docs-Management-Flow.md](./Docs-Management-Flow.md) | Doc's own header says `Trạng thái: Draft — chờ PM review` — flag that when answering, don't present it as final policy |
31
31
  | PM/BrSE/Comtor — ingest a Backlog/Jira/SharePoint link or pasted text into `AK-Docs/01.QnA/` | [Project-Structure.md](./Project-Structure.md) (§ `01.QnA/`), `.claude/skills/ingest-data/SKILL.md` | `ak use` → taskType `ingest-data`, 2-gate flow (fetch/classify/draft → branch+MR). SharePoint link fetch is **not connected yet** — falls back to pasted text |
32
+ | Any role — how to read `System-Requirement_v{N}.md` (who reads which field, Classification/Implementation Reference/Tech Reference meaning), why it's separate from UC Spec, and how to review/approve it without reading code | [System-Requirement-Read-Guide.md](./System-Requirement-Read-Guide.md) | Field glossary + Classification state machine (Gap/Assumption/Decision/Deviation) + FAQ (why not merge with UC Spec, who writes it, when to update) + 6-step review checklist |
32
33
 
33
34
  ## Unanswered topics (do not invent — say so and stop here)
34
35
 
@@ -382,7 +382,7 @@ ak execute ./testcases/AD10.md # AI starts execute-flow with this TC file
382
382
  ak execute # AI asks: "TC file ở đâu?"
383
383
  ```
384
384
 
385
- Output lands in `ak-test/{repo}/results/{screenId}/run-{N}/` — never deleted between runs.
385
+ Evidence (screenshots/video/trace.zip) lands in `AK-Docs/03.Testing/04.Evidence/{repo}/{featureDir}/run-{N}/` — never deleted between runs. Scripts, result/report/bug docs live in `AK-Docs/03.Testing/` instead (05.Scripts / 02.Reports / 06.Bugs) so they're versioned with the rest of the project's docs, while binary evidence stays out of that git history.
386
386
 
387
387
  ### Figma Design → Code
388
388
 
@@ -0,0 +1,178 @@
1
+ # Hướng Dẫn Đọc System Requirement (mọi role)
2
+
3
+ > **Dành cho:** bất kỳ ai cần đọc một `System-Requirement_v{N}.md` — PM, Comtor, BrSE, Tester, Dev, Tech Lead. Mục tiêu của tài liệu này: giúp bạn biết **mình cần đọc phần nào**, đọc xong hiểu đúng, không cần đọc code hay đọc hết mọi dòng.
4
+ > **Tài liệu được đọc:** `AK-Docs/02.BA-Specs/00.Requirements/[functionId]/System-Requirement_v{N}.md`, sinh ra bởi task type **"📐 Create System Requirement"** — cầu nối giữa UC Spec (BA) và code (Dev).
5
+ > **Nếu bạn là người duyệt (approve)** tài liệu này, xem thêm Mục 5 (Checklist) — phần còn lại của guide vẫn áp dụng, checklist chỉ là bước cuối.
6
+
7
+ ---
8
+
9
+ ## 1. Ai đọc phần nào
10
+
11
+ Mỗi `System-Requirement_v{N}.md` đã có sẵn bảng này ngay ở đầu file (nói 1 lần, không lặp lại theo từng dòng). Nhắc lại ở đây để bạn không cần mở file mới nhớ ra:
12
+
13
+ | Field trong tài liệu | Ai cần đọc |
14
+ |---|---|
15
+ | `Requirement` | PM/BrSE/Comtor, Tester |
16
+ | `System Behavior` | Tester |
17
+ | `Error Response` | Tester (đầy đủ, gồm HTTP code) — PM/BrSE/Comtor chỉ cần câu thông báo hiển thị |
18
+ | `Traced UC Ref` / `Traced UC BR` / `Traced Exception Flow` | PM/BrSE/Comtor (đối chiếu UC Spec) |
19
+ | `Classification` | PM/BrSE/Comtor — dấu hiệu "cần quyết định" hoặc "đã chốt" |
20
+ | `Implementation Reference` / `Tech Reference` | Dev |
21
+ | Mục 5 (Acceptance Test Scenarios) | Tester |
22
+
23
+ **Dev và AI đọc toàn bộ tài liệu.** Nếu bạn là PM/Comtor/BrSE và thấy 1 dòng `Implementation Reference` mình không hiểu — đó là bình thường, **bỏ qua**, không phải bạn thiếu kiến thức.
24
+
25
+ ---
26
+
27
+ ## 2. Cách đọc 1 item (Requirement/System Behavior/Implementation Reference)
28
+
29
+ `System-Requirement_v{N}.md` được thiết kế theo 3 tầng, mỗi tầng cho 1 nhóm người đọc khác nhau trong **cùng một item**:
30
+
31
+ | Tầng | Viết bằng | Dành cho | Bạn cần đọc? |
32
+ |---|---|---|---|
33
+ | **Requirement** | Ngôn ngữ nghiệp vụ, không có tên class/method/framework | PM, Comtor, BrSE, **Tester** | ✅ Luôn đọc |
34
+ | **System Behavior** | Vẫn ngôn ngữ thường, mô tả điều kiện/thứ tự xử lý | BA, Tester | ✅ Luôn đọc |
35
+ | **Error Response** | HTTP code + message hiển thị cho end-user | Tester | ✅ Đọc nếu là Validation/Exception |
36
+ | **Implementation Reference / Tech Reference** | file:line, class, method, enum | Dev | ❌ **Bỏ qua được** — không phải Dev thì không cần đọc |
37
+
38
+ **Nguyên tắc:** nếu bạn phải đọc `Implementation Reference` để hiểu `Requirement` đang nói gì, đó là **lỗi của tài liệu** (leak kỹ thuật lên tầng nghiệp vụ) — báo lại cho Dev viết lại, không phải bạn thiếu kiến thức.
39
+
40
+ ---
41
+
42
+ ## 3. Giải thích về Classification
43
+
44
+ Mỗi item (FR/NFR/VR/ER) có thể mang 1 trong 4 nhãn `Classification`.
45
+
46
+ | Nhãn | Nghĩa | Ai tạo ra | Hành động bạn cần làm |
47
+ |---|---|---|---|
48
+ | **Gap** | UC Spec chưa có nội dung này | Dev, khi viết tài liệu | PM/BA phải trả lời. **Còn Gap chưa trả lời → tài liệu chưa được approve.** |
49
+ | **Assumption** | Dev suy đoán, chưa ai xác nhận | Dev | PM confirm → thành Decision. PM reject → quay lại Gap |
50
+ | **Decision** | Đã chốt, có ngày và người chốt | Sau khi PM trả lời | Chỉ đọc, không cần hành động |
51
+ | **Deviation** | Code hiện tại khác UC Spec | Dev, khi so sánh với code thật | BA/PM chọn: sửa code theo UC Spec, hoặc sửa UC Spec theo code |
52
+
53
+ ### Khi 1 item có nhiều quyết định — cách đọc
54
+
55
+ Trường hợp 1 item có **2+ quyết định** liên quan (ví dụ BA chốt 1 phần, Dev chốt phần còn lại). Ví dụ:
56
+
57
+ ```
58
+ Classification: Gap → Decision
59
+ - OQ-35 (BA): sử dụng mã lượt đặt hàng để xác định yêu cầu đặt hàng trùng và tránh tạo đơn nhiều lần.
60
+ - D-03 (Dev): nếu mã lượt đặt hàng đã được xử lý, không tạo đơn mới; trả về HTTP 400 kèm đơn đã tạo trước đó. Mã có hiệu lực trong 30 phút.
61
+ ```
62
+
63
+ Cách đọc: mỗi dòng là **1 mã số + ai chốt + nội dung ngắn**.
64
+ - `OQ-xx` = quyết định gốc do BA chốt, kế thừa từ UC Spec (thường trong lúc Q&A trước khi UC Spec được ký duyệt).
65
+ - `D-xx` = quyết định phát sinh riêng khi Dev soạn tài liệu System Requirement này (ví dụ: UC Spec chốt "phải chống trùng đơn" nhưng chưa viết rõ máy chủ trả gì — Dev phải tự chốt thêm chi tiết kỹ thuật đó, ghi lại thành D-xx để không tự quyết ngầm).
66
+
67
+ Nếu bạn không nhớ hoặc không đồng ý với 1 trong các quyết định đó, nêu lại ngay — đừng chờ tới khi ra sản phẩm.
68
+
69
+ ---
70
+
71
+ ## 4. Workflow trạng thái Classification
72
+
73
+ ```mermaid
74
+ %%{init: {'flowchart': {'curve': 'linear'}}}%%
75
+ flowchart TD
76
+ Start([Dev viết draft]) --> Gap[Gap]
77
+ Gap -->|"PM/BA trả lời chắc chắn"| Decision[Decision]
78
+ Gap -->|"PM/BA trả lời<br/>nhưng chưa chắc 100%"| Assumption[Assumption]
79
+ Assumption -->|"PM confirm đúng"| Decision
80
+ Assumption -->|"PM reject / cần hỏi lại"| Gap
81
+ Decision -->|"sau này Dev thấy<br/>code thực tế khác"| Deviation[Deviation]
82
+ Deviation -->|"PM chọn sửa code<br/>theo UC Spec (đã fix xong)"| Decision
83
+ Deviation -->|"PM chọn giữ code, sửa UC Spec<br/>(BA cập nhật UC Spec, tăng version mới)"| Decision
84
+ ```
85
+
86
+ **Rule:** tài liệu **không được approve** khi còn item ở trạng thái `Gap` chưa trả lời. `Assumption` được phép tồn tại tạm nếu PM đã xác nhận "tạm chấp nhận, sẽ chốt sau" — nhưng phải ghi rõ trong Mục 8 (Decision Log), không được im lặng bỏ qua.
87
+
88
+ ---
89
+
90
+ ## 5. Checklist Review (dành cho người duyệt — không cần đọc code)
91
+
92
+ Làm theo đúng thứ tự — dừng và reject ngay khi 1 bước fail.
93
+
94
+ ### Bước 1 — Đọc Executive Summary (30 giây)
95
+ - [ ] `Traceability coverage` = X/X? Thiếu → tài liệu chưa đầy đủ, trả lại Dev.
96
+ - [ ] `Action needed from PM` có danh sách → đây là Gap/Assumption bạn phải trả lời **trước**, ngay tại bước này.
97
+
98
+ ### Bước 2 — Khớp 1-1 với UC Spec (Mục 0 — Traceability Matrix)
99
+ - [ ] Mở UC Spec `v{N}` ghi ở header song song.
100
+ - [ ] Mỗi Main/Alternative/Exception Flow, mỗi Business Rule trong UC Spec → tìm đúng 1 dòng tương ứng trong Traceability Matrix.
101
+ - [ ] Thiếu dòng nào → **reject**.
102
+
103
+ ### Bước 3 — Đọc tầng Requirement (Mục 1–4)
104
+ - [ ] Chỉ đọc `Requirement` + `System Behavior` — bỏ qua `Implementation Reference`.
105
+ - [ ] Thấy tên class/method/framework lọt vào `Requirement`/`System Behavior` → **reject**, yêu cầu viết lại.
106
+ - [ ] Với Validation/Exception: `Error Response` phải giữ HTTP code + message hiển thị.
107
+
108
+ ### Bước 4 — Xử lý từng nhãn Classification
109
+ - [ ] `Gap`/`Assumption` → trả lời theo workflow ở Mục 4.
110
+ - [ ] `Deviation` → chọn rõ: sửa code hay sửa UC Spec — không để lơ lửng.
111
+ - [ ] `Decision` → chỉ xác nhận đúng là điều đã chốt; không nhớ đã chốt → hỏi lại, đừng mặc định đúng.
112
+
113
+ ### Bước 5 — Đối chiếu Mục 7 (Assumptions/Gaps/Decisions/Deviations)
114
+ - [ ] Mọi item có nhãn ở Mục 1–4 phải có dòng tương ứng ở Mục 7. Thiếu → reject.
115
+
116
+ ### Bước 6 — Quyết định
117
+ - [ ] Còn `Gap` chưa trả lời → **không approve**.
118
+ - [ ] Pass hết Bước 1–5 → gõ `APPROVED`.
119
+
120
+ ---
121
+
122
+ ## 6. Câu hỏi thường gặp (FAQ)
123
+
124
+ ### System Requirement để làm gì? Tôi có UC Spec rồi thì cần gì System Requirement nữa?
125
+
126
+ UC Spec và System Requirement trả lời 2 câu hỏi khác nhau:
127
+
128
+ - **UC Spec (BA viết)** trả lời: *"hệ thống PHẢI làm gì theo mong muốn của khách/nghiệp vụ?"* — viết **trước khi** biết chắc code hiện tại đang làm gì, không cần Dev tham gia để ký duyệt.
129
+ - **System Requirement (Dev viết, sau khi đọc UC Spec + mở code thật ra đối chiếu)** trả lời: *"code hiện tại đã làm đúng chưa? Còn thiếu gì? Có tình huống nào UC Spec không viết tới nhưng hệ thống vẫn phải xử lý?"*
130
+
131
+ Ví dụ thật trong tài liệu BUY074: UC Spec chỉ viết "chống bán vượt tồn kho", nhưng KHÔNG viết tới tình huống "2 khách đặt cùng 1 sản phẩm cùng lúc thì ai thắng, ai thua, giỏ của người thua xử lý sao, có bị deadlock không nếu đơn có nhiều sản phẩm giao nhau". Đây là những **Gap** mà chỉ khi Dev đọc code + tưởng tượng ra kịch bản thật mới phát hiện được — BA khi viết UC Spec không có đủ góc nhìn kỹ thuật để lường trước. System Requirement chính là nơi những Gap này được phát hiện, hỏi lại BA/PM, và ghi lại chốt là gì.
132
+
133
+ Nói ngắn: **UC Spec = ý định. System Requirement = ý định đó khi va vào code thật thì phải cụ thể hoá ra sao.**
134
+
135
+ ### Vì sao không gộp UC Spec và System Requirement thành 1 tài liệu, review 1 lần cho gọn?
136
+
137
+ 3 lý do:
138
+
139
+ 1. **Thời điểm ký duyệt khác nhau.** UC Spec phải được BA/PM ký duyệt **trước**, không cần chờ Dev có thời gian đọc hết code. Nếu gộp 2 tài liệu, UC Spec sẽ bị kẹt chờ Dev investigate code xong mới ký được — làm chậm cả quy trình dù bản chất nghiệp vụ đã rõ và có thể duyệt độc lập với chi tiết kỹ thuật.
140
+ 2. **Người review và tiêu chí review khác nhau.** Review UC Spec cần Dev đánh giá "khả thi kỹ thuật ở mức khái niệm" + Tester đánh giá "khả năng test được ở mức khái niệm". Review System Requirement cần Dev + Tester **đối chiếu từng dòng với UC Spec** (khác câu hỏi, khác độ chi tiết) — trộn 2 việc vào 1 lần review dễ khiến người review làm qua loa 1 trong 2, thay vì làm kỹ cả 2.
141
+ 3. **Traceability rõ ràng hơn khi tách riêng.** Mỗi `System-Requirement_v{N}` phải matching đúng 1 phiên bản UC Spec (`UC-Spec-Version` header) — nếu 2 tài liệu là một, việc UC Spec đổi version (do yêu cầu nghiệp vụ đổi) và System Requirement đổi version (do Dev phát hiện thêm case khi code) sẽ lẫn vào nhau, khó biết cái gì đổi vì lý do gì.
142
+
143
+ **Nhưng:** Dự án có thể linh hoạt sắp xếp gộp 1 buổi review chung cho 2 tài liệu này, trong trường hợp có thể output 2 tài liệu cùng nhau thay vì phải chờ 1 khoảng thời gian dài để Dev điều tra.
144
+
145
+ ### System Requirement có được phép thay đổi/thêm nội dung so với UC Spec không?
146
+
147
+ Không. System Requirement **không bao giờ bịa ra** nội dung mà UC Spec không có — mọi FR/VR/ER phải trace được về 1 dòng cụ thể trong UC Spec, hoặc được đánh dấu `Gap`/`Assumption`/`Deviation` và chờ PM/BA xác nhận. Nếu bạn thấy 1 `Requirement` mà không tìm được nguồn trong UC Spec, đó là lỗi — báo lại ngay (xem Bước 2/3 ở Mục 5).
148
+
149
+ ### Khi nào cần viết lại/update System Requirement?
150
+
151
+ Hai trường hợp: (1) UC Spec lên version mới (BA sửa yêu cầu) → System Requirement phải `RESYNC` theo version mới; (2) trong lúc code 1 ticket, Dev phát hiện 1 case UC Spec có viết nhưng System Requirement bỏ sót → được đề xuất bổ sung, ghi thêm 1 dòng ở Change Log (Mục 9), không cần tăng version vì UC Spec chưa đổi.
152
+
153
+ ### Mục 8 (Decision Log) chỉ có 1 dòng ngắn — thiếu thông tin à?
154
+
155
+ Không thiếu — chủ ý tránh viết trùng 2 nơi. Chi tiết đầy đủ đã nằm trong dòng `Classification` của item tương ứng ở Mục 1–4; Mục 8 chỉ là bảng tra cứu ngược (ID → ai chốt → ngày → 1 dòng tóm tắt).
156
+
157
+ ### Tôi không hiểu `Implementation Reference` ghi gì, có sao không?
158
+
159
+ Tuỳ role. Nếu bạn là **PM/BrSE/Comtor/Tester** — không sao, tầng đó không dành cho bạn (xem Mục 1, 2); nếu bạn *cần* hiểu nó để đánh giá đúng/sai của `Requirement`, đó là lỗi tài liệu — báo lại, đừng tự trách mình thiếu kiến thức.
160
+
161
+ Nếu bạn là **Dev** — **bắt buộc phải hiểu**, vì đây chính là field ghi cho bạn (file:line/class/method để code) và AI cũng dựa vào nó ở Gate 3 coding. Không hiểu được thì không phải lỗi của bạn cần bỏ qua, mà là dấu hiệu tài liệu viết thiếu rõ (ví dụ thiếu context, path sai, hoặc tham chiếu tới code không còn tồn tại) — cần hỏi lại người viết (Dev khác/AI) hoặc tự mở code kiểm tra trước khi bắt đầu implement, không được đoán.
162
+
163
+ ### `Tech Reference` trong Mục 6.2 (Glossary) khác gì `Implementation Reference`?
164
+
165
+ `Implementation Reference` nằm rải trong từng item, chỉ Dev cần. `Tech Reference` ở Mục 6.2 là **bảng tra cứu tập trung** — mỗi giá trị kỹ thuật (ví dụ enum `TagStatusEnum::PENDING`) map sang 1 ý nghĩa nghiệp vụ đã được PM xác nhận (`Decision`) hoặc chưa (`Assumption`). Dùng bảng này khi muốn biết "giá trị thô này nghĩa là gì với nghiệp vụ" mà không cần lục từng item.
166
+
167
+ ### Tài liệu này có thay UC Spec không?
168
+
169
+ Không. UC Spec là nguồn nghiệp vụ gốc (BA sign-off). System Requirement là bản dịch sang góc nhìn Dev + trace lại UC Spec.
170
+
171
+ ---
172
+
173
+ ## 7. Liên quan
174
+
175
+ - Skill sinh ra tài liệu này: `.claude/skills/create-system-requirement/SKILL.md`
176
+ - Template: `.claude/skills/create-system-requirement/system-requirement-template-v1.md`
177
+ - Cấu trúc thư mục `02.BA-Specs/`: [BA-Specs-Structure.md](./BA-Specs-Structure.md)
178
+ - Quy trình SDLC end-to-end (Checkpoint #2/#3, gộp thread review): `docs/internal/SDLC-Unified-Workflow_v1.0.md`
@@ -38,30 +38,34 @@
38
38
  │ ├── Users.csv
39
39
  │ └── Fixtures.sql
40
40
 
41
- ├── 04.Evidence/ # Gate 3: Screenshots, videos, logs per execution
42
- └── F-001_User-Login/
43
- ├── TICKET-100_2026-06-15/ # Ticket + date to identify execution round
44
- │ ├── TC_001_PASS/
45
- └── Screenshot.png
46
- └── TC_002_FAIL/
47
- ├── Screenshot.png
48
- └── Video.mp4
49
- └── TICKET-100_Retest_2026-06-18/
50
- │ └── TC_002_PASS/
51
- │ └── Screenshot.png
41
+ ├── 04.Evidence/ # ⚠️ MUST be in .gitignore binary (screenshots/video/trace.zip)
42
+ ├── F-001_User-Login/ # manual QA evidence (screenshots attached by hand)
43
+ │ └── TICKET-100_2026-06-15/ # Ticket + date to identify execution round
44
+ └── TC_003_PASS/
45
+ │ │ └── Screenshot.png
46
+ │ └── {repo}/{featureDir}/run-{N}/ # execute-test flow's AUTOMATION evidence (Gate 3)
47
+ │ ├── results.json # Playwright JSON output
48
+ │ └── {TC_ID}-{scenario}/
49
+ ├── step-NN-{desc}.png
50
+ │ └── trace.zip
52
51
 
53
- ├── 05.Scripts/ # Playwright automation (by Repo → Feature)
52
+ ├── 05.Scripts/ # Playwright automation — RUNNABLE project (by Repo → Feature)
53
+ │ ├── package.json # 1 install for the whole 05.Scripts tree
54
+ │ ├── tsconfig.json
55
+ │ ├── node_modules/ # gitignored — see Rules
56
+ │ ├── Shared/ # Fixtures, helpers, evidence-helper used across repos
57
+ │ │ ├── fixtures/test.ts
58
+ │ │ ├── BasePage.ts
59
+ │ │ └── evidence-helper.ts # waitForUiSettled / highlightElement / captureStepEvidence
54
60
  │ ├── Repo1/ # e.g. frontend app
55
- │ │ ├── playwright.config.ts # baseURL, browser config for this repo
61
+ │ │ ├── playwright.config.ts # baseURL, EVIDENCE_DIR-driven outputDir for this repo
62
+ │ │ ├── pages/LoginPage.ts
56
63
  │ │ └── F-001_User-Login/
57
64
  │ │ └── Login.spec.ts
58
- ├── Repo2/ # e.g. admin app
59
- ├── playwright.config.ts
60
- └── F-003_Admin-Panel/
61
- └── Admin.spec.ts
62
- │ └── Shared/ # Fixtures, helpers used across repos
63
- │ ├── Fixtures.ts
64
- │ └── Helpers.ts
65
+ └── Repo2/ # e.g. admin app
66
+ ├── playwright.config.ts
67
+ └── F-003_Admin-Panel/
68
+ └── Admin.spec.ts
65
69
 
66
70
  ├── 06.Bugs/ # Gate 3: Bug reports (AI draft on TC fail)
67
71
  │ └── F-001_User-Login/
@@ -109,9 +113,9 @@
109
113
  | Gate | Output | Folder |
110
114
  |---|---|---|
111
115
  | Gate 1 | Chuẩn bị & Lập kế hoạch thực thi | (Console output / Work Plan) |
112
- | Gate 2 | Đồng bộ kịch bản kiểm thử (Script Sync) | `05.Scripts/[Repo]/[Feature]/[Feature].spec.ts` |
113
- | Gate 3 | Thực thi test & Thu thập evidence | `04.Evidence/[Feature]/[Ticket]_[Date]/` & `06.Bugs/[Feature]/` |
114
- | Gate 4 | Báo cáo test & Log bug | `02.Reports/[Feature]/[Ticket]/Execution-Report.md` |
116
+ | Gate 2 | Đồng bộ kịch bản kiểm thử (Script Sync) | `05.Scripts/[Repo]/[Feature]/[Feature].spec.ts` (project chạy được tại chỗ — có `package.json`/`node_modules`) |
117
+ | Gate 3 | Thực thi test & Thu thập evidence | Binary evidence (screenshot/video/`trace.zip`) → `04.Evidence/[Repo]/[Feature]/run-{N}/` (gitignored, xem Rules) & bug reports (text) → `06.Bugs/[Repo]/[Feature]/run-{N}/` |
118
+ | Gate 4 | Báo cáo test & Log bug | `02.Reports/[Repo]/[Feature]/run-{N}/testreport.md` |
115
119
 
116
120
  ---
117
121
 
@@ -119,6 +123,8 @@
119
123
 
120
124
  - Không tự sửa template — template nằm trong shared repo riêng
121
125
  - Lưu testcase và kết quả lên GitLab **sau khi Gate 4 được APPROVED**
122
- - Khi retest: tạo subfolder `TICKET-XXX_Retest_Date/` mới trong Evidence — không ghi đè cũ
123
- - `05.Scripts/` chỉ chứa `.spec.ts` `playwright.config.ts` — không chứa testcase `.md`
126
+ - Khi retest: tạo subfolder `run-{N+1}/` mới trong Evidence & Reports — không ghi đè cũ
127
+ - `05.Scripts/` 1 Playwright project chạy tại chỗ trong AK-Docs (`.spec.ts`, `playwright.config.ts`, `pages/`, `Shared/` fixtures + `evidence-helper.ts`, `package.json`, `node_modules/`) — không chứa testcase `.md`
128
+ - `05.Scripts/**/node_modules/`, `test-results/`, `playwright-report/`, `blob-report/` **phải** nằm trong `.gitignore` của repo chứa AK-Docs — execute-flow Gate 1 tự kiểm tra và thêm nếu thiếu
129
+ - **`04.Evidence/` phải nằm trong `.gitignore`** — dù chứa cả evidence tay (manual QA) và evidence automation (execute-test), toàn bộ nội dung là binary (screenshot/video/`trace.zip`), không commit lên Git. Không có `ak-test/` hay working dir nào khác ngoài AK-Docs cho flow này nữa.
124
130
  - `07.AI-Artifacts/` là working docs của AI — không phải tài liệu chính thức
@@ -171,19 +171,21 @@ ak execute # manual — AI asks for TC file
171
171
  - `[target]` — Optional. A ticket ID (`PROJ-44`), a path to a TC file (`./testcases/AD10.md`), or omitted for manual entry.
172
172
 
173
173
  **What it does (4 gates):**
174
- 1. **Gate 1 — Pre-flight:** Parse TC file, verify `ak-test/{repo}/` and `playwright.config.ts` exist, check `BASE_URL`
175
- 2. **Gate 2 — Script Sync:** Hash-based sync — gen new TCs, update changed, skip unchanged. Uses Playwright MCP for real selectors (never fabricates).
176
- 3. **Gate 3 — Execute & Evidence:** Run Playwright, organize evidence into `run-{N}/`, update TC file R1/R2 columns (`✅ Pass` · `❌ Fail` · `⏭️ Untest` · `⏳ Pending`)
177
- 4. **Gate 4 — Report & Bug Logging:** Generate `testreport.md`, confirm each bug with TESTER before logging to Jira
174
+ 1. **Gate 1 — Pre-flight:** Parse TC file, verify `AK-Docs/03.Testing/` subfolders and `AK-Docs/03.Testing/05.Scripts/{repo}/playwright.config.ts` exist (auto-scaffold if missing), check `BASE_URL`
175
+ 2. **Gate 2 — Script Sync:** Hash-based sync — gen new TCs, update changed, skip unchanged. Uses Playwright MCP for real selectors (never fabricates). Every step captures evidence via `evidence-helper.ts` and asserts on actual Expected Result content (see "DOM Verification Rules" in `execute-flow` SKILL.md).
176
+ 3. **Gate 3 — Execute & Evidence:** Run Playwright from `AK-Docs/03.Testing/05.Scripts/`, evidence written into `AK-Docs/03.Testing/04.Evidence/{repo}/{featureDir}/run-{N}/` via `EVIDENCE_DIR`, update TC file R1/R2 columns (`✅ Pass` · `❌ Fail` · `⏭️ Untest` · `⏳ Pending`)
177
+ 4. **Gate 4 — Report & Bug Logging:** Generate `testreport.md` in AK-Docs, confirm each bug with TESTER before logging to Jira
178
178
 
179
179
  **Output structure:**
180
180
  ```
181
- ak-test/{repo}/
182
- ├── scripts/{screenId}/{ScreenID}.spec.ts
183
- └── results/{screenId}/run-{N}/
184
- ├── {TC_ID}-{scenario}/ (screenshots, trace.zip, result.md)
185
- ├── bugs/BUG-NNN-{slug}.md
186
- └── testreport.md
181
+ AK-Docs/03.Testing/
182
+ ├── 04.Evidence/{repo}/{featureDir}/run-{N}/ # gitignored — screenshots, trace.zip
183
+ └── {TC_ID}-{scenario}/
184
+ ├── 05.Scripts/{repo}/{featureDir}/{ScreenID}.spec.ts # runnable Playwright project
185
+ ├── 02.Reports/{repo}/{featureDir}/run-{N}/
186
+ │ ├── {TC_ID}-{scenario}/result.md
187
+ │ └── testreport.md
188
+ └── 06.Bugs/{repo}/{featureDir}/run-{N}/BUG-NNN-{slug}.md
187
189
  ```
188
190
 
189
191
  **Example:**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@relipa/ai-flow-kit",
3
- "version": "0.2.1",
3
+ "version": "0.2.2-beta.0",
4
4
  "description": "All-in-one AI Flow Kit for team development with Claude AI - skills, templates, and MCP adapters",
5
5
  "author": "Example Team",
6
6
  "publishConfig": {
package/scripts/prompt.js CHANGED
@@ -386,16 +386,16 @@ Follow gates IN ORDER. Do NOT skip or merge gates.
386
386
 
387
387
  ### GATE 1 — Pre-flight & Work Plan (auto-start)
388
388
  **INVOKE:** \`execute-flow\` skill
389
- Check: MCP Playwright configured, TC file is parseable, \`ak-test/{repo}/\` scaffold exists, \`BASE_URL\` set, Playwright config exists. Display the work plan (TC file, repo, screen, BASE_URL) → wait for **APPROVED**.
389
+ Check: MCP Playwright configured, TC file is parseable, \`AK-Docs/03.Testing/\` subfolders exist (\`04.Evidence/\`, \`05.Scripts/\`, \`02.Reports/\`, \`06.Bugs/\`), \`BASE_URL\` set, \`AK-Docs/03.Testing/05.Scripts/{repo}/playwright.config.ts\` exists (auto-scaffold if missing), \`.gitignore\` covers \`03.Testing/04.Evidence/\` and \`05.Scripts/**/node_modules\`. Display the work plan (TC file, repo, screen, BASE_URL) → wait for **APPROVED**.
390
390
 
391
391
  ### GATE 2 — Script Sync
392
392
  Only runs after Gate 1 APPROVED.
393
393
  **INVOKE:** \`script-sync\` skill
394
- Hash-based TC↔script sync: new TC → generate Playwright test via MCP snapshot/locator (never fabricate selectors); changed TC → update; unchanged → skip; manual/blocked → mark Untest/Pending. Display new/updated/skipped/manual counts → wait for **APPROVED**.
394
+ Hash-based TC↔script sync: new TC → generate Playwright test via MCP snapshot/locator (never fabricate selectors, never use a locator matching more than one element); changed TC → update; unchanged → skip; manual/blocked → mark Untest/Pending. Every step calls \`captureStepEvidence()\` from \`Shared/evidence-helper.ts\`. Display new/updated/skipped/manual counts → wait for **APPROVED**.
395
395
 
396
396
  ### GATE 3 — Execute & Evidence
397
397
  Only runs after Gate 2 APPROVED.
398
- Run \`BASE_URL=<url> npx playwright test scripts/{screenId}/{ScreenID}.spec.ts\`, organize evidence (screenshots/trace/result.md) into \`ak-test/{repo}/results/{screenId}/run-{N}/\`, auto-draft bug reports for failures, update R1/R2 columns in the TC file. Supports \`RETEST: [TC_ID]\` and \`PR: [url]\`. Display pass/fail/untest/pending counts → wait for **APPROVED** (all Critical/High bugs resolved).
398
+ Run from \`AK-Docs/03.Testing/05.Scripts/\` with \`EVIDENCE_DIR\` pointed at \`AK-Docs/03.Testing/04.Evidence/{repo}/{featureDir}/run-{N}/\` (gitignored), organize evidence (screenshots/trace) there and text output (\`result.md\`, \`testreport.md\`) into \`AK-Docs/03.Testing/02.Reports/{repo}/{featureDir}/run-{N}/\`, auto-draft bug reports into \`AK-Docs/03.Testing/06.Bugs/{repo}/{featureDir}/run-{N}/\`, update R1/R2 columns in the TC file. Cross-check assertions against the TC's actual Expected Result before recording PASS/FAIL — don't trust Playwright's exit code alone. Supports \`RETEST: [TC_ID]\` and \`PR: [url]\`. Display pass/fail/untest/pending counts → wait for **APPROVED** (all Critical/High bugs resolved).
399
399
 
400
400
  ### GATE 4 — Report & Bug Logging (wait for APPROVED)
401
401
  Only runs after Gate 3 APPROVED.
@@ -18,7 +18,9 @@ const HARNESS_FILES = [
18
18
 
19
19
  const GITIGNORE_LINES = [
20
20
  '# Playwright',
21
+ 'node_modules/',
21
22
  'playwright-report/',
23
+ 'blob-report/',
22
24
  'test-results/',
23
25
  'tests/e2e/.auth/',
24
26
  '.env',