docs: consolidate audit and analysis reports into docs/audits/
Move 36 root-level audit/analysis documents and 7 web app audit documents into docs/audits/ directory to declutter the project root. Remove stale EXPLORATION_SUMMARY.txt. Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
89
docs/audits/QUICK_REFERENCE_ROOT.md
Normal file
89
docs/audits/QUICK_REFERENCE_ROOT.md
Normal file
@@ -0,0 +1,89 @@
|
||||
# 🎯 QUICK REFERENCE: 3 Missing Test Files
|
||||
|
||||
## Priority: HIGH - All need tests
|
||||
|
||||
### 1️⃣ reject-listing.handler.spec.ts
|
||||
**Location:** `apps/api/src/modules/admin/application/__tests__/`
|
||||
**Pattern to follow:** `approve-listing.handler.spec.ts`
|
||||
**Test coverage needed:**
|
||||
- ✅ Happy path: Successfully rejects PENDING_REVIEW listing
|
||||
- ✅ Error: NotFoundException when listing doesn't exist
|
||||
- ✅ Error: ValidationException for wrong listing status
|
||||
- ✅ Verify: listingRepo.update() called once
|
||||
- ✅ Verify: ListingRejectedEvent published with correct data
|
||||
|
||||
**Key code:**
|
||||
- Command: RejectListingCommand(listingId, adminId, reason)
|
||||
- Handler: RejectListingHandler
|
||||
- Event: ListingRejectedEvent
|
||||
- Result: { listingId, status: 'REJECTED', message }
|
||||
|
||||
---
|
||||
|
||||
### 2️⃣ get-revenue-stats.handler.spec.ts
|
||||
**Location:** `apps/api/src/modules/admin/application/__tests__/`
|
||||
**Pattern to follow:** `get-dashboard-stats.handler.spec.ts`
|
||||
**Test coverage needed:**
|
||||
- ✅ Query returns RevenueStatsItem[] from repository
|
||||
- ✅ Verify: adminQueryRepo.getRevenueStats() called with startDate, endDate, groupBy
|
||||
- ✅ Support both 'day' and 'month' groupBy values
|
||||
- ✅ Default groupBy is 'month'
|
||||
- ✅ Handle empty results (empty array)
|
||||
|
||||
**Key code:**
|
||||
- Query: GetRevenueStatsQuery(startDate, endDate, groupBy='month')
|
||||
- Handler: GetRevenueStatsHandler
|
||||
- Returns: RevenueStatsItem[] with { period, totalRevenue, subscriptionRevenue, listingFeeRevenue, featuredListingRevenue, transactionCount }
|
||||
|
||||
---
|
||||
|
||||
### 3️⃣ user-deactivated.listener.spec.ts
|
||||
**Location:** `apps/api/src/modules/admin/application/__tests__/`
|
||||
**Pattern to follow:** `user-banned.listener.spec.ts`
|
||||
**Test coverage needed:**
|
||||
- ✅ Event listener handles 'user.deactivated' event
|
||||
- ✅ Expires listings with status ACTIVE or PENDING_REVIEW
|
||||
- ✅ Only updates deactivated user's listings
|
||||
- ✅ Logs initial handling and result
|
||||
- ✅ Handle case with 0 listings updated
|
||||
- ✅ Handle case with multiple listings updated
|
||||
|
||||
**Key code:**
|
||||
- Listener: UserDeactivatedListener
|
||||
- Event: UserDeactivatedEvent (async: true)
|
||||
- Action: prisma.listing.updateMany() where sellerId matches & status in [ACTIVE, PENDING_REVIEW]
|
||||
- Logging: Initial + result count
|
||||
|
||||
---
|
||||
|
||||
## Mock Setup Templates
|
||||
|
||||
### For Handler (Command):
|
||||
```typescript
|
||||
mockListingRepo = { findById, update, ... };
|
||||
mockEventBus = { publish };
|
||||
handler = new RejectListingHandler(mockListingRepo, mockEventBus);
|
||||
```
|
||||
|
||||
### For Query Handler:
|
||||
```typescript
|
||||
mockAdminQueryRepo = { getRevenueStats };
|
||||
handler = new GetRevenueStatsHandler(mockAdminQueryRepo);
|
||||
```
|
||||
|
||||
### For Listener:
|
||||
```typescript
|
||||
mockPrisma = { listing: { updateMany }, user: { findUnique } };
|
||||
mockLogger = { log };
|
||||
listener = new UserDeactivatedListener(mockPrisma, mockLogger);
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Testing Checklist
|
||||
|
||||
- [ ] reject-listing.handler.spec.ts created
|
||||
- [ ] get-revenue-stats.handler.spec.ts created
|
||||
- [ ] user-deactivated.listener.spec.ts created
|
||||
- [ ] All tests pass: `npm test admin`
|
||||
- [ ] Coverage report shows green for all 3 files
|
||||
Reference in New Issue
Block a user