Skip to content

Comments

test: improve unit test coverage with 16 new test files#329

Open
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
devin/1771699057-improve-unit-test-coverage
Open

test: improve unit test coverage with 16 new test files#329
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
devin/1771699057-improve-unit-test-coverage

Conversation

@devin-ai-integration
Copy link

test: add 16 new unit test files for reducers, selectors, and utils

Summary

Adds unit tests for 16 previously untested files across reducers, selectors, utilities, and core constants. All tests follow existing patterns in the codebase.

Reducers (8 files):

  • alert — SHOW_ALERT, HIDE_ALERT, initial state, unknown actions
  • bookmarks — ADD_BOOKMARK, REMOVE_BOOKMARK, edge cases
  • modals — all toggle actions including show: false, show: null, toggling behavior
  • navigation — SET_CURRENT_ROUTE, SET_CURRENT_BOTTOM_NAV_ROUTE, selectors
  • experimentalSettings — SET_SECURITY_ALERTS_ENABLED on/off
  • infuraAvailability — BLOCKED/NOT_BLOCKED, getInfuraBlockedSelector, exported constants
  • legalNotices — privacy policy actions, idempotent shown-date storage, action creators
  • browser/selectors — selectBrowserHistory, selectSearchEngine

Selectors (3 files):

  • banner — selectDismissedBanners with memoization check
  • browser — history → Recents category (reversed), bookmarks → Favorites category
  • bridgeController — selectBridgeControllerState, selectQuoteRequest

Utilities (3 files):

  • confirm-tx — gas price calculations, hex comparisons, currency formatting, exponential rounding
  • browserScripts — string content checks for injected JS scripts (SPA listener, window info, postMessage)
  • accounts — getAccountNameWithENS with ENS/custom name/missing account scenarios

Core constants (2 files):

  • MetaMetrics.constants — anonymous ID export
  • RatesController/constants — state change event name

Review & Testing Checklist for Human

  • confirm-tx.test.js only covers 7/10 exported functionsgetValueFromWeiHex, getTransactionFee, and convertTokenToFiat are untested. Decide if these gaps are acceptable or need coverage.
  • util/accounts/index.test.ts uses as any casts and simplified mocks for safeToChecksumAddress (lowercases) and isDefaultAccountName (regex). Verify these mocks approximate the real implementations closely enough to be meaningful.
  • browserScripts.test.ts and constant tests are shallow — they primarily assert that strings contain substrings or equal hardcoded values. Evaluate whether these provide meaningful regression value or just pad coverage numbers.
  • Run yarn test:unit and yarn test:validate-coverage to confirm all tests pass in the full suite and that coverage thresholds are met. Only individual test files were verified locally, not the full suite or coverage validation.
  • Planned but missing: bridgeStatusController selector test and util/bridge/index.ts (serializeQuoteMetadata) test were identified as targets but not implemented.

Notes

…ules

Add 16 new test files covering previously untested code:

Reducers:
- alert reducer (SHOW_ALERT, HIDE_ALERT, initial state)
- bookmarks reducer (ADD_BOOKMARK, REMOVE_BOOKMARK)
- modals reducer (all toggle actions with edge cases)
- navigation reducer (SET_CURRENT_ROUTE, SET_CURRENT_BOTTOM_NAV_ROUTE)
- experimentalSettings reducer (SET_SECURITY_ALERTS_ENABLED)
- infuraAvailability reducer (BLOCKED, NOT_BLOCKED, selector)
- legalNotices reducer (privacy policy actions, action creators)
- browser/selectors (selectBrowserHistory, selectSearchEngine)

Selectors:
- banner selectors (selectDismissedBanners with memoization)
- browser selectors (history with Recents category, bookmarks with Favorites)
- bridgeController selectors (selectBridgeControllerState, selectQuoteRequest)

Utilities:
- confirm-tx (gas calculations, currency formatting, rounding)
- browserScripts (SPA listener, window info, postMessage scripts)
- accounts (getAccountNameWithENS with ENS/custom names)

Core:
- MetaMetrics.constants (anonymous ID export)
- RatesController constants (state change event)

Co-Authored-By: unknown <>
@devin-ai-integration
Copy link
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant