Skip to content

This PR adds comprehensive test coverage and enhances validation for the creators module, addressing four key issues - #1305

Merged
aji70 merged 7 commits into
MyFanss:mainfrom
Tukura11:main
Jun 26, 2026
Merged

This PR adds comprehensive test coverage and enhances validation for the creators module, addressing four key issues#1305
aji70 merged 7 commits into
MyFanss:mainfrom
Tukura11:main

Conversation

@Tukura11

Copy link
Copy Markdown
Contributor

Summary

This PR adds comprehensive test coverage and enhances validation for the creators module, addressing four key issues:

All tests follow existing repo patterns and pass successfully in the test suite.

Changes

#991 — Creators service unit tests (happy path)

  • Added comprehensive happy path tests covering all primary service methods:
    • createPlan(): validates plan creation with correct return shape and event publishing
    • getPlan(): tests retrieval by ID and handling of non-existent plans
    • getCreatorPlans(): tests filtering plans by creator
    • findAllPlans(): tests pagination with cursor support and hasMore flag
    • findCreatorPlans(): tests paginated retrieval for specific creators
    • listCreators(): tests plan listing with optional chain merge
    • searchCreators(): tests creator search with pagination and result shaping
  • Tests verify correct data shapes, pagination metadata, and repository interactions
  • Existing logging and resilience tests retained

#992 — Creators DTO validation tests

  • Created DashboardQueryDto.spec.ts with 23 validation tests covering:
    • window parameter (accepts 7d/30d/90d/all, rejects invalid values)
    • from/to parameters (ISO date string validation)
    • Default values (30d default for window)
    • Combined parameter validation
    • Edge cases (empty objects, null values, invalid dates)
  • Created CreatePlanDto with class-validator decorators enforcing:
    • Required fields with @isnotempty()
    • Type validation (string for creator/asset/amount, number for intervalDays)
    • Range validation (1-365 days for subscription interval)
  • Created CreatePlanDto.spec.ts with 45 validation tests covering:
    • Individual field validation scenarios
    • Missing/empty/null field handling
    • Type mismatch rejection
    • Range boundary violations
    • Combined validation of all fields

#993 — Creators primary endpoint e2e test

  • Created creators.e2e-spec.ts with comprehensive e2e tests for:
    • Primary endpoint GET /v1/creators (search creators)
      • Response shape validation (data, limit, hasMore, nextCursor)
      • Query parameter support (q, search, limit, cursor)
      • Pagination handling
      • Invalid parameter rejection (limit > 100, negative values)
      • Sensitive field exclusion (no password_hash, email, role, etc.)
    • Supporting endpoints:
      • GET /v1/creators/list (list with chain merge option)
      • GET /v1/creators/plans (all plans paginated)
      • POST /v1/creators/plans (create plan with validation)
    • Authentication validation

#994 — Creators pagination/limit query support

  • Verified existing cursor-based pagination implementation:
    • PaginationDto enforces limit (1-100, default 20) via @min(1) and @max(100)
    • Cursor-based pagination supported on all list endpoints
    • Invalid limits properly rejected by validation pipe
  • Enhanced controller to use CreatePlanDto for plan creation:
    • Validates all required fields via DTO
    • Enforces type constraints (string amounts for precision)
    • Validates intervalDays range (1-365 days)
    • Provides consistent error responses for invalid input

Notes

Assumptions & Patterns

  • Primary endpoint identified: GET /v1/creators (creator search) is the main public-facing endpoint for listing creators with search and
    pagination
  • Pagination style: Cursor-based pagination reused from existing implementation (consistent with sibling modules)
  • E2E DB setup: Uses AppModule bootstrap pattern consistent with existing e2e tests (cors-security, api-versioning, rate-limit)
  • DTO validation: Follows class-validator patterns established in SearchCreatorsDto and other repo DTOs
  • Test patterns: Service tests use mock query builders and Logger spies; e2e tests use supertest with HTTP assertions

Test Coverage Summary

  • Service unit tests: 17 happy path tests across 7 methods
  • DTO validation tests: 68 tests covering invalid input and edge cases
  • E2E tests: 17 endpoint tests covering happy path, error handling, and security
  • Total tests added: 102 new tests, all passing

Closes #991, Closes #992, Closes #993, Closes #994

@drips-wave

drips-wave Bot commented Jun 26, 2026

Copy link
Copy Markdown

@Tukura11 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

2 participants