Skip to content

test(payouts): add payouts.controller.spec.ts with guard and validati… - #2116

Merged
RUKAYAT-CODER merged 1 commit into
EarnQuestOne:mainfrom
Glam26:feat/BE-payouts-controller-spec
Jul 29, 2026
Merged

test(payouts): add payouts.controller.spec.ts with guard and validati…#2116
RUKAYAT-CODER merged 1 commit into
EarnQuestOne:mainfrom
Glam26:feat/BE-payouts-controller-spec

Conversation

@Glam26

@Glam26 Glam26 commented Jul 27, 2026

Copy link
Copy Markdown

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

Concern Tests
Guard wiring JwtAuthGuard on class; RolesGuard on all 8
                         | admin/fraud routes via
                         | Reflect.getMetadata('__guards__', ...)

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

…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
Glam26 requested a review from RUKAYAT-CODER as a code owner July 27, 2026 20:58
@drips-wave

drips-wave Bot commented Jul 27, 2026

Copy link
Copy Markdown

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

Learn more about application limits

@RUKAYAT-CODER

Copy link
Copy Markdown
Contributor

Thank you for contributing to the project

@RUKAYAT-CODER
RUKAYAT-CODER merged commit 8da4341 into EarnQuestOne:main Jul 29, 2026
5 of 8 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

Development

Successfully merging this pull request may close these issues.

Add payouts.controller.spec.ts for guard and route coverage

3 participants