Skip to content

AdminService has no unit tests: user management and fraud actions are uncovered #1086

Description

@nanaf6203-bit

AdminService has no unit tests: user management and fraud actions are uncovered

Labels / Complexity: testing · Medium Complexity — Medium

Problem

src/admin/ has 9 files but only 2 specs, both in test/admin/ (backup.service.spec.ts, transaction-status.dto.spec.ts) — neither covers AdminService. The service implements the highest-privilege operations: user management, fraud blocking/scans, and content administration. None of it is pinned by tests, so a regression that lets an admin action misfire ships silently; with the admin e2e gap (#112), the module is unguarded at both levels.

Why this is architecturally hard

  1. Privilege escalation is the risk. Tests must pin that admin actions require the right role (guards) and that the service enforces its own checks — the defense-in-depth boundary.
  2. Fraud actions are stateful. Block/scan flows mutate user and alert state; tests need controlled fixtures asserting the resulting state transitions.

Acceptance criteria

  • Unit tests cover user-management actions and at least one fraud action (block/scan) with role enforcement.
  • Tests run in CI via npm test; the PR reports coverage via npm run test:cov.

Out of scope

Admin e2e coverage (#112); admin behavior changes.

Getting started

  • src/admin/admin.service.ts — the service to cover
  • src/admin/admin.controller.ts — the routes and guards

Commands: npm test, npm run test:cov.

Good first files to read: src/admin/admin.service.ts, test/admin/backup.service.spec.ts.

Activity

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

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions