Skip to content

Add comprehensive SendTokensScreen tests (Closes #82) - #120

Open
Codex723 wants to merge 1 commit into
ecotask-network:mainfrom
Codex723:GrantFox
Open

Add comprehensive SendTokensScreen tests (Closes #82)#120
Codex723 wants to merge 1 commit into
ecotask-network:mainfrom
Codex723:GrantFox

Conversation

@Codex723

Copy link
Copy Markdown

Title: Add comprehensive test coverage for SendTokensScreen

Closes #82

Summary

This PR adds full test coverage for src/screens/SendTokensScreen.tsx, which was previously untested despite handling the entire payment flow. It covers input validation, destination/amount/asset handling, the Lobstr delegation path vs. the in-app signing path, error handling, and success confirmation display.

Changes

  • New test file: src/__tests__/SendTokensScreen.test.tsx with 19 test cases (acceptance criteria required 10+).

Coverage highlights

  • Rendering — in-app vs. Lobstr variants (subtitle + "Send" / "Send via Lobstr" button label).
  • Input validation — invalid destination address, invalid amount, destination validated before amount, and a no-op when no wallet is connected.
  • Lobstr delegation — opens the SEP-7 pay URI with trimmed args, shows the "Payment opened in Lobstr" confirmation alert, clears the inputs, and refreshes balances after the 3s delay (fake timers); error path when LobstrNotInstalledError is thrown.
  • In-app signinggetInAppSecret + signAndSubmitPayment called with the correct params, success alert with the truncated transaction hash, balance refresh, and input clearing; missing-secret-key error path.
  • Error handling — network failures surface the thrown message; op_no_trust maps to the friendly trustline message.
  • Asset selection/config — ECO and USDC assets wired to their configured issuers, plus both "not configured" error branches.
  • UI state — spinner + disabled send button while a submission is in flight, and Cancel → goBack.

Testing

  • Targeted suite: 19/19 tests passed
  • Full suite (npm test): 43 suites / 380 tests passed
  • Typecheck (tsc --noEmit): clean (0 errors)
  • ESLint: 0 errors (only the same no-floating-promises warnings already present in existing tests)

Notes

  • Mocking follows the repo's existing conventions (jest.mock for useWalletStore, useStellarWallet, getInAppSecret, signAndSubmitPayment, isValidAmount, isValidPublicKey, openLobstrForPayment/LobstrNotInstalledError, @react-navigation/native; Alert spy; react-test-renderer + act).
  • react-native-config is mocked with inline values (matching useStellarWallet.test.tsx) so the ECO/USDC asset paths can run.
  • No production/business logic was changed — this is a test-only PR.

@cybermax4200 cybermax4200 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

your branch naming does'nt follow the repo convention

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Testing] Zero test coverage for SendTokensScreen — payment signing and Lobstr delegation

3 participants