Skip to content

#532 security Comment Section : Test Coverage Increase#682

Merged
RUKAYAT-CODER merged 1 commit into
rinafcode:mainfrom
olaayoade27-coder:feat/532-test-coverage-increase
May 28, 2026
Merged

#532 security Comment Section : Test Coverage Increase#682
RUKAYAT-CODER merged 1 commit into
rinafcode:mainfrom
olaayoade27-coder:feat/532-test-coverage-increase

Conversation

@olaayoade27-coder
Copy link
Copy Markdown
Contributor

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

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.

pr close #532

All 61 tests pass. No regressions introduced.

Linked Issue

Closes #N


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)

…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 4aadc44 into rinafcode:main May 28, 2026
6 of 11 checks passed
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.

Implement feature flags/toggles for safe deployments

2 participants