@torus-engineering/tas-kit 1.9.0 → 1.11.1

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 (68) hide show
  1. package/.claude/commands/ado-create.md +17 -17
  2. package/.claude/commands/ado-delete.md +11 -11
  3. package/.claude/commands/ado-get.md +12 -12
  4. package/.claude/commands/ado-status.md +12 -12
  5. package/.claude/commands/ado-update.md +15 -15
  6. package/.claude/commands/tas-adr.md +33 -33
  7. package/.claude/commands/tas-apitest-plan.md +173 -173
  8. package/.claude/commands/tas-apitest.md +143 -143
  9. package/.claude/commands/tas-brainstorm.md +14 -14
  10. package/.claude/commands/tas-bug.md +113 -113
  11. package/.claude/commands/tas-design.md +37 -37
  12. package/.claude/commands/tas-dev.md +128 -128
  13. package/.claude/commands/tas-e2e-mobile.md +155 -155
  14. package/.claude/commands/tas-e2e-web.md +163 -163
  15. package/.claude/commands/tas-e2e.md +102 -102
  16. package/.claude/commands/tas-epic.md +35 -35
  17. package/.claude/commands/tas-feature.md +47 -47
  18. package/.claude/commands/tas-fix.md +51 -51
  19. package/.claude/commands/tas-functest-mobile.md +144 -144
  20. package/.claude/commands/tas-functest-web.md +192 -192
  21. package/.claude/commands/tas-functest.md +76 -76
  22. package/.claude/commands/tas-init.md +14 -14
  23. package/.claude/commands/tas-plan.md +198 -200
  24. package/.claude/commands/tas-prd.md +37 -37
  25. package/.claude/commands/tas-review.md +111 -111
  26. package/.claude/commands/tas-sad.md +43 -43
  27. package/.claude/commands/tas-security.md +87 -81
  28. package/.claude/commands/tas-spec.md +20 -20
  29. package/.claude/commands/tas-status.md +13 -13
  30. package/.claude/commands/tas-story.md +91 -91
  31. package/.claude/commands/tas-verify.md +51 -51
  32. package/.claude/rules/common/post-review-agent.md +49 -49
  33. package/.claude/rules/common/project-status.md +14 -14
  34. package/.claude/rules/common/stack-detection.md +6 -6
  35. package/.claude/rules/common/token-logging.md +27 -27
  36. package/.claude/rules/csharp/api-testing.md +171 -171
  37. package/.claude/skills/ado-integration/SKILL.md +36 -36
  38. package/.claude/skills/tas-conventions/SKILL.md +32 -32
  39. package/.claude/skills/tas-implementation-complete/SKILL.md +100 -99
  40. package/.claude/skills/tas-tdd/SKILL.md +123 -123
  41. package/.claude/skills/token-logger/SKILL.md +19 -19
  42. package/.tas/README.md +266 -1520
  43. package/.tas/checklists/code-review.md +13 -13
  44. package/.tas/checklists/security.md +3 -3
  45. package/.tas/checklists/story-done.md +11 -11
  46. package/.tas/hooks/README.md +138 -0
  47. package/.tas/hooks/pre-commit +26 -0
  48. package/.tas/hooks/security-scan.js +599 -0
  49. package/.tas/project-status-example.yaml +3 -3
  50. package/.tas/tas-example.yaml +25 -8
  51. package/.tas/templates/ADR.md +16 -16
  52. package/.tas/templates/API-Test-Spec.md +3 -3
  53. package/.tas/templates/Bug.md +12 -12
  54. package/.tas/templates/Design-Spec.md +8 -8
  55. package/.tas/templates/E2E-Execution-Report.md +1 -1
  56. package/.tas/templates/Epic.md +1 -1
  57. package/.tas/templates/Feature.md +10 -10
  58. package/.tas/templates/Func-Test-Spec.md +3 -3
  59. package/.tas/templates/SAD.md +106 -106
  60. package/.tas/templates/Security-Report.md +3 -3
  61. package/.tas/templates/Story.md +9 -9
  62. package/.tas/tools/tas-ado-readme.md +169 -169
  63. package/.tas/tools/tas-ado.py +1 -1
  64. package/CLAUDE-Example.md +37 -58
  65. package/README.md +294 -42
  66. package/bin/cli.js +24 -7
  67. package/lib/install.js +161 -47
  68. package/package.json +1 -1
@@ -1,128 +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 đã đủ 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` Story ID hoặc file path.
32
- Nếu không có: đọc `project-status.yaml`, tìm stories `status: Committed` hoặc `status: In Progress`. Nếu nhiều hơn một, liệt để 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 Technical Plan. Chạy `/tas-plan {Story-ID}` trước khi implement."
43
- - `require_plan: false` → tiếp tục, hiển thị warning chờ xác nhận:
44
- > "⚠️ Quick mode: Story chưa 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 Technical Plan (quick mode) → phân tích AC implement trực tiếp theo AC.
57
-
58
- ### Bước 3 — Implement
59
-
60
- **Nếu stack 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 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 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 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.
1
+ # /tas-dev $ARGUMENTS
2
+
3
+ Role: SE - Software Engineer
4
+ Implement a User Story per approved Technical Plan.
5
+
6
+ ## Always / Ask / Never
7
+
8
+ | | Action |
9
+ |---|---|
10
+ | **Always** | Check `plan_status` before implementing |
11
+ | **Always** | Follow tasks in Story's `## Technical Plan` |
12
+ | **Always** | Launch independent review agent after implement — no review in same session |
13
+ | **Ask** | When discover plan needs significant changes during coding |
14
+ | **Ask** | When need to read files outside plan scope |
15
+ | **Never** | Implement outside Story scope |
16
+ | **Never** | Skip review step after implement |
17
+
18
+ ## IMPORTANT - File Reading Rules
19
+ - ONLY read Story file — Technical Plan has enough technical context.
20
+ - Don't auto-read PRD, SAD, ADR, Design-Spec unless user confirms.
21
+ - Don't list directories, don't scan project structure.
22
+ - Don't read `.tas/checklists/story-done.md` at first step (only at final step).
23
+
24
+ ## Stack Detection
25
+ Read `.claude/rules/common/stack-detection.md`.
26
+
27
+ ## Actions
28
+
29
+ ### Step 1 — Identify Story
30
+
31
+ `$ARGUMENTS` is Story ID or file path.
32
+ If none: read `project-status.yaml`, find stories with `status: Committed` or `status: In Progress`. If more than one, list for user to choose.
33
+ Read Story file.
34
+
35
+ ### Step 1.5 — Gate: Check plan_status
36
+
37
+ Read `plan_status` from Story frontmatter.
38
+
39
+ **If `plan_status: pending`:**
40
+ Read `require_plan` from root/`tas.yaml`:
41
+ - `require_plan: true` (or field doesn't exist) → **STOP**:
42
+ > "This Story has no Technical Plan. Run `/tas-plan {Story-ID}` before implementing."
43
+ - `require_plan: false` → continue, show warning and wait for confirmation:
44
+ > "⚠️ Quick mode: Story has no Technical Plan. Continue implementing?"
45
+
46
+ **If `plan_status: completed`:** continue normally.
47
+
48
+ ### Step 2 — Read Technical Plan
49
+
50
+ From Story file, read `## Technical Plan` section:
51
+ - Chosen approach
52
+ - Files to Change / Files to Create
53
+ - Database Changes, Config Changes
54
+ - Tasks list (checklist to follow in order)
55
+
56
+ If no Technical Plan (quick mode) → analyze AC and implement directly per AC.
57
+
58
+ ### Step 3 — Implement
59
+
60
+ **If stack is Node.js/Express/Next.js** → invoke skill `js-backend-patterns` to reference
61
+ repository pattern, service layer, N+1 prevention, caching, error handling before coding.
62
+
63
+ #### If `use_tdd = true` in `tas.yaml`:
64
+ a. **Red phase** — Write test cases FIRST per AC in Story. Run tests, confirm FAIL.
65
+
66
+ Platform-specific (from 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** — Write minimal code to pass tests.
72
+ c. **Refactor** — Clean up, ensure tests still pass.
73
+
74
+ #### If `use_tdd = false`:
75
+ a. Implement code per AC + Tasks in Technical Plan
76
+ b. Write unit tests covering cases in `## Unit Test Cases`
77
+ c. Run tests, fix if fail
78
+ If tests still fail after 1 self-fix: launch `build-resolver` agent with error output to diagnose.
79
+
80
+ During implementation, tick each completed task in Story file: `- [x] Task 1: ...`
81
+
82
+ If discover plan needs significant changesnotify user before changing direction.
83
+
84
+ ### Step 4 — Post-Implementation Review (Isolated Agent)
85
+
86
+ Follow `.claude/rules/common/post-review-agent.md`.
87
+ Pass in: Story file path, changed files list, stack (from CLAUDE.md), lang_agent.
88
+
89
+ ### Step 5 — Definition of Done
90
+
91
+ Read `.tas/checklists/story-done.md`, verify each item, tick in Story:
92
+ - `- [x] Technical plan completed` — if plan_status: completed (or quick mode confirmed)
93
+ - `- [x] Code implemented` — if implementation done
94
+ - `- [x] Unit tests pass` — if tests passed
95
+ - `- [x] No regression` — if full test suite passed
96
+ - `- [x] Documentation updated (if needed)` — if updated
97
+ - `- [x] Code review passed` — if review gate passed (no Critical/High)
98
+ - `- [ ] Acceptance criteria verified` — DO NOT tick, let PE verify
99
+
100
+ **Optional — if Story changes public API, database schema, or setup:**
101
+ Launch `doc-updater` agent: update related docs (README, SAD section, API docs).
102
+ > Scope: [changed files list]. Story: [Story ID + title].
103
+ > Only update outdated docs — don't rewrite from scratch.
104
+
105
+ ### Step 6 — Wrap up
106
+
107
+ Update Story status → `In Progress` (if not already).
108
+ Create commit message per conventions in `CLAUDE.md`.
109
+ Ask: "Tests OK and review passed — have you tested manually? Want to move to Deploy Test?"
110
+
111
+ If Yes:
112
+ - Update Story status → `Deploy Test`
113
+ - Add Changelog entry
114
+ - Update `project-status.yaml`
115
+ - Suggest: `/ado-update story {ado-id} --status "Deploy Test"` if using ADO
116
+
117
+ ## Principles
118
+ - DO NOT implement outside Story scope
119
+ - Each public method MUST have XML doc comment (C#) or JSDoc (TypeScript) or docstring (Python)
120
+ - Review must run through independent Agent — not inline in current session
121
+ - **When to create ADR** (if Technical Plan didn't mention):
122
+ - Architecture changes affecting multiple components
123
+ - New design pattern or framework
124
+ - Important technical trade-off decisions
125
+
126
+ ## Final Step — Token Log
127
+
128
+ Invoke skill `token-logger`: write AI Usage Log to working Story file.
@@ -1,155 +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 khongbao 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/
1
+ # /tas-e2e-mobile $ARGUMENTS
2
+
3
+ Role: SE / QA
4
+ Generate Detox E2E test scripts from an E2E Scenario markdown file.
5
+
6
+ ## IMPORTANT - Layer 3: Mobile E2E Scripts
7
+ - Create Detox test scripts from E2E-Scenario (markdown)
8
+ - Scripts located in `apps/mobile/e2e/flows/`
9
+ - REUSE helpers from Layer 2 functional tests (features/)
10
+ - Chain functional test steps into end-to-end flows
11
+
12
+ ## Actions
13
+
14
+ ### Step 1: Identify Scenario
15
+ 1. $ARGUMENTS is path to E2E-Scenario-*.md file
16
+ 2. If not provided: scan `docs/epics/**/E2E-Scenario-*.md` and `docs/e2e-scenarios/E2E-Scenario-*.md`
17
+ 3. List scenarios and ask user to choose
18
+
19
+ ### Step 2: Check Prerequisites
20
+ 1. Check `apps/mobile/` exists. If notgraceful error
21
+ 2. Read scenario file to get:
22
+ - Scenario steps and flow
23
+ - FT ID references ("Builds on FT IDs" column)
24
+ - FT Reuse Map (section at end)
25
+ - Test data per environment
26
+ - Scenario type (single-epic / cross-epic)
27
+
28
+ ### Step 3: Find Functional Test Helpers
29
+ From FT Reuse Map in scenario:
30
+ 1. Find each source file in `apps/mobile/e2e/features/`
31
+ 2. Verify helper functions exist
32
+ 3. If helper doesn't existcreate stub and note "TODO: implement helper"
33
+ 4. Import map: FT ID → file path → function name
34
+
35
+ ### Step 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
+ ### Step 5: Update package.json Script
98
+ Add or update script in `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
+ ### Step 6: Generate Execution Report (Optional)
104
+ After running tests, generate report from `.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
+ ## Run Tests
134
+ ```bash
135
+ # Run specific E2E flow
136
+ yarn e2e:flow:{scenario-slug}
137
+
138
+ # Run all E2E flows
139
+ npx detox test --configuration ios.sim.debug --testPathPattern='e2e/flows/'
140
+
141
+ # Run with Android
142
+ npx detox test --configuration android.emu.debug --testPathPattern='e2e/flows/{scenario}'
143
+
144
+ # Run and generate report
145
+ npx detox test --configuration ios.sim.debug --testPathPattern='e2e/flows/{scenario}' --reporters=jest-junit
146
+ ```
147
+
148
+ ## Principles
149
+ - MUST reuse helpers from Layer 2 when possible, DO NOT rewrite existing logic
150
+ - Each step in E2E flow should correspond to 1 functional test helper
151
+ - Steps without FT reference → write new logic in flow file
152
+ - Scripts MUST be runnable from CLI, WITHOUT Claude window
153
+ - If apps/mobile/ doesn't existgraceful error
154
+ - describe block uses full E2E ID for grep-ability
155
+ - import paths: relative from flows/ up to features/