Skip to content

Establish test infrastructure with Freighter/RPC mocking and cover highest-risk hooks #82

Description

@meshackyaro

Description

No *.test.*/*.spec.* file exists anywhere in this repo, no test framework is installed, and .github/workflows/ci.yml only runs lint, typecheck, and build. The highest-risk logic in the codebase — wallet connection/polling (hooks/useAccount.ts), the on-chain event placeholder (hooks/useSubscription.ts), and the API routes that silently fall back to mock data (pages/api/profile.ts, pages/api/usdc-price.ts) — has zero coverage. This is what makes it hard: none of it can be tested without properly mocking the Freighter browser extension API and Soroban RPC responses, which the codebase has no existing pattern for.

Component

Frontend

Difficulty

🔴 Hard

Tasks

  • Choose and install a test framework compatible with Next.js 13 Pages Router (Jest + React Testing Library is the conventional choice)
  • Build a reusable mock for @stellar/freighter-api (connect/disconnect/getAddress/signTransaction) so wallet-dependent hooks/components are testable without a real extension
  • Build a reusable mock/fixture layer for Soroban RPC responses (simulate results, ledger entries) for when the contract-integration work lands
  • Write coverage for useAccount.ts (connect, disconnect, switch-account, polling behavior) and the API routes' mock-fallback branches
  • Wire test/test:coverage scripts into package.json and add a test step to .github/workflows/ci.yml

Acceptance Criteria

  • A test framework is installed and runnable via npm test
  • Freighter and RPC mocking utilities exist and are documented (README or a testing.md) so future contract-integration work can reuse them
  • useAccount.ts and both API routes have meaningful test coverage (not just snapshot/smoke tests)
  • CI runs the test suite on every PR and fails the build on test failures

Estimated Time

2-3 days

Activity

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions