test: improve unit test coverage with 16 new test files#329
Open
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
Open
test: improve unit test coverage with 16 new test files#329devin-ai-integration[bot] wants to merge 1 commit intomainfrom
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
Conversation
…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 <>
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 actionsbookmarks— ADD_BOOKMARK, REMOVE_BOOKMARK, edge casesmodals— all toggle actions includingshow: false,show: null, toggling behaviornavigation— SET_CURRENT_ROUTE, SET_CURRENT_BOTTOM_NAV_ROUTE, selectorsexperimentalSettings— SET_SECURITY_ALERTS_ENABLED on/offinfuraAvailability— BLOCKED/NOT_BLOCKED,getInfuraBlockedSelector, exported constantslegalNotices— privacy policy actions, idempotent shown-date storage, action creatorsbrowser/selectors— selectBrowserHistory, selectSearchEngineSelectors (3 files):
banner— selectDismissedBanners with memoization checkbrowser— history → Recents category (reversed), bookmarks → Favorites categorybridgeController— selectBridgeControllerState, selectQuoteRequestUtilities (3 files):
confirm-tx— gas price calculations, hex comparisons, currency formatting, exponential roundingbrowserScripts— string content checks for injected JS scripts (SPA listener, window info, postMessage)accounts— getAccountNameWithENS with ENS/custom name/missing account scenariosCore constants (2 files):
MetaMetrics.constants— anonymous ID exportRatesController/constants— state change event nameReview & Testing Checklist for Human
confirm-tx.test.jsonly covers 7/10 exported functions —getValueFromWeiHex,getTransactionFee, andconvertTokenToFiatare untested. Decide if these gaps are acceptable or need coverage.util/accounts/index.test.tsusesas anycasts and simplified mocks forsafeToChecksumAddress(lowercases) andisDefaultAccountName(regex). Verify these mocks approximate the real implementations closely enough to be meaningful.browserScripts.test.tsand 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.yarn test:unitandyarn test:validate-coverageto 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.bridgeStatusControllerselector test andutil/bridge/index.ts(serializeQuoteMetadata) test were identified as targets but not implemented.Notes
npx jest <file> --no-coverage