Skip to content

Feat/test coverage config idempotency gateway dispute - #1232

Open
bilkee wants to merge 4 commits into
CodeGirlsInc:mainfrom
bilkee:feat/test-coverage-config-idempotency-gateway-dispute
Open

Feat/test coverage config idempotency gateway dispute#1232
bilkee wants to merge 4 commits into
CodeGirlsInc:mainfrom
bilkee:feat/test-coverage-config-idempotency-gateway-dispute

Conversation

@bilkee

@bilkee bilkee commented Aug 25, 2026

Copy link
Copy Markdown

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

bilkee and others added 4 commits August 25, 2026 22:00
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>
@vercel

vercel Bot commented Aug 25, 2026

Copy link
Copy Markdown
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.

@drips-wave

drips-wave Bot commented Aug 25, 2026

Copy link
Copy Markdown

@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! 🚀

Learn more about application limits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant