# Testing — Folder Structure

> **Managed by:** Tester  
> **Organized by:** Output Type → Function-ID (Scripts: Repo → Function-ID)  
> **Naming:** Function-ID format `F-001_User-Login`, Evidence by `TICKET-ID_Date`  
> **Note:** Templates are managed in a separate shared repo.

---

## Folder Tree

```
03.Testing/
│
├── 00.Strategies/                          # Test strategy & approach (project-level)
│   ├── Overview.md
│   ├── Regression-Strategy.md
│   └── Execution-Strategy.md
│
├── 01.Testcases/                           # Gate 2: Test cases per feature
│   └── F-001_User-Login/
│       ├── Testcase_v2.md                  # Current version
│       └── _archive/
│           └── Testcase_v1.md
│
├── 02.Reports/                             # Gate 4: Execution & regression reports
│   ├── F-001_User-Login/
│   │   ├── TICKET-100/
│   │   │   ├── Execution-Report.md
│   │   │   └── Bug-Summary.md
│   │   └── TICKET-100_Retest/
│   │       └── Execution-Report.md
│   └── Regression/                         # Regression runs per sprint
│       └── Sprint-01_Regression.md
│
├── 03.Test-Data/                           # Test data: CSV, JSON, SQL fixtures
│   └── F-001_User-Login/
│       ├── Users.csv
│       └── Fixtures.sql
│
├── 04.Evidence/                            # ⚠️ MUST be in .gitignore — binary (screenshots/video/trace.zip)
│   ├── F-001_User-Login/                   # manual QA evidence (screenshots attached by hand)
│   │   └── TICKET-100_2026-06-15/          # Ticket + date to identify execution round
│   │       └── TC_003_PASS/
│   │           └── Screenshot.png
│   └── {repo}/{featureDir}/run-{N}/        # execute-test flow's AUTOMATION evidence (Gate 3)
│       ├── results.json                    # Playwright JSON output
│       └── {TC_ID}-{scenario}/
│           ├── step-NN-{desc}.png
│           └── trace.zip
│
├── 05.Scripts/                             # Playwright automation — RUNNABLE project (by Repo → Feature)
│   ├── package.json                        # 1 install for the whole 05.Scripts tree
│   ├── tsconfig.json
│   ├── node_modules/                       # gitignored — see Rules
│   ├── Shared/                             # Fixtures, helpers, evidence-helper used across repos
│   │   ├── fixtures/test.ts
│   │   ├── BasePage.ts
│   │   └── evidence-helper.ts              # waitForUiSettled / highlightElement / captureStepEvidence
│   ├── Repo1/                              # e.g. frontend app
│   │   ├── playwright.config.ts            # baseURL, EVIDENCE_DIR-driven outputDir for this repo
│   │   ├── pages/LoginPage.ts
│   │   └── F-001_User-Login/
│   │       └── Login.spec.ts
│   └── Repo2/                              # e.g. admin app
│       ├── playwright.config.ts
│       └── F-003_Admin-Panel/
│           └── Admin.spec.ts
│
├── 06.Bugs/                                # Gate 3: Bug reports (AI draft on TC fail)
│   └── F-001_User-Login/
│       └── BUG-001_Login-Timeout.md
│
└── 07.AI-Artifacts/                        # AI working docs: Gate 1-2 outputs
    └── F-001_User-Login/
        ├── Gate1_Test-Analysis.md          # Gate 1: scope, flows, risks
        ├── Gate2_QnA.md                    # Gate 2: Q&A clarification (internal)
        └── Gate2_Coverage-Matrix.md        # Gate 2: coverage matrix
```

---

## File Naming Convention

| Element | Convention | Example |
|---|---|---|
| Section folder | `{N}.{Pascal-Case}/` | `00.Strategies/`, `04.Evidence/` |
| Feature folder | `F-{3-digit}_{Pascal-Case}/` | `F-001_User-Login/` |
| Testcase file | `Testcase_v{N}.md` | `Testcase_v2.md` |
| Evidence folder | `TICKET-{ID}_{YYYY-MM-DD}/` | `TICKET-100_2026-06-15/` |
| Retest folder | `TICKET-{ID}_Retest_{YYYY-MM-DD}/` | `TICKET-100_Retest_2026-06-18/` |
| TC result folder | `TC_{ID}_{PASS\|FAIL}/` | `TC_001_PASS/` |
| Bug file | `BUG-{ID}_{Pascal-Description}.md` | `BUG-001_Login-Timeout.md` |
| Script config | `playwright.config.ts` | per Repo folder |
| Script file | `{Feature}.spec.ts` | `Login.spec.ts` |
| Archive folder | `_archive/` | inside feature folder |

> **`execute-test` flow naming (khác các dòng trên):** `execute-flow`/`script-sync` không dùng `F-{3-digit}_{Pascal-Case}` — chúng thao tác trên TC file theo `ScreenID` (functionId rút gọn từ ticket, vd `AD10`), nên feature folder dưới `05.Scripts/`, `02.Reports/`, `06.Bugs/`, `04.Evidence/` dùng `featureDir = {ScreenID}_{Screen-Name-kebab-case}` (vd `AD10_create-product`), và script file là `{ScreenID}.spec.ts` (vd `AD10.spec.ts`) chứ không phải `{Feature}.spec.ts`. Xem `execute-flow` SKILL.md.

---

## Gate → Folder Mapping

### 1. Quy trình Tạo Test Case (`create-testcase`)

| Gate | Output | Folder |
|---|---|---|
| Gate 1 | Phân tích yêu cầu & Đánh giá rủi ro | `07.AI-Artifacts/[functionId]_01_Requirement_Analysis_Result.md` |
| Gate 2 | Xây dựng kịch bản (Scenarios) | `07.AI-Artifacts/[functionId]_02_Test_Scenarios_Result.md` |
| Gate 3 | Thiết kế Test Case chi tiết (Draft) | `07.AI-Artifacts/[functionId]_03_Test_Cases_Draft_Result.md` |
| Gate 4 | Review & Tối ưu hóa (TestCase chính thức) | `01.Testcases/[Feature]/[functionId]_TestCase.md` & `07.AI-Artifacts/[functionId]_04_Test_Cases_Final_Result.md` |

### 2. Quy trình Thực thi Test (`execute-test`)

| Gate | Output | Folder |
|---|---|---|
| Gate 1 | Chuẩn bị & Lập kế hoạch thực thi | (Console output / Work Plan) |
| 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`) |
| 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}/` |
| Gate 4 | Báo cáo test & Log bug | `02.Reports/[Repo]/[Feature]/run-{N}/testreport.md` |

---

## Rules

- Không tự sửa template — template nằm trong shared repo riêng
- Lưu testcase và kết quả lên GitLab **sau khi Gate 4 được APPROVED**
- Khi retest: tạo subfolder `run-{N+1}/` mới trong Evidence & Reports — không ghi đè cũ
- `05.Scripts/` là 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`
- `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
- **`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.
- `07.AI-Artifacts/` là working docs của AI — không phải tài liệu chính thức
