chore: update project documentation, audit reports, and initialize IDE configuration files
Some checks failed
CI / Lint → Typecheck → Test → Build (22) (push) Failing after 29s
CI / E2E Tests (push) Has been skipped
CodeQL Analysis / CodeQL (javascript-typescript) (push) Failing after 2m42s
Deploy / Build Web Image (push) Failing after 27s
Deploy / Build AI Services Image (push) Failing after 29s
E2E Tests / Playwright E2E (push) Failing after 43s
Deploy / Build API Image (push) Failing after 1m31s
Security Scanning / Dependency Audit (pnpm) (push) Failing after 6s
Security Scanning / Trivy Scan — API Image (push) Failing after 5m35s
Security Scanning / Trivy Scan — AI Services Image (push) Failing after 3m45s
Deploy / Deploy to Staging (push) Has been skipped
Deploy / Smoke Test Staging (push) Has been skipped
Deploy / Deploy to Production (push) Has been skipped
Deploy / Smoke Test Production (push) Has been skipped
Deploy / Rollback Staging (push) Has been skipped
Deploy / Rollback Production (push) Has been skipped
Security Scanning / Trivy Scan — Web Image (push) Failing after 13m51s
Security Scanning / Trivy Filesystem Scan (push) Failing after 14m46s
Security Scanning / Security Gate (push) Has been cancelled
Some checks failed
CI / Lint → Typecheck → Test → Build (22) (push) Failing after 29s
CI / E2E Tests (push) Has been skipped
CodeQL Analysis / CodeQL (javascript-typescript) (push) Failing after 2m42s
Deploy / Build Web Image (push) Failing after 27s
Deploy / Build AI Services Image (push) Failing after 29s
E2E Tests / Playwright E2E (push) Failing after 43s
Deploy / Build API Image (push) Failing after 1m31s
Security Scanning / Dependency Audit (pnpm) (push) Failing after 6s
Security Scanning / Trivy Scan — API Image (push) Failing after 5m35s
Security Scanning / Trivy Scan — AI Services Image (push) Failing after 3m45s
Deploy / Deploy to Staging (push) Has been skipped
Deploy / Smoke Test Staging (push) Has been skipped
Deploy / Deploy to Production (push) Has been skipped
Deploy / Smoke Test Production (push) Has been skipped
Deploy / Rollback Staging (push) Has been skipped
Deploy / Rollback Production (push) Has been skipped
Security Scanning / Trivy Scan — Web Image (push) Failing after 13m51s
Security Scanning / Trivy Filesystem Scan (push) Failing after 14m46s
Security Scanning / Security Gate (push) Has been cancelled
This commit is contained in:
@@ -1,383 +1,383 @@
|
||||
# Test Coverage Documentation Index
|
||||
# Chỉ Mục Tài Liệu Kiểm Thử
|
||||
|
||||
**Generated:** 2026-04-11
|
||||
**Total Lines of Documentation:** 3,014
|
||||
**Total Files Analyzed:** 17 untested source files
|
||||
**Tạo ngày:** 2026-04-11
|
||||
**Tổng số dòng tài liệu:** 3.014
|
||||
**Tổng số tệp được phân tích:** 17 tệp nguồn chưa có kiểm thử
|
||||
|
||||
---
|
||||
|
||||
## 📚 Documentation Files
|
||||
## 📚 Các Tệp Tài Liệu
|
||||
|
||||
### 1. **README_TEST_COVERAGE.md** (9.1 KB)
|
||||
Start here for complete overview and roadmap.
|
||||
### 1. **README_TEST_COVERAGE.md** (9,1 KB)
|
||||
Bắt đầu từ đây để có cái nhìn tổng quan đầy đủ và lộ trình thực hiện.
|
||||
|
||||
**Contains:**
|
||||
- Overview of all 4 documentation files
|
||||
- File organization by module (Inquiries, Leads, Reviews)
|
||||
- Priority testing levels (Critical 🔴, High 🟡, Medium 🟢)
|
||||
- 3-week testing roadmap with time estimates
|
||||
- Key testing patterns for each file type
|
||||
- Critical formulas to verify in tests
|
||||
- Common test data and import statements
|
||||
- Troubleshooting guide
|
||||
- Quick start instructions
|
||||
**Nội dung:**
|
||||
- Tổng quan về cả 4 tệp tài liệu
|
||||
- Tổ chức tệp theo mô-đun (Inquiries, Leads, Reviews)
|
||||
- Mức độ ưu tiên kiểm thử (Quan trọng 🔴, Cao 🟡, Trung bình 🟢)
|
||||
- Lộ trình kiểm thử 3 tuần kèm ước tính thời gian
|
||||
- Các mẫu kiểm thử quan trọng cho từng loại tệp
|
||||
- Các công thức then chốt cần xác minh trong kiểm thử
|
||||
- Dữ liệu kiểm thử chung và câu lệnh import
|
||||
- Hướng dẫn xử lý sự cố
|
||||
- Hướng dẫn khởi động nhanh
|
||||
|
||||
**Time to read:** 5-10 minutes
|
||||
**Thời gian đọc:** 5–10 phút
|
||||
|
||||
---
|
||||
|
||||
### 2. **TEST_COVERAGE_ANALYSIS.md** (55 KB)
|
||||
Complete reference with all 17 source files and full implementations.
|
||||
Tài liệu tham khảo đầy đủ với tất cả 17 tệp nguồn và triển khai chi tiết.
|
||||
|
||||
**Contains:**
|
||||
- Executive summary
|
||||
- **PART 1: INQUIRIES MODULE** (4 files)
|
||||
- PrismaInquiryRepository (146 lines)
|
||||
- InquiriesController (120 lines)
|
||||
- CreateInquiryDto (20 lines)
|
||||
- ListInquiriesDto (20 lines)
|
||||
**Nội dung:**
|
||||
- Tóm tắt điều hành
|
||||
- **PHẦN 1: MÔ-ĐUN INQUIRIES** (4 tệp)
|
||||
- PrismaInquiryRepository (146 dòng)
|
||||
- InquiriesController (120 dòng)
|
||||
- CreateInquiryDto (20 dòng)
|
||||
- ListInquiriesDto (20 dòng)
|
||||
|
||||
- **PART 2: LEADS MODULE** (6 files)
|
||||
- PrismaLeadRepository (151 lines)
|
||||
- LeadScore ValueObject (16 lines)
|
||||
- LeadsController (126 lines)
|
||||
- CreateLeadDto (35 lines)
|
||||
- ListLeadsDto (30 lines)
|
||||
- UpdateLeadStatusDto (14 lines)
|
||||
- **PHẦN 2: MÔ-ĐUN LEADS** (6 tệp)
|
||||
- PrismaLeadRepository (151 dòng)
|
||||
- LeadScore ValueObject (16 dòng)
|
||||
- LeadsController (126 dòng)
|
||||
- CreateLeadDto (35 dòng)
|
||||
- ListLeadsDto (30 dòng)
|
||||
- UpdateLeadStatusDto (14 dòng)
|
||||
|
||||
- **PART 3: REVIEWS MODULE** (5 files)
|
||||
- PrismaReviewRepository (162 lines)
|
||||
- Rating ValueObject (16 lines)
|
||||
- ReviewsController (122 lines)
|
||||
- CreateReviewDto (26 lines)
|
||||
- ListReviewsDto (42 lines)
|
||||
- **PHẦN 3: MÔ-ĐUN REVIEWS** (5 tệp)
|
||||
- PrismaReviewRepository (162 dòng)
|
||||
- Rating ValueObject (16 dòng)
|
||||
- ReviewsController (122 dòng)
|
||||
- CreateReviewDto (26 dòng)
|
||||
- ListReviewsDto (42 dòng)
|
||||
|
||||
- **PART 4: REFERENCE TEST PATTERNS** (3 test files)
|
||||
- CreateInquiryHandler test pattern
|
||||
- CreateLeadHandler test pattern
|
||||
- ReviewsController test pattern
|
||||
- **PHẦN 4: MẪU KIỂM THỬ THAM KHẢO** (3 tệp kiểm thử)
|
||||
- Mẫu kiểm thử CreateInquiryHandler
|
||||
- Mẫu kiểm thử CreateLeadHandler
|
||||
- Mẫu kiểm thử ReviewsController
|
||||
|
||||
- Summary table of all files
|
||||
- Testing priorities
|
||||
- Test coverage goals
|
||||
- Bảng tóm tắt tất cả tệp
|
||||
- Các ưu tiên kiểm thử
|
||||
- Mục tiêu độ bao phủ kiểm thử
|
||||
|
||||
**Time to read:** 30-45 minutes for complete review
|
||||
**Thời gian đọc:** 30–45 phút để xem xét đầy đủ
|
||||
|
||||
**How to use:**
|
||||
1. Find the file you want to test
|
||||
2. Read the full implementation
|
||||
3. Review the "Key Methods to Test" section
|
||||
4. Check "Test Scenarios" section
|
||||
5. Cross-reference with templates in TEST_TEMPLATES.md
|
||||
**Cách sử dụng:**
|
||||
1. Tìm tệp bạn muốn kiểm thử
|
||||
2. Đọc toàn bộ phần triển khai
|
||||
3. Xem mục "Key Methods to Test"
|
||||
4. Kiểm tra mục "Test Scenarios"
|
||||
5. Đối chiếu với các mẫu trong TEST_TEMPLATES.md
|
||||
|
||||
---
|
||||
|
||||
### 3. **TEST_COVERAGE_QUICK_REFERENCE.md** (9.1 KB)
|
||||
Checklists and quick lookup reference.
|
||||
### 3. **TEST_COVERAGE_QUICK_REFERENCE.md** (9,1 KB)
|
||||
Danh sách kiểm tra và tài liệu tra cứu nhanh.
|
||||
|
||||
**Contains:**
|
||||
- 17 files overview with line counts
|
||||
- Quick test scenarios by type:
|
||||
- Repositories (3 files) - checklist + specific notes
|
||||
- Value Objects (2 files) - validation ranges
|
||||
- Controllers (2 files) - endpoint checklist
|
||||
- DTOs (10 files) - validation rules
|
||||
**Nội dung:**
|
||||
- Tổng quan 17 tệp kèm số dòng
|
||||
- Các kịch bản kiểm thử nhanh theo loại:
|
||||
- Repositories (3 tệp) — danh sách kiểm tra + ghi chú cụ thể
|
||||
- Value Objects (2 tệp) — phạm vi xác thực
|
||||
- Controllers (2 tệp) — danh sách kiểm tra endpoint
|
||||
- DTOs (10 tệp) — quy tắc xác thực
|
||||
|
||||
- Test priority matrix:
|
||||
- Critical: 4 items (business logic)
|
||||
- High: 5 items (data integrity)
|
||||
- Medium: 3 items (validation/guards)
|
||||
- Ma trận ưu tiên kiểm thử:
|
||||
- Quan trọng: 4 mục (logic nghiệp vụ)
|
||||
- Cao: 5 mục (toàn vẹn dữ liệu)
|
||||
- Trung bình: 3 mục (xác thực/guards)
|
||||
|
||||
- Test execution order recommendation
|
||||
- Mock setup templates (4 examples)
|
||||
- Key formulas to verify
|
||||
- File locations reference
|
||||
- Khuyến nghị thứ tự thực thi kiểm thử
|
||||
- Mẫu thiết lập mock (4 ví dụ)
|
||||
- Các công thức then chốt cần xác minh
|
||||
- Tài liệu tham chiếu vị trí tệp
|
||||
|
||||
**Time to read:** 3-5 minutes for lookup
|
||||
**Thời gian đọc:** 3–5 phút để tra cứu
|
||||
|
||||
**How to use:**
|
||||
1. Find the file type you're testing
|
||||
2. Check the quick checklist
|
||||
3. Jump to detailed section in Analysis for more info
|
||||
4. Copy the mock template from this file
|
||||
**Cách sử dụng:**
|
||||
1. Tìm loại tệp bạn đang kiểm thử
|
||||
2. Kiểm tra danh sách kiểm tra nhanh
|
||||
3. Chuyển đến mục chi tiết trong Analysis để biết thêm thông tin
|
||||
4. Sao chép mẫu mock từ tệp này
|
||||
|
||||
---
|
||||
|
||||
### 4. **TEST_TEMPLATES.md** (16 KB)
|
||||
Ready-to-use code templates for all file types.
|
||||
Các mẫu code sẵn sàng sử dụng cho tất cả loại tệp.
|
||||
|
||||
**Contains:**
|
||||
- Repository Test Template
|
||||
- Setup with mocked Prisma
|
||||
- Test findById()
|
||||
- Test save()
|
||||
- Test findByListing() with pagination
|
||||
**Nội dung:**
|
||||
- Mẫu kiểm thử Repository
|
||||
- Thiết lập với Prisma được mock
|
||||
- Kiểm thử findById()
|
||||
- Kiểm thử save()
|
||||
- Kiểm thử findByListing() với phân trang
|
||||
|
||||
- Value Object Test Template
|
||||
- Test create() with valid values
|
||||
- Test boundary values
|
||||
- Test invalid values
|
||||
- Test error messages
|
||||
- Test getters
|
||||
- Mẫu kiểm thử Value Object
|
||||
- Kiểm thử create() với giá trị hợp lệ
|
||||
- Kiểm thử giá trị biên
|
||||
- Kiểm thử giá trị không hợp lệ
|
||||
- Kiểm thử thông báo lỗi
|
||||
- Kiểm thử getters
|
||||
|
||||
- DTO Test Template
|
||||
- Test required fields validation
|
||||
- Test optional fields
|
||||
- Test field constraints (email, range)
|
||||
- Test type transformation
|
||||
- Mẫu kiểm thử DTO
|
||||
- Kiểm thử xác thực trường bắt buộc
|
||||
- Kiểm thử trường tùy chọn
|
||||
- Kiểm thử ràng buộc trường (email, phạm vi)
|
||||
- Kiểm thử chuyển đổi kiểu dữ liệu
|
||||
|
||||
- Controller Test Template
|
||||
- Setup with mocked buses
|
||||
- Test command dispatch
|
||||
- Test parameter mapping
|
||||
- Test null handling
|
||||
- Test default values
|
||||
- Mẫu kiểm thử Controller
|
||||
- Thiết lập với bus được mock
|
||||
- Kiểm thử điều phối lệnh (command dispatch)
|
||||
- Kiểm thử ánh xạ tham số
|
||||
- Kiểm thử xử lý null
|
||||
- Kiểm thử giá trị mặc định
|
||||
|
||||
- Helper Tests
|
||||
- Pagination calculation tests
|
||||
- Aggregation formula tests
|
||||
- DTO pagination tests
|
||||
- Các kiểm thử trợ giúp
|
||||
- Kiểm thử tính toán phân trang
|
||||
- Kiểm thử công thức tổng hợp
|
||||
- Kiểm thử phân trang DTO
|
||||
|
||||
**Time to read:** 10-15 minutes while writing tests
|
||||
**Thời gian đọc:** 10–15 phút trong khi viết kiểm thử
|
||||
|
||||
**How to use:**
|
||||
1. Copy the appropriate template for your file type
|
||||
2. Paste into your test file
|
||||
3. Replace generic names with your specific file names
|
||||
4. Update imports and test data
|
||||
5. Run and verify tests pass
|
||||
**Cách sử dụng:**
|
||||
1. Sao chép mẫu phù hợp cho loại tệp của bạn
|
||||
2. Dán vào tệp kiểm thử
|
||||
3. Thay thế tên chung bằng tên tệp cụ thể của bạn
|
||||
4. Cập nhật các import và dữ liệu kiểm thử
|
||||
5. Chạy và xác minh kiểm thử vượt qua
|
||||
|
||||
---
|
||||
|
||||
## 🎯 Quick Navigation by Task
|
||||
## 🎯 Điều Hướng Nhanh Theo Nhiệm Vụ
|
||||
|
||||
### "I want to understand what needs testing"
|
||||
→ Start with **README_TEST_COVERAGE.md** (5 min)
|
||||
→ Then **TEST_COVERAGE_QUICK_REFERENCE.md** (3 min)
|
||||
### "Tôi muốn hiểu những gì cần kiểm thử"
|
||||
→ Bắt đầu với **README_TEST_COVERAGE.md** (5 phút)
|
||||
→ Sau đó **TEST_COVERAGE_QUICK_REFERENCE.md** (3 phút)
|
||||
|
||||
### "I want to write tests for a specific file"
|
||||
→ Find the file in **TEST_COVERAGE_QUICK_REFERENCE.md**
|
||||
→ Read detailed implementation in **TEST_COVERAGE_ANALYSIS.md**
|
||||
→ Copy template from **TEST_TEMPLATES.md**
|
||||
→ Adapt template to your file
|
||||
### "Tôi muốn viết kiểm thử cho một tệp cụ thể"
|
||||
→ Tìm tệp trong **TEST_COVERAGE_QUICK_REFERENCE.md**
|
||||
→ Đọc triển khai chi tiết trong **TEST_COVERAGE_ANALYSIS.md**
|
||||
→ Sao chép mẫu từ **TEST_TEMPLATES.md**
|
||||
→ Điều chỉnh mẫu theo tệp của bạn
|
||||
|
||||
### "I want to understand a specific component"
|
||||
→ Look up file in **TEST_COVERAGE_ANALYSIS.md**
|
||||
→ Find section with "Key Methods to Test"
|
||||
→ Find section with "Test Scenarios"
|
||||
→ Check **TEST_TEMPLATES.md** for pattern
|
||||
### "Tôi muốn hiểu một thành phần cụ thể"
|
||||
→ Tra cứu tệp trong **TEST_COVERAGE_ANALYSIS.md**
|
||||
→ Tìm mục "Key Methods to Test"
|
||||
→ Tìm mục "Test Scenarios"
|
||||
→ Kiểm tra **TEST_TEMPLATES.md** để xem mẫu
|
||||
|
||||
### "I want formulas and calculations"
|
||||
→ **TEST_COVERAGE_QUICK_REFERENCE.md** - "Key Formulas to Verify"
|
||||
→ **TEST_TEMPLATES.md** - Aggregation Test Helper
|
||||
→ **TEST_COVERAGE_ANALYSIS.md** - Specific repo section
|
||||
### "Tôi muốn công thức và phép tính"
|
||||
→ **TEST_COVERAGE_QUICK_REFERENCE.md** — "Key Formulas to Verify"
|
||||
→ **TEST_TEMPLATES.md** — Aggregation Test Helper
|
||||
→ **TEST_COVERAGE_ANALYSIS.md** — Mục repo cụ thể
|
||||
|
||||
### "I need mock setup examples"
|
||||
→ **TEST_COVERAGE_QUICK_REFERENCE.md** - Mock Setup Template
|
||||
→ **TEST_TEMPLATES.md** - First section for each type
|
||||
### "Tôi cần ví dụ thiết lập mock"
|
||||
→ **TEST_COVERAGE_QUICK_REFERENCE.md** — Mock Setup Template
|
||||
→ **TEST_TEMPLATES.md** — Phần đầu tiên cho mỗi loại
|
||||
|
||||
---
|
||||
|
||||
## 📋 17 Files at a Glance
|
||||
## 📋 17 Tệp Tổng Quan
|
||||
|
||||
### Inquiries (4 files)
|
||||
| File | Type | Key Test |
|
||||
|------|------|----------|
|
||||
| prisma-inquiry.repository.ts | Repository | Pagination, relationships |
|
||||
| inquiries.controller.ts | Controller | 4 endpoints, guards |
|
||||
| create-inquiry.dto.ts | DTO | 3 validations |
|
||||
| list-inquiries.dto.ts | DTO | Pagination validation |
|
||||
### Inquiries (4 tệp)
|
||||
| Tệp | Loại | Kiểm thử chính |
|
||||
|-----|------|----------------|
|
||||
| prisma-inquiry.repository.ts | Repository | Phân trang, quan hệ |
|
||||
| inquiries.controller.ts | Controller | 4 endpoint, guards |
|
||||
| create-inquiry.dto.ts | DTO | 3 xác thực |
|
||||
| list-inquiries.dto.ts | DTO | Xác thực phân trang |
|
||||
|
||||
### Leads (6 files)
|
||||
| File | Type | Key Test |
|
||||
|------|------|----------|
|
||||
| prisma-lead.repository.ts | Repository | Stats aggregation |
|
||||
| lead-score.vo.ts | ValueObject | Range 0-100 |
|
||||
| leads.controller.ts | Controller | 5 endpoints, role guard |
|
||||
| create-lead.dto.ts | DTO | 6 validations |
|
||||
| list-leads.dto.ts | DTO | Status enum |
|
||||
| update-lead-status.dto.ts | DTO | Status validation |
|
||||
### Leads (6 tệp)
|
||||
| Tệp | Loại | Kiểm thử chính |
|
||||
|-----|------|----------------|
|
||||
| prisma-lead.repository.ts | Repository | Tổng hợp thống kê |
|
||||
| lead-score.vo.ts | ValueObject | Phạm vi 0–100 |
|
||||
| leads.controller.ts | Controller | 5 endpoint, role guard |
|
||||
| create-lead.dto.ts | DTO | 6 xác thực |
|
||||
| list-leads.dto.ts | DTO | Enum trạng thái |
|
||||
| update-lead-status.dto.ts | DTO | Xác thực trạng thái |
|
||||
|
||||
### Reviews (5 files)
|
||||
| File | Type | Key Test |
|
||||
|------|------|----------|
|
||||
| prisma-review.repository.ts | Repository | Distribution stats |
|
||||
| rating.vo.ts | ValueObject | Integer 1-5 only |
|
||||
| reviews.controller.ts | Controller | 5 endpoints, mixed auth |
|
||||
| create-review.dto.ts | DTO | 4 validations |
|
||||
| list-reviews.dto.ts | DTO | 2 DTOs, pagination |
|
||||
### Reviews (5 tệp)
|
||||
| Tệp | Loại | Kiểm thử chính |
|
||||
|-----|------|----------------|
|
||||
| prisma-review.repository.ts | Repository | Thống kê phân phối |
|
||||
| rating.vo.ts | ValueObject | Chỉ số nguyên 1–5 |
|
||||
| reviews.controller.ts | Controller | 5 endpoint, xác thực hỗn hợp |
|
||||
| create-review.dto.ts | DTO | 4 xác thực |
|
||||
| list-reviews.dto.ts | DTO | 2 DTO, phân trang |
|
||||
|
||||
---
|
||||
|
||||
## ⏱️ Time Estimates
|
||||
## ⏱️ Ước Tính Thời Gian
|
||||
|
||||
### By File Type
|
||||
- **Value Objects** (2 files): 30-45 minutes
|
||||
- **DTOs** (10 files): 2-3 hours (using templates)
|
||||
- **Controllers** (2 files): 1.5-2 hours
|
||||
- **Repositories** (3 files): 2.5-3.5 hours
|
||||
### Theo Loại Tệp
|
||||
- **Value Objects** (2 tệp): 30–45 phút
|
||||
- **DTOs** (10 tệp): 2–3 giờ (sử dụng mẫu)
|
||||
- **Controllers** (2 tệp): 1,5–2 giờ
|
||||
- **Repositories** (3 tệp): 2,5–3,5 giờ
|
||||
|
||||
### Total: 9-14 hours
|
||||
### Tổng cộng: 9–14 giờ
|
||||
|
||||
### Recommended Order
|
||||
1. Value Objects (fastest, builds confidence)
|
||||
2. DTOs (quick, many file repetition)
|
||||
3. Controllers (medium complexity)
|
||||
4. Repositories (most complex, worth doing last)
|
||||
### Thứ Tự Khuyến Nghị
|
||||
1. Value Objects (nhanh nhất, xây dựng sự tự tin)
|
||||
2. DTOs (nhanh, lặp lại nhiều tệp)
|
||||
3. Controllers (độ phức tạp trung bình)
|
||||
4. Repositories (phức tạp nhất, nên làm cuối cùng)
|
||||
|
||||
---
|
||||
|
||||
## 🔍 What Each File Tests
|
||||
## 🔍 Mỗi Tệp Kiểm Thử Những Gì
|
||||
|
||||
### Value Objects
|
||||
- **LeadScore.vo**
|
||||
- ✓ Valid range 0-100
|
||||
- ✓ Rejection of invalid values
|
||||
- ✓ Error message in Vietnamese
|
||||
- ✓ Phạm vi hợp lệ 0–100
|
||||
- ✓ Từ chối giá trị không hợp lệ
|
||||
- ✓ Thông báo lỗi bằng tiếng Việt
|
||||
|
||||
- **Rating.vo**
|
||||
- ✓ Valid integers 1-5 only
|
||||
- ✓ Rejection of 0, 6, floats
|
||||
- ✓ Error message in Vietnamese
|
||||
- ✓ Chỉ số nguyên hợp lệ 1–5
|
||||
- ✓ Từ chối 0, 6, số thập phân
|
||||
- ✓ Thông báo lỗi bằng tiếng Việt
|
||||
|
||||
### DTOs
|
||||
- **Pagination DTOs** (4 files)
|
||||
- ✓ Page/limit validation
|
||||
- ✓ Type transformation
|
||||
- ✓ Default values
|
||||
- **Pagination DTOs** (4 tệp)
|
||||
- ✓ Xác thực page/limit
|
||||
- ✓ Chuyển đổi kiểu dữ liệu
|
||||
- ✓ Giá trị mặc định
|
||||
|
||||
- **Status DTOs** (2 files)
|
||||
- ✓ Enum validation
|
||||
- ✓ Only valid statuses accepted
|
||||
- **Status DTOs** (2 tệp)
|
||||
- ✓ Xác thực enum
|
||||
- ✓ Chỉ chấp nhận trạng thái hợp lệ
|
||||
|
||||
- **Create DTOs** (4 files)
|
||||
- ✓ Required field validation
|
||||
- ✓ Optional field handling
|
||||
- ✓ Field constraints (email, length, range)
|
||||
- **Create DTOs** (4 tệp)
|
||||
- ✓ Xác thực trường bắt buộc
|
||||
- ✓ Xử lý trường tùy chọn
|
||||
- ✓ Ràng buộc trường (email, độ dài, phạm vi)
|
||||
|
||||
### Controllers
|
||||
- **InquiriesController**
|
||||
- ✓ 4 endpoints with correct dispatch
|
||||
- ✓ JWT authentication
|
||||
- ✓ Role-based guards (AGENT)
|
||||
- ✓ 4 endpoint với điều phối chính xác
|
||||
- ✓ Xác thực JWT
|
||||
- ✓ Guards dựa trên vai trò (AGENT)
|
||||
|
||||
- **LeadsController**
|
||||
- ✓ 5 endpoints with correct dispatch
|
||||
- ✓ Class-level role guard (AGENT)
|
||||
- ✓ Optional field handling
|
||||
- ✓ 5 endpoint với điều phối chính xác
|
||||
- ✓ Role guard ở cấp class (AGENT)
|
||||
- ✓ Xử lý trường tùy chọn
|
||||
|
||||
- **ReviewsController**
|
||||
- ✓ 5 endpoints with correct dispatch
|
||||
- ✓ Mixed authentication (some endpoints public)
|
||||
- ✓ User ownership verification
|
||||
- ✓ 5 endpoint với điều phối chính xác
|
||||
- ✓ Xác thực hỗn hợp (một số endpoint công khai)
|
||||
- ✓ Xác minh quyền sở hữu của người dùng
|
||||
|
||||
### Repositories
|
||||
- **PrismaInquiryRepository**
|
||||
- ✓ CRUD: findById, save, markAsRead
|
||||
- ✓ Paginated: findByListing, findByAgent
|
||||
- ✓ Aggregation: countUnreadByAgent
|
||||
- ✓ Data mapping: toDomain
|
||||
- ✓ Phân trang: findByListing, findByAgent
|
||||
- ✓ Tổng hợp: countUnreadByAgent
|
||||
- ✓ Ánh xạ dữ liệu: toDomain
|
||||
|
||||
- **PrismaLeadRepository**
|
||||
- ✓ CRUD: findById, save, update, delete
|
||||
- ✓ Pagination with optional status filter
|
||||
- ✓ Aggregation: getStatsByAgent (conversion rate, avg score)
|
||||
- ✓ Data mapping including LeadScore VO
|
||||
- ✓ Phân trang với bộ lọc trạng thái tùy chọn
|
||||
- ✓ Tổng hợp: getStatsByAgent (tỷ lệ chuyển đổi, điểm trung bình)
|
||||
- ✓ Ánh xạ dữ liệu kể cả LeadScore VO
|
||||
|
||||
- **PrismaReviewRepository**
|
||||
- ✓ CRUD: findById, findByUserAndTarget, save, delete
|
||||
- ✓ Pagination: findByTarget, findByUserId
|
||||
- ✓ Aggregation: getStats (distribution, average rating)
|
||||
- ✓ Data mapping including Rating VO
|
||||
- ✓ Phân trang: findByTarget, findByUserId
|
||||
- ✓ Tổng hợp: getStats (phân phối, điểm đánh giá trung bình)
|
||||
- ✓ Ánh xạ dữ liệu kể cả Rating VO
|
||||
|
||||
---
|
||||
|
||||
## 📖 Reference Examples
|
||||
## 📖 Ví Dụ Tham Khảo
|
||||
|
||||
### Working Test Patterns
|
||||
Three complete test files are included as references:
|
||||
### Mẫu Kiểm Thử Đang Hoạt Động
|
||||
Ba tệp kiểm thử đầy đủ được đưa vào làm tài liệu tham khảo:
|
||||
|
||||
1. **create-inquiry.handler.spec.ts** (99 lines)
|
||||
1. **create-inquiry.handler.spec.ts** (99 dòng)
|
||||
- Mock repository, EventBus, Prisma
|
||||
- Happy path test
|
||||
- Error handling test
|
||||
- Event publishing verification
|
||||
- Kiểm thử đường đi thành công (happy path)
|
||||
- Kiểm thử xử lý lỗi
|
||||
- Xác minh phát sự kiện
|
||||
|
||||
2. **create-lead.handler.spec.ts** (121 lines)
|
||||
- Similar pattern to create-inquiry
|
||||
- Tests optional field handling
|
||||
- Tests ValueObject validation
|
||||
2. **create-lead.handler.spec.ts** (121 dòng)
|
||||
- Mẫu tương tự như create-inquiry
|
||||
- Kiểm thử xử lý trường tùy chọn
|
||||
- Kiểm thử xác thực ValueObject
|
||||
|
||||
3. **reviews.controller.spec.ts** (135 lines)
|
||||
- Controller endpoint testing
|
||||
- Bus dispatch verification
|
||||
- Query parameter handling
|
||||
- Default value application
|
||||
3. **reviews.controller.spec.ts** (135 dòng)
|
||||
- Kiểm thử endpoint controller
|
||||
- Xác minh điều phối bus
|
||||
- Xử lý tham số truy vấn
|
||||
- Áp dụng giá trị mặc định
|
||||
|
||||
---
|
||||
|
||||
## ✅ Testing Checklist Template
|
||||
## ✅ Mẫu Danh Sách Kiểm Tra Kiểm Thử
|
||||
|
||||
```
|
||||
Module: ___________________
|
||||
File: _____________________
|
||||
|
||||
Imports:
|
||||
- [ ] Test framework imported
|
||||
- [ ] Classes imported
|
||||
- [ ] Mocks ready
|
||||
- [ ] Framework kiểm thử đã được import
|
||||
- [ ] Các class đã được import
|
||||
- [ ] Mocks đã sẵn sàng
|
||||
|
||||
Setup:
|
||||
- [ ] beforeEach creates fresh mocks
|
||||
- [ ] Dependencies injected
|
||||
- [ ] Test data prepared
|
||||
- [ ] beforeEach tạo mocks mới
|
||||
- [ ] Các dependency đã được inject
|
||||
- [ ] Dữ liệu kiểm thử đã được chuẩn bị
|
||||
|
||||
Happy Path:
|
||||
- [ ] Basic functionality test
|
||||
- [ ] Return values verified
|
||||
- [ ] Methods called correctly
|
||||
- [ ] Kiểm thử chức năng cơ bản
|
||||
- [ ] Xác minh giá trị trả về
|
||||
- [ ] Các phương thức được gọi đúng cách
|
||||
|
||||
Edge Cases:
|
||||
- [ ] Null/undefined handling
|
||||
- [ ] Empty results handling
|
||||
- [ ] Boundary values
|
||||
- [ ] Xử lý Null/undefined
|
||||
- [ ] Xử lý kết quả rỗng
|
||||
- [ ] Giá trị biên
|
||||
|
||||
Error Cases:
|
||||
- [ ] Invalid input rejection
|
||||
- [ ] Error messages verified
|
||||
- [ ] Guard validation
|
||||
- [ ] Từ chối đầu vào không hợp lệ
|
||||
- [ ] Xác minh thông báo lỗi
|
||||
- [ ] Xác thực guard
|
||||
|
||||
Cleanup:
|
||||
- [ ] Mocks cleaned after each test
|
||||
- [ ] No test interdependencies
|
||||
- [ ] Mocks được làm sạch sau mỗi kiểm thử
|
||||
- [ ] Không có sự phụ thuộc giữa các kiểm thử
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 💡 Pro Tips
|
||||
## 💡 Mẹo Hay
|
||||
|
||||
1. **Start Small**: Begin with Value Objects (simplest)
|
||||
2. **Copy-Paste**: Use templates, don't write from scratch
|
||||
3. **Test Early**: Run tests as you write them
|
||||
4. **Be Thorough**: Include both happy and error paths
|
||||
5. **Use Existing**: Reference existing tests in the codebase
|
||||
6. **Verify Formulas**: Test arithmetic calculations carefully
|
||||
7. **Mock Everything**: Don't hit real database in tests
|
||||
8. **Test Guards**: Don't forget authentication/authorization
|
||||
1. **Bắt đầu nhỏ**: Bắt đầu với Value Objects (đơn giản nhất)
|
||||
2. **Sao chép-dán**: Sử dụng mẫu, đừng viết từ đầu
|
||||
3. **Kiểm thử sớm**: Chạy kiểm thử ngay khi bạn viết
|
||||
4. **Kỹ càng**: Bao gồm cả đường đi thành công lẫn trường hợp lỗi
|
||||
5. **Dùng lại**: Tham khảo các kiểm thử hiện có trong codebase
|
||||
6. **Xác minh công thức**: Kiểm thử kỹ các phép tính số học
|
||||
7. **Mock tất cả**: Không truy cập cơ sở dữ liệu thực trong kiểm thử
|
||||
8. **Kiểm thử Guards**: Đừng quên xác thực/phân quyền
|
||||
|
||||
---
|
||||
|
||||
## 🆘 Need Help?
|
||||
## 🆘 Cần Giúp Đỡ?
|
||||
|
||||
1. **Configuration question?** → See README_TEST_COVERAGE.md
|
||||
2. **Template needed?** → See TEST_TEMPLATES.md
|
||||
3. **Implementation details?** → See TEST_COVERAGE_ANALYSIS.md
|
||||
4. **Quick lookup?** → See TEST_COVERAGE_QUICK_REFERENCE.md
|
||||
5. **Existing example?** → Check modules' `__tests__` directories
|
||||
1. **Câu hỏi về cấu hình?** → Xem README_TEST_COVERAGE.md
|
||||
2. **Cần mẫu?** → Xem TEST_TEMPLATES.md
|
||||
3. **Chi tiết triển khai?** → Xem TEST_COVERAGE_ANALYSIS.md
|
||||
4. **Tra cứu nhanh?** → Xem TEST_COVERAGE_QUICK_REFERENCE.md
|
||||
5. **Ví dụ hiện có?** → Kiểm tra các thư mục `__tests__` của mô-đun
|
||||
|
||||
---
|
||||
|
||||
**Document Version:** 1.0
|
||||
**Last Updated:** 2026-04-11
|
||||
**Total Documentation:** 3,014 lines across 4 files
|
||||
**Coverage:** 17 untested source files (Inquiries, Leads, Reviews modules)
|
||||
**Phiên bản tài liệu:** 1.0
|
||||
**Cập nhật lần cuối:** 2026-04-11
|
||||
**Tổng tài liệu:** 3.014 dòng trong 4 tệp
|
||||
**Độ bao phủ:** 17 tệp nguồn chưa có kiểm thử (các mô-đun Inquiries, Leads, Reviews)
|
||||
|
||||
Reference in New Issue
Block a user