spec-lite 1.2.1 → 1.3.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.
@@ -65,13 +65,14 @@ Nếu `prd.md` chưa có → dừng, yêu cầu chạy `/spec-prd` trước.
65
65
 
66
66
  Dùng khi onboarding một project đã có code vào SDD. Mục tiêu: extract main artifacts từ codebase hiện có, sau đó chuyển vào **Integration Pipeline** để implement.
67
67
 
68
- **Thứ tự bắt buộc:** `init` → `component` → `feature`
68
+ **Thứ tự bắt buộc:** `init` → `component` → `feature` → `tsd` *(tùy chọn — bootstrap test coverage tracking)*
69
69
 
70
70
  | Command | Scan | Reads | Writes |
71
71
  | --- | --- | --- | --- |
72
72
  | `/spec-brownfield-init [path]` | tech stack, README, auth, infra | attachments | `prd.md` *(no indexes)*, `domain.md` *(glossary only)*, `sad.md` |
73
73
  | `/spec-brownfield-component [path]` | module dirs, service/controller/entity files | `prd.md`, `domain.md` | `component/{C-XXX}-*/crd.md + cdd.md`; update `prd.md` Component Index; cascade Shared Entities → `domain.md` |
74
74
  | `/spec-brownfield-feature [path]` | use cases, routes, test files | `prd.md`, `domain.md`, `component/*/crd.md` | `feature/{F-XXX}-*/frd.md + fdd.md`; update `prd.md` Feature Index |
75
+ | `/spec-tsd [F-XXX]` | — *(không scan code, derive 100% từ frd)* | `feature/{F-XXX}-*/frd.md`, `fdd.md` *(optional)* | `feature/{F-XXX}-*/tsd.md` |
75
76
 
76
77
  ### Phân chia trách nhiệm
77
78
 
@@ -143,6 +144,24 @@ Component Index và Feature Index **để placeholder** — sẽ được điề
143
144
 
144
145
  ---
145
146
 
147
+ ### `/spec-tsd [F-XXX]`
148
+
149
+ **Mục tiêu:** Bootstrap `tsd.md` (Test Spec Document) cho một feature trực tiếp từ frd.md — mechanical derive Test Scenarios + Test Cases. KHÔNG cần integration.
150
+
151
+ **Khi nào dùng:**
152
+ - **Brownfield onboarding** — sau `/spec-brownfield-feature` đã sinh frd.md, chạy `/spec-tsd` cho từng feature để có test coverage tracking từ ngày 1.
153
+ - **Greenfield deferred** — feature đã có frd.md từ lâu nhưng tsd.md chưa được tạo.
154
+ - **Ad-hoc rebuild** — tsd drift khỏi frd, regenerate fresh.
155
+
156
+ **Khi nào KHÔNG dùng:**
157
+ - Có integration cascade từ spec.md → frd → muốn cập nhật tsd theo changeset → dùng `/spec-test` (preserve ID stable).
158
+
159
+ **Derivation:** mechanical 1:1 từ frd — mỗi Flow → TS, mỗi US/AC → Functional TC, mỗi VR → ≥1 positive + 1+ negative Validation TC, mỗi FAC → Feature AC TC. Priority deterministic theo US Priority + FAC group. KHÔNG interview.
160
+
161
+ **Cảnh báo overwrite:** nếu tsd.md đã tồn tại, skill hỏi confirm rõ ràng — regenerate sẽ reassign IDs từ 001 và làm vỡ test code references nếu có.
162
+
163
+ ---
164
+
146
165
  ### Thứ tự thực hiện
147
166
 
148
167
  ```
@@ -155,6 +174,9 @@ Component Index và Feature Index **để placeholder** — sẽ được điề
155
174
  /spec-brownfield-feature [path]
156
175
 
157
176
 
177
+ /spec-tsd [F-XXX] (tùy chọn — chạy cho mỗi feature để bootstrap tsd.md)
178
+
179
+
158
180
  (fill in NEEDS_CLARIFY items khi có thêm context)
159
181
 
160
182
 
@@ -171,6 +193,7 @@ Sau khi main artifacts đã sẵn sàng (từ greenfield hoặc brownfield), m
171
193
  | --- | --- | --- |
172
194
  | `/spec-new [requirement]` | `prd.md`, `domain.md`, frd(s), crd(s) | `specs/integrations/{slug}/spec.md` |
173
195
  | `/spec-tech [number]` | `sad.md`, `domain.md`, cdd(s), fdd(s), `spec.md` | `specs/integrations/{slug}/tech.md` |
196
+ | `/spec-test [number]` | `spec.md`, frd(s), tsd(s), `tech.md` *(optional)* | `specs/integrations/{slug}/test.md`, `feature/{F-XXX}/tsd.md` |
174
197
  | `/plan` | `spec.md`, `tech.md`, `domain.md` | `plan.md`, `todo.md` |
175
198
  | `/build` | `plan.md`, `todo.md` | *(source code)* |
176
199
  | `/review-integration` | `spec.md`, `tech.md`, `plan.md`, `todo.md`, *(source code)* | *(findings report)* |
@@ -212,6 +235,30 @@ Context load: `spec.md` + `sad.md` + `domain.md` + `cdd.md` (cho mỗi component
212
235
 
213
236
  ---
214
237
 
238
+ ### `/spec-test [number]`
239
+
240
+ Tạo `specs/integrations/{slug}/test.md` cho một integration. Chạy bởi **QC** sau khi `spec.md` đã được approve. **Song song / độc lập** với `/spec-tech` — cả hai chỉ phụ thuộc `spec.md`. Không có thứ tự bắt buộc giữa chúng.
241
+
242
+ **Luôn hiển thị danh sách tất cả integrations** trong `specs/integrations/`, đánh dấu `✓` những cái đã có `test.md`. Nếu có argument → chọn luôn không cần hiển thị.
243
+
244
+ **Gate check:** spec.md phải `approved` + `features:` non-empty. Integration có `features: []` (thuần component) → dừng vì component-level `tsd` không tồn tại trong kit này.
245
+
246
+ Context load: `spec.md` + `frd.md` (cho mỗi feature — source của TC) + `tsd.md` (cho mỗi feature nếu tồn tại, để diff và assign next ID) + `tech.md` *(optional, hint env / data set / NFR threshold)*.
247
+
248
+ **KHÔNG interview** — agent **mechanical derive** TC từ frd.md:
249
+ - mỗi Flow → 1 Test Scenario (`TS-F{NNN}-{seq}`)
250
+ - mỗi US AC → 1 Functional TC
251
+ - mỗi VR → 1 positive + 1+ negative Validation TC
252
+ - mỗi FAC → 1 Feature AC TC (theo nhóm e2e / consistency / NFR / data & migration)
253
+
254
+ Priority deterministic: US Priority Must/Should/Could → P0/P1/P2 (TC cover US/AC); VR → inherit max priority của Refs; FAC e2e/security/data → P0, consistency/perf/a11y → P1.
255
+
256
+ **Cascade Proposals** đề xuất delta cho mỗi `feature/{F-XXX}/tsd.md` qua Changes blocks với markers `[NEW]/[MODIFY {field}]/[REMOVE]`. Feature no-delta → **bỏ block hoàn toàn**, ghi `no-op` trong Cascade Summary.
257
+
258
+ QC review: override priority defaults, fill placeholders (env / data / OOS / strategy), add extra edge cases ngoài AC/VR nếu thấy cần. Sau confirm → auto-cascade ghi tsd.md.
259
+
260
+ ---
261
+
215
262
  ### `/plan`
216
263
 
217
264
  Tạo `plan.md` và `todo.md` từ `spec.md` + `tech.md`. Là SDD wrapper quanh `planning-and-task-breakdown`.
@@ -288,21 +335,77 @@ Di chuyển integration đã hoàn thành hoặc không còn active từ `specs/
288
335
 
289
336
  ```
290
337
  /spec-new [requirement]
291
- (human review + apply cascade proposals + approve)
292
-
293
- /spec-tech
294
- (human review + apply cascade proposals + approve)
338
+ (human review + auto-cascade frd / crd / prd / domain / sad)
295
339
 
296
- /plan
297
- (human approve)
298
-
299
- /build ←──────────────┐
300
-
301
- /review-integration │ (nếu Critical/Important)
302
- │ │
303
- [approve] ──────────┘ (nếu Suggestion only)
304
-
305
- /archive (khi integration Done, dọn dẹp khỏi integrations/)
340
+ ▼ (spec.md approved)
341
+ ┌───────────────────────┬───────────────────────┐
342
+ DEV branch │ QC branch (song song) │
343
+ ▼ ▼
344
+ /spec-tech /spec-test
345
+ (review + cascade (review + cascade
346
+ → cdd / fdd / sad) → tsd)
347
+ │ │
348
+ └───────────┬───────────┘
349
+ (tech.md approved /plan KHÔNG đợi test.md)
350
+
351
+ /plan
352
+ (human approve)
353
+
354
+ /build ←──────────────┐
355
+ │ │
356
+ /review-integration │ (nếu Critical/Important)
357
+ │ │
358
+ [approve] ─────────────────┘ (nếu Suggestion only)
359
+
360
+ /archive
361
+ ```
362
+
363
+ > **Lưu ý:** `/spec-tech` (DEV) và `/spec-test` (QC) chạy song song / độc lập — cả hai chỉ phụ thuộc `spec.md` approved. `/plan` chỉ chờ `tech.md` (test tasks tự QC manage trong test framework, không phải plan.md).
364
+
365
+ ---
366
+
367
+ ## Project-level review
368
+
369
+ Khác với `/review-integration` (chạy sau `/build` cho một integration cụ thể), `/review-everything` review toàn bộ codebase đối chiếu với main artifacts.
370
+
371
+ | Command | Reads | Writes |
372
+ | --- | --- | --- |
373
+ | `/review-everything` | `prd.md`, `domain.md`, `sad.md`, *(source code)* | `specs/integrations/{NNN}-{slug}/review-findings.md` *(qua /spec-new)* |
374
+
375
+ ### `/review-everything`
376
+
377
+ Review codebase ở project level theo năm trục của `code-review-and-quality`. Spawn 5 subagent song song — cùng context (prd / domain / sad), khác axis (Correctness / Readability / Architecture / Security / Performance).
378
+
379
+ **Output** — findings table phân loại theo severity scale của `code-review-and-quality`: Critical, Required, Optional/Consider, Nit, FYI.
380
+
381
+ **Sau khi có findings**, hỏi user severity tier muốn xử lý:
382
+
383
+ - Critical only
384
+ - Critical + Required (must-fix)
385
+ - Critical + Required + Optional
386
+ - Tất cả (kèm Nit + FYI)
387
+ - Bỏ qua — chỉ xem findings
388
+
389
+ Nếu user chọn fix → gom selected findings thành raw requirement, invoke `/spec-new` với ARGUMENT đó. Integration được tạo và xử lý như integration thường (`/spec-tech` → `/plan` → `/build`).
390
+
391
+ `review-findings.md` (full snapshot, gồm cả deferred) được ghi vào `specs/integrations/{NNN}-{slug}/` để traceability.
392
+
393
+ **Khi dùng:**
394
+
395
+ - Health-check định kỳ, audit trước release lớn
396
+ - Cross-team review hoặc onboarding owner mới
397
+ - Khi nghi ngờ drift / vi phạm guardrails tích luỹ qua nhiều integration
398
+
399
+ ```
400
+ /review-everything
401
+
402
+ [findings table]
403
+
404
+ user chọn severity tier
405
+
406
+ (nếu fix) /spec-new ←─── raw requirement (gom từ findings)
407
+
408
+ /spec-tech → /plan → /build (integration bình thường)
306
409
  ```
307
410
 
308
411
  ---
@@ -0,0 +1,166 @@
1
+ ---
2
+ id: "{id}"
3
+ slug: "{slug}"
4
+ title: "{title}"
5
+ features: []
6
+ status: draft
7
+ created: {YYYY-MM-DD}
8
+ referenced_by:
9
+ - conventions.md > 4. Integration Artifacts > 4.7 test.md > Cấu trúc
10
+ - skills/spec-test/SKILL.md > Process > Bước 4: Write — sinh draft
11
+ ---
12
+
13
+ ## Context
14
+
15
+ <!-- Tóm tắt ngắn các thông tin quan trọng từ context đã load (spec.md, tech.md, frd.md, current tsd.md của các feature touched), để file self-contained. -->
16
+
17
+ ## Test Strategy
18
+
19
+ <!--
20
+ Strategy cho integration này — KHÔNG lặp lại Strategy chung của feature.
21
+ Chỉ ghi delta hoặc nhấn mạnh phần đặc thù integration:
22
+ - Loại test ưu tiên (functional / validation / FAC / cross-story consistency / NFR).
23
+ - Environments / data set / fixture đặc thù.
24
+ - Risk areas (vd: data migration cần backfill verify, integration đụng auth flow → security regression).
25
+ -->
26
+
27
+ ### Approach
28
+
29
+ - {bullet ngắn}
30
+
31
+ ### Environments
32
+
33
+ | Env | Mục đích | Data set | Ghi chú |
34
+ | --- | --- | --- | --- |
35
+ | {dev / staging / prod-like} | {functional / E2E / load} | {seed / anonymized prod} | ... |
36
+
37
+ ## Changes
38
+
39
+ <!--
40
+ test.md = changeset patch áp lên feature tsd.md(s). Mỗi block dưới đây tương ứng 1 feature bị touched.
41
+ Lặp block cho mỗi feature trong `features:` frontmatter mà có delta TC.
42
+
43
+ **Khi nào BỎ block của 1 feature:**
44
+ - Diff giữa frd hiện tại và tsd.md hiện tại của feature đó = empty (frd không thêm/đổi item nào mà tsd chưa cover).
45
+ - Bỏ block hoàn toàn, ghi `no-op` cho feature đó trong Cascade Summary để minh bạch.
46
+
47
+ **Operation:**
48
+ - `create` — feature/{F-XXX}/tsd.md chưa tồn tại. Nội dung đầy đủ theo template gốc, mọi TS/TC implicit [NEW] (không cần marker).
49
+ - `update` — feature/{F-XXX}/tsd.md đã tồn tại. Chỉ liệt kê TS/TC bị ảnh hưởng. Mỗi item có marker:
50
+ - `[NEW]` — TS/TC chưa có trong tsd hiện tại
51
+ - `[MODIFY {field}]` — TS/TC đã có, đang đổi field cụ thể (ví dụ `[MODIFY steps]`, `[MODIFY expected]`, `[MODIFY priority]`, `[MODIFY covers]`)
52
+ - `[REMOVE]` — TS/TC đã có, sẽ bị xóa (ID retire — không tái sử dụng)
53
+
54
+ **Format reference:** dùng đúng format của template gốc — KHÔNG duplicate skeleton ở đây. `templates/main/feature/tsd-template.md` là single source of truth cho format.
55
+
56
+ **ID assignment:** agent đọc tsd.md hiện tại của feature để xác định next ID:
57
+ - `TS-F{NNN}-{seq}` cho Test Scenarios
58
+ - `TC-F{NNN}-{seq}` cho Test Cases (Functional, Validation, Feature AC dùng chung sequence — không reset theo loại)
59
+ - ID **stable** — không tái sử dụng khi [REMOVE], không renumber khi [MODIFY].
60
+
61
+ **Auto-cascade:** sau khi human approve test.md, agent tự apply tất cả Changes blocks vào feature tsd.md. Integration test.md được giữ như PR record bất biến.
62
+ -->
63
+
64
+ ### feature/{F-XXX}-{feature-slug}/tsd.md *(lặp block cho mỗi feature trong `features:` mà có delta TC; bỏ block nếu no-delta)*
65
+
66
+ **Operation:** create | update
67
+ **Format reference:** [tsd-template.md](../../templates/main/feature/tsd-template.md)
68
+
69
+ <!--
70
+ operation=create → nội dung đầy đủ theo tsd-template.md (Overview, Test Strategy, Test Scenarios, Functional TCs, Validation TCs, Feature AC TCs, Test Data, Traceability Matrix, Out of Scope, Dependencies).
71
+ operation=update → chỉ liệt kê TS/TC bị ảnh hưởng, mỗi item có marker, và **bắt buộc update Traceability Matrix** rows tương ứng.
72
+
73
+ Ví dụ operation=update:
74
+
75
+ #### Test Scenarios
76
+
77
+ ##### TS-F001-003 [NEW]: Refund flow — happy + edge
78
+
79
+ - **Flow ref:** `frd.md > Flow 3: Refund`
80
+ - **Preconditions:** order đã thanh toán xong, refund window còn hạn
81
+ - **Postconditions:** số tiền hoàn về phương thức thanh toán gốc
82
+ - **Paths:**
83
+ - Happy: order paid → refund click → confirm → refunded
84
+ - Edge: order paid → refund click → past window → blocked
85
+ - **Test cases:** `TC-F001-022`, `TC-F001-023`
86
+
87
+ #### Functional Test Cases
88
+
89
+ ##### TC-F001-022 [NEW]: Refund order trong window
90
+
91
+ | Field | Value |
92
+ | --- | --- |
93
+ | **Type** | Functional — positive |
94
+ | **Priority** | P0 |
95
+ | **Covers** | `US-F001-005`, `AC-F001-012` |
96
+ | **Scenario** | `TS-F001-003` |
97
+ | **Preconditions** | order paid 1h trước |
98
+
99
+ **Steps:**
100
+
101
+ 1. Login customer
102
+ 2. Vào order detail
103
+ 3. Click "Refund"
104
+ 4. Confirm refund
105
+
106
+ **Expected:**
107
+
108
+ - Refund record được tạo với status `processing`
109
+ - Email notification gửi tới customer
110
+
111
+ ##### TC-F001-008 [MODIFY expected]
112
+ - Expected: 2-3 phút → 30s (sau khi tech.md tối ưu queue)
113
+
114
+ ##### TC-F001-015 [REMOVE]
115
+ - Lý do: superseded by TC-F001-022 (cover same AC, scope hẹp hơn)
116
+
117
+ #### Validation Test Cases
118
+
119
+ | TC ID | Covers VR | Field | Input | Expected | Polarity | Op |
120
+ | --- | --- | --- | --- | --- | --- | --- |
121
+ | `TC-F001-030` | `VR-F001-008` | `refund_reason` | `"Customer changed mind"` | accept | positive | NEW |
122
+ | `TC-F001-031` | `VR-F001-008` | `refund_reason` | `"abc"` | reject — min length | negative | NEW |
123
+
124
+ #### Feature AC Test Cases
125
+
126
+ ##### TC-F001-040 [NEW]: E2E checkout + refund
127
+
128
+ | Field | Value |
129
+ | --- | --- |
130
+ | **Type** | Feature AC — e2e |
131
+ | **Priority** | P0 |
132
+ | **Covers** | `FAC-F001-004` |
133
+ | **Spans** | `US-F001-001`, `US-F001-005` |
134
+
135
+ **Steps:** ...
136
+ **Expected:** ...
137
+
138
+ #### Traceability Matrix
139
+
140
+ Bổ sung row cho mọi item mới + cập nhật row cho item bị [MODIFY]. KHÔNG xóa row của [REMOVE] — đánh dấu retire.
141
+
142
+ | FRD Item | Type | Covered by | Status | Op |
143
+ | --- | --- | --- | --- | --- |
144
+ | `US-F001-005` | US | `TC-F001-022` | ✅ | NEW |
145
+ | `AC-F001-012` | Story AC | `TC-F001-022` | ✅ | NEW |
146
+ | `VR-F001-008` | VR | `TC-F001-030`, `TC-F001-031` | ✅ | NEW |
147
+ | `FAC-F001-004` | Feature AC | `TC-F001-040` | ✅ | NEW |
148
+ | Flow 3 | Flow | `TS-F001-003` | ✅ | NEW |
149
+ -->
150
+
151
+ ## Out of Scope
152
+
153
+ <!-- Những gì KHÔNG được test trong integration này và lý do (vd: thuộc layer khác như infra audit, NFR đã verify ở integration trước, ...) -->
154
+
155
+ ## Open Questions
156
+
157
+ <!-- Các điểm còn mơ hồ cần clarify trước khi proceed. Xóa section nếu không có. -->
158
+
159
+ ## Cascade Summary
160
+
161
+ <!-- Bảng tóm tắt để reviewer scan nhanh trước khi approve. Liệt kê **tất cả** feature trong `features:` — feature no-delta ghi operation `no-op`. -->
162
+
163
+ | Artifact | Operation | Summary |
164
+ | --- | --- | --- |
165
+ | `feature/F-XXX-{slug}/tsd.md` | create / update | {ngắn: +N TS, +M TC, modify TC-F001-008, remove TC-F001-015} |
166
+ | `feature/F-YYY-{slug}/tsd.md` | no-op | frd không đổi, tsd hiện tại đã cover full |
@@ -27,6 +27,8 @@ Mọi thay đổi structure ở file này tự động propagate qua Changes blo
27
27
  {Mô tả các luồng thao tác của user để hoàn thành mục tiêu của feature này.}
28
28
  {Mỗi flow là một Mermaid flowchart riêng, bao gồm happy case và tất cả edge cases quan trọng.}
29
29
 
30
+ Flow numbering **stable** — không renumber khi xóa flow. Nếu xóa Flow 1, Flow 2 giữ nguyên số (không tái sử dụng số 1).
31
+
30
32
  ### Flow 1: {Tên luồng chính}
31
33
 
32
34
  ```mermaid
@@ -46,19 +48,32 @@ flowchart TD
46
48
  A(["Điểm bắt đầu"]) --> B["..."]
47
49
  ```
48
50
 
49
- ## Feature-level Acceptance Criteria
51
+ ## Feature Acceptance Criteria
50
52
 
51
- Criteria áp dụng cho toàn bộ feature — không gắn với story cụ thể (ví dụ: performance, security, accessibility).
52
- AC ID format: `AC-F{NNN}-{seq}` — đánh số tăng dần toàn feature (không reset giữa sections).
53
+ Criteria áp dụng cho **toàn bộ feature**phần Story AC không cover được. Mọi Feature AC phải test được pass/fail.
53
54
 
54
- - `AC-{F_ID}-001`
55
- - **Given** {precondition}
55
+ Thường gồm 4 nhóm:
56
+ - **End-to-end liên story** — full happy path đi qua nhiều story.
57
+ - **Cross-story consistency** — UI/behavior đồng nhất giữa các màn trong feature.
58
+ - **Non-functional** — performance, accessibility, browser support, i18n, security.
59
+ - **Data & migration** — backfill, schema migration, không mất data cũ.
60
+
61
+ > Out of scope: release readiness (runbook/rollout/legal sign-off) và success metric/KPI post-release — đặt ở artifact khác (`tech.md`, `sad.md`, hoặc PMO checklist).
62
+
63
+ Feature AC ID format: `FAC-F{NNN}-{seq}` — counter **độc lập** với Story AC (`AC-F{NNN}-{seq}`). ID **stable** — không tái sử dụng seq khi xóa, không renumber.
64
+
65
+ Format: **Given/When/Then bắt buộc** — kể cả NFR / consistency. **Then phải đo được**: ngưỡng cụ thể HOẶC danh sách item so sánh.
66
+
67
+ - `FAC-{F_ID}-001`
68
+ - **Given** {precondition đo được}
56
69
  - **When** {action}
57
- - **Then** {expected outcome}
70
+ - **Then** {outcome có threshold hoặc danh sách cụ thể, không vague}
58
71
 
59
72
  ## User Stories
60
73
 
61
- US ID format: `US-F{NNN}-{seq}` — đánh số tăng dần toàn feature.
74
+ US ID format: `US-F{NNN}-{seq}` — đánh số tăng dần toàn feature. ID **stable** — không tái sử dụng seq khi xóa, không renumber.
75
+
76
+ Story AC ID format: `AC-F{NNN}-{seq}` — đánh số tăng dần toàn feature (không reset giữa các story). ID **stable** — không tái sử dụng seq khi xóa, không renumber.
62
77
 
63
78
  ### US-{F_ID}-001: {Story title}
64
79
 
@@ -0,0 +1,220 @@
1
+ ---
2
+ id: tsd-{feature}
3
+ type: tsd
4
+ status: draft
5
+ owner: "{QC}"
6
+ feature_id: "{Feature ID — match frd.md}"
7
+ frd_ref: "feature/{F-XXX}-{slug}/frd.md"
8
+ referenced_by:
9
+ - conventions.md > 3. Main Artifacts > 3.3 Feature level > tsd.md > Cấu trúc
10
+ ---
11
+
12
+ <!--
13
+ Canonical format cho feature/{F-XXX}-{slug}/tsd.md.
14
+ Sinh từ frd.md — mỗi AC / VR / Flow phải có ít nhất 1 test case cover.
15
+ Traceability Matrix ở cuối là source of truth để kiểm tra coverage trước khi đóng feature.
16
+
17
+ TSD chỉ tồn tại ở FEATURE level — không tách tsd riêng cho component.
18
+ Component là internal building block; contract của component được verify gián tiếp qua TC ở đây
19
+ và qua unit test trong code (không phải spec artifact).
20
+ -->
21
+
22
+ # Test Spec: {Feature Name}
23
+
24
+ ## Overview
25
+
26
+ {Phạm vi tsd này — feature gì, các luồng / AC / VR chính cần verify, trong 2-3 câu.}
27
+
28
+ ## Test Strategy
29
+
30
+ ### Approach
31
+
32
+ - **Functional**: verify từng US / Story AC theo happy + edge.
33
+ - **Validation**: derive 1:1 từ Verification Rules.
34
+ - **Flow-based (E2E)**: chạy theo Mermaid flows trong frd.
35
+ - **Feature AC**: cover các Feature AC — e2e liên story, cross-story consistency, NFR, data & migration.
36
+
37
+ ### Environments
38
+
39
+ | Env | Mục đích | Data set | Ghi chú |
40
+ | --- | --- | --- | --- |
41
+ | {dev / staging / prod-like} | {functional / E2E / load} | {seed / anonymized prod} | ... |
42
+
43
+ ## Test Scenarios
44
+
45
+ Mỗi scenario gắn với 1 flow trong `frd.md > User Flows`. Scenario mô tả end-to-end path; test case chi tiết liệt kê ở section bên dưới.
46
+
47
+ TS ID format: `TS-F{NNN}-{seq}` — đánh số tăng dần toàn feature. ID **stable** — đã assign rồi giữ nguyên kể cả khi xóa (không tái sử dụng seq, không renumber).
48
+
49
+ ### TS-{F_ID}-001: {Tên — match Flow 1 trong frd}
50
+
51
+ - **Flow ref:** `frd.md > Flow 1: {tên}`
52
+ - **Preconditions:** {state trước khi chạy}
53
+ - **Postconditions:** {state sau khi pass}
54
+ - **Paths:**
55
+ - Happy: A → B → C(happy) → D → F
56
+ - Edge: A → B → C(edge) → E → G
57
+ - **Test cases:** `TC-{F_ID}-001`, `TC-{F_ID}-002`, ...
58
+
59
+ ---
60
+
61
+ ### TS-{F_ID}-002: {Tên — match Flow 2 nếu có}
62
+
63
+ ...
64
+
65
+ ## Functional Test Cases
66
+
67
+ Cover User Stories và Acceptance Criteria trong frd.
68
+
69
+ TC ID format: `TC-F{NNN}-{seq}` — đánh số tăng dần toàn feature. ID **stable** (không tái sử dụng seq khi xóa, không renumber). Nếu xóa TC → ID đó retire, seq mới tiếp tục tăng từ max.
70
+
71
+ ### TC-{F_ID}-001: {Title ngắn — verb-first}
72
+
73
+ | Field | Value |
74
+ | --- | --- |
75
+ | **Type** | Functional — positive / negative |
76
+ | **Priority** | P0 / P1 / P2 |
77
+ | **Covers** | `US-{F_ID}-001`, `AC-{F_ID}-001` |
78
+ | **Scenario** | `TS-{F_ID}-001` |
79
+ | **Preconditions** | ... |
80
+
81
+ **Steps:**
82
+
83
+ 1. {action}
84
+ 2. {action}
85
+ 3. {action}
86
+
87
+ **Expected:**
88
+
89
+ - {observable outcome 1}
90
+ - {observable outcome 2}
91
+
92
+ **Test data:** {ref Test Data section hoặc inline literal}
93
+
94
+ ---
95
+
96
+ ### TC-{F_ID}-002: ...
97
+
98
+ ## Validation Test Cases
99
+
100
+ Derive 1:1 từ Verification Rules trong frd. Mỗi `VR-F{NNN}-{seq}` cần ít nhất:
101
+ - 1 positive (rule pass)
102
+ - 1+ negative — mỗi nhánh fail là 1 case riêng (vd VR "email format" → 1 case cho missing `@`, 1 case cho missing domain, ...)
103
+
104
+ Form bảng để dễ scan; case phức tạp có thể tách ra block riêng như Functional TC.
105
+
106
+ | TC ID | Covers VR | Field | Input | Expected | Polarity |
107
+ | --- | --- | --- | --- | --- | --- |
108
+ | `TC-{F_ID}-010` | `VR-{F_ID}-001` | `email` | `"user@example.com"` | accept | positive |
109
+ | `TC-{F_ID}-011` | `VR-{F_ID}-001` | `email` | `""` | reject — required | negative |
110
+ | `TC-{F_ID}-012` | `VR-{F_ID}-001` | `email` | `"abc"` | reject — invalid format | negative |
111
+
112
+ ## Feature AC Test Cases
113
+
114
+ Cover Feature Acceptance Criteria (`FAC-*`) trong frd. Feature AC trong frd đã ở format G/W/T → TC ở đây dịch 1:1: Given → Preconditions, When → Steps, Then → Expected.
115
+
116
+ ### TC-{F_ID}-040: {Title — e2e liên story}
117
+
118
+ | Field | Value |
119
+ | --- | --- |
120
+ | **Type** | Feature AC — e2e |
121
+ | **Priority** | P0 / P1 / P2 |
122
+ | **Covers** | `FAC-{F_ID}-001` |
123
+ | **Spans** | `US-{F_ID}-001`, `US-{F_ID}-002`, `US-{F_ID}-003` |
124
+ | **Preconditions** | account mới chưa onboard |
125
+
126
+ **Steps:**
127
+
128
+ 1. Đăng ký account mới
129
+ 2. Verify email qua link
130
+ 3. Hoàn thành onboarding form
131
+ 4. Thực hiện first transaction
132
+
133
+ **Expected:**
134
+
135
+ - Toàn bộ flow chạy trong 1 session, không cần support intervene
136
+ - State persist đúng giữa các step (refresh không mất tiến độ)
137
+
138
+ ---
139
+
140
+ ### TC-{F_ID}-041: {Title — consistency}
141
+
142
+ | Field | Value |
143
+ | --- | --- |
144
+ | **Type** | Feature AC — consistency |
145
+ | **Priority** | P1 |
146
+ | **Covers** | `FAC-{F_ID}-002` |
147
+ | **Preconditions** | feature đã deploy lên test env, 3 màn Register / Profile / Admin Create accessible |
148
+
149
+ **Steps:**
150
+
151
+ 1. Trigger empty `email` validation ở Register
152
+ 2. Trigger empty `email` validation ở Profile
153
+ 3. Trigger empty `email` validation ở Admin Create
154
+ 4. Trigger invalid format `"abc"` ở cả 3 màn
155
+
156
+ **Expected:**
157
+
158
+ - 3 message ở step 1-3 identical (cùng text, cùng style)
159
+ - 3 message ở step 4 identical
160
+
161
+ ---
162
+
163
+ ### TC-{F_ID}-050: {Title — NFR perf}
164
+
165
+ | Field | Value |
166
+ | --- | --- |
167
+ | **Type** | Feature AC — performance |
168
+ | **Priority** | P0 |
169
+ | **Covers** | `FAC-{F_ID}-003` |
170
+ | **Preconditions** | env perf-test, dataset baseline đã load |
171
+
172
+ **Steps:**
173
+
174
+ 1. Chạy load test (k6 / JMeter) profile 100 RPS sustained 5 phút lên `/login`
175
+ 2. Đọc p95 latency từ summary report
176
+
177
+ **Expected:**
178
+
179
+ - p95 ≤ 500ms
180
+ - Error rate ≤ 0.1%
181
+
182
+ ## Test Data
183
+
184
+ | Data set | Mục đích | Nguồn | Refresh |
185
+ | --- | --- | --- | --- |
186
+ | `seed_users` | functional positive | fixture / factory | mỗi run |
187
+ | `boundary_inputs` | validation edges | inline trong TC | n/a |
188
+
189
+ ## Traceability Matrix
190
+
191
+ **Source of truth** để verify coverage trước khi đóng feature. Mỗi item từ frd phải xuất hiện. Gap → đánh ❌ và mô tả rõ ở phần "Gaps" bên dưới.
192
+
193
+ | FRD Item | Type | Covered by | Status |
194
+ | --- | --- | --- | --- |
195
+ | Flow 1 | Flow | `TS-{F_ID}-001` | ✅ |
196
+ | `US-{F_ID}-001` | US | `TC-{F_ID}-001`, `TC-{F_ID}-002` | ✅ |
197
+ | `AC-{F_ID}-001` | Story AC | `TC-{F_ID}-001` | ✅ |
198
+ | `VR-{F_ID}-001` | VR | `TC-{F_ID}-010`, `TC-{F_ID}-011`, `TC-{F_ID}-012` | ✅ |
199
+ | `FAC-{F_ID}-001` | Feature AC | `TC-{F_ID}-040` | ✅ |
200
+ | `FAC-{F_ID}-002` | Feature AC | `TC-{F_ID}-041` | ✅ |
201
+ | `FAC-{F_ID}-003` | Feature AC | `TC-{F_ID}-050` | ✅ |
202
+ | `AC-{F_ID}-00X` | Story AC | — | ❌ chưa có TC |
203
+
204
+ ### Gaps
205
+
206
+ {Liệt kê item ❌ kèm lý do tạm hoãn / blocker — empty nếu coverage đầy đủ.}
207
+
208
+ ## Out of Scope
209
+
210
+ - {những gì tsd này KHÔNG cover — lý do (vd: thuộc layer khác như infra/security audit, đã verify ở môi trường khác, ...)}
211
+
212
+ ## Dependencies
213
+
214
+ ### FRD reference
215
+
216
+ - `frd.md` của feature này — mọi ID (`US-`, `AC-`, `VR-`, Flow) phải match.
217
+
218
+ ### Components Used (input only)
219
+
220
+ Tham chiếu `frd.md > Components Used` để hiểu contract của các component được feature này dùng. Behavior của component được verify **gián tiếp** qua các TC ở đây — không tách tsd riêng cho component.
@@ -1,60 +0,0 @@
1
- ---
2
- id: "003-assign-todo"
3
- slug: "assign-todo"
4
- title: "Assign Todo — Test Plan"
5
- features: ["F-004"]
6
- status: draft
7
- created: 2026-04-21
8
- ---
9
-
10
- ## Test Strategy
11
-
12
- Approach tổng quan: test pyramid distribution, environment setup, fixtures.
13
-
14
- ## AC Coverage Matrix
15
-
16
- | AC ID | Primary Level | Test Case ID(s) | Status |
17
- |-------|--------------|-----------------|--------|
18
- | AC-F004-001 | Component | TC-001 | draft |
19
- | AC-F004-002 | Component | TC-002 | draft |
20
- | ... |
21
-
22
- ## Verification Rules Coverage
23
-
24
- Mỗi rule trong `frd.md > Verification Rules` của feature phải có **≥ 1 positive test case** (input hợp lệ pass) và **≥ 1 negative test case** (input vi phạm rule bị reject). Nếu rule áp dụng ở nhiều layer (client + gateway, xem `fdd.md > Verification Implementation`) → cover từng layer.
25
-
26
- | Rule ID | Layer (từ FDD) | Test Case ID(s) | Status |
27
- |---------|----------------|-----------------|--------|
28
- | VR-F004-001 | service | TC-010 (pos), TC-011 (neg) | draft |
29
- | VR-F004-002 | gateway | TC-012 (neg) | draft |
30
- | ... |
31
-
32
- ## Test Cases
33
-
34
- ### TC-001: Non-owner không thấy assign control
35
- **Verifies:** AC-F004-001 (primary)
36
- **Level:** Component test (TodoModal)
37
- **Setup:**
38
- - Render TodoModal với prop `isOwner: false`
39
- **Steps:**
40
- 1. Mở modal
41
- 2. Query assign control
42
- **Expected:**
43
- - Assign control không có trong DOM
44
- **Negative variants:** —
45
-
46
- ### TC-006: Happy path assign
47
- **Verifies:** AC-F004-006, AC-F004-007 (primary), AC-F004-008 (supporting)
48
- **Level:** E2E (Playwright)
49
- **Setup:**
50
- - Seed: userA, userB
51
- - userA login, tạo todo
52
- **Steps:**
53
- 1. userA mở task detail
54
- 2. Click assign, chọn userB
55
- 3. Confirm
56
- **Expected:**
57
- - Modal hiển thị owner = userB
58
- - Refresh dashboard → card hiển thị userB
59
- **Verification queries:**
60
- - DB: `SELECT * FROM todo_history WHERE todo_id=? AND event_type='ASSIGNED'` → 1 row, payload đúng