Skip to content

Add unit tests for useWallet, stellarSync, useBlockchainSync, and twoFactorUtils#621

Merged
llinsss merged 7 commits into
DogStark:mainfrom
scriptnovaa:feature/unit-tests-issues-525-526-527-528
Jun 24, 2026
Merged

Add unit tests for useWallet, stellarSync, useBlockchainSync, and twoFactorUtils#621
llinsss merged 7 commits into
DogStark:mainfrom
scriptnovaa:feature/unit-tests-issues-525-526-527-528

Conversation

@scriptnovaa

@scriptnovaa scriptnovaa commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Summary

Changes

File Type
src/hooks/useWallet.ts New — wallet state hook
src/hooks/useWallet.test.ts New — tests for #525
src/lib/blockchain/StellarService.ts Modified — added getServer()
src/lib/blockchain/stellarSync.ts Modified — removed as any cast
src/lib/blockchain/stellarSync.test.ts New — tests for #526
src/hooks/useBlockchainSync.test.ts New — tests for #527
src/utils/twoFactorUtils.test.ts New — tests for #528

Test plan

  • Run npx ts-node --project tsconfig.test.json src/utils/twoFactorUtils.test.ts
  • Run npx ts-node --project tsconfig.test.json src/hooks/useWallet.test.ts
  • Run npx ts-node --project tsconfig.test.json src/lib/blockchain/stellarSync.test.ts
  • Run npx ts-node --project tsconfig.test.json src/hooks/useBlockchainSync.test.ts

Closes #525
Closes #526
Closes #527
Closes #528

scriptnovaa and others added 2 commits June 24, 2026 13:30
…FactorUtils (DogStark#525 DogStark#526 DogStark#527 DogStark#528)

- Add useWallet.ts hook with balance polling and error state
- Add useWallet.test.ts covering loaded state and network failure paths
- Add StellarService.getServer() to replace the as-any cast in stellarSync.verifyRecord
- Add stellarSync.test.ts covering sync eligibility, status queries, and typed server access
- Add useBlockchainSync.test.ts covering syncRecord success/failure and verifyRecord paths
- Add twoFactorUtils.test.ts covering TOTP validation, backup code format, QR URI, and uniqueness

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@drips-wave

drips-wave Bot commented Jun 24, 2026

Copy link
Copy Markdown

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

scriptnovaa and others added 5 commits June 24, 2026 14:17
…eService in pet tests

- Replace useWallet.ts with the authoritative upstream version (uses walletService,
  walletService.fetchAccountData, walletService.createWallet etc.) to resolve build
  conflict — the upstream already had this hook implemented
- Update useWallet.test.ts to test the upstream hook's actual API (createWallet,
  importWallet, deleteWallet, sendPayment, fundTestnet, balance fetch error handling)
- Add CacheService mock to pets.service.spec.ts — PetsService gained a CacheService
  dependency (index [3]) in a recent upstream PR but the test module was not updated,
  causing Nest DI resolution failures on every PR CI run

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Frontend:
- Rename src/i18n/index.ts → index.tsx to fix Turbopack JSX parse error

Backend tests:
- create-block.dto.ts: rename blockedId → blockedUserId to match BlockService and specs
- create-report.dto.ts: revert to reportedUserId/category fields matching ReportService/specs
- gdpr.service.ts + spec: replace TooManyRequestsException (not in @nestjs/common v11)
  with a local HttpException subclass using HttpStatus.TOO_MANY_REQUESTS (429)
- vet-verification.service.spec.ts: add CacheService mock (VetVerificationService
  gained this dependency but the test module was not updated)
- ipfs.service.ts: fix FormData namespace import (import * as → default import) to
  allow new FormData() construction
- jest.config.js: add moduleNameMapper for src/ and @/ path aliases so specs that
  import cross-module via absolute src/ paths resolve correctly

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- block.entity.ts: rename blockerId/blockedId to blocker/blockedUser to match service usage; add optional blockedUserEntity property
- report.service.ts: use entity fields (reporterId, targetId, targetType, reason) instead of non-existent reporter/reportedUser/category relations; cast save() result to Report
- gdpr.service.spec.ts: use DataSource class token instead of 'DataSource' string token so NestJS DI can resolve it

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- ipfs.service.ts: replace new Function dynamic import with regular import() so Jest can mock kubo-rpc-client
- report.service.ts: cast updateDto.status to entity's ReportStatus type (different enums: enums/ vs entity file)
- gdpr.service.ts: export TooManyRequestsException so spec can import the same class
- gdpr.service.spec.ts: import TooManyRequestsException from service (fixes instanceof mismatch); fix PasswordUtil spy to use jest.spyOn(PasswordUtil, 'comparePassword'); use resetAllMocks() to clear one-time mock queues between tests

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…elds

After renaming blockerId/blockedId to blocker/blockedUser in block.entity.ts,
update blocking-reporting.service.ts to use the new field names consistently.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@llinsss llinsss merged commit b2ce2c3 into DogStark:main Jun 24, 2026
8 of 12 checks passed
Jambox11 pushed a commit to Jambox11/petChain-Frontend that referenced this pull request Jun 24, 2026
…ssues-525-526-527-528

Add unit tests for useWallet, stellarSync, useBlockchainSync, and twoFactorUtils
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