Description Test Coverage Gap Analysis Report — micr-dev/anonq
Executive Summary
Metric
Value
Total source files
20 (non-UI-library)
Files with tests
0
Estimated test coverage
~0%
Test framework
None
Overall risk
🔴 Critical
Prioritized Test Coverage Gaps
🔴 P0 — Critical
#
File
Untested Logic
1
lib/data/questionService.ts
All DB operations — addQuestion, addAnswer (transactional with rollback), deleteQuestion, getAllQA, getQuestionById
2
app/api/admin/questions/route.ts
Auth0 session check, isAllowedUser guard, DELETE missing-ID returns 400
3
app/api/admin/answer/route.ts
Auth guard, input validation (empty, >2000 chars), question-not-found 404
4
lib/auth0.ts
isAllowedUser() — null/undefined/empty/allowed/denied emails
5
app/api/questions/route.ts
Dual rate limiting (100/15min + 5/hour), input validation
🟠 P1 — High
#
File
Untested Logic
6
lib/services/apiService.ts
Grammar correction API integration, notification dispatch
7
lib/config.ts
Configuration singleton, env var fallbacks
8
app/api/questions/regenerate/route.ts
Rate-limited paid API calls
9
lib/api.ts
Client-side API wrapper
10
app/api/questions/qa/route.ts
Public Q&A endpoint
🟡 P2 — Medium
#
File
Risk
11
components/QuestionForm.tsx
Form submission flow, character limits
12
components/AdminDashboardClient.tsx
Full admin flow
13
components/HomeClient.tsx
QA polling, toast notifications
🟢 P3 — Low
#
File
Risk
14
components/QAList.tsx
Display-only
15
components/FaultyTerminal.tsx
Visual WebGL effect
16-20
Types, utils, hooks, pages
Low complexity
Recommended Test Cases
P0-1: lib/data/questionService.ts
should insert a trimmed question and return it
should insert answer and mark question as answered
should rollback answer if question update fails
should join questions with answers and sort correctly
P0-4: lib/auth0.ts
should return false for null/undefined/empty email
should return true for allowed email (case-insensitive)
P0-5: app/api/questions/route.ts
should reject empty content (400)
should return 429 when rate limit exceeded
should submit question and return 201
Recommended Infrastructure
Install Vitest: npm install -D vitest @vitejs/plugin-react jsdom
Install API testing: npm install -D node-mocks-http
Create vitest.config.ts with @/ alias support
Update test script: "test": "vitest run"
Top 3 Immediate Actions
Add questionService.ts tests — addAnswer has manual transaction/rollback, prime candidate for silent data corruption
Add auth guard tests — Without tests, any regression opens admin to unauthorized users
Add rate limiter tests — Complex in-memory rate limiting needs testing
Reactions are currently unavailable
You can’t perform that action at this time.
Test Coverage Gap Analysis Report —
micr-dev/anonqExecutive Summary
Prioritized Test Coverage Gaps
🔴 P0 — Critical
lib/data/questionService.tsaddQuestion,addAnswer(transactional with rollback),deleteQuestion,getAllQA,getQuestionByIdapp/api/admin/questions/route.tsisAllowedUserguard, DELETE missing-ID returns 400app/api/admin/answer/route.tslib/auth0.tsisAllowedUser()— null/undefined/empty/allowed/denied emailsapp/api/questions/route.ts🟠 P1 — High
lib/services/apiService.tslib/config.tsapp/api/questions/regenerate/route.tslib/api.tsapp/api/questions/qa/route.ts🟡 P2 — Medium
components/QuestionForm.tsxcomponents/AdminDashboardClient.tsxcomponents/HomeClient.tsx🟢 P3 — Low
components/QAList.tsxcomponents/FaultyTerminal.tsxRecommended Test Cases
P0-1:
lib/data/questionService.tsP0-4:
lib/auth0.tsP0-5:
app/api/questions/route.tsRecommended Infrastructure
npm install -D vitest @vitejs/plugin-react jsdomnpm install -D node-mocks-httpvitest.config.tswith@/alias support"test": "vitest run"Top 3 Immediate Actions
questionService.tstests —addAnswerhas manual transaction/rollback, prime candidate for silent data corruption