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,19 +1,19 @@
|
||||
# MCP Module - Quick Reference & Testing Guide
|
||||
# Module MCP - Hướng Dẫn Tham Khảo Nhanh & Kiểm Thử
|
||||
|
||||
## 📋 Module at a Glance
|
||||
## 📋 Tổng Quan Module
|
||||
|
||||
| Aspect | Details |
|
||||
| Khía cạnh | Chi tiết |
|
||||
|--------|---------|
|
||||
| **Location** | `apps/api/src/modules/mcp/` |
|
||||
| **Total Files** | 4 source files (2 TypeScript + 1 module config + 1 export) |
|
||||
| **Test Files** | 1 test file (174 lines) |
|
||||
| **Architecture** | Presentation layer only (simplified) |
|
||||
| **Testing Framework** | Vitest with Globals enabled |
|
||||
| **Test Coverage** | Controller well tested, Module/Infrastructure untested |
|
||||
| **Vị trí** | `apps/api/src/modules/mcp/` |
|
||||
| **Tổng số tệp** | 4 tệp nguồn (2 TypeScript + 1 cấu hình module + 1 xuất) |
|
||||
| **Tệp kiểm thử** | 1 tệp kiểm thử (174 dòng) |
|
||||
| **Kiến trúc** | Chỉ có tầng trình bày (đơn giản hóa) |
|
||||
| **Framework kiểm thử** | Vitest với Globals được bật |
|
||||
| **Độ phủ kiểm thử** | Controller được kiểm thử kỹ, Module/Infrastructure chưa được kiểm thử |
|
||||
|
||||
---
|
||||
|
||||
## 📁 File Listing (Complete)
|
||||
## 📁 Danh Sách Tệp (Đầy Đủ)
|
||||
|
||||
```
|
||||
✅ TESTED ✅ SOURCE ❌ NOT TESTED
|
||||
@@ -27,20 +27,20 @@ MCP module/ mcp/
|
||||
└── mcp-transport.controller.spec.ts ✅ [174 lines]
|
||||
```
|
||||
|
||||
### File Details
|
||||
### Chi Tiết Tệp
|
||||
|
||||
| File | Type | Lines | Status | Purpose |
|
||||
| Tệp | Loại | Dòng | Trạng thái | Mục đích |
|
||||
|------|------|-------|--------|---------|
|
||||
| `index.ts` | Export | 1 | ✅ | Module entry point |
|
||||
| `mcp.module.ts` | Config | 22 | ⚠️ | NestJS module setup |
|
||||
| `mcp-transport.controller.ts` | Controller | 102 | ✅ | HTTP/SSE transport |
|
||||
| `mcp-transport.controller.spec.ts` | Test | 174 | ✅ | Controller tests |
|
||||
| `index.ts` | Xuất | 1 | ✅ | Điểm vào module |
|
||||
| `mcp.module.ts` | Cấu hình | 22 | ⚠️ | Thiết lập module NestJS |
|
||||
| `mcp-transport.controller.ts` | Controller | 102 | ✅ | Vận chuyển HTTP/SSE |
|
||||
| `mcp-transport.controller.spec.ts` | Kiểm thử | 174 | ✅ | Kiểm thử controller |
|
||||
|
||||
---
|
||||
|
||||
## 🏗️ Architecture Diagram
|
||||
## 🏗️ Sơ Đồ Kiến Trúc
|
||||
|
||||
### Current DDD Structure (Simplified)
|
||||
### Cấu Trúc DDD Hiện Tại (Đơn Giản Hóa)
|
||||
|
||||
```
|
||||
┌─────────────────────────────────────────────────┐
|
||||
@@ -58,7 +58,7 @@ MCP module/ mcp/
|
||||
└─────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
### Missing Layers (Not Implemented)
|
||||
### Các Tầng Còn Thiếu (Chưa Được Triển Khai)
|
||||
|
||||
```
|
||||
❌ Domain Layer
|
||||
@@ -78,9 +78,9 @@ MCP module/ mcp/
|
||||
|
||||
---
|
||||
|
||||
## 🧪 Testing Overview
|
||||
## 🧪 Tổng Quan Kiểm Thử
|
||||
|
||||
### Test File Stats
|
||||
### Thống Kê Tệp Kiểm Thử
|
||||
|
||||
```
|
||||
File: mcp-transport.controller.spec.ts
|
||||
@@ -94,7 +94,7 @@ File: mcp-transport.controller.spec.ts
|
||||
└── handleMessage(): 2 tests
|
||||
```
|
||||
|
||||
### Test Breakdown by Suite
|
||||
### Phân Tích Kiểm Thử Theo Bộ
|
||||
|
||||
```
|
||||
1. Security Decorators (4 tests)
|
||||
@@ -119,7 +119,7 @@ File: mcp-transport.controller.spec.ts
|
||||
|
||||
---
|
||||
|
||||
## 🎯 Key Classes & Methods
|
||||
## 🎯 Các Lớp & Phương Thức Chính
|
||||
|
||||
### McpIntegrationModule
|
||||
```typescript
|
||||
@@ -163,9 +163,9 @@ class McpTransportController {
|
||||
|
||||
---
|
||||
|
||||
## 🔧 Testing Patterns Used
|
||||
## 🔧 Các Mẫu Kiểm Thử Được Sử Dụng
|
||||
|
||||
### 1. Mock Pattern (Vitest)
|
||||
### 1. Mẫu Mock (Vitest)
|
||||
```typescript
|
||||
// Mocking external module classes
|
||||
vi.mock('@goodgo/mcp-servers', () => ({
|
||||
@@ -177,7 +177,7 @@ vi.mock('@goodgo/mcp-servers', () => ({
|
||||
}));
|
||||
```
|
||||
|
||||
### 2. Service Mock Pattern
|
||||
### 2. Mẫu Mock Dịch Vụ
|
||||
```typescript
|
||||
const mockRegistry = {
|
||||
getServerNames: vi.fn(),
|
||||
@@ -185,7 +185,7 @@ const mockRegistry = {
|
||||
};
|
||||
```
|
||||
|
||||
### 3. Decorator Verification Pattern
|
||||
### 3. Mẫu Xác Minh Decorator
|
||||
```typescript
|
||||
// Using Reflect API for NestJS decorators
|
||||
const guards = Reflect.getMetadata('__guards__', McpTransportController);
|
||||
@@ -195,7 +195,7 @@ const throttleLimit = Reflect.getMetadata(
|
||||
);
|
||||
```
|
||||
|
||||
### 4. Error Testing Pattern
|
||||
### 4. Mẫu Kiểm Thử Lỗi
|
||||
```typescript
|
||||
// Testing HTTP errors
|
||||
await expect(
|
||||
@@ -212,9 +212,9 @@ try {
|
||||
|
||||
---
|
||||
|
||||
## 📚 Testing Patterns from Other Modules
|
||||
## 📚 Các Mẫu Kiểm Thử Từ Các Module Khác
|
||||
|
||||
### Auth Module - Simple Handler Pattern
|
||||
### Module Auth - Mẫu Handler Đơn Giản
|
||||
```typescript
|
||||
// Minimal dependencies, focused testing
|
||||
describe('LoginUserHandler', () => {
|
||||
@@ -233,7 +233,7 @@ describe('LoginUserHandler', () => {
|
||||
});
|
||||
```
|
||||
|
||||
### Payments Module - Complex Handler Pattern
|
||||
### Module Payments - Mẫu Handler Phức Tạp
|
||||
```typescript
|
||||
// Multiple dependencies, rich testing scenarios
|
||||
describe('CreatePaymentHandler', () => {
|
||||
@@ -260,7 +260,7 @@ describe('CreatePaymentHandler', () => {
|
||||
});
|
||||
```
|
||||
|
||||
### Payments Domain - DDD Pattern
|
||||
### Domain Payments - Mẫu DDD
|
||||
```typescript
|
||||
// Explicit imports, entity behavior testing
|
||||
import { describe, it, expect } from 'vitest';
|
||||
@@ -282,7 +282,7 @@ describe('PaymentEntity', () => {
|
||||
});
|
||||
```
|
||||
|
||||
### Infrastructure Service - Crypto Pattern
|
||||
### Dịch Vụ Infrastructure - Mẫu Crypto
|
||||
```typescript
|
||||
// Complex external service testing
|
||||
describe('ZalopayService', () => {
|
||||
@@ -308,9 +308,9 @@ describe('ZalopayService', () => {
|
||||
|
||||
---
|
||||
|
||||
## 🚀 Running Tests
|
||||
## 🚀 Chạy Kiểm Thử
|
||||
|
||||
### Test Commands
|
||||
### Lệnh Kiểm Thử
|
||||
```bash
|
||||
# Run all MCP tests
|
||||
pnpm test -- src/modules/mcp
|
||||
@@ -325,7 +325,7 @@ pnpm test -- --coverage src/modules/mcp
|
||||
pnpm test -- src/modules/mcp/presentation/__tests__/mcp-transport.controller.spec.ts
|
||||
```
|
||||
|
||||
### Vitest Configuration
|
||||
### Cấu Hình Vitest
|
||||
```typescript
|
||||
// apps/api/vitest.config.ts
|
||||
{
|
||||
@@ -340,30 +340,30 @@ pnpm test -- src/modules/mcp/presentation/__tests__/mcp-transport.controller.spe
|
||||
|
||||
---
|
||||
|
||||
## 💡 Recommendations
|
||||
## 💡 Khuyến Nghị
|
||||
|
||||
### Immediate (High Priority)
|
||||
- ✅ Controller is well tested - maintain this
|
||||
- 📝 Add tests for `McpIntegrationModule.onModuleInit()`
|
||||
- 📝 Test module dependency injection
|
||||
### Ngay Lập Tức (Ưu Tiên Cao)
|
||||
- ✅ Controller được kiểm thử kỹ - duy trì điều này
|
||||
- 📝 Thêm kiểm thử cho `McpIntegrationModule.onModuleInit()`
|
||||
- 📝 Kiểm thử dependency injection của module
|
||||
|
||||
### Future (Lower Priority)
|
||||
- 🏗️ If domain logic is added, create domain tests
|
||||
- 🏗️ If application handlers are added, follow payments module pattern
|
||||
- 🏗️ Add integration tests for full SSE lifecycle
|
||||
### Tương Lai (Ưu Tiên Thấp Hơn)
|
||||
- 🏗️ Nếu logic domain được thêm vào, tạo kiểm thử domain
|
||||
- 🏗️ Nếu application handler được thêm vào, theo mẫu module payments
|
||||
- 🏗️ Thêm kiểm thử tích hợp cho toàn bộ vòng đời SSE
|
||||
|
||||
### Best Practices to Follow
|
||||
1. **Use globals pattern** for simple tests (like existing controller tests)
|
||||
2. **Use explicit imports** for complex domain tests
|
||||
3. **Use helper factories** for complex entity setup
|
||||
4. **Use Reflect API** for decorator verification
|
||||
5. **Test both happy path AND error cases**
|
||||
6. **Use regex matching** for error message assertions
|
||||
7. **Verify service calls** with `toHaveBeenCalledWith()`
|
||||
### Các Phương Pháp Tốt Nhất Cần Tuân Theo
|
||||
1. **Sử dụng mẫu globals** cho các kiểm thử đơn giản (như kiểm thử controller hiện có)
|
||||
2. **Sử dụng import tường minh** cho các kiểm thử domain phức tạp
|
||||
3. **Sử dụng helper factory** cho thiết lập entity phức tạp
|
||||
4. **Sử dụng Reflect API** để xác minh decorator
|
||||
5. **Kiểm thử cả happy path VÀ các trường hợp lỗi**
|
||||
6. **Sử dụng khớp regex** cho các xác nhận thông báo lỗi
|
||||
7. **Xác minh lời gọi dịch vụ** với `toHaveBeenCalledWith()`
|
||||
|
||||
---
|
||||
|
||||
## 📖 File Location Reference
|
||||
## 📖 Tham Chiếu Vị Trí Tệp
|
||||
|
||||
```
|
||||
GoodGo Platform Root
|
||||
@@ -383,4 +383,4 @@ GoodGo Platform Root
|
||||
|
||||
---
|
||||
|
||||
Generated: April 11, 2026
|
||||
Được tạo: ngày 11 tháng 4 năm 2026
|
||||
|
||||
Reference in New Issue
Block a user