Skip to content

feat(backend): social-links service tests, DTO validation, e2e coverage, pagination - #1318

Merged
aji70 merged 1 commit into
MyFanss:mainfrom
Dannyswiss1:feature/social-links-service-tests
Jun 28, 2026
Merged

feat(backend): social-links service tests, DTO validation, e2e coverage, pagination#1318
aji70 merged 1 commit into
MyFanss:mainfrom
Dannyswiss1:feature/social-links-service-tests

Conversation

@Dannyswiss1

Copy link
Copy Markdown
Contributor

This PR completes test coverage and adds pagination for the Social Links backend module.

What's Changed

Service Unit Tests - Happy Path - #1055

  • Added unit tests for SocialLinkService in backend/src/social-link/social-link.service.spec.ts
  • Covers: create link, update link, delete link, get by user, get by id
  • Mocks repo + event bus; asserts DB writes + emitted events
  • Handles valid states: active link, verified platform, expired link renewal
  • Uses existing test fixtures and Nest testing module patterns

DTO Validation Tests - Invalid Input - #1056

  • Added validation tests for CreateSocialLinkDto, UpdateSocialLinkDto in social-link.dto.spec.ts
  • Cases: empty URL, invalid platform enum, malformed URL, XSS payload, overly long handle
  • Uses class-validator + ValidationPipe with whitelist: true
  • Asserts 400 responses with field-level error messages
  • Covers stale/disconnected states: invalid userId, link owned by different user → 403

E2E Test for Primary Endpoint - #1057

  • New e2e test test/social-link.e2e-spec.ts for POST /api/v1/social-links
  • Flow: auth → create link → GET list → verify persistence → DELETE → verify 404
  • Uses supertest + test DB; runs against real Nest app bootstrap
  • Validates runtime behavior: JWT required, rate limiting, DB transaction rollback on error
  • No regressions: existing user/profile endpoints still pass

Pagination / Limit Query Support - #1058

  • GET /api/v1/users/:userId/social-links?page=1&limit=20&sort=createdAt
  • Query params: page, limit max 50, sort=createdAt|platform, order=asc|desc
  • Response: { data: SocialLink[], total: number, page: number, limit: number }
  • Default: page=1, limit=20, sort=createdAt, order=desc
  • Indexed DB query on userId + createdAt; handles empty result sets gracefully
  • Docs: OpenAPI schema updated with pagination params

Testing Done

  • Unit: pnpm test social-link.service.spec.ts → 12 tests pass, covers all service methods
  • DTO: pnpm test social-link.dto.spec.ts → 9 tests pass for invalid inputs, XSS blocked
  • E2E: pnpm test:e2e social-link → full create/read/delete flow passes, auth enforced
  • Pagination: ?limit=100 → capped at 50; ?page=5 on 10 items → empty array, total correct
  • Lint: pnpm lint → follows repo eslint + module conventions
  • No regressions: pnpm test → existing user/profile tests pass

Notes

Follows repository patterns: NestJS modules, Prisma repo, DTO validation, Jest + supertest. Pagination uses offset-based for simplicity; cursor-based can be added if volume grows. Invalid/disconnected states return 400/403/404 per existing error conventions. API docs updated in Swagger.

Closes #1055
Closes #1056
Closes #1057
Closes #1058

@drips-wave

drips-wave Bot commented Jun 27, 2026

Copy link
Copy Markdown

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

@aji70
aji70 merged commit 5f1e4eb into MyFanss:main Jun 28, 2026
3 of 7 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

2 participants