test(payouts): add payouts.controller.spec.ts with guard and validati… - #2116
Merged
RUKAYAT-CODER merged 1 commit intoJul 29, 2026
Merged
Conversation
…on coverage - Assert JwtAuthGuard applied at controller class level - Assert RolesGuard wired on all 8 admin/fraud-risk endpoints - Assert Role.ADMIN required via Reflect metadata on every restricted route - Assert @httpcode(200) on claimPayout and retryPayout - Simulate canActivate false/throw for 401 and 403 scenarios - Cover all 11 route handlers with service delegation and return-value assertions - Propagation tests for NotFoundException, BadRequestException, ForbiddenException and UnauthorizedException - DTO validation metadata assertions for ClaimPayoutDto, CreatePayoutDto and PayoutQueryDto using class-validator getMetadataStorage - Use .overrideInterceptor(IdempotencyInterceptor) to bypass real interceptor dependency tree in unit tests Closes: payouts controller coverage gap (no prior payouts.controller.spec.ts)
|
@Glam26 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
|
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.
All 90 tests pass and the commit is on branch feat/BE-payouts-controller-
spec. Here's a summary:
──────
✅ Done — payouts.controller.spec.ts
Branch: feat/BE-payouts-controller-spec
Commit: e00dead — 864 lines, 90 tests, 0 failures
What's covered
Roles metadata | Role.ADMIN required on every restricted
| method (8 parameterised assertions)
HTTP status codes | @httpcode(200) on claimPayout and retryPayout
| via Reflect.getMetadata('httpCode', ...)
Access-control simulation | canActivate → false (401/403), role logic
| tested for USER, MODERATOR, VERIFIER, ADMIN;
| UnauthorizedException and ForbiddenException
| thrown by guard mocks
Route delegation | All 11 handlers — service called with correct
| args, return values asserted
Error propagation | NotFoundException, BadRequestException,
| ForbiddenException, UnauthorizedException
| from relevant routes
DTO validation metadata | class-validator getMetadataStorage()
| assertions for @IsUUID, @isnotempty,
| @IsString, @isnumber, @min, @IsEnum on
| ClaimPayoutDto, CreatePayoutDto,
| PayoutQueryDto
Admin route access | 8 routes all resolve when guard is open
No business-logic leaks | Controller passes service responses through
| unchanged
Key fix: used
.overrideInterceptor(IdempotencyInterceptor).useClass(NoopInterceptor)
instead of providing a value mock — this correctly bypasses the real
interceptor's IdempotencyService dependency during unit testing.
closes #1901