Skip to content

Add unit tests for question-bank, feedback-templates, event-validation, event-batching services - #1358

Merged
RUKAYAT-CODER merged 1 commit into
rinafcode:mainfrom
monique-7arch:test/service-unit-tests
Aug 27, 2026
Merged

Add unit tests for question-bank, feedback-templates, event-validation, event-batching services#1358
RUKAYAT-CODER merged 1 commit into
rinafcode:mainfrom
monique-7arch:test/service-unit-tests

Conversation

@monique-7arch

Copy link
Copy Markdown

Summary

Closes four issues, each asking for unit test coverage on a previously-untested service:

  • Closes Add unit tests for question-bank service #1263QuestionBankService: create (success + repository failure) and findByAssessment (pagination shape, default page/limit, repository failure).
  • Closes Add unit tests for feedback-templates service #1260FeedbackTemplatesService: create (defaults + explicit isDefault), findOne (found / NotFoundException), findAll (owner-scoped and unscoped), findDefault, update/remove (partial field updates, NotFoundException, ForbiddenException on non-owner), and render (placeholder substitution, verdict thresholds, the divide-by-zero guard on maxScore, rubric/criterion/level lookups, unknown placeholders).
  • Closes Add unit tests for event-validation service #1258EventValidationService: missing eventType, an unregistered event type, missing required fields, valueConstraints (min/max/allowedValues), custom validation, validateEventOrThrow, and registerSchema/getSchema.
  • Closes Add unit tests for event-batching service #1257EventBatchingService: addEvent (batch growth, auto-flush once BATCH_SIZE is reached, discarding events after shutdown begins), forceFlush (persists and clears the batch, no-op when empty, re-queues and rethrows on a failed insert), and the module lifecycle (periodic flush on the configured interval, final flush + interval teardown on onModuleDestroy).

No production code was touched — this is test-only, per each issue's scope.

Test plan

  • npx jest on all four new spec files — 50 passed, 0 failed
  • npm run typecheck (tsconfig.build.json) — clean
  • eslint on the new files — clean

…idation, event-batching services

Closes rinafcode#1263, rinafcode#1260, rinafcode#1258, rinafcode#1257 — four previously-untested services
each get a focused *.spec.ts covering every public method's success and
failure/edge-case paths:

- QuestionBankService: create (success + repo failure), findByAssessment
  (pagination shape, defaults, repo failure).
- FeedbackTemplatesService: create (defaults + explicit isDefault),
  findOne (found/NotFoundException), findAll (owner-scoped/unscoped),
  findDefault, update/remove (partial updates, NotFoundException,
  ForbiddenException on non-owner), and render (placeholder
  substitution, verdict thresholds, divide-by-zero guard, rubric/
  criterion/level lookups, unknown placeholders).
- EventValidationService: missing eventType, unregistered event type,
  missing required fields, value constraints (min/max/allowedValues),
  custom validation, validateEventOrThrow, registerSchema/getSchema.
- EventBatchingService: addEvent (batch growth, auto-flush at
  BATCH_SIZE, shutdown discard), forceFlush (persists + clears, no-op
  on empty, re-queue + rethrow on failure), and the module lifecycle
  (periodic flush on the configured interval, final flush + interval
  teardown on destroy).

Verified: `npx jest` on all four specs (50 passed), `npm run typecheck`
(tsconfig.build.json, which these excluded *.spec.ts files don't affect
anyway) and `eslint --fix` are clean.
@drips-wave

drips-wave Bot commented Aug 27, 2026

Copy link
Copy Markdown

@monique-7arch Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@RUKAYAT-CODER

Copy link
Copy Markdown
Contributor

Thank you for contributing to the project.

@RUKAYAT-CODER
RUKAYAT-CODER merged commit 473c6db into rinafcode:main Aug 27, 2026
3 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

3 participants