@torus-engineering/tas-kit 1.7.0 → 1.8.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.
- package/.claude/commands/tas-adr.md +33 -29
- package/.claude/commands/tas-api-test.md +95 -0
- package/.claude/commands/tas-bug.md +113 -109
- package/.claude/commands/tas-design.md +37 -33
- package/.claude/commands/tas-dev.md +128 -115
- package/.claude/commands/tas-e2e-mobile.md +155 -0
- package/.claude/commands/tas-e2e-web.md +163 -0
- package/.claude/commands/tas-e2e.md +102 -0
- package/.claude/commands/tas-epic.md +35 -31
- package/.claude/commands/tas-feature.md +47 -43
- package/.claude/commands/tas-fix.md +51 -47
- package/.claude/commands/tas-functest-mobile.md +144 -0
- package/.claude/commands/tas-functest-web.md +192 -0
- package/.claude/commands/tas-functest.md +76 -0
- package/.claude/commands/tas-plan.md +200 -184
- package/.claude/commands/tas-prd.md +37 -33
- package/.claude/commands/tas-review.md +111 -104
- package/.claude/commands/tas-sad.md +43 -39
- package/.claude/commands/tas-security.md +81 -80
- package/.claude/commands/tas-story.md +91 -87
- package/.claude/commands/tas-verify.md +51 -41
- package/.claude/rules/common/post-review-agent.md +49 -39
- package/.claude/rules/common/testing.md +24 -0
- package/.claude/rules/common/token-logging.md +27 -0
- package/.claude/rules/csharp/api-testing.md +171 -0
- package/.claude/rules/csharp/patterns.md +10 -0
- package/.claude/rules/python/patterns.md +10 -0
- package/.claude/rules/typescript/patterns.md +10 -0
- package/.claude/rules/web/performance.md +9 -0
- package/.claude/skills/api-design/SKILL.md +3 -1
- package/.claude/skills/{backend-patterns → js-backend-patterns}/SKILL.md +2 -1
- package/.claude/skills/tas-implementation-complete/SKILL.md +99 -97
- package/.claude/skills/tas-tdd/SKILL.md +123 -82
- package/.claude/skills/token-logger/SKILL.md +19 -0
- package/.tas/templates/E2E-Execution-Report.md +198 -0
- package/.tas/templates/E2E-Mobile-Spec.md +130 -0
- package/.tas/templates/E2E-Report.md +174 -0
- package/.tas/templates/E2E-Scenario.md +180 -0
- package/.tas/templates/E2E-Web-Spec.md +164 -0
- package/.tas/templates/Feature.md +55 -55
- package/.tas/templates/Func-Test-Script.md +254 -0
- package/.tas/templates/Func-Test-Spec.md +187 -0
- package/.tas/templates/SAD.md +274 -274
- package/.tas/templates/Story.md +90 -88
- package/bin/cli.js +56 -56
- package/lib/deleted-files.json +33 -0
- package/lib/install.js +213 -176
- package/package.json +34 -34
- package/.claude/agents/README.md +0 -83
- package/.claude/agents/ado-agent.md +0 -39
- package/.claude/agents/code-architect.md +0 -62
- package/.claude/agents/code-simplifier.md +0 -53
- package/.claude/agents/comment-analyzer.md +0 -59
- package/.claude/agents/conversation-analyzer.md +0 -57
- package/.claude/agents/docs-lookup.md +0 -55
- package/.claude/agents/harness-optimizer.md +0 -62
- package/.claude/agents/loop-operator.md +0 -56
- package/.claude/agents/performance-optimizer.md +0 -78
- package/.claude/agents/pr-test-analyzer.md +0 -68
- package/.claude/agents/pytorch-build-resolver.md +0 -76
- package/.claude/agents/refactor-cleaner.md +0 -70
- package/.claude/agents/seo-specialist.md +0 -75
- package/.claude/agents/silent-failure-hunter.md +0 -69
- package/.claude/agents/type-design-analyzer.md +0 -75
- package/.claude/rules/common/agents.md +0 -65
- package/.claude/rules/common/coding-style.md +0 -90
- package/.claude/rules/common/development-workflow.md +0 -44
- package/.claude/rules/common/git-workflow.md +0 -24
- package/.claude/rules/common/performance.md +0 -55
- package/.claude/skills/agent-harness-construction/SKILL.md +0 -77
- package/.claude/skills/agent-introspection-debugging/SKILL.md +0 -157
|
@@ -1,115 +1,128 @@
|
|
|
1
|
-
# /tas-dev $ARGUMENTS
|
|
2
|
-
|
|
3
|
-
Vai trò: SE - Software Engineer
|
|
4
|
-
Implement một User Story theo Technical Plan đã được duyệt.
|
|
5
|
-
|
|
6
|
-
## Always / Ask / Never
|
|
7
|
-
|
|
8
|
-
| | Hành động |
|
|
9
|
-
|---|---|
|
|
10
|
-
| **Always** | Kiểm tra `plan_status` trước khi implement |
|
|
11
|
-
| **Always** | Follow tasks trong `## Technical Plan` của Story |
|
|
12
|
-
| **Always** | Launch review agent độc lập sau khi implement — không review trong cùng session |
|
|
13
|
-
| **Ask** | Khi phát hiện plan cần thay đổi đáng kể trong lúc code |
|
|
14
|
-
| **Ask** | Khi cần đọc thêm file ngoài scope của plan |
|
|
15
|
-
| **Never** | Implement ngoài scope Story |
|
|
16
|
-
| **Never** | Skip bước review sau khi implement |
|
|
17
|
-
|
|
18
|
-
## QUAN TRỌNG - Quy tắc đọc file
|
|
19
|
-
- CHỈ đọc Story file — Technical Plan đã có đủ context kỹ thuật.
|
|
20
|
-
- Không tự đọc PRD, SAD, ADR, Design-Spec trừ khi user xác nhận.
|
|
21
|
-
- Không list thư mục, không quét project structure.
|
|
22
|
-
- Không đọc `.tas/checklists/story-done.md` ở bước đầu (chỉ đọc ở bước cuối).
|
|
23
|
-
|
|
24
|
-
## Stack Detection
|
|
25
|
-
Đọc `.claude/rules/common/stack-detection.md`.
|
|
26
|
-
|
|
27
|
-
## Hành động
|
|
28
|
-
|
|
29
|
-
### Bước 1 — Xác định Story
|
|
30
|
-
|
|
31
|
-
`$ARGUMENTS` là Story ID hoặc file path.
|
|
32
|
-
Nếu không có: đọc `project-status.yaml`, tìm stories có `status: Committed` hoặc `status: In Progress`. Nếu nhiều hơn một, liệt kê để user chọn.
|
|
33
|
-
Đọc Story file.
|
|
34
|
-
|
|
35
|
-
### Bước 1.5 — Gate: Kiểm tra plan_status
|
|
36
|
-
|
|
37
|
-
Đọc `plan_status` từ frontmatter của Story.
|
|
38
|
-
|
|
39
|
-
**Nếu `plan_status: pending`:**
|
|
40
|
-
Đọc `require_plan` từ root/`tas.yaml`:
|
|
41
|
-
- `require_plan: true` (hoặc field không tồn tại) → **DỪNG LẠI**:
|
|
42
|
-
> "Story này chưa có Technical Plan. Chạy `/tas-plan {Story-ID}` trước khi implement."
|
|
43
|
-
- `require_plan: false` → tiếp tục, hiển thị warning và chờ xác nhận:
|
|
44
|
-
> "⚠️ Quick mode: Story chưa có Technical Plan. Tiếp tục implement không?"
|
|
45
|
-
|
|
46
|
-
**Nếu `plan_status: completed`:** tiếp tục bình thường.
|
|
47
|
-
|
|
48
|
-
### Bước 2 — Đọc Technical Plan
|
|
49
|
-
|
|
50
|
-
Từ Story file, đọc section `## Technical Plan`:
|
|
51
|
-
- Approach đã chọn
|
|
52
|
-
- Files to Change / Files to Create
|
|
53
|
-
- Database Changes, Config Changes
|
|
54
|
-
- Tasks list (checklist thực hiện theo thứ tự)
|
|
55
|
-
|
|
56
|
-
Nếu không có Technical Plan (quick mode) → phân tích AC và implement trực tiếp theo AC.
|
|
57
|
-
|
|
58
|
-
### Bước 3 — Implement
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
1
|
+
# /tas-dev $ARGUMENTS
|
|
2
|
+
|
|
3
|
+
Vai trò: SE - Software Engineer
|
|
4
|
+
Implement một User Story theo Technical Plan đã được duyệt.
|
|
5
|
+
|
|
6
|
+
## Always / Ask / Never
|
|
7
|
+
|
|
8
|
+
| | Hành động |
|
|
9
|
+
|---|---|
|
|
10
|
+
| **Always** | Kiểm tra `plan_status` trước khi implement |
|
|
11
|
+
| **Always** | Follow tasks trong `## Technical Plan` của Story |
|
|
12
|
+
| **Always** | Launch review agent độc lập sau khi implement — không review trong cùng session |
|
|
13
|
+
| **Ask** | Khi phát hiện plan cần thay đổi đáng kể trong lúc code |
|
|
14
|
+
| **Ask** | Khi cần đọc thêm file ngoài scope của plan |
|
|
15
|
+
| **Never** | Implement ngoài scope Story |
|
|
16
|
+
| **Never** | Skip bước review sau khi implement |
|
|
17
|
+
|
|
18
|
+
## QUAN TRỌNG - Quy tắc đọc file
|
|
19
|
+
- CHỈ đọc Story file — Technical Plan đã có đủ context kỹ thuật.
|
|
20
|
+
- Không tự đọc PRD, SAD, ADR, Design-Spec trừ khi user xác nhận.
|
|
21
|
+
- Không list thư mục, không quét project structure.
|
|
22
|
+
- Không đọc `.tas/checklists/story-done.md` ở bước đầu (chỉ đọc ở bước cuối).
|
|
23
|
+
|
|
24
|
+
## Stack Detection
|
|
25
|
+
Đọc `.claude/rules/common/stack-detection.md`.
|
|
26
|
+
|
|
27
|
+
## Hành động
|
|
28
|
+
|
|
29
|
+
### Bước 1 — Xác định Story
|
|
30
|
+
|
|
31
|
+
`$ARGUMENTS` là Story ID hoặc file path.
|
|
32
|
+
Nếu không có: đọc `project-status.yaml`, tìm stories có `status: Committed` hoặc `status: In Progress`. Nếu nhiều hơn một, liệt kê để user chọn.
|
|
33
|
+
Đọc Story file.
|
|
34
|
+
|
|
35
|
+
### Bước 1.5 — Gate: Kiểm tra plan_status
|
|
36
|
+
|
|
37
|
+
Đọc `plan_status` từ frontmatter của Story.
|
|
38
|
+
|
|
39
|
+
**Nếu `plan_status: pending`:**
|
|
40
|
+
Đọc `require_plan` từ root/`tas.yaml`:
|
|
41
|
+
- `require_plan: true` (hoặc field không tồn tại) → **DỪNG LẠI**:
|
|
42
|
+
> "Story này chưa có Technical Plan. Chạy `/tas-plan {Story-ID}` trước khi implement."
|
|
43
|
+
- `require_plan: false` → tiếp tục, hiển thị warning và chờ xác nhận:
|
|
44
|
+
> "⚠️ Quick mode: Story chưa có Technical Plan. Tiếp tục implement không?"
|
|
45
|
+
|
|
46
|
+
**Nếu `plan_status: completed`:** tiếp tục bình thường.
|
|
47
|
+
|
|
48
|
+
### Bước 2 — Đọc Technical Plan
|
|
49
|
+
|
|
50
|
+
Từ Story file, đọc section `## Technical Plan`:
|
|
51
|
+
- Approach đã chọn
|
|
52
|
+
- Files to Change / Files to Create
|
|
53
|
+
- Database Changes, Config Changes
|
|
54
|
+
- Tasks list (checklist thực hiện theo thứ tự)
|
|
55
|
+
|
|
56
|
+
Nếu không có Technical Plan (quick mode) → phân tích AC và implement trực tiếp theo AC.
|
|
57
|
+
|
|
58
|
+
### Bước 3 — Implement
|
|
59
|
+
|
|
60
|
+
**Nếu stack là Node.js/Express/Next.js** → invoke skill `js-backend-patterns` để tham khảo
|
|
61
|
+
repository pattern, service layer, N+1 prevention, caching, error handling trước khi code.
|
|
62
|
+
|
|
63
|
+
#### Nếu `use_tdd = true` trong `tas.yaml`:
|
|
64
|
+
a. **Red phase** — Viết test cases TRƯỚC theo AC trong Story. Chạy tests, xác nhận FAIL.
|
|
65
|
+
|
|
66
|
+
Platform-specific (từ stack detection):
|
|
67
|
+
- **Mobile (React Native)**: Jest + React Testing Library — Components (`render`, `fireEvent`, `screen`), Hooks (`renderHook`), Services/API (Jest mocks + MSW), Utils, Zustand stores. File: `src/**/*.test.ts(x)`
|
|
68
|
+
- **Web (React + Node)**: Vitest/Jest + React Testing Library — Components, Hooks, Services (MSW/Nock), Backend services (Jest). File: `src/**/*.test.ts(x)`
|
|
69
|
+
- **Backend (.NET)**: xUnit — Unit (services, repositories), Integration (TestServer), API (WebApplicationFactory). File: `tests/Unit/`, `tests/Integration/`, `tests/Api/`
|
|
70
|
+
|
|
71
|
+
b. **Green phase** — Viết code tối thiểu để pass tests.
|
|
72
|
+
c. **Refactor** — Clean up, đảm bảo tests vẫn pass.
|
|
73
|
+
|
|
74
|
+
#### Nếu `use_tdd = false`:
|
|
75
|
+
a. Implement code theo AC + Tasks trong Technical Plan
|
|
76
|
+
b. Viết unit tests cover các cases trong `## Unit Test Cases`
|
|
77
|
+
c. Chạy tests, fix nếu fail
|
|
78
|
+
→ Nếu tests vẫn fail sau 1 lần tự fix: launch `build-resolver` agent với error output để diagnose.
|
|
79
|
+
|
|
80
|
+
Trong quá trình implement, tick từng task hoàn thành trong Story file: `- [x] Task 1: ...`
|
|
81
|
+
|
|
82
|
+
Nếu phát hiện plan cần thay đổi đáng kể → thông báo user trước khi thay đổi hướng.
|
|
83
|
+
|
|
84
|
+
### Bước 4 — Post-Implementation Review (Isolated Agent)
|
|
85
|
+
|
|
86
|
+
Thực hiện theo `.claude/rules/common/post-review-agent.md`.
|
|
87
|
+
Truyền vào: Story file path, danh sách changed files, stack (từ CLAUDE.md), lang_agent.
|
|
88
|
+
|
|
89
|
+
### Bước 5 — Definition of Done
|
|
90
|
+
|
|
91
|
+
Đọc `.tas/checklists/story-done.md`, verify từng mục, tick vào Story:
|
|
92
|
+
- `- [x] Technical plan completed` — nếu plan_status: completed (hoặc quick mode xác nhận)
|
|
93
|
+
- `- [x] Code implemented` — nếu implement xong
|
|
94
|
+
- `- [x] Unit tests pass` — nếu tests đã pass
|
|
95
|
+
- `- [x] No regression` — nếu toàn bộ test suite pass
|
|
96
|
+
- `- [x] Documentation updated (if needed)` — nếu đã cập nhật
|
|
97
|
+
- `- [x] Code review passed` — nếu review gate pass (không có Critical/High)
|
|
98
|
+
- `- [ ] Acceptance criteria verified` — KHÔNG tick, để PE verify
|
|
99
|
+
|
|
100
|
+
**Optional — nếu Story thay đổi API public, database schema, hoặc setup:**
|
|
101
|
+
Launch `doc-updater` agent: cập nhật docs liên quan (README, SAD section, API docs).
|
|
102
|
+
> Scope: [danh sách changed files]. Story: [Story ID + title].
|
|
103
|
+
> Chỉ cập nhật phần docs đã lỗi thời — không viết lại từ đầu.
|
|
104
|
+
|
|
105
|
+
### Bước 6 — Wrap up
|
|
106
|
+
|
|
107
|
+
Cập nhật Story status → `In Progress` (nếu chưa).
|
|
108
|
+
Tạo commit message theo conventions trong `CLAUDE.md`.
|
|
109
|
+
Hỏi: "Tests OK và review passed rồi — bạn đã test thủ công chưa? Muốn chuyển sang Deploy Test không?"
|
|
110
|
+
|
|
111
|
+
Nếu Yes:
|
|
112
|
+
- Cập nhật Story status → `Deploy Test`
|
|
113
|
+
- Thêm Changelog entry
|
|
114
|
+
- Cập nhật `project-status.yaml`
|
|
115
|
+
- Gợi ý: `/ado-update story {ado-id} --status "Deploy Test"` nếu dùng ADO
|
|
116
|
+
|
|
117
|
+
## Nguyên tắc
|
|
118
|
+
- KHÔNG implement ngoài scope của Story
|
|
119
|
+
- Mỗi public method PHẢI có XML doc comment (C#) hoặc JSDoc (TypeScript) hoặc docstring (Python)
|
|
120
|
+
- Review phải chạy qua Agent độc lập — không inline trong session hiện tại
|
|
121
|
+
- **Khi nào cần tạo ADR** (nếu Technical Plan chưa đề cập):
|
|
122
|
+
- Thay đổi kiến trúc ảnh hưởng nhiều components
|
|
123
|
+
- Thêm mới design pattern hoặc framework
|
|
124
|
+
- Quyết định trade-off kỹ thuật quan trọng
|
|
125
|
+
|
|
126
|
+
## Bước cuối — Token Log
|
|
127
|
+
|
|
128
|
+
Invoke skill `token-logger`: ghi AI Usage Log vào file Story đang làm việc.
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
# /tas-e2e-mobile $ARGUMENTS
|
|
2
|
+
|
|
3
|
+
Vai tro: SE / QA
|
|
4
|
+
Generate Detox E2E test scripts tu mot E2E Scenario markdown file.
|
|
5
|
+
|
|
6
|
+
## QUAN TRONG - Layer 3: Mobile E2E Scripts
|
|
7
|
+
- Tao Detox test scripts tu E2E-Scenario (markdown)
|
|
8
|
+
- Scripts nam trong `apps/mobile/e2e/flows/`
|
|
9
|
+
- REUSE helpers tu Layer 2 functional tests (features/)
|
|
10
|
+
- Chain functional test steps thanh end-to-end flows
|
|
11
|
+
|
|
12
|
+
## Hanh dong
|
|
13
|
+
|
|
14
|
+
### Buoc 1: Xac dinh Scenario
|
|
15
|
+
1. $ARGUMENTS la path den E2E-Scenario-*.md file
|
|
16
|
+
2. Neu khong co: scan `docs/epics/**/E2E-Scenario-*.md` va `docs/e2e-scenarios/E2E-Scenario-*.md`
|
|
17
|
+
3. List scenarios va hoi user chon
|
|
18
|
+
|
|
19
|
+
### Buoc 2: Kiem tra Prerequisites
|
|
20
|
+
1. Kiem tra `apps/mobile/` ton tai. Neu khong → bao loi graceful
|
|
21
|
+
2. Doc scenario file de lay:
|
|
22
|
+
- Scenario steps va flow
|
|
23
|
+
- FT ID references (cot "Builds on FT IDs")
|
|
24
|
+
- FT Reuse Map (section cuoi)
|
|
25
|
+
- Test data per environment
|
|
26
|
+
- Scenario type (single-epic / cross-epic)
|
|
27
|
+
|
|
28
|
+
### Buoc 3: Tim Functional Test Helpers
|
|
29
|
+
Tu FT Reuse Map trong scenario:
|
|
30
|
+
1. Tim tung source file trong `apps/mobile/e2e/features/`
|
|
31
|
+
2. Verify helper functions ton tai
|
|
32
|
+
3. Neu helper khong ton tai → tao stub va ghi note "TODO: implement helper"
|
|
33
|
+
4. Import map: FT ID → file path → function name
|
|
34
|
+
|
|
35
|
+
### Buoc 4: Generate E2E Script
|
|
36
|
+
|
|
37
|
+
**File output**: `apps/mobile/e2e/flows/{scenario-slug}.e2e.ts`
|
|
38
|
+
|
|
39
|
+
**Structure**:
|
|
40
|
+
```typescript
|
|
41
|
+
/**
|
|
42
|
+
* E2E Flow: {Scenario Name}
|
|
43
|
+
* Scenario: {Scenario_ID}
|
|
44
|
+
* Epic(s): {Epic_ID(s)}
|
|
45
|
+
* Type: {single-epic | cross-epic}
|
|
46
|
+
*
|
|
47
|
+
* Generated by /tas-e2e-mobile
|
|
48
|
+
* Spec: {path to E2E-Scenario-*.md}
|
|
49
|
+
*/
|
|
50
|
+
|
|
51
|
+
import { device, element, expect, by, waitFor } from 'detox';
|
|
52
|
+
import { TEST_IDS } from '../test-ids';
|
|
53
|
+
import { loadTestData, getCredentials } from '../helpers/data-loader';
|
|
54
|
+
import { login, logout, navigateToTab } from '../helpers/test-utils';
|
|
55
|
+
|
|
56
|
+
// Layer 2 helpers (reuse from functional tests)
|
|
57
|
+
import { fillLoginForm, verifyLoginSuccess } from '../features/{epic}/{feature}/helpers';
|
|
58
|
+
import { viewAllergenList } from '../features/{epic2}/{feature2}/helpers';
|
|
59
|
+
|
|
60
|
+
const testData = loadTestData();
|
|
61
|
+
|
|
62
|
+
describe('E2E Flow: {Scenario Name}', () => {
|
|
63
|
+
beforeAll(async () => {
|
|
64
|
+
await device.launchApp({ newInstance: true });
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
// Main Flow
|
|
68
|
+
describe('{PROJECT}_E{EPIC}_E2E_001_H: {Flow Title}', () => {
|
|
69
|
+
it('Step 1: {Action}', async () => {
|
|
70
|
+
// Reuses: AL_E002_F002_S001_FT_001_H
|
|
71
|
+
const creds = getCredentials();
|
|
72
|
+
await fillLoginForm(creds.email, creds.password);
|
|
73
|
+
await verifyLoginSuccess();
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it('Step 2: {Action}', async () => {
|
|
77
|
+
// Reuses: AL_E003_F001_S001_FT_001_H
|
|
78
|
+
await viewAllergenList();
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it('Step 3: {New logic - no FT reference}', async () => {
|
|
82
|
+
// New step: no functional test helper exists
|
|
83
|
+
await element(by.id(TEST_IDS.SCAN.SCREEN.CAMERA)).tap();
|
|
84
|
+
// ...
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
// Alternate Flow (if defined in scenario)
|
|
89
|
+
describe('{PROJECT}_E{EPIC}_E2E_002_N: {Alternate Flow}', () => {
|
|
90
|
+
it('should handle {error condition}', async () => {
|
|
91
|
+
// ...
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Buoc 5: Update package.json Script
|
|
98
|
+
Them hoac update script trong `apps/mobile/package.json`:
|
|
99
|
+
```json
|
|
100
|
+
"e2e:flow:{scenario-slug}": "detox test --configuration ios.sim.debug --testPathPattern='e2e/flows/{scenario-slug}'"
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Buoc 6: Generate Execution Report (Optional)
|
|
104
|
+
Sau khi chay tests, generate report tu `.tas/templates/E2E-Execution-Report.md`:
|
|
105
|
+
- Summary metrics (passed/failed/skipped)
|
|
106
|
+
- Results by test ID
|
|
107
|
+
- Failed test details
|
|
108
|
+
- Performance metrics
|
|
109
|
+
- AC coverage analysis
|
|
110
|
+
|
|
111
|
+
## File Structure Output
|
|
112
|
+
```
|
|
113
|
+
apps/mobile/e2e/flows/
|
|
114
|
+
├── {scenario-1-slug}.e2e.ts
|
|
115
|
+
├── {scenario-2-slug}.e2e.ts
|
|
116
|
+
└── ...
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## Reuse Strategy
|
|
120
|
+
```
|
|
121
|
+
Layer 2 (features/) Layer 3 (flows/)
|
|
122
|
+
┌───────────────────┐ ┌──────────────────────┐
|
|
123
|
+
│ helpers.ts │──────>│ {scenario}.e2e.ts │
|
|
124
|
+
│ - fillLoginForm()│ │ import { fillLogin } │
|
|
125
|
+
│ - verifyLogin() │ │ import { viewList } │
|
|
126
|
+
└───────────────────┘ │ │
|
|
127
|
+
┌───────────────────┐ │ Step 1: fillLogin() │
|
|
128
|
+
│ helpers.ts │──────>│ Step 2: viewList() │
|
|
129
|
+
│ - viewList() │ │ Step 3: new logic │
|
|
130
|
+
└───────────────────┘ └──────────────────────┘
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## Chay Tests
|
|
134
|
+
```bash
|
|
135
|
+
# Chay E2E flow cu the
|
|
136
|
+
yarn e2e:flow:{scenario-slug}
|
|
137
|
+
|
|
138
|
+
# Chay tat ca E2E flows
|
|
139
|
+
npx detox test --configuration ios.sim.debug --testPathPattern='e2e/flows/'
|
|
140
|
+
|
|
141
|
+
# Chay voi Android
|
|
142
|
+
npx detox test --configuration android.emu.debug --testPathPattern='e2e/flows/{scenario}'
|
|
143
|
+
|
|
144
|
+
# Chay va generate report
|
|
145
|
+
npx detox test --configuration ios.sim.debug --testPathPattern='e2e/flows/{scenario}' --reporters=jest-junit
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## Nguyen tac
|
|
149
|
+
- PHAI reuse helpers tu Layer 2 khi co the, KHONG viet lai logic da co
|
|
150
|
+
- Moi step trong E2E flow nen tuong ung voi 1 functional test helper
|
|
151
|
+
- Steps khong co FT reference → viet logic moi trong flow file
|
|
152
|
+
- Scripts PHAI chay duoc tu CLI, KHONG can cua so Claude
|
|
153
|
+
- Neu apps/mobile/ khong ton tai → bao loi graceful
|
|
154
|
+
- describe block dung full E2E ID de grep duoc
|
|
155
|
+
- import paths: relative tu flows/ len features/
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
# /tas-e2e-web $ARGUMENTS
|
|
2
|
+
|
|
3
|
+
Vai tro: SE / QA
|
|
4
|
+
Generate Playwright E2E test scripts tu mot E2E Scenario markdown file.
|
|
5
|
+
|
|
6
|
+
## QUAN TRONG - Layer 3: Web E2E Scripts
|
|
7
|
+
- Tao Playwright test scripts tu E2E-Scenario (markdown)
|
|
8
|
+
- Scripts nam trong `apps/web/e2e/flows/`
|
|
9
|
+
- REUSE helpers tu Layer 2 functional tests (features/)
|
|
10
|
+
- Cross-browser testing (Chromium, Firefox, WebKit)
|
|
11
|
+
- Chain functional test steps thanh end-to-end flows
|
|
12
|
+
|
|
13
|
+
## Hanh dong
|
|
14
|
+
|
|
15
|
+
### Buoc 1: Xac dinh Scenario
|
|
16
|
+
1. $ARGUMENTS la path den E2E-Scenario-*.md file
|
|
17
|
+
2. Neu khong co: scan `docs/epics/**/E2E-Scenario-*.md` va `docs/e2e-scenarios/E2E-Scenario-*.md`
|
|
18
|
+
3. List scenarios va hoi user chon
|
|
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-e2e-mobile."
|
|
23
|
+
> DUNG LAI, KHONG tao file.
|
|
24
|
+
2. Doc scenario file de lay:
|
|
25
|
+
- Scenario steps va flow
|
|
26
|
+
- FT ID references
|
|
27
|
+
- FT Reuse Map
|
|
28
|
+
- Test data per environment
|
|
29
|
+
3. Doc `apps/web/playwright.config.ts` (neu co)
|
|
30
|
+
|
|
31
|
+
### Buoc 3: Tim Functional Test Helpers
|
|
32
|
+
Tu FT Reuse Map trong scenario:
|
|
33
|
+
1. Tim source files trong `apps/web/e2e/features/`
|
|
34
|
+
2. Verify helper functions va page objects ton tai
|
|
35
|
+
3. Neu helper khong ton tai → tao stub va ghi "TODO: implement helper"
|
|
36
|
+
4. Import map: FT ID → file path → function name
|
|
37
|
+
|
|
38
|
+
### Buoc 4: Generate E2E Script
|
|
39
|
+
|
|
40
|
+
**File output**: `apps/web/e2e/flows/{scenario-slug}.spec.ts`
|
|
41
|
+
|
|
42
|
+
**Structure**:
|
|
43
|
+
```typescript
|
|
44
|
+
/**
|
|
45
|
+
* E2E Flow: {Scenario Name}
|
|
46
|
+
* Scenario: {Scenario_ID}
|
|
47
|
+
* Epic(s): {Epic_ID(s)}
|
|
48
|
+
* Type: {single-epic | cross-epic}
|
|
49
|
+
*
|
|
50
|
+
* Generated by /tas-e2e-web
|
|
51
|
+
* Spec: {path to E2E-Scenario-*.md}
|
|
52
|
+
*/
|
|
53
|
+
|
|
54
|
+
import { test, expect, Page } from '@playwright/test';
|
|
55
|
+
import { loadTestData, getCredentials } from '../helpers/data-loader';
|
|
56
|
+
|
|
57
|
+
// Layer 2 helpers (reuse from functional tests)
|
|
58
|
+
import { fillLoginForm, verifyLoginSuccess } from '../features/{epic}/{feature}/helpers';
|
|
59
|
+
import { viewAllergenList } from '../features/{epic2}/{feature2}/helpers';
|
|
60
|
+
|
|
61
|
+
const testData = loadTestData();
|
|
62
|
+
|
|
63
|
+
test.describe('E2E Flow: {Scenario Name}', () => {
|
|
64
|
+
test.beforeEach(async ({ page }) => {
|
|
65
|
+
await page.goto(testData.baseUrl);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
// Main Flow
|
|
69
|
+
test.describe('{PROJECT}_E{EPIC}_E2E_001_H: {Flow Title}', () => {
|
|
70
|
+
test('Complete flow', async ({ page }) => {
|
|
71
|
+
// Step 1: Login (reuses AL_E002_F002_S001_FT_001_H)
|
|
72
|
+
const creds = getCredentials();
|
|
73
|
+
await fillLoginForm(page, creds.email, creds.password);
|
|
74
|
+
await verifyLoginSuccess(page);
|
|
75
|
+
|
|
76
|
+
// Step 2: View allergen list (reuses AL_E003_F001_S001_FT_001_H)
|
|
77
|
+
await viewAllergenList(page);
|
|
78
|
+
|
|
79
|
+
// Step 3: New logic (no FT reference)
|
|
80
|
+
await page.getByTestId('scan-button').click();
|
|
81
|
+
await expect(page.getByTestId('scan-result')).toBeVisible();
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
// Cross-browser validation
|
|
86
|
+
test.describe('{PROJECT}_E{EPIC}_E2E_001_H - Cross-browser', () => {
|
|
87
|
+
test('should complete flow on all browsers', async ({ page, browserName }) => {
|
|
88
|
+
test.info().annotations.push({ type: 'browser', description: browserName });
|
|
89
|
+
// Same flow, validated across browsers via Playwright projects config
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
// Alternate/Error flows
|
|
94
|
+
test.describe('{PROJECT}_E{EPIC}_E2E_002_N: {Error Flow}', () => {
|
|
95
|
+
test('should handle {error condition}', async ({ page }) => {
|
|
96
|
+
// ...
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Buoc 5: Update package.json Script
|
|
103
|
+
Them hoac update script trong `apps/web/package.json`:
|
|
104
|
+
```json
|
|
105
|
+
"e2e:flow:{scenario-slug}": "npx playwright test e2e/flows/{scenario-slug}"
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Buoc 6: Generate Execution Report (Optional)
|
|
109
|
+
Tu `.tas/templates/E2E-Execution-Report.md`:
|
|
110
|
+
- Bao gom browser-specific results
|
|
111
|
+
- Viewport testing results
|
|
112
|
+
- Performance metrics (LCP, INP, CLS)
|
|
113
|
+
|
|
114
|
+
## File Structure Output
|
|
115
|
+
```
|
|
116
|
+
apps/web/e2e/flows/
|
|
117
|
+
├── {scenario-1-slug}.spec.ts
|
|
118
|
+
├── {scenario-2-slug}.spec.ts
|
|
119
|
+
└── ...
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## Reuse Strategy
|
|
123
|
+
```
|
|
124
|
+
Layer 2 (features/) Layer 3 (flows/)
|
|
125
|
+
┌───────────────────┐ ┌──────────────────────────┐
|
|
126
|
+
│ helpers.ts │──────>│ {scenario}.spec.ts │
|
|
127
|
+
│ - fillLogin(page)│ │ import { fillLogin } │
|
|
128
|
+
│ - verify(page) │ │ import { viewList } │
|
|
129
|
+
└───────────────────┘ │ │
|
|
130
|
+
┌───────────────────┐ │ Step 1: fillLogin(page) │
|
|
131
|
+
│ helpers.ts │──────>│ Step 2: viewList(page) │
|
|
132
|
+
│ - viewList(page) │ │ Step 3: new logic │
|
|
133
|
+
└───────────────────┘ └──────────────────────────┘
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Note: Web helpers nhan `page: Page` parameter (khac voi mobile dung global Detox API).
|
|
137
|
+
|
|
138
|
+
## Chay Tests
|
|
139
|
+
```bash
|
|
140
|
+
# Chay E2E flow cu the
|
|
141
|
+
yarn e2e:flow:{scenario-slug}
|
|
142
|
+
|
|
143
|
+
# Chay tat ca E2E flows
|
|
144
|
+
npx playwright test e2e/flows/
|
|
145
|
+
|
|
146
|
+
# Chay chi tren Firefox
|
|
147
|
+
npx playwright test --project=firefox e2e/flows/{scenario}
|
|
148
|
+
|
|
149
|
+
# Chay voi debug UI
|
|
150
|
+
npx playwright test --ui e2e/flows/{scenario}
|
|
151
|
+
|
|
152
|
+
# Chay va generate HTML report
|
|
153
|
+
npx playwright test e2e/flows/{scenario} --reporter=html
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
## Nguyen tac
|
|
157
|
+
- PHAI reuse helpers tu Layer 2 khi co the
|
|
158
|
+
- Web helpers PHAI nhan `page: Page` parameter (dependency injection)
|
|
159
|
+
- Scripts PHAI chay duoc tu CLI
|
|
160
|
+
- Neu apps/web/ khong ton tai → bao loi graceful, KHONG tao
|
|
161
|
+
- Cross-browser: Chromium, Firefox, WebKit (tu playwright.config.ts)
|
|
162
|
+
- describe block dung full E2E ID
|
|
163
|
+
- import paths: relative tu flows/ len features/
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# /tas-e2e $ARGUMENTS
|
|
2
|
+
|
|
3
|
+
Vai tro: QA / PE
|
|
4
|
+
Generate E2E test scenario documents tu mot Epic hoac user flow description.
|
|
5
|
+
|
|
6
|
+
## QUAN TRONG - Layer 3: E2E Testing
|
|
7
|
+
- E2E tests kiem tra TOAN BO flow lien ket giua nhieu features/stories
|
|
8
|
+
- E2E scenario PHAI reference FT IDs tu Layer 2 (Functional Tests)
|
|
9
|
+
- E2E scripts (tao boi /tas-e2e-mobile hoac /tas-e2e-web) se REUSE helpers tu Layer 2
|
|
10
|
+
- Output la markdown scenario file, KHONG phai test code
|
|
11
|
+
|
|
12
|
+
## Hanh dong
|
|
13
|
+
|
|
14
|
+
### Buoc 1: Xac dinh Input
|
|
15
|
+
$ARGUMENTS co the la:
|
|
16
|
+
- **Epic ID** (vd: "Epic-002", "AL-Epic-002-authentication") → generate scenarios tu tat ca features/stories trong epic
|
|
17
|
+
- **Flow description** (vd: "user registration to first scan") → generate cross-epic scenario
|
|
18
|
+
|
|
19
|
+
Neu khong co $ARGUMENTS: list cac Epics hien co va hoi user chon.
|
|
20
|
+
|
|
21
|
+
### Buoc 2: Thu thap Context
|
|
22
|
+
|
|
23
|
+
#### Neu la Epic ID:
|
|
24
|
+
1. Doc Epic file va tat ca Feature files ben trong
|
|
25
|
+
2. Doc tat ca Story files cua cac Features
|
|
26
|
+
3. Tim tat ca `Func-Test-*.md` files de lay FT IDs
|
|
27
|
+
|
|
28
|
+
#### Neu la Flow Description:
|
|
29
|
+
1. Search across `docs/epics/` de tim Features/Stories lien quan
|
|
30
|
+
2. Xac dinh cac Epics lien quan (cross-epic scenario)
|
|
31
|
+
3. Thu thap FT IDs tu Func-Test-*.md files
|
|
32
|
+
|
|
33
|
+
### Buoc 3: Doc template
|
|
34
|
+
Doc `.tas/templates/E2E-Scenario.md`
|
|
35
|
+
Doc `root/tas.yaml` de lay project code
|
|
36
|
+
|
|
37
|
+
### Buoc 4: Generate Scenario
|
|
38
|
+
|
|
39
|
+
#### Naming Convention:
|
|
40
|
+
- **Single-epic**: `{PROJECT}_E{EPIC}_E2E_{NNN}_{MODIFIER}`
|
|
41
|
+
- Example: `AL_E002_E2E_001_H`
|
|
42
|
+
- **Cross-epic**: `{PROJECT}_XEPIC_E2E_{NNN}_{MODIFIER}`
|
|
43
|
+
- Example: `AL_XEPIC_E2E_001_H`
|
|
44
|
+
|
|
45
|
+
#### Scenario Steps Table:
|
|
46
|
+
Moi step PHAI co cot "Builds on FT IDs" de reference Layer 2:
|
|
47
|
+
|
|
48
|
+
```markdown
|
|
49
|
+
| Step | Screen/Page | Action | Expected Result | Builds on FT IDs |
|
|
50
|
+
|------|-------------|--------|-----------------|-------------------|
|
|
51
|
+
| 1 | Login Screen | User logs in | Home screen shown | AL_E002_F002_S001_FT_001_H |
|
|
52
|
+
| 2 | Home Screen | View allergen list | List displayed | AL_E003_F001_S001_FT_001_H |
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Neu step KHONG co FT reference → ghi "-" (new logic, chua co func test)
|
|
56
|
+
|
|
57
|
+
#### Noi dung generate:
|
|
58
|
+
1. Flow Overview (narrative description)
|
|
59
|
+
2. Scenario Steps table
|
|
60
|
+
3. Step Details (chi tiet tung buoc)
|
|
61
|
+
4. Alternate Flows (neu co)
|
|
62
|
+
5. Error Flows (neu co)
|
|
63
|
+
6. Test Data per environment
|
|
64
|
+
7. Prerequisites checklist
|
|
65
|
+
8. Success Criteria
|
|
66
|
+
9. FT Reuse Map (map step → FT ID → helper function)
|
|
67
|
+
|
|
68
|
+
### Buoc 5: Output File
|
|
69
|
+
- **Single-epic**: `docs/epics/{epic-dir}/E2E-Scenario-{NNN}-{slug}.md`
|
|
70
|
+
- **Cross-epic**: `docs/e2e-scenarios/E2E-Scenario-{NNN}-{slug}.md`
|
|
71
|
+
|
|
72
|
+
Auto-create `docs/e2e-scenarios/` directory neu chua ton tai.
|
|
73
|
+
|
|
74
|
+
### Buoc 6: Prompting
|
|
75
|
+
Sau khi generate, hoi user:
|
|
76
|
+
- "Co flow phu nao can cover khong?"
|
|
77
|
+
- "Co error scenario nao can them khong?"
|
|
78
|
+
- "Test data cho cac environment da day du chua?"
|
|
79
|
+
- "Co can test tren ca mobile va web khong?"
|
|
80
|
+
|
|
81
|
+
## FT Reuse Map
|
|
82
|
+
Moi scenario file co section "FT Reuse Map" de:
|
|
83
|
+
- Map scenario step → FT ID → source file → helper function
|
|
84
|
+
- /tas-e2e-mobile va /tas-e2e-web doc section nay de import helpers tu Layer 2
|
|
85
|
+
|
|
86
|
+
```markdown
|
|
87
|
+
## FT Reuse Map
|
|
88
|
+
| Step | FT ID | Source File | Helper Function |
|
|
89
|
+
|------|-------|-------------|-----------------|
|
|
90
|
+
| 1 | AL_E002_F002_S001_FT_001_H | features/auth/login/helpers.ts | fillLoginForm() |
|
|
91
|
+
| 2 | AL_E003_F001_S001_FT_001_H | features/home/allergens/helpers.ts | viewAllergenList() |
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Status Flow
|
|
95
|
+
Draft → Ready → Implemented → Verified
|
|
96
|
+
|
|
97
|
+
## Nguyen tac
|
|
98
|
+
- Output la MARKDOWN scenario, KHONG phai test code
|
|
99
|
+
- Test code duoc tao boi /tas-e2e-mobile hoac /tas-e2e-web
|
|
100
|
+
- Moi step NEN reference FT IDs khi co the (de reuse, khong viet lai)
|
|
101
|
+
- Scenario phai testable: co preconditions, test data, success criteria ro rang
|
|
102
|
+
- Cross-epic scenarios dung prefix XEPIC thay vi Epic number
|