test: add AdminService unit tests for user management and fraud actions - #1173
Merged
nanaf6203-bit merged 1 commit intoSep 1, 2026
Merged
Conversation
AdminService had no test coverage despite implementing the highest-privilege operations. Pin the behavior and the RBAC boundary: - admin.service.spec.ts: cover getDashboard, listUsers (offset and base64 cursor pagination), updateUser (role/block audit logging, session revocation, not-found path), setUserBlockedState, moderation queue, approve/reject/flag/bulk moderation, and fraud delegation (review, block, user/property scans) — AdminService statement coverage rises to ~77% - admin.controller.spec.ts: assert every user-management and fraud route carries the ADMIN role metadata and that RolesGuard admits ADMIN while rejecting USER/AGENT with ForbiddenException
|
@shadrackmanfred 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! 🚀 |
nanaf6203-bit
approved these changes
Sep 1, 2026
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 the missing unit coverage for
AdminService— the highest-privilege service in the module — plus a controller-level RBAC spec that pins the admin-only boundary. Prior to this PRsrc/admin/admin.service.tshad 0% coverage; the module had no spec at all for the service.Coverage (from the scoped run below)
Coverage command used:
npx jest test/admin --coverage --collectCoverageFrom='src/admin/**/*.ts'What's covered
test/admin/admin.service.spec.ts(25 tests)listUsers(page/limit defaults, search filter, base64 cursor pagination incl. no-double-offset, next-cursor generation),updateUser(not-found path, field updates,ROLE_CHANGEaudit log + session revocation on role change,USER_BLOCKED/USER_UNBLOCKEDaudit logs),setUserBlockedStategetModerationQueue(default PENDING status, status + cursor filters),approveProperty,rejectProperty,flagProperty(incl. activity log),bulkModerate(approve vs. flag paths, per-owner logs)listFraudAlerts, alert summary,reviewFraudAlert,addFraudAlertNote,blockFraudUser(block from alert),scanUserForFraud,scanPropertyForFraud— each asserting the fraud-service delegation with the acting adminupdateTransactionStatusdelegates with actortest/admin/admin.controller.spec.ts(3 tests)@Roles(UserRole.ADMIN)metadataRolesGuardadmitsADMINand rejectsUSERandAGENTwithForbiddenExceptionon admin-only routesVerification
npm test— new specs pass (module total: 32 tests, 4 suites)npx tsc --noEmit— no new errorsCloses #1086