Skip to content

Frontend unit tests for error decoder & pre-flight layer #1

Description

@gbengaeben

Category: Testing | Priority: High | Dependencies: none | Out of scope: browser/UI component tests (separate issue)

Description & Context: frontend/src/lib/stellar/errors.ts and preflight.ts turn opaque Soroban failures into user guidance, but the frontend has no test framework and no committed tests — they were only smoke-tested ad hoc. A regression silently ships cryptic HostErrors to users.

Acceptance Criteria / DoD:

  • vitest added to frontend/package.json with a npm test script; CI (frontend.yml) runs it on every push and PR
  • errors.test.ts covers: every contract code 1–20 → mapped message; each HOST_ERROR_PATTERNS category (balance, fee, trustline, TTL, auth, contract-missing); Freighter rejection; network error; WalletError/PreflightError pass-through; unknown error fallback
  • preflight.test.ts covers: runPreflight returns ALL failures (not fail-fast); every assert* returns null on pass / message on fail; mocked Freighter (isConnected/isAllowed/getAddress) and Horizon/RPC responses
  • npm test exits 0 in CI

How to verify: cd frontend && npm test — all green; break one mapping and confirm the suite fails.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    frontendFrontend (React/Vite/TS)testingTest coverage & QA

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions