Skip to content

fix: resolve 3 assigned issues for jonathanayubausara-a11y (#459, #463, #464)#552

Open
jonathanayubausara-a11y wants to merge 1 commit into
MettaChain:mainfrom
jonathanayubausara-a11y:fix/jonathanayubausara-issues-459-463-464
Open

fix: resolve 3 assigned issues for jonathanayubausara-a11y (#459, #463, #464)#552
jonathanayubausara-a11y wants to merge 1 commit into
MettaChain:mainfrom
jonathanayubausara-a11y:fix/jonathanayubausara-issues-459-463-464

Conversation

@jonathanayubausara-a11y

Copy link
Copy Markdown

Summary

This PR addresses 3 issues assigned to @jonathanayubausara-a11y in the Stellar Wave program.

Issue #459 (P3): WalletModal detection re-runs on every render

  • Problem: detectInstalledWallets in WalletModal ran on every render even though window.ethereum cannot change between renders.
  • Fix: Wrapped wallet detection in useMemo with an empty dependency array, so it runs only once on mount.
  • Files: src/components/WalletModal.tsx

Issue #463 (P2): Add unit tests for qrCodeSecurity

  • Problem: src/utils/security/qrCodeSecurity.ts had insufficient test coverage.
  • Fix: Added comprehensive test cases covering:
    • Phishing URL detection
    • Deep-link validation (ethereum:, wc:, ftp:)
    • Unsafe protocol blocking (vbscript:, javascript:, data:, blob:)
    • Whitespace trimming
    • Allowed host matching (exact and subdomain)
    • URL length boundary cases
    • Empty input after trimming
    • Uppercase protocol handling
    • Suspicious domain warnings
    • getDisplaySafeUrl edge cases (empty input, exact max length, truncation)
  • Added jest mock for PhishingProtection to isolate tests
  • Files: src/utils/security/__tests__/qrCodeSecurity.test.ts

Issue #464 (P2): Add unit tests for useCurrencyConverter

  • Problem: src/hooks/useCurrencyConverter.ts had no test file despite touching rate fetching, caching, and storage.
  • Fix: Created comprehensive test suite with 24 tests covering:
    • Initial state (loading, null rate)
    • Successful ETH/USD rate fetch
    • HTTP error handling (429 status)
    • Network failures with localStorage cache fallback
    • Fresh cache reuse (<60 seconds)
    • Stale cache refresh (>60 seconds)
    • Storage re-hydration on mount
    • Conversion functions (convertEthToUsd, formatEthPrice, formatUsdPrice)
    • Refetch functionality with error handling
    • Auto-refresh interval setup and cleanup
    • Edge cases (missing/null/undefined/malformed responses)
    • Proper fake timer cleanup in beforeEach/afterEach
  • Files: src/hooks/__tests__/useCurrencyConverter.test.ts (new)

Verification

  • All 46 new/enhanced tests pass
  • useMemo properly prevents re-computation on re-renders
  • qrCodeSecurity tests cover phishing, deep-links, edge cases
  • useCurrencyConverter tests cover fetching, caching, conversion

closes #459
closes #463
closes #464

…n#459, MettaChain#463, MettaChain#464)

- fix(MettaChain#459): memoize detectInstalledWallets with useMemo to prevent
  re-running wallet detection on every render in WalletModal
- test(MettaChain#463): add comprehensive unit tests for qrCodeSecurity covering
  phishing URL detection, deep-link validation, vbscript protocol,
  allowed hosts matching, edge cases, and getDisplaySafeUrl scenarios
- test(MettaChain#464): add unit tests for useCurrencyConverter covering fetch
  failures, stale data, network reconnect, storage re-hydration,
  conversion functions, auto-refresh interval, and edge cases

closes MettaChain#459
closes MettaChain#463
closes MettaChain#464
@drips-wave

drips-wave Bot commented Jun 27, 2026

Copy link
Copy Markdown

@jonathanayubausara-a11y 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

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: add unit tests for useCurrencyConverter testing: add unit tests for qrCodeSecurity perf: WalletModal detection re-runs on every render

1 participant