Skip to content

feat: unit tests for ab-testing services + rate-limiting indexes (#1249–#1252) - #1357

Merged
RUKAYAT-CODER merged 2 commits into
rinafcode:mainfrom
demilade18-git:feat/issues-1249-1250-1251-1252
Aug 28, 2026
Merged

feat: unit tests for ab-testing services + rate-limiting indexes (#1249–#1252)#1357
RUKAYAT-CODER merged 2 commits into
rinafcode:mainfrom
demilade18-git:feat/issues-1249-1250-1251-1252

Conversation

@demilade18-git

Copy link
Copy Markdown
Contributor

Summary

Implements four issues in a single PR. Build clean, 70 new tests pass.


#1249 — Add database indexes to the rate-limiting entity

src/rate-limiting/entities/rate-limiting.entity.ts

Added @Index decorators covering the columns used in common query paths:

Index Columns Rationale
IDX_rate_limiting_userId userId Primary per-user lookup
IDX_rate_limiting_endpoint endpoint Per-route filter
IDX_rate_limiting_userId_endpoint userId, endpoint Composite for the most frequent query
IDX_rate_limiting_windowStart windowStart Range/cleanup queries

src/migrations/1800000000000-add-rate-limiting-indexes.ts

TypeORM migration that creates the same indexes with IF NOT EXISTS guards so it is safe to apply on databases that were previously synchronised.


#1250 — Unit tests for automated-decision.service.ts

Created src/ab-testing/automation/automated-decision.service.spec.ts.

Covers every public method with success and failure paths:

  • autoSelectWinner — not-found, not-running, below duration threshold, not statistically significant
  • isReadyForWinnerSelection — not-found, not-running, below threshold, ready path
  • getDecisionRecommendations — not-found, not-running, not-ready
  • autoAllocateTraffic — not-found, disabled flag, reallocation triggered

#1251 — Unit tests for experiment.service.ts

Created src/ab-testing/experiments/experiment.service.spec.ts.

Covers: updateExperiment, addVariant, removeVariant, updateTrafficAllocation (invalid sum, not-found, transaction path), getExperimentResults, archiveExperiment, pauseExperiment, resumeExperiment — all with happy path and error path.


#1252 — Unit tests for ab-testing-reports.service.ts

Created src/ab-testing/reporting/ab-testing-reports.service.spec.ts.

Covers: generateExperimentReport (success, not-found), getDashboardSummary (empty, status counts, filter applied), generatePerformanceComparisonReport (no data, winner present), exportExperimentData (not-found, CSV output), getExperimentTimeline (empty, with data).


Closes #1249
Closes #1250
Closes #1251
Closes #1252

Closes rinafcode#1249
Closes rinafcode#1250
Closes rinafcode#1251
Closes rinafcode#1252

## rinafcode#1249 — Add database indexes to the rate-limiting entity
- Add @Index decorators to rate-limiting.entity.ts covering userId,
  endpoint, (userId, endpoint) composite, and windowStart columns
- Add migration 1800000000000-add-rate-limiting-indexes.ts that creates
  the same indexes with IF NOT EXISTS guards (safe on existing DBs)

## rinafcode#1250 — Unit tests for automated-decision service
- Create automated-decision.service.spec.ts
- Covers: autoSelectWinner (not-found, not-running, below-threshold,
  not-significant), isReadyForWinnerSelection (not-found, not-running,
  below-threshold, ready), getDecisionRecommendations (not-found,
  not-running, not-ready), autoAllocateTraffic (not-found, disabled,
  reallocation triggered)

## rinafcode#1251 — Unit tests for experiment service
- Create experiment.service.spec.ts
- Covers: updateExperiment, addVariant, removeVariant,
  updateTrafficAllocation (bad sum, not-found, transaction),
  getExperimentResults, archiveExperiment, pauseExperiment,
  resumeExperiment — all with success and failure paths

## rinafcode#1252 — Unit tests for ab-testing-reports service
- Create ab-testing-reports.service.spec.ts
- Covers: generateExperimentReport (success, not-found),
  getDashboardSummary (empty, status counts, filter),
  generatePerformanceComparisonReport (no data, with winner),
  exportExperimentData (not-found, CSV output),
  getExperimentTimeline (empty, with data)

All 70 tests pass. Build clean.
@drips-wave

drips-wave Bot commented Aug 27, 2026

Copy link
Copy Markdown

@demilade18-git 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

Well done on the job done so far!
Kindly fix workflow to pass

@RUKAYAT-CODER

Copy link
Copy Markdown
Contributor

Thank you for contributing to the project

@RUKAYAT-CODER
RUKAYAT-CODER merged commit 71c4124 into rinafcode:main Aug 28, 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

2 participants