feat: unit tests for ab-testing services + rate-limiting indexes (#1249–#1252) - #1357
Merged
RUKAYAT-CODER merged 2 commits intoAug 28, 2026
Merged
Conversation
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.
|
@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! 🚀 |
Contributor
|
Well done on the job done so far! |
…e-limit migration
Contributor
|
Thank you for contributing to the project |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.tsAdded
@Indexdecorators covering the columns used in common query paths:IDX_rate_limiting_userIduserIdIDX_rate_limiting_endpointendpointIDX_rate_limiting_userId_endpointuserId, endpointIDX_rate_limiting_windowStartwindowStartsrc/migrations/1800000000000-add-rate-limiting-indexes.tsTypeORM migration that creates the same indexes with
IF NOT EXISTSguards so it is safe to apply on databases that were previously synchronised.#1250 — Unit tests for
automated-decision.service.tsCreated
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 significantisReadyForWinnerSelection— not-found, not-running, below threshold, ready pathgetDecisionRecommendations— not-found, not-running, not-readyautoAllocateTraffic— not-found, disabled flag, reallocation triggered#1251 — Unit tests for
experiment.service.tsCreated
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.tsCreated
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