@torus-engineering/tas-kit 1.7.0 → 1.9.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.
Files changed (73) hide show
  1. package/.claude/commands/tas-adr.md +33 -29
  2. package/.claude/commands/tas-apitest-plan.md +173 -0
  3. package/.claude/commands/tas-apitest.md +143 -0
  4. package/.claude/commands/tas-bug.md +113 -109
  5. package/.claude/commands/tas-design.md +37 -33
  6. package/.claude/commands/tas-dev.md +128 -115
  7. package/.claude/commands/tas-e2e-mobile.md +155 -0
  8. package/.claude/commands/tas-e2e-web.md +163 -0
  9. package/.claude/commands/tas-e2e.md +102 -0
  10. package/.claude/commands/tas-epic.md +35 -31
  11. package/.claude/commands/tas-feature.md +47 -43
  12. package/.claude/commands/tas-fix.md +51 -47
  13. package/.claude/commands/tas-functest-mobile.md +144 -0
  14. package/.claude/commands/tas-functest-web.md +192 -0
  15. package/.claude/commands/tas-functest.md +76 -0
  16. package/.claude/commands/tas-plan.md +200 -184
  17. package/.claude/commands/tas-prd.md +37 -33
  18. package/.claude/commands/tas-review.md +111 -104
  19. package/.claude/commands/tas-sad.md +43 -39
  20. package/.claude/commands/tas-security.md +81 -80
  21. package/.claude/commands/tas-story.md +91 -87
  22. package/.claude/commands/tas-verify.md +51 -41
  23. package/.claude/rules/common/post-review-agent.md +49 -39
  24. package/.claude/rules/common/testing.md +24 -0
  25. package/.claude/rules/common/token-logging.md +27 -0
  26. package/.claude/rules/csharp/api-testing.md +171 -0
  27. package/.claude/rules/csharp/patterns.md +10 -0
  28. package/.claude/rules/python/patterns.md +10 -0
  29. package/.claude/rules/typescript/patterns.md +10 -0
  30. package/.claude/rules/web/performance.md +9 -0
  31. package/.claude/skills/api-design/SKILL.md +3 -1
  32. package/.claude/skills/{backend-patterns → js-backend-patterns}/SKILL.md +2 -1
  33. package/.claude/skills/tas-implementation-complete/SKILL.md +99 -97
  34. package/.claude/skills/tas-tdd/SKILL.md +123 -82
  35. package/.claude/skills/token-logger/SKILL.md +19 -0
  36. package/.tas/templates/API-Test-Spec.md +400 -0
  37. package/.tas/templates/E2E-Execution-Report.md +198 -0
  38. package/.tas/templates/E2E-Mobile-Spec.md +130 -0
  39. package/.tas/templates/E2E-Report.md +174 -0
  40. package/.tas/templates/E2E-Scenario.md +180 -0
  41. package/.tas/templates/E2E-Web-Spec.md +164 -0
  42. package/.tas/templates/Feature.md +55 -55
  43. package/.tas/templates/Func-Test-Script.md +254 -0
  44. package/.tas/templates/Func-Test-Spec.md +187 -0
  45. package/.tas/templates/SAD.md +274 -274
  46. package/.tas/templates/Story.md +90 -88
  47. package/bin/cli.js +56 -56
  48. package/lib/deleted-files.json +36 -0
  49. package/lib/install.js +213 -176
  50. package/package.json +34 -34
  51. package/.claude/agents/README.md +0 -83
  52. package/.claude/agents/ado-agent.md +0 -39
  53. package/.claude/agents/code-architect.md +0 -62
  54. package/.claude/agents/code-simplifier.md +0 -53
  55. package/.claude/agents/comment-analyzer.md +0 -59
  56. package/.claude/agents/conversation-analyzer.md +0 -57
  57. package/.claude/agents/docs-lookup.md +0 -55
  58. package/.claude/agents/harness-optimizer.md +0 -62
  59. package/.claude/agents/loop-operator.md +0 -56
  60. package/.claude/agents/performance-optimizer.md +0 -78
  61. package/.claude/agents/pr-test-analyzer.md +0 -68
  62. package/.claude/agents/pytorch-build-resolver.md +0 -76
  63. package/.claude/agents/refactor-cleaner.md +0 -70
  64. package/.claude/agents/seo-specialist.md +0 -75
  65. package/.claude/agents/silent-failure-hunter.md +0 -69
  66. package/.claude/agents/type-design-analyzer.md +0 -75
  67. package/.claude/rules/common/agents.md +0 -65
  68. package/.claude/rules/common/coding-style.md +0 -90
  69. package/.claude/rules/common/development-workflow.md +0 -44
  70. package/.claude/rules/common/git-workflow.md +0 -24
  71. package/.claude/rules/common/performance.md +0 -55
  72. package/.claude/skills/agent-harness-construction/SKILL.md +0 -77
  73. package/.claude/skills/agent-introspection-debugging/SKILL.md +0 -157
@@ -1,31 +1,35 @@
1
- # /tas-epic $ARGUMENTS
2
-
3
- Vai trò: PE - Product Engineer
4
- Tạo mới hoặc cập nhật Epic document.
5
-
6
- ## Prerequisite
7
- - docs/prd.md phải tồn tại
8
-
9
- ## Hành động
10
- 1. Cần context từ root/tas.yaml và docs/prd.md
11
- 2. Cần context từ .tas/templates/Epic.md
12
- 3. Xác định chế độ dựa vào $ARGUMENTS:
13
-
14
- ### Chế độ CREATE ($ARGUMENTS là mô tả Epic mới, hoặc không có $ARGUMENTS):
15
- 4. Nếu không có $ARGUMENTS, hỏi user mô tả Epic.
16
- 5. Đọc project.code từ root/tas.yaml. Quét docs/epics/ để xác định số thứ tự.
17
- 6. Tạo thư mục docs/epics/{code}-Epic-{NNN}-{slug}/
18
- 7. Tạo file docs/epics/{code}-Epic-{NNN}-{slug}/{code}-Epic-{NNN}-{slug}.md
19
- 8. Cập nhật `project-status.yaml` theo `.claude/rules/common/project-status.md` — thêm entry vào `epics`.
20
-
21
- ### Chế độ UPDATE ($ARGUMENTS là Epic ID, ví dụ: "Epic-001"):
22
- 4. Tìm thư mục docs/epics/{code}-Epic-001-*/
23
- 5. Cần context từ file Epic hiện tại
24
- 6. Hỏi user cần thay đổi gì (cập nhật scope, thêm feature, đổi status...)
25
- 7. Cập nhật file, thêm changelog
26
- 8. Cập nhật `project-status.yaml` theo `.claude/rules/common/project-status.md` — cập nhật `epics.{EPIC_ID}.status`.
27
-
28
- ## Nguyên tắc
29
- - Mỗi Epic map với một business capability trong PRD
30
- - Epic KHÔNG chứa chi tiết kỹ thuật, chỉ chứa business value
31
- - Ước lượng effort ở mức T-shirt size: S/M/L/XL
1
+ # /tas-epic $ARGUMENTS
2
+
3
+ Vai trò: PE - Product Engineer
4
+ Tạo mới hoặc cập nhật Epic document.
5
+
6
+ ## Prerequisite
7
+ - docs/prd.md phải tồn tại
8
+
9
+ ## Hành động
10
+ 1. Cần context từ root/tas.yaml và docs/prd.md
11
+ 2. Cần context từ .tas/templates/Epic.md
12
+ 3. Xác định chế độ dựa vào $ARGUMENTS:
13
+
14
+ ### Chế độ CREATE ($ARGUMENTS là mô tả Epic mới, hoặc không có $ARGUMENTS):
15
+ 4. Nếu không có $ARGUMENTS, hỏi user mô tả Epic.
16
+ 5. Đọc project.code từ root/tas.yaml. Quét docs/epics/ để xác định số thứ tự.
17
+ 6. Tạo thư mục docs/epics/{code}-Epic-{NNN}-{slug}/
18
+ 7. Tạo file docs/epics/{code}-Epic-{NNN}-{slug}/{code}-Epic-{NNN}-{slug}.md
19
+ 8. Cập nhật `project-status.yaml` theo `.claude/rules/common/project-status.md` — thêm entry vào `epics`.
20
+
21
+ ### Chế độ UPDATE ($ARGUMENTS là Epic ID, ví dụ: "Epic-001"):
22
+ 4. Tìm thư mục docs/epics/{code}-Epic-001-*/
23
+ 5. Cần context từ file Epic hiện tại
24
+ 6. Hỏi user cần thay đổi gì (cập nhật scope, thêm feature, đổi status...)
25
+ 7. Cập nhật file, thêm changelog
26
+ 8. Cập nhật `project-status.yaml` theo `.claude/rules/common/project-status.md` — cập nhật `epics.{EPIC_ID}.status`.
27
+
28
+ ## Nguyên tắc
29
+ - Mỗi Epic map với một business capability trong PRD
30
+ - Epic KHÔNG chứa chi tiết kỹ thuật, chỉ chứa business value
31
+ - Ước lượng effort ở mức T-shirt size: S/M/L/XL
32
+
33
+ ## Bước cuối — Token Log
34
+
35
+ Invoke skill `token-logger`: ghi AI Usage Log vào file Epic đang làm việc.
@@ -1,43 +1,47 @@
1
- # /tas-feature $ARGUMENTS
2
-
3
- Vai trò: PE - Product Engineer
4
- Tạo mới hoặc cập nhật Feature document, bao gồm thiết kế Integration Test và E2E/Acceptance Test.
5
-
6
- ## Prerequisite
7
- - Ít nhất một Epic phải tồn tại trong docs/epics/
8
-
9
- ## Hành động
10
- 1. Cần context từ root/tas.yaml
11
- 2. Cần context từ .tas/templates/Feature.md
12
- 3. Xác định chế độ dựa vào $ARGUMENTS:
13
-
14
- ### Chế độ CREATE ($ARGUMENTS là mô tả Feature mới, hoặc không có $ARGUMENTS):
15
- 4. Đọc project.code từ root/tas.yaml. Liệt kê các Epic hiện có, hỏi user Feature này thuộc Epic nào.
16
- 5. Quét thư mục Epic đã chọn để xác định số thứ tự Feature.
17
- 6. Tạo thư mục docs/epics/{code}-Epic-{NNN}-{slug}/{code}-Feature-{NNN}-{slug}/
18
- 7. Tạo file {code}-Feature-{NNN}-{slug}.md trong thư mục đó
19
- 8. Sau khi PE điền mô tả và acceptance criteria, TỰ ĐỘNG chuyển sang thiết kế test:
20
- a. **Integration Test Cases**: Hỏi PE:
21
- - "Feature này tương tác với service/module nào khác?"
22
- - "Các flow liên kết giữa stories cần test những gì?"
23
- - "Có data flow nào cần verify end-to-end trong feature này?"
24
- Ghi vào section Integration Test Cases.
25
- b. **E2E / Acceptance Test Cases**: Hỏi PE:
26
- - "User scenario chính để verify feature này trên Staging là gì?"
27
- - "Có scenario nào cần test với data thật hoặc gần thật?"
28
- - "Acceptance criteria nào cần PE verify thủ công?"
29
- Ghi vào section E2E Test Cases. Đây là checklist PE dùng ở Phase 2 khi chạy /tas-verify.
30
- 9. Cập nhật `project-status.yaml` theo `.claude/rules/common/project-status.md` — thêm entry vào `epics.{EPIC_ID}.features`.
31
-
32
- ### Chế độ UPDATE ($ARGUMENTS là Feature ID, ví dụ: "Feature-003"):
33
- 4. Tìm file Feature trong cây docs/epics/ (dùng glob)
34
- 5. Cần context từ file Feature hiện tại
35
- 6. Hỏi user cần thay đổi gì (thêm story, cập nhật AC, thêm test cases, đổi status...)
36
- 7. Cập nhật file, thêm changelog
37
- 8. Cập nhật `project-status.yaml` theo `.claude/rules/common/project-status.md` — cập nhật `epics.{EPIC_ID}.features.{FEATURE_ID}.status`.
38
-
39
- ## Nguyên tắc
40
- - Feature là một chức năng cụ thể, có thể demo được
41
- - Feature PHẢI có acceptance criteria rõ ràng, testable
42
- - Integration Test Cases PHẢI cover các flow liên kết giữa stories
43
- - E2E Test Cases PHẢI đủ để PE verify feature trên Staging ở Phase 2
1
+ # /tas-feature $ARGUMENTS
2
+
3
+ Vai trò: PE - Product Engineer
4
+ Tạo mới hoặc cập nhật Feature document, bao gồm thiết kế Integration Test và E2E/Acceptance Test.
5
+
6
+ ## Prerequisite
7
+ - Ít nhất một Epic phải tồn tại trong docs/epics/
8
+
9
+ ## Hành động
10
+ 1. Cần context từ root/tas.yaml
11
+ 2. Cần context từ .tas/templates/Feature.md
12
+ 3. Xác định chế độ dựa vào $ARGUMENTS:
13
+
14
+ ### Chế độ CREATE ($ARGUMENTS là mô tả Feature mới, hoặc không có $ARGUMENTS):
15
+ 4. Đọc project.code từ root/tas.yaml. Liệt kê các Epic hiện có, hỏi user Feature này thuộc Epic nào.
16
+ 5. Quét thư mục Epic đã chọn để xác định số thứ tự Feature.
17
+ 6. Tạo thư mục docs/epics/{code}-Epic-{NNN}-{slug}/{code}-Feature-{NNN}-{slug}/
18
+ 7. Tạo file {code}-Feature-{NNN}-{slug}.md trong thư mục đó
19
+ 8. Sau khi PE điền mô tả và acceptance criteria, TỰ ĐỘNG chuyển sang thiết kế test:
20
+ a. **Integration Test Cases**: Hỏi PE:
21
+ - "Feature này tương tác với service/module nào khác?"
22
+ - "Các flow liên kết giữa stories cần test những gì?"
23
+ - "Có data flow nào cần verify end-to-end trong feature này?"
24
+ Ghi vào section Integration Test Cases.
25
+ b. **E2E / Acceptance Test Cases**: Hỏi PE:
26
+ - "User scenario chính để verify feature này trên Staging là gì?"
27
+ - "Có scenario nào cần test với data thật hoặc gần thật?"
28
+ - "Acceptance criteria nào cần PE verify thủ công?"
29
+ Ghi vào section E2E Test Cases. Đây là checklist PE dùng ở Phase 2 khi chạy /tas-verify.
30
+ 9. Cập nhật `project-status.yaml` theo `.claude/rules/common/project-status.md` — thêm entry vào `epics.{EPIC_ID}.features`.
31
+
32
+ ### Chế độ UPDATE ($ARGUMENTS là Feature ID, ví dụ: "Feature-003"):
33
+ 4. Tìm file Feature trong cây docs/epics/ (dùng glob)
34
+ 5. Cần context từ file Feature hiện tại
35
+ 6. Hỏi user cần thay đổi gì (thêm story, cập nhật AC, thêm test cases, đổi status...)
36
+ 7. Cập nhật file, thêm changelog
37
+ 8. Cập nhật `project-status.yaml` theo `.claude/rules/common/project-status.md` — cập nhật `epics.{EPIC_ID}.features.{FEATURE_ID}.status`.
38
+
39
+ ## Nguyên tắc
40
+ - Feature là một chức năng cụ thể, có thể demo được
41
+ - Feature PHẢI có acceptance criteria rõ ràng, testable
42
+ - Integration Test Cases PHẢI cover các flow liên kết giữa stories
43
+ - E2E Test Cases PHẢI đủ để PE verify feature trên Staging ở Phase 2
44
+
45
+ ## Bước cuối — Token Log
46
+
47
+ Invoke skill `token-logger`: ghi AI Usage Log vào file Feature đang làm việc.
@@ -1,47 +1,51 @@
1
- # /tas-fix $ARGUMENTS
2
-
3
- Vai trò: SE - Software Engineer
4
- Quick fix cho bug nhỏ hoặc lỗi rõ ràng — không cần tạo ticket, không cần full lifecycle.
5
- Dùng khi: solo dev, hotfix nhanh, bug tìm thấy trong lúc dev.
6
- Khác với /tas-bug: không tạo Bug file, không track status, không deploy flow.
7
-
8
- ## Stack Detection
9
- Đọc `.claude/rules/common/stack-detection.md`.
10
-
11
- ## Hành động
12
-
13
- ### 1. Hiểu bug
14
- $ARGUMENTS là mô tả lỗi, error message, hoặc file:line_number.
15
- - Nếu có error message/stack trace: parse ngay, xác định file và dòng lỗi
16
- - Nếu chỉ có mô tả: hỏi 1 câu duy nhất để làm rõ (reproduce steps hoặc expected vs actual)
17
- - KHÔNG hỏi nhiều hơn 1 câu
18
-
19
- ### 2. Diagnose (tối đa 3 file đọc)
20
- - Đọc file lỗi và các file liên quan trực tiếp
21
- - Xác định root cause trong 1-2 câu ngắn
22
- - KHÔNG đọc toàn bộ project, KHÔNG quét cấu trúc folder
23
- - Nếu cần đọc thêm file ngoài 3 file đầu tiên: hỏi user xác nhận
24
-
25
- ### 3. Fix với regression test
26
-
27
- Trước khi fix, đọc các rules liên quan:
28
- - `.claude/rules/common/security.md` — kiểm tra fix có tạo ra security risk không
29
- - `.claude/rules/common/testing.md` — pattern viết regression test
30
- - `.claude/rules/[lang_rules]/coding-style.md` — conventions của stack hiện tại (nếu xác định được)
31
-
32
- Sau đó:
33
- a. Viết 1 test case tối thiểu reproduce bug (nếu project có test framework)
34
- b. Xác nhận test FAIL
35
- c. Fix code đúng root cause
36
- d. Xác nhận test PASS
37
- e. Chạy nhanh test suite nếu có (để check regression)
38
-
39
- ### 4. Wrap up
40
- - Output commit message: `fix: <mô tả ngắn gọn>`
41
- - Nhắc: "Nếu bug này có khả năng tái phát hoặc ảnh hưởng production, cân nhắc dùng /tas-bug để track đầy đủ."
42
-
43
- ## Nguyên tắc
44
- - Tổng số file đọc ≤ 3 trừ khi được cho phép
45
- - Fix đúng root cause, KHÔNG patch symptom
46
- - Nếu fix kéo theo thay đổi architecture → dừng, gợi ý dùng /tas-bug + /tas-adr
47
- - Nếu bug thuộc production và severity cao → dừng, gợi ý dùng /tas-bug với severity Critical/High
1
+ # /tas-fix $ARGUMENTS
2
+
3
+ Vai trò: SE - Software Engineer
4
+ Quick fix cho bug nhỏ hoặc lỗi rõ ràng — không cần tạo ticket, không cần full lifecycle.
5
+ Dùng khi: solo dev, hotfix nhanh, bug tìm thấy trong lúc dev.
6
+ Khác với /tas-bug: không tạo Bug file, không track status, không deploy flow.
7
+
8
+ ## Stack Detection
9
+ Đọc `.claude/rules/common/stack-detection.md`.
10
+
11
+ ## Hành động
12
+
13
+ ### 1. Hiểu bug
14
+ $ARGUMENTS là mô tả lỗi, error message, hoặc file:line_number.
15
+ - Nếu có error message/stack trace: parse ngay, xác định file và dòng lỗi
16
+ - Nếu chỉ có mô tả: hỏi 1 câu duy nhất để làm rõ (reproduce steps hoặc expected vs actual)
17
+ - KHÔNG hỏi nhiều hơn 1 câu
18
+
19
+ ### 2. Diagnose (tối đa 3 file đọc)
20
+ - Đọc file lỗi và các file liên quan trực tiếp
21
+ - Xác định root cause trong 1-2 câu ngắn
22
+ - KHÔNG đọc toàn bộ project, KHÔNG quét cấu trúc folder
23
+ - Nếu cần đọc thêm file ngoài 3 file đầu tiên: hỏi user xác nhận
24
+
25
+ ### 3. Fix với regression test
26
+
27
+ Trước khi fix, đọc các rules liên quan:
28
+ - `.claude/rules/common/security.md` — kiểm tra fix có tạo ra security risk không
29
+ - `.claude/rules/common/testing.md` — pattern viết regression test
30
+ - `.claude/rules/[lang_rules]/coding-style.md` — conventions của stack hiện tại (nếu xác định được)
31
+
32
+ Sau đó:
33
+ a. Viết 1 test case tối thiểu reproduce bug (nếu project có test framework)
34
+ b. Xác nhận test FAIL
35
+ c. Fix code đúng root cause
36
+ d. Xác nhận test PASS
37
+ e. Chạy nhanh test suite nếu có (để check regression)
38
+
39
+ ### 4. Wrap up
40
+ - Output commit message: `fix: <mô tả ngắn gọn>`
41
+ - Nhắc: "Nếu bug này có khả năng tái phát hoặc ảnh hưởng production, cân nhắc dùng /tas-bug để track đầy đủ."
42
+
43
+ ## Nguyên tắc
44
+ - Tổng số file đọc ≤ 3 trừ khi được cho phép
45
+ - Fix đúng root cause, KHÔNG patch symptom
46
+ - Nếu fix kéo theo thay đổi architecture → dừng, gợi ý dùng /tas-bug + /tas-adr
47
+ - Nếu bug thuộc production và severity cao → dừng, gợi ý dùng /tas-bug với severity Critical/High
48
+
49
+ ## Bước cuối — Token Log
50
+
51
+ Invoke skill `token-logger`: ghi AI Usage Log vào file Story hoặc Bug liên quan (nếu có).
@@ -0,0 +1,144 @@
1
+ # /tas-functest-mobile $ARGUMENTS
2
+
3
+ Vai tro: SE / QA
4
+ Generate tat ca Detox automation test scripts cho mot mobile Feature.
5
+
6
+ ## QUAN TRONG - Layer 2: Mobile Functional Test Scripts
7
+ - Tao Detox test scripts tu Func-Test-Spec (markdown)
8
+ - Scripts nam trong `apps/mobile/e2e/features/`
9
+ - Reusable helpers duoc export de Layer 3 (E2E) tai su dung
10
+ - Data hardcoded trong test, credentials tu .env
11
+
12
+ ## Hanh dong
13
+
14
+ ### Buoc 1: Xac dinh Feature
15
+ 1. $ARGUMENTS la Feature ID hoac file path
16
+ 2. Neu khong co: scan `docs/epics/**/Feature-*.md` tim features co status In Progress
17
+ 3. Doc Feature file de lay Epic/Feature numbers va danh sach Stories
18
+
19
+ ### Buoc 2: Kiem tra Prerequisites
20
+ 1. Kiem tra `apps/mobile/` ton tai. Neu khong → bao loi:
21
+ > "Mobile app chua ton tai trong project nay. Vui long tao apps/mobile/ truoc."
22
+ 2. Tim tat ca `Func-Test-*.md` files trong Feature directory:
23
+ ```
24
+ docs/epics/{epic-dir}/{feature-dir}/Func-Test-*.md
25
+ ```
26
+ 3. Neu khong co Func-Test-Spec nao → bao loi:
27
+ > "Chua co Func-Test-Spec nao cho Feature nay. Chay /tas-functest {story-ID} truoc."
28
+ 4. Doc `apps/mobile/e2e/test-ids.ts` de biet testID hien co
29
+ 5. Doc `apps/mobile/e2e/helpers/data-loader.ts` va `test-utils.ts` de hieu patterns
30
+
31
+ ### Buoc 3: Aggregate FT Test Cases
32
+ - Tu tat ca Func-Test-Spec files, tong hop danh sach FT test cases
33
+ - Nhom theo Story
34
+ - Lay test data requirements tu moi spec
35
+
36
+ ### Buoc 4: Generate Test Scripts
37
+ Voi MOI Story co Func-Test-Spec:
38
+
39
+ **File output**: `apps/mobile/e2e/features/{epic-slug}/{feature-slug}/{story-slug}.func.e2e.ts`
40
+
41
+ **Structure**:
42
+ ```typescript
43
+ /**
44
+ * Functional Tests: {Story Name}
45
+ * Story: {Story_ID}
46
+ * Feature: {Feature_ID}
47
+ * Epic: {Epic_ID}
48
+ *
49
+ * Generated by /tas-functest-mobile
50
+ * Spec: docs/epics/{epic-dir}/{feature-dir}/Func-Test-{story-slug}.md
51
+ */
52
+
53
+ import { device, element, expect, by, waitFor } from 'detox';
54
+ import { TEST_IDS } from '../../../test-ids';
55
+ import { loadTestData, getCredentials } from '../../../helpers/data-loader';
56
+ import { login, navigateTo } from '../../../helpers/test-utils';
57
+
58
+ const testData = loadTestData();
59
+
60
+ describe('{Feature Name} - {Story Name}', () => {
61
+ beforeAll(async () => {
62
+ await device.launchApp({ newInstance: true });
63
+ });
64
+
65
+ beforeEach(async () => {
66
+ await device.reloadReactNative();
67
+ });
68
+
69
+ // AC Reference: AC-1
70
+ describe('{PROJECT}_E{EPIC}_F{FEATURE}_S{STORY}_FT_001_H', () => {
71
+ it('should {description from spec}', async () => {
72
+ // Given: {precondition}
73
+ // When: {action}
74
+ // Then: {expected}
75
+ });
76
+ });
77
+ });
78
+ ```
79
+
80
+ ### Buoc 5: Update test-ids.ts (neu can)
81
+ - Neu test cases can testID chua co trong test-ids.ts
82
+ - Them testID moi theo naming convention hien tai
83
+ - Giu nguyen structure: nested object voi dot notation
84
+
85
+ ### Buoc 6: Generate Feature Helpers
86
+ Tao file `apps/mobile/e2e/features/{epic-slug}/{feature-slug}/helpers.ts`:
87
+ ```typescript
88
+ /**
89
+ * Reusable helpers cho {Feature Name}
90
+ * Duoc tai su dung boi Layer 3 E2E scripts
91
+ */
92
+
93
+ export async function {featureSpecificHelper}() {
94
+ // Helper logic extracted from functional tests
95
+ }
96
+ ```
97
+
98
+ ### Buoc 7: Update package.json Script
99
+ Them hoac update script trong `apps/mobile/package.json`:
100
+ ```json
101
+ "functest:mobile:{feature-slug}": "detox test --configuration ios.sim.debug --testPathPattern='e2e/features/{epic-slug}/{feature-slug}'"
102
+ ```
103
+
104
+ ### Buoc 8: Generate Index
105
+ Tao `apps/mobile/e2e/features/{epic-slug}/{feature-slug}/index.ts`:
106
+ ```typescript
107
+ export * from './helpers';
108
+ ```
109
+
110
+ ## File Structure Output
111
+ ```
112
+ apps/mobile/e2e/features/
113
+ └── {epic-slug}/
114
+ └── {feature-slug}/
115
+ ├── {story-1-slug}.func.e2e.ts
116
+ ├── {story-2-slug}.func.e2e.ts
117
+ ├── helpers.ts
118
+ └── index.ts
119
+ ```
120
+
121
+ ## Test Data Convention
122
+ - **Hardcoded values**: Truc tiep trong test (vd: "invalid@email", "short")
123
+ - **Credentials**: `const creds = getCredentials();` → password tu process.env
124
+ - **Environment data**: `const testData = loadTestData();` → doc tu test-data.{env}.json
125
+ - **KHONG BAO GIO** hardcode passwords/tokens trong test files
126
+
127
+ ## Chay Tests
128
+ ```bash
129
+ # Chay tat ca func tests cho feature
130
+ yarn functest:mobile:{feature-slug}
131
+
132
+ # Chay chi mot story
133
+ npx detox test --configuration ios.sim.debug --testPathPattern='e2e/features/{epic}/{feature}/{story}'
134
+
135
+ # Chay voi Android
136
+ npx detox test --configuration android.emu.debug --testPathPattern='e2e/features/{epic}/{feature}'
137
+ ```
138
+
139
+ ## Nguyen tac
140
+ - Script PHAI chay duoc ngay tu CLI, KHONG can cua so Claude
141
+ - Moi describe block dung full FT ID de grep duoc
142
+ - Helpers PHAI export de Layer 3 reuse
143
+ - KHONG import tu Layer 3 (flows/), chi export LEN Layer 3
144
+ - Neu apps/mobile/ khong ton tai → bao loi graceful, KHONG tao
@@ -0,0 +1,192 @@
1
+ # /tas-functest-web $ARGUMENTS
2
+
3
+ Vai tro: SE / QA
4
+ Generate tat ca Playwright automation test scripts cho mot web Feature.
5
+
6
+ ## QUAN TRONG - Layer 2: Web Functional Test Scripts
7
+ - Tao Playwright test scripts tu Func-Test-Spec (markdown)
8
+ - Scripts nam trong `apps/web/e2e/features/`
9
+ - Reusable helpers duoc export de Layer 3 (E2E) tai su dung
10
+ - Data hardcoded trong test, credentials tu .env
11
+ - Cross-viewport testing (mobile, tablet, desktop)
12
+
13
+ ## Hanh dong
14
+
15
+ ### Buoc 1: Xac dinh Feature
16
+ 1. $ARGUMENTS la Feature ID hoac file path
17
+ 2. Neu khong co: scan `docs/epics/**/Feature-*.md` tim features co status In Progress
18
+ 3. Doc Feature file de lay Epic/Feature numbers va danh sach Stories
19
+
20
+ ### Buoc 2: Kiem tra Prerequisites
21
+ 1. Kiem tra `apps/web/` ton tai. Neu khong → bao:
22
+ > "Web app chua ton tai trong project nay. Neu project chi co mobile, dung /tas-functest-mobile."
23
+ > DUNG LAI, KHONG tao file.
24
+ 2. Tim tat ca `Func-Test-*.md` files trong Feature directory:
25
+ ```
26
+ docs/epics/{epic-dir}/{feature-dir}/Func-Test-*.md
27
+ ```
28
+ 3. Neu khong co Func-Test-Spec nao → bao loi:
29
+ > "Chua co Func-Test-Spec nao cho Feature nay. Chay /tas-functest {story-ID} truoc."
30
+ 4. Doc `apps/web/playwright.config.ts` (neu co) de hieu config hien tai
31
+ 5. Doc `apps/web/e2e/helpers/` (neu co) de hieu patterns
32
+
33
+ ### Buoc 3: Aggregate FT Test Cases
34
+ - Tu tat ca Func-Test-Spec files, tong hop danh sach FT test cases
35
+ - Nhom theo Story
36
+ - Lay test data requirements tu moi spec
37
+
38
+ ### Buoc 4: Generate Test Scripts
39
+ Voi MOI Story co Func-Test-Spec:
40
+
41
+ **File output**: `apps/web/e2e/features/{epic-slug}/{feature-slug}/{story-slug}.func.spec.ts`
42
+
43
+ **Structure**:
44
+ ```typescript
45
+ /**
46
+ * Functional Tests: {Story Name}
47
+ * Story: {Story_ID}
48
+ * Feature: {Feature_ID}
49
+ * Epic: {Epic_ID}
50
+ *
51
+ * Generated by /tas-functest-web
52
+ * Spec: docs/epics/{epic-dir}/{feature-dir}/Func-Test-{story-slug}.md
53
+ */
54
+
55
+ import { test, expect } from '@playwright/test';
56
+ import { loadTestData, getCredentials } from '../../../helpers/data-loader';
57
+
58
+ const testData = loadTestData();
59
+
60
+ test.describe('{Feature Name} - {Story Name}', () => {
61
+ test.beforeEach(async ({ page }) => {
62
+ await page.goto('/target-page');
63
+ });
64
+
65
+ // AC Reference: AC-1
66
+ test.describe('{PROJECT}_E{EPIC}_F{FEATURE}_S{STORY}_FT_001_H', () => {
67
+ test('should {description from spec}', async ({ page }) => {
68
+ // Given: {precondition}
69
+ // When: {action}
70
+ await page.getByTestId('element-id').click();
71
+ // Then: {expected}
72
+ await expect(page.getByTestId('result')).toBeVisible();
73
+ });
74
+ });
75
+
76
+ // Viewport testing for responsive features
77
+ test.describe('{PROJECT}_E{EPIC}_F{FEATURE}_S{STORY}_FT_001_H - Viewports', () => {
78
+ const viewports = [
79
+ { width: 375, height: 812, name: 'mobile' },
80
+ { width: 768, height: 1024, name: 'tablet' },
81
+ { width: 1280, height: 720, name: 'desktop' },
82
+ ];
83
+
84
+ for (const vp of viewports) {
85
+ test(`should work on ${vp.name} (${vp.width}x${vp.height})`, async ({ page }) => {
86
+ await page.setViewportSize({ width: vp.width, height: vp.height });
87
+ // Test responsive behavior
88
+ });
89
+ }
90
+ });
91
+ });
92
+ ```
93
+
94
+ ### Buoc 5: Generate Feature Helpers
95
+ Tao file `apps/web/e2e/features/{epic-slug}/{feature-slug}/helpers.ts`:
96
+ ```typescript
97
+ import { Page, expect } from '@playwright/test';
98
+
99
+ /**
100
+ * Reusable helpers cho {Feature Name}
101
+ * Duoc tai su dung boi Layer 3 E2E scripts
102
+ */
103
+
104
+ export async function {featureSpecificHelper}(page: Page) {
105
+ // Helper logic extracted from functional tests
106
+ }
107
+ ```
108
+
109
+ ### Buoc 6: Generate/Update Data Loader (neu chua co)
110
+ Neu `apps/web/e2e/helpers/data-loader.ts` chua ton tai, tao:
111
+ ```typescript
112
+ type TestEnv = 'dev' | 'staging' | 'prod';
113
+
114
+ export function loadTestData(env?: TestEnv) {
115
+ const targetEnv = env || (process.env.TEST_ENV as TestEnv) || 'dev';
116
+ return require(`../data/test-data.${targetEnv}.json`);
117
+ }
118
+
119
+ export function getCredentials(userType = 'default') {
120
+ const data = loadTestData();
121
+ const user = data.users[userType] || data.users.default;
122
+ return {
123
+ email: user.email,
124
+ password: process.env.TEST_USER_PASSWORD || '',
125
+ };
126
+ }
127
+ ```
128
+
129
+ ### Buoc 7: Update package.json Script
130
+ Them hoac update script trong `apps/web/package.json`:
131
+ ```json
132
+ "functest:web:{feature-slug}": "npx playwright test e2e/features/{epic-slug}/{feature-slug}"
133
+ ```
134
+
135
+ ### Buoc 8: Generate Index
136
+ Tao `apps/web/e2e/features/{epic-slug}/{feature-slug}/index.ts`:
137
+ ```typescript
138
+ export * from './helpers';
139
+ ```
140
+
141
+ ## File Structure Output
142
+ ```
143
+ apps/web/e2e/features/
144
+ └── {epic-slug}/
145
+ └── {feature-slug}/
146
+ ├── {story-1-slug}.func.spec.ts
147
+ ├── {story-2-slug}.func.spec.ts
148
+ ├── helpers.ts
149
+ └── index.ts
150
+ ```
151
+
152
+ ## Selector Strategy (Playwright)
153
+ - **Uu tien**: `data-testid` → `page.getByTestId('login-submit')`
154
+ - **Text content**: `page.getByText('Welcome')`
155
+ - **Role**: `page.getByRole('button', { name: 'Submit' })`
156
+ - **Label**: `page.getByLabel('Email')`
157
+ - KHONG dung CSS selectors truyen thong (`.class`, `#id`) tru khi bat buoc
158
+
159
+ ## Cross-Browser Testing
160
+ - Chromium (bat buoc)
161
+ - Firefox (bat buoc)
162
+ - WebKit (bat buoc)
163
+ - Config trong `playwright.config.ts` projects section
164
+
165
+ ## Test Data Convention
166
+ - **Hardcoded values**: Truc tiep trong test
167
+ - **Credentials**: `getCredentials()` → password tu process.env
168
+ - **Environment data**: `loadTestData()` → tu test-data.{env}.json
169
+ - **KHONG BAO GIO** hardcode passwords/tokens
170
+
171
+ ## Chay Tests
172
+ ```bash
173
+ # Chay tat ca func tests cho feature
174
+ yarn functest:web:{feature-slug}
175
+
176
+ # Chay chi mot story
177
+ npx playwright test e2e/features/{epic}/{feature}/{story}
178
+
179
+ # Chay voi browser cu the
180
+ npx playwright test --project=firefox e2e/features/{epic}/{feature}
181
+
182
+ # Chay voi debug UI
183
+ npx playwright test --ui e2e/features/{epic}/{feature}
184
+ ```
185
+
186
+ ## Nguyen tac
187
+ - Script PHAI chay duoc ngay tu CLI
188
+ - Moi describe block dung full FT ID
189
+ - Helpers PHAI export de Layer 3 reuse
190
+ - KHONG import tu Layer 3 (flows/)
191
+ - Neu apps/web/ khong ton tai → bao loi graceful, KHONG tao
192
+ - Test phai work tren tat ca viewports (mobile, tablet, desktop)
@@ -0,0 +1,76 @@
1
+ # /tas-functest $ARGUMENTS
2
+
3
+ Vai tro: SE / QA
4
+ Generate Functional Test Specification tu mot User Story, lien ket test cases voi Acceptance Criteria (AC).
5
+
6
+ ## QUAN TRONG - Layer 2: Functional Testing
7
+ - Functional tests (FT) nam giua Unit tests (Layer 1) va E2E tests (Layer 3)
8
+ - FT test tung chuc nang/story rieng le, KHONG test flow lien ket giua nhieu features
9
+ - Moi FT case PHAI reference AC-ID de traceability
10
+
11
+ ## Hanh dong
12
+
13
+ ### Buoc 1: Xac dinh Story
14
+ 1. $ARGUMENTS la Story ID hoac file path
15
+ 2. Neu khong co $ARGUMENTS: scan `docs/epics/**/Story-*.md` tim stories co status In Progress hoac Committed
16
+ 3. Doc Story file de lay:
17
+ - Tat ca Acceptance Criteria (AC-1, AC-2, ...)
18
+ - Epic/Feature/Story numbers (tu frontmatter hoac file path)
19
+ - Platform context (mobile/web/backend)
20
+ 4. Doc `root/tas.yaml` de lay project code (vd: "AL")
21
+
22
+ ### Buoc 2: Auto-detect Platform
23
+ Tu Story context, xac dinh platform:
24
+ - **Mobile**: Keywords "screen", "navigation", "React Native", "Detox"; paths `apps/mobile/src/features/*`
25
+ - **Web**: Keywords "browser", "page", "Playwright", "React"; paths `apps/web/*`
26
+ - **Backend**: Keywords "API endpoint", "service", "controller"; paths `src/Torus.*`, `tests/`
27
+ - Neu khong xac dinh duoc: hoi user
28
+
29
+ ### Buoc 3: Generate FT Test Cases
30
+ Doc template tu `.tas/templates/Func-Test-Spec.md`
31
+
32
+ Naming format:
33
+ ```
34
+ {PROJECT}_E{EPIC}_F{FEATURE}_S{STORY}_FT_{NNN}_{MODIFIER}
35
+ ```
36
+
37
+ Voi moi AC, generate:
38
+ - **BAT BUOC**: 1 Happy path test (H)
39
+ - **NEN CO**: 1 Negative test (N) neu co error scenarios
40
+ - **TUY CHON**: 1 Edge case test (E) neu co boundary conditions
41
+
42
+ Moi test case PHAI co cot AC-ID trong bang mapping.
43
+
44
+ ### Buoc 4: Generate Test Data Requirements
45
+ - Xac dinh data can thiet cho moi test case
46
+ - Data hardcoded: ghi truc tiep trong scenario
47
+ - Credentials: chi reference `process.env.TEST_USER_PASSWORD`, KHONG hardcode
48
+ - Data per environment: reference `test-data.{env}.json`
49
+
50
+ ### Buoc 5: Output File
51
+ Luu file tai:
52
+ ```
53
+ docs/epics/{epic-dir}/{feature-dir}/Func-Test-{story-slug}.md
54
+ ```
55
+
56
+ ### Buoc 6: Prompting
57
+ Sau khi generate, hoi user:
58
+ - "Co edge case nao can them khong?"
59
+ - "Co negative test scenario nao bi bo sot khong?"
60
+ - "Co test case nao can danh dau P0 Critical khong?"
61
+ - "Test data va fixtures can chuan bi gi them?"
62
+
63
+ ## Traceability Feature
64
+ - Moi FT case gan AC-ID trong cot mapping
65
+ - Khi AC thay doi: grep AC-ID trong Func-Test-*.md de biet FT nao can update
66
+ - Trong test script, moi describe block co comment `// AC Reference: AC-{N}`
67
+
68
+ ## Status Flow
69
+ Draft → Ready → Implemented → Verified
70
+
71
+ ## Nguyen tac
72
+ - KHONG tao test code, chi tao specification (markdown)
73
+ - Test code duoc tao boi `/tas-functest-mobile` hoac `/tas-functest-web`
74
+ - Func-Test-Spec la input cho Layer 2 script generation
75
+ - Moi AC phai co it nhat 1 FT case
76
+ - FT dung type code `FT`, KHONG dung `E2E` hay `UT`