# Test Coverage Audit - Quick Reference Guide **Generated:** April 10, 2026 **Repository:** GoodGo Platform AI Monorepo **Modules Audited:** Listings, Auth, Search --- ## ๐Ÿ“Š Coverage Overview | Module | Source Files | Test Files | Coverage | Status | |--------|:----:|:----:|:---:|:---:| | **Listings** | 42 | 13 | **31%** | โš ๏ธ Low | | **Auth** | 56 | 21 | **38%** | โš ๏ธ Low | | **Search** | 22 | 10 | **45%** | โš ๏ธ Low | | **TOTAL** | **120** | **44** | **37%** | โš ๏ธ Low | --- ## ๐Ÿ”ด CRITICAL - Must Test First (11 files) ### AUTH Module - Security Critical (4 files) ``` 1. presentation/guards/jwt-auth.guard.ts โ””โ”€ Why: Token validation security โ””โ”€ Test: Valid tokens, expired, invalid signatures 2. presentation/guards/roles.guard.ts โ””โ”€ Why: Authorization enforcement โ””โ”€ Test: Admin access, user access, denied access 3. infrastructure/repositories/prisma-user.repository.ts โ””โ”€ Why: Primary user data access โ””โ”€ Test: CRUD operations, user lookup queries 4. infrastructure/strategies/jwt.strategy.ts โ””โ”€ Why: JWT authentication โ””โ”€ Test: Token validation, user extraction ``` ### LISTINGS Module - Business Logic Critical (4 files) ``` 5. infrastructure/services/prisma-duplicate-detector.ts โ””โ”€ Why: Core duplicate detection โ””โ”€ Test: Database queries, similarity logic 6. infrastructure/services/prisma-price-validator.ts โ””โ”€ Why: Price validation logic โ””โ”€ Test: Price ranges, validation rules 7. infrastructure/repositories/prisma-listing.repository.ts โ””โ”€ Why: Primary listing data access โ””โ”€ Test: CRUD operations, complex queries 8. domain/services/moderation.service.ts โ””โ”€ Why: Moderation business rules โ””โ”€ Test: Approval/rejection logic, scoring ``` ### SEARCH Module - Integration Critical (2 files) ``` 9. infrastructure/services/typesense-client.service.ts โ””โ”€ Why: Search engine integration โ””โ”€ Test: Client init, connection, errors 10. infrastructure/services/postgres-search.repository.ts โ””โ”€ Why: Fallback search implementation โ””โ”€ Test: Query building, fallback logic ``` --- ## ๐Ÿ“‹ Complete Listings Module Files ### โœ… Already Tested (13 files) **Application Layer (8):** - โœ“ create-listing.handler.spec.ts - โœ“ get-listing.handler.spec.ts - โœ“ get-pending-moderation.handler.spec.ts - โœ“ moderate-listing.handler.spec.ts - โœ“ price-validator.spec.ts - โœ“ search-listings.handler.spec.ts - โœ“ update-listing-status.handler.spec.ts - โœ“ upload-media.handler.spec.ts **Domain Layer (5):** - โœ“ duplicate-detector.spec.ts - โœ“ listing-events.spec.ts - โœ“ listing.entity.spec.ts - โœ“ property.entity.spec.ts - โœ“ value-objects.spec.ts ### โŒ Missing Tests (29 files) **Domain Layer (10):** - โœ— domain/services/moderation.service.ts [TIER 1] - โœ— domain/repositories/listing.repository.ts (interface) - โœ— domain/repositories/property.repository.ts (interface) - โœ— domain/repositories/listing-read.dto.ts - โœ— domain/events/listing-approved.event.ts - โœ— domain/events/listing-sold.event.ts - โœ— domain/events/listing-status-changed.event.ts - โœ— domain/entities/* (already has tests - consolidate if needed) - โœ— domain/value-objects/* (already has tests - consolidate if needed) - โœ— domain/services/duplicate-detector.ts (has handler test, needs unit test) **Application Layer (0 - All Covered):** All handlers and commands are tested. **Infrastructure Layer (6):** - โœ— infrastructure/services/prisma-duplicate-detector.ts [TIER 1] - โœ— infrastructure/services/prisma-price-validator.ts [TIER 1] - โœ— infrastructure/services/media-storage.service.ts - โœ— infrastructure/repositories/prisma-listing.repository.ts [TIER 1] - โœ— infrastructure/repositories/prisma-property.repository.ts - โœ— infrastructure/repositories/listing-read.queries.ts **Presentation Layer (13):** - โœ— listings.module.ts - โœ— presentation/controllers/listings.controller.ts - โœ— presentation/dto/create-listing.dto.ts - โœ— presentation/dto/moderate-listing.dto.ts - โœ— presentation/dto/search-listings.dto.ts - โœ— presentation/dto/update-listing-status.dto.ts --- ## ๐Ÿ“‹ Complete Auth Module Files ### โœ… Already Tested (21 files) **Application Layer (12):** - โœ“ cancel-user-deletion.handler.spec.ts - โœ“ export-user-data.handler.spec.ts - โœ“ force-delete-user.handler.spec.ts - โœ“ get-agent-by-user-id.handler.spec.ts - โœ“ get-profile.handler.spec.ts - โœ“ login-user.handler.spec.ts - โœ“ process-scheduled-deletions.handler.spec.ts - โœ“ refresh-token.handler.spec.ts - โœ“ register-user.handler.spec.ts - โœ“ request-user-deletion.handler.spec.ts - โœ“ verify-kyc.handler.spec.ts **Infrastructure Layer (4):** - โœ“ google-oauth.strategy.spec.ts - โœ“ oauth.service.spec.ts - โœ“ token.service.spec.ts - โœ“ zalo-oauth.strategy.spec.ts **Domain Layer (5):** - โœ“ auth-events.spec.ts - โœ“ email.vo.spec.ts - โœ“ hashed-password.vo.spec.ts - โœ“ phone.vo.spec.ts - โœ“ user.entity.spec.ts **Integration (1):** - โœ“ auth.integration.spec.ts ### โŒ Missing Tests (35 files) **Infrastructure Layer (6):** - โœ— infrastructure/strategies/jwt.strategy.ts [TIER 1] - โœ— infrastructure/strategies/local.strategy.ts - โœ— infrastructure/repositories/prisma-user.repository.ts [TIER 1] - โœ— infrastructure/repositories/prisma-refresh-token.repository.ts **Presentation Layer (14):** - โœ— presentation/guards/jwt-auth.guard.ts [TIER 1 - CRITICAL] - โœ— presentation/guards/roles.guard.ts [TIER 1 - CRITICAL] - โœ— presentation/guards/local-auth.guard.ts - โœ— presentation/guards/google-oauth.guard.ts - โœ— presentation/decorators/current-user.decorator.ts - โœ— presentation/decorators/roles.decorator.ts - โœ— presentation/controllers/auth.controller.ts - โœ— presentation/controllers/oauth.controller.ts - โœ— presentation/controllers/user-data.controller.ts - โœ— presentation/dto/login.dto.ts - โœ— presentation/dto/register.dto.ts - โœ— presentation/dto/refresh-token.dto.ts - โœ— presentation/dto/verify-kyc.dto.ts - โœ— presentation/dto/force-delete-user.dto.ts - โœ— presentation/dto/request-deletion.dto.ts **Other (15):** - โœ— auth.module.ts --- ## ๐Ÿ“‹ Complete Search Module Files ### โœ… Already Tested (10 files) **Application Layer (4):** - โœ“ geo-search.handler.spec.ts - โœ“ reindex-all.handler.spec.ts - โœ“ search-properties.handler.spec.ts - โœ“ sync-listing.handler.spec.ts **Infrastructure Layer (4):** - โœ“ listing-approved.handler.spec.ts - โœ“ listing-indexer.service.spec.ts - โœ“ resilient-search.repository.spec.ts - โœ“ typesense-search.repository.spec.ts **Domain Layer (1):** - โœ“ search-domain.spec.ts **Presentation Layer (1):** - โœ“ search.controller.spec.ts ### โŒ Missing Tests (12 files) **Infrastructure Layer (3):** - โœ— infrastructure/services/typesense-client.service.ts [TIER 1] - โœ— infrastructure/services/postgres-search.repository.ts [TIER 1] - โœ— infrastructure/event-handlers/listing-status-changed.handler.ts **Presentation Layer (2):** - โœ— presentation/dto/geo-search.dto.ts - โœ— presentation/dto/search-properties.dto.ts **Other (1):** - โœ— search.module.ts --- ## ๐ŸŽฏ Implementation Roadmap ### Week 1 - Critical Security & Business Logic (11 files) **Time: ~20-25 hours** - [ ] **AUTH** - jwt-auth.guard.spec.ts (3h) - [ ] **AUTH** - roles.guard.spec.ts (3h) - [ ] **AUTH** - prisma-user.repository.spec.ts (3h) - [ ] **AUTH** - jwt.strategy.spec.ts (3h) - [ ] **LISTINGS** - prisma-duplicate-detector.spec.ts (2.5h) - [ ] **LISTINGS** - prisma-price-validator.spec.ts (2.5h) - [ ] **LISTINGS** - prisma-listing.repository.spec.ts (3h) - [ ] **LISTINGS** - moderation.service.spec.ts (2.5h) - [ ] **SEARCH** - typesense-client.service.spec.ts (2.5h) - [ ] **SEARCH** - postgres-search.repository.spec.ts (2.5h) ### Week 2-3 - High Priority Infrastructure (9 files) **Time: ~15-18 hours** - [ ] **AUTH** - local.strategy.spec.ts (2.5h) - [ ] **AUTH** - prisma-refresh-token.repository.spec.ts (2.5h) - [ ] **AUTH** - local-auth.guard.spec.ts (2.5h) - [ ] **AUTH** - google-oauth.guard.spec.ts (2.5h) - [ ] **LISTINGS** - prisma-property.repository.spec.ts (2.5h) - [ ] **LISTINGS** - listing-read.queries.spec.ts (2.5h) - [ ] **LISTINGS** - media-storage.service.spec.ts (2h) - [ ] **SEARCH** - listing-status-changed.handler.spec.ts (2h) ### Week 4 - Medium Priority (Controllers, Decorators) **Time: ~12-15 hours** - [ ] **AUTH** - auth.controller.spec.ts (2.5h) - [ ] **AUTH** - oauth.controller.spec.ts (2.5h) - [ ] **AUTH** - user-data.controller.spec.ts (2h) - [ ] **AUTH** - current-user.decorator.spec.ts (1.5h) - [ ] **AUTH** - roles.decorator.spec.ts (1.5h) - [ ] **LISTINGS** - listings.controller.spec.ts (2.5h) - [ ] **SEARCH** - Nothing here (controller already tested) ### Week 5+ - DTOs, Module Configuration, E2E Tests **Time: ~10+ hours** - [ ] All DTO validation tests (3-4 files per module) - [ ] Module configuration tests - [ ] End-to-end integration tests - [ ] Full user flow tests --- ## ๐Ÿงช Test Type Guidelines ### Unit Tests (50 minutes per file avg) **For:** Services, repositories, value objects, entities ```typescript // Test structure describe('ServiceName', () => { let service: ServiceName; let mockDependency: Mock; beforeEach(() => { mockDependency = mock(); service = new ServiceName(mockDependency); }); it('should handle success case', () => {}); it('should handle error case', () => {}); }); ``` ### Integration Tests (60 minutes per file avg) **For:** Repositories, event handlers, strategies ```typescript // Test structure - usually with database/real service describe('RepositoryName', () => { let repository: RepositoryName; let prisma: PrismaClient; // or real client beforeEach(async () => { await setupTestDatabase(); repository = new RepositoryName(prisma); }); afterEach(async () => { await cleanupTestDatabase(); }); }); ``` ### Guard/Decorator Tests (30 minutes per file avg) **For:** Guards, decorators, middleware ```typescript // Test structure describe('GuardName', () => { let guard: GuardName; let mockExecutionContext: Mock; it('should allow authorized requests', () => {}); it('should deny unauthorized requests', () => {}); }); ``` ### Controller Tests (40 minutes per file avg) **For:** REST controllers ```typescript // Test structure describe('ControllerName', () => { let controller: ControllerName; let mockService: Mock; it('should handle POST request', () => {}); it('should return 400 for invalid input', () => {}); }); ``` ### DTO Tests (20 minutes per file avg) **For:** Data validation objects ```typescript // Test structure - focus on validation describe('DtoName', () => { it('should validate correct data', () => {}); it('should reject invalid email', () => {}); it('should reject short password', () => {}); }); ``` --- ## ๐Ÿ“Š Coverage by Architectural Layer ### Domain Layer | Category | Listings | Auth | Search | Total | Coverage | |----------|:---:|:---:|:---:|:---:|:---:| | Entities | 3/3 โœ“ | 1/1 โœ“ | - | 4/4 | **100%** | | Value Objects | 3/3 โœ“ | 3/3 โœ“ | 2/2 โœ“ | 8/8 | **100%** | | Services | 2/3 | - | - | 2/3 | **67%** | | Repositories | 0/3 | 0/2 | 0/1 | 0/6 | **0%** | | Events | 1/4 | 1/4 | - | 2/8 | **25%** | | **Total Domain** | **9/16** | **5/10** | **2/3** | **16/29** | **55%** | ### Application Layer | Category | Listings | Auth | Search | Total | Coverage | |----------|:---:|:---:|:---:|:---:|:---:| | Handlers | 8/8 โœ“ | 12/12 โœ“ | 8/8 โœ“ | 28/28 | **100%** | | Commands | - | - | - | - | **100%** | | Queries | - | - | - | - | **100%** | | **Total App** | **8/8** | **12/12** | **8/8** | **28/28** | **100%** | ### Infrastructure Layer | Category | Listings | Auth | Search | Total | Coverage | |----------|:---:|:---:|:---:|:---:|:---:| | Repositories | 0/3 | 0/2 | 0/2 | 0/7 | **0%** | | Services | 1/3 | 2/2 โœ“ | 3/5 | 6/10 | **60%** | | Strategies | - | 2/4 | - | 2/4 | **50%** | | Event Handlers | - | - | 1/2 | 1/2 | **50%** | | **Total Infra** | **1/6** | **4/8** | **4/9** | **9/23** | **39%** | ### Presentation Layer | Category | Listings | Auth | Search | Total | Coverage | |----------|:---:|:---:|:---:|:---:|:---:| | Controllers | 0/1 | 0/3 | 1/1 โœ“ | 1/5 | **20%** | | Guards | - | 0/4 | - | 0/4 | **0%** | | Decorators | - | 0/2 | - | 0/2 | **0%** | | DTOs | 0/4 | 0/6 | 0/2 | 0/12 | **0%** | | **Total Presentation** | **0/5** | **0/15** | **1/3** | **1/23** | **4%** | ### Summary | Layer | Files | Tested | Coverage | |-------|:---:|:---:|:---:| | **Domain** | 29 | 16 | 55% | | **Application** | 28 | 28 | 100% โœ“ | | **Infrastructure** | 23 | 9 | 39% | | **Presentation** | 23 | 1 | 4% | | **TOTAL** | **103** | **54** | **52%** | --- ## ๐Ÿ“ Notes - Coverage percentages exclude index.ts barrel files - Commands/Queries are tested via their handlers - Abstract repository interfaces are not tested (only implementations) - Integration tests marked separately from unit tests - Estimated times assume Vitest/Jest experience