Feat/test coverage config idempotency gateway dispute - #1232
Open
bilkee wants to merge 4 commits into
Open
Conversation
Add config.validation.spec.ts covering missing required keys and out-of-range/malformed values. Add .positive() to port fields (APP_PORT, DATABASE_PORT, REDIS_PORT, MAIL_PORT) and rate-limit fields (THROTTLE_TTL, THROTTLE_LIMIT) to reject negative numbers. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
Add idempotency.interceptor.spec.ts covering: - Basic pass-through and replay for duplicate keys - ConflictException for same key with different request body - TTL expiry (stale cached responses not replayed) - Concurrent duplicate request deduplication via ReplaySubject Upgrade interceptor to use ReplaySubject for concurrent deduplication, add configurable TTL for cache entries, and clean up stale entries on reuse. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
Add documents.gateway.spec.ts covering: - Reject unauthenticated connections (no token) with error + disconnect - Reject invalid JWT tokens with descriptive error - Accept valid tokens and join user-scoped room - Status events emitted to document-specific rooms, not broadcast globally - Subscribe access control: owner-only, admin bypass, missing document rejection 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
Add dispute-reason-classifier.service.spec.ts covering: - Each classification category with representative input text - Case-insensitive matching - First-match priority when multiple reasons match - Fallback/unclassified case returns null - Empty description and empty reasons table edge cases 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
Contributor
|
@bilkee is attempting to deploy a commit to the Mftee's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@bilkee 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! 🚀 |
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
Adds comprehensive test coverage for four previously untested areas of the backend, plus a small schema hardening fix.
Task 1 — Config Validation Tests
Added config.validation.spec.ts (33 tests) covering every required key's missing case, out-of-range values (negative ports/limits), invalid URIs, short JWT secrets, invalid NODE_ENV, and placeholder-rejection in production.
Added .positive() to APP_PORT, DATABASE_PORT, REDIS_PORT, MAIL_PORT, THROTTLE_TTL, and THROTTLE_LIMIT in the Joi schema to reject negative numbers at startup.
Closes [BE-157] config.validation.ts: no test that invalid environment fails startup #1122
Task 2 — Idempotency Interceptor Tests & Hardening
Added idempotency.interceptor.spec.ts (7 tests) covering pass-through, cache replay, TTL expiry, ConflictException on body mismatch, and concurrent deduplication.
Rewrote the interceptor to use ReplaySubject for concurrent request deduplication (fixes a race condition where the in-flight map was re-populated after a synchronous observable completed).
Added configurable TTL (default 24h) with automatic stale-entry expiration on reuse.
Closes [BE-158] IdempotencyInterceptor: expiry and concurrent-duplicate-request handling untested #1123
Task 3 — Documents Gateway Tests
Added documents.gateway.spec.ts (12 tests) covering JWT verification (reject no token, reject invalid token, accept valid token), room-scoped event emission, and subscribe access control (owner-only, admin bypass, missing document).
Closes [BE-159] DocumentsGateway: no authentication check on WebSocket connection #1124
Task 4 — Dispute Reason Classifier Tests
Added dispute-reason-classifier.service.spec.ts (12 tests) covering each classification category, case-insensitive matching, first-match priority, fallback/unclassified case, empty description, and empty reasons table.
Closes [BE-160] DisputeReasonClassifierService is wired but untested #1125