Skip to content

#532 security Comment Section : Test Coverage Increase#683

Merged
RUKAYAT-CODER merged 27 commits into
rinafcode:feat-fixfrom
olaayoade27-coder:feat-fix
May 28, 2026
Merged

#532 security Comment Section : Test Coverage Increase#683
RUKAYAT-CODER merged 27 commits into
rinafcode:feat-fixfrom
olaayoade27-coder:feat-fix

Conversation

@olaayoade27-coder
Copy link
Copy Markdown
Contributor

@olaayoade27-coder olaayoade27-coder commented May 28, 2026

Linked Issue

Closes #532


What does this PR do?


Type of change

  • ✨ New feature (non-breaking change that adds functionality)
  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • 💥 Breaking change (fix or feature that changes existing API behaviour)
  • ♻️ Refactor (no functional change, no new feature)
  • 🧪 Tests only (no production code changes)
  • 📝 Documentation only
  • 🔧 Chore (build, dependencies, CI config)

Pre-merge checklist (required)

Do not remove items. Unchecked items without an explanation will block merge.

Branch & metadata

  • Branch name follows feature/issue-<N>-<slug> / fix/issue-<N>-<slug> convention
  • Branch is up to date with the target branch (develop or main)
  • All commits and the PR title follow the Conventional Commits format with issue reference

Code quality & tests

  • npm run lint:ci — zero ESLint warnings
  • npm run format:check — Prettier reports no changes needed
  • npm run typecheck — zero TypeScript errors
  • npm run test:ci — all tests pass, coverage ≥ 70%
  • New service methods have corresponding .spec.ts unit tests
  • New API endpoints are covered by at least one e2e test
  • No existing tests were deleted (if any were, justification is provided in the PR description)

Error handling & NestJS best practices

  • All new/updated DTOs use class-validator / class-transformer decorators and are wired through NestJS pipes (e.g. global ValidationPipe or explicit)
  • All controller entry points validate external input at the boundary (no unvalidated raw any/unknown reaching the domain)
  • Controllers/services throw appropriate NestJS HTTP exceptions (e.g. BadRequestException, UnauthorizedException, ForbiddenException, NotFoundException) instead of generic Error
  • Any new error shapes are handled by existing exception filters or the filters have been updated accordingly
  • Logging goes through the shared logging abstraction (e.g. Nest Logger or central logger service) with meaningful, structured messages
  • Authentication/authorization guards (e.g. AuthGuard, role/permissions guards, custom guards) are applied to all new/modified endpoints where appropriate
  • If an endpoint is intentionally public, this is explicitly mentioned in the PR description with rationale

API documentation / Swagger

  • Swagger / OpenAPI decorators are added or updated for all new/changed controller endpoints (including DTOs, responses, and error schemas)
  • I have started the app locally and confirmed the /api (or Swagger UI) reflects new/changed endpoints correctly
  • If there are no API surface changes, this is explicitly stated in the PR description

Breaking changes

  • This PR does not introduce a breaking API change
  • OR: this PR introduces a breaking change and it is documented below, with migration notes

Breaking change description (if applicable)


Test evidence (required)

Commands run locally

# Example (edit as needed)
npm run lint:ci
npm run format:check
npm run typecheck
npm run test:ci

Manual / API verification

# Example: describe manual tests, curl commands, or Postman collections used

Screenshots / recordings (if applicable)

pr close #682

Gozirimdev and others added 27 commits May 26, 2026 23:14
- Add DecompressionMiddleware to handle gzip, brotli, and deflate compression
- Implement Content-Encoding header detection and processing
- Add comprehensive unit tests with multiple compression format coverage
- Support case-insensitive encoding detection
- Include error handling for decompression failures
- Integrate middleware into main application bootstrap
- Add detailed documentation on usage and configuration

Acceptance Criteria:
✅ Gzip decompression
✅ Brotli decompression
✅ Deflate decompression
✅ Content-Encoding header handling

The middleware:
- Uses Node.js built-in zlib module (no external dependencies)
- Automatically decompresses request payloads based on Content-Encoding header
- Removes Content-Encoding header after decompression
- Gracefully handles errors with HTTP 400 responses
- Passes through uncompressed or unsupported encoding requests
- Skips GET, HEAD, and DELETE requests (no body expected)
- Rename bootstrap to bootstrapWorker for clarity
- Add cluster mode support with primary/worker process handling
- Add graceful shutdown handling with configurable timeout
- Remove redundant comments for cleaner code
- Preserve DecompressionMiddleware integration
- Remove unnecessary variable tracking in middleware
- Fix type inference for error parameters
- Use proper Error type handling with instanceof checks
- Remove unused imports from test file
- Use PassThrough from stream import instead of require
- Simplify stream piping to avoid circular references
- Fix shadowed variable name in transform function
- Improve error handling with proper type checking
Implements an in-process debugging toolkit for developers:

- Request/response inspection: DebugCaptureMiddleware records every
  exchange into a bounded in-memory ring buffer with header redaction
  and body truncation; exposed via GET /debug/requests[/:id].
- Request replay: RequestReplayService re-issues a captured request
  against the running instance (or a custom base URL) and diffs the
  response status; POST /debug/requests/:id/replay with header/body
  overrides for replacing redacted credentials.
- Performance timeline: TimelineRecorder captures per-phase spans with
  high-resolution timing; PerformanceTimelineService surfaces slowest
  hotspots; GET /debug/requests/:id/timeline.
- Stack trace enhancement: StackTraceService parses raw V8 stacks into
  structured frames, flags application vs node_module/internal frames,
  follows the error cause chain; GET /debug/requests/:id/trace.

Capture middleware mounts only outside production (or DEBUG_CAPTURE=true)
and excludes /debug/* to avoid recursion. Endpoints are admin-only.
Wires DebuggingModule into AppModule.
Implements a PostgreSQL index optimizer that recommends, creates,
monitors and retires indexes from the catalog and pg_stat_* views.

- Query analysis for index recommendations: QueryAnalysisService finds
  foreign-key columns lacking a covering index (Postgres does not index
  FK columns automatically), scores/prioritises them by seq-scan
  activity from pg_stat_user_tables, and surfaces slow statements from
  pg_stat_statements when available.
- Automatic index creation: IndexCreationService applies recommendations
  via CREATE INDEX CONCURRENTLY IF NOT EXISTS, caps creations per run,
  verifies indisvalid and drops invalid concurrent builds.
- Index usage monitoring: IndexUsageMonitorService samples
  pg_stat_user_indexes scan counts/sizes and classifies indexes
  (primary/unique/constraint-backed).
- Stale index removal: StaleIndexService drops unused, sufficiently
  large indexes via DROP INDEX CONCURRENTLY, never touching primary,
  unique or constraint-backed indexes.
- IndexOptimizationService orchestrates the cycle on a weekly @Cron,
  inert unless INDEX_OPT_ENABLED=true; every destructive action is gated
  behind dry-run and explicit auto-create/auto-drop flags.

Exposes admin-only endpoints under /database/index-optimization and
wires the module plus ScheduleModule.forRoot() into AppModule.
…decompression

feat(rinafcode#651): implement request decompression handling
…debugging

feat(debugging): add developer debugging toolkit
- Add ETL pipeline service with extract/transform/load stages
- Add DataWarehouseService with in-memory store, query, and aggregate
- Add BiIntegrationService for report generation and JSON/CSV export
- Add DashboardGateway (WebSocket /dashboard namespace) for real-time updates
- Add DataPipelineController with REST endpoints for ETL, warehouse, and BI
- Wire DataPipelineModule into AppModule
- Add 23 unit tests covering all three services
- Fix jest.config.js ts-jest tsconfig to include @types/jest types

Closes rinafcode#635
- Add API versioning interceptor and module with global response transform
- Add global exception filter for standardized error responses
- Add OpenAPI spec generation scripts and GitHub Pages deployment workflow
- Update controllers to align with versioned API structure
- Add flakiness reporter and improve test utilities

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
feat(schema): add schema versioning, tracking, diff visualization, and history access
…user-quotas

Feat/rate limiting user quotas
…ytics-pipeline-635

feat: implement advanced data analytics pipeline (rinafcode#635)
feat(api): add API versioning, response transforms, and OpenAPI docs
- Register SessionModule globally in AppModule
- Redis-backed session store via ioredis with TTL timeout management
- Session serialization/deserialization via JSON.stringify/parse
- Cross-instance session access via shared Redis client
- Distributed lock mechanism for concurrent session safety
- Legacy session migration support
- Add 13 unit tests covering createSession, getSession, touchSession,
  removeSession, migrateSession, and withLock

Closes rinafcode#641
…ssion-management

feat(session): implement distributed session management with Redis
…x-optimization

feat(database): add automatic index optimizer
…ode#532)

Add comprehensive unit tests for 7 previously untested services (61 tests):

- assessment/feedback/feedback-generation.service.spec.ts
  Tests all three feedback tiers (excellent/good/keep-practicing) and
  boundary values at exactly 50% and 80%.

- assessment/scoring/score-calculation.service.spec.ts
  Tests MULTIPLE_CHOICE, TRUE_FALSE, CODING question types including
  correct/wrong/null responses and unknown question type fallback.

- moderation/safety/content-safety.service.spec.ts
  Tests clean content (score=0), each flagged keyword (violence, hate,
  explicit, spam, scam), score capping at 1.0, case-insensitivity,
  and empty string input.

- moderation/manual/manual-review.service.spec.ts
  Tests enqueue (create+save), getQueue (pending filter + ordering),
  and markReviewed (status update).

- assessment/assessments.service.spec.ts
  Tests full CRUD (findAll, findOne, findByIds, create, update, remove),
  startAssessment, submitAssessment (not-found, timed-out, graded paths),
  and getResults.

- courses/lessons/lessons.service.spec.ts
  Tests create (module not found), findOne, update, and remove — all
  including NotFoundException paths.

- messaging/messaging.service.spec.ts
  Tests addMessageToQueue (with/without options, error propagation),
  processMessages (processor registration), and getQueueStatus.

All 61 tests pass. No regressions introduced.

Closes rinafcode#532
@RUKAYAT-CODER RUKAYAT-CODER merged commit dc0712c into rinafcode:feat-fix May 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants