From 119219b5d21254d52467ae41274f2aa07a1d651d Mon Sep 17 00:00:00 2001 From: Thomas Huang Date: Tue, 29 Nov 2022 07:42:59 -0800 Subject: [PATCH] Continue converting tests from enzyme to @testing-library/react (#16458) * Add transaction activity log component * Remove duplicate tx activity log snapshot. * Convert Advanced Tab to tlr. * Lint fix * Convert Settings Tab test to tlr. * Convert Send Amount Row test to tlr. * Convert Send Row Error Message test to tlr. * Add Mock Send State json file. * Lint fix * Use proper testid for jazz icon for settings e2e * Update Send Amount Row snapshot --- test/data/mock-send-state.json | 1338 +++++++++++++++++ test/e2e/tests/settings-general.spec.js | 2 +- .../send-amount-row.test.js.snap | 217 +++ .../send-amount-row.component.test.js | 102 -- .../send-amount-row.container.test.js | 39 - .../send-amount-row/send-amount-row.test.js | 110 ++ .../send-row-error-message.test.js.snap | 13 + .../send-row-error-message.component.test.js | 32 - .../send-row-error-message.container.test.js | 28 - .../send-row-error-message.test.js | 55 + .../settings-tab/settings-tab.component.js | 10 +- .../settings-tab.component.test.js | 142 -- .../settings-tab/settings-tab.test.js | 95 ++ 13 files changed, 1836 insertions(+), 347 deletions(-) create mode 100644 test/data/mock-send-state.json create mode 100644 ui/pages/send/send-content/send-amount-row/__snapshots__/send-amount-row.test.js.snap delete mode 100644 ui/pages/send/send-content/send-amount-row/send-amount-row.component.test.js delete mode 100644 ui/pages/send/send-content/send-amount-row/send-amount-row.container.test.js create mode 100644 ui/pages/send/send-content/send-amount-row/send-amount-row.test.js create mode 100644 ui/pages/send/send-content/send-row-wrapper/send-row-error-message/__snapshots__/send-row-error-message.test.js.snap delete mode 100644 ui/pages/send/send-content/send-row-wrapper/send-row-error-message/send-row-error-message.component.test.js delete mode 100644 ui/pages/send/send-content/send-row-wrapper/send-row-error-message/send-row-error-message.container.test.js create mode 100644 ui/pages/send/send-content/send-row-wrapper/send-row-error-message/send-row-error-message.test.js delete mode 100644 ui/pages/settings/settings-tab/settings-tab.component.test.js create mode 100644 ui/pages/settings/settings-tab/settings-tab.test.js diff --git a/test/data/mock-send-state.json b/test/data/mock-send-state.json new file mode 100644 index 000000000..72eefb6ef --- /dev/null +++ b/test/data/mock-send-state.json @@ -0,0 +1,1338 @@ +{ + "ENS": { + "resolution": "" + }, + "appState": { + "networkDropdownOpen": false, + "gasIsLoading": false, + "isLoading": false, + "modal": { + "open": false, + "modalState": { + "name": null, + "props": {} + }, + "previousModalState": { + "name": null + } + }, + "warning": null + }, + "history": { + "mostRecentOverviewPage": "/mostRecentOverviewPage" + }, + "metamask": { + "ipfsGateway": "", + "dismissSeedBackUpReminder": false, + "usePhishDetect": true, + "participateInMetaMetrics": false, + "gasEstimateType": "fee-market", + "gasFeeEstimates": { + "low": { + "minWaitTimeEstimate": 180000, + "maxWaitTimeEstimate": 300000, + "suggestedMaxPriorityFeePerGas": "3", + "suggestedMaxFeePerGas": "53" + }, + "medium": { + "minWaitTimeEstimate": 15000, + "maxWaitTimeEstimate": 60000, + "suggestedMaxPriorityFeePerGas": "7", + "suggestedMaxFeePerGas": "70" + }, + "high": { + "minWaitTimeEstimate": 0, + "maxWaitTimeEstimate": 15000, + "suggestedMaxPriorityFeePerGas": "10", + "suggestedMaxFeePerGas": "100" + }, + "estimatedBaseFee": "50", + "historicalBaseFeeRange": ["28.533098435", "70.351148354"], + "baseFeeTrend": "up", + "latestPriorityFeeRange": ["1", "40"], + "historicalPriorityFeeRange": ["0.1458417", "700.156384646"], + "priorityFeeTrend": "down", + "networkCongestion": 0.90625 + }, + "snaps": [{}], + "preferences": { + "hideZeroBalanceTokens": false, + "showFiatInTestnets": false, + "showTestNetworks": true, + "useNativeCurrencyAsPrimaryCurrency": true + }, + "ensResolutionsByAddress": {}, + "isAccountMenuOpen": false, + "isUnlocked": true, + "alertEnabledness": { + "unconnectedAccount": true + }, + "featureFlags": { + "showIncomingTransactions": true + }, + "network": "5", + "provider": { + "type": "rpc", + "chainId": "0x5" + }, + "keyrings": [ + { + "type": "HD Key Tree", + "accounts": [ + "0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc", + "0xec1adf982415d2ef5ec55899b9bfb8bc0f29251b" + ] + }, + { + "type": "Ledger Hardware", + "accounts": ["0xc42edfcc21ed14dda456aa0756c153f7985d8813"] + }, + { + "type": "Simple Key Pair", + "accounts": ["0xeb9e64b93097bc15f01f13eae97015c57ab64823"] + } + ], + "identities": { + "0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc": { + "address": "0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc", + "name": "Test Account" + }, + "0xec1adf982415d2ef5ec55899b9bfb8bc0f29251b": { + "address": "0xec1adf982415d2ef5ec55899b9bfb8bc0f29251b", + "name": "Test Account 2" + }, + "0xc42edfcc21ed14dda456aa0756c153f7985d8813": { + "address": "0xc42edfcc21ed14dda456aa0756c153f7985d8813", + "name": "Test Ledger 1" + }, + "0xeb9e64b93097bc15f01f13eae97015c57ab64823": { + "name": "Test Account 3", + "address": "0xeb9e64b93097bc15f01f13eae97015c57ab64823" + } + }, + "networkDetails": { + "EIPS": { + "1559": true + } + }, + "frequentRpcListDetail": [], + "subjectMetadata": {}, + "notifications": { + "test": { + "id": "test", + "origin": "local:http://localhost:8086/", + "createdDate": 1652967897732, + "readDate": null, + "message": "Hello, http://localhost:8086!" + }, + "test2": { + "id": "test2", + "origin": "local:http://localhost:8086/", + "createdDate": 1652967897732, + "readDate": 1652967897732, + "message": "Hello, http://localhost:8086!" + } + }, + "cachedBalances": {}, + "incomingTransactions": {}, + "unapprovedTxs": { + "8393540981007587": { + "id": 8393540981007587, + "time": 1536268017676, + "status": "unapproved", + "metamaskNetworkId": "4", + "loadingDefaults": false, + "txParams": { + "from": "0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc", + "to": "0xc42edfcc21ed14dda456aa0756c153f7985d8813", + "value": "0x0", + "gas": "0x5208", + "gasPrice": "0x3b9aca00" + }, + "history": [ + { + "id": 8393540981007587, + "time": 1536268017676, + "status": "unapproved", + "metamaskNetworkId": "4", + "loadingDefaults": true, + "txParams": { + "from": "0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc", + "to": "0xc42edfcc21ed14dda456aa0756c153f7985d8813", + "value": "0x0", + "gas": "0x5208", + "gasPrice": "0x3b9aca00" + } + }, + [ + { + "op": "replace", + "path": "/loadingDefaults", + "value": false, + "timestamp": 1536268017685 + } + ], + [ + { + "op": "add", + "path": "/origin", + "value": "MetaMask", + "note": "#newUnapprovedTransaction - adding the origin", + "timestamp": 1536268017686 + } + ] + ], + "origin": "MetaMask" + } + }, + "selectedAddress": "0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc", + "accounts": { + "0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc": { + "balance": "0x0", + "address": "0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc" + }, + "0xec1adf982415d2ef5ec55899b9bfb8bc0f29251b": { + "address": "0xec1adf982415d2ef5ec55899b9bfb8bc0f29251b", + "balance": "0x0" + }, + "0xc42edfcc21ed14dda456aa0756c153f7985d8813": { + "address": "0xc42edfcc21ed14dda456aa0756c153f7985d8813", + "balance": "0x0" + }, + "0xeb9e64b93097bc15f01f13eae97015c57ab64823": { + "address": "0xeb9e64b93097bc15f01f13eae97015c57ab64823", + "balance": "0x0" + } + }, + "tokens": [ + { + "address": "0x108cf70c7d384c552f42c07c41c0e1e46d77ea0d", + "symbol": "TEST", + "decimals": "0" + }, + { + "address": "0xd8f6a2ffb0fc5952d16c9768b71cfd35b6399aa5", + "decimals": "8", + "symbol": "TEST2" + }, + { + "address": "0x617b3f8050a0bd94b6b1da02b4384ee5b4df13f4", + "symbol": "META", + "decimals": "18" + } + ], + "contractExchangeRates": { + "0x108cf70c7d384c552f42c07c41c0e1e46d77ea0d": 0.00039345803819379796, + "0xd8f6a2ffb0fc5952d16c9768b71cfd35b6399aa5": 0.00008189274407698049 + }, + "ticker": "ETH", + "currentCurrency": "usd", + "nativeCurrency": "ETH", + "conversionRate": 556.12, + "addressBook": { + "0x5": { + "0xc42edfcc21ed14dda456aa0756c153f7985d8813": { + "address": "0xc42edfcc21ed14dda456aa0756c153f7985d8813", + "chainId": "0x5", + "isEns": false, + "memo": "", + "name": "Address Book Account 1" + } + } + }, + "unapprovedMsgs": {}, + "unapprovedMsgCount": 0, + "unapprovedPersonalMsgs": {}, + "unapprovedPersonalMsgCount": 0, + "unapprovedDecryptMsgs": {}, + "unapprovedDecryptMsgCount": 0, + "unapprovedEncryptionPublicKeyMsgs": {}, + "unapprovedEncryptionPublicKeyMsgCount": 0, + "unapprovedTypedMessages": {}, + "unapprovedTypedMessagesCount": 0, + "useTokenDetection": true, + "advancedGasFee": { + "maxBaseFee": "75", + "priorityFee": "2" + }, + "tokenList": { + "0x2260fac5e5542a773aa44fbcfedf7c193bc2c599": { + "address": "0x2260fac5e5542a773aa44fbcfedf7c193bc2c599", + "symbol": "WBTC", + "decimals": 8, + "name": "Wrapped Bitcoin", + "iconUrl": "https://s3.amazonaws.com/airswap-token-images/WBTC.png", + "aggregators": [ + "airswapLight", + "bancor", + "cmc", + "coinGecko", + "kleros", + "oneInch", + "paraswap", + "pmm", + "totle", + "zapper", + "zerion", + "zeroEx" + ], + "occurrences": 12 + }, + "0x0bc529c00c6401aef6d220be8c6ea1667f6ad93e": { + "address": "0x0bc529c00c6401aef6d220be8c6ea1667f6ad93e", + "symbol": "YFI", + "decimals": 18, + "name": "yearn.finance", + "iconUrl": "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0x0bc529c00C6401aEF6D220BE8C6Ea1667F6Ad93e/logo.png", + "aggregators": [ + "airswapLight", + "bancor", + "cmc", + "coinGecko", + "kleros", + "oneInch", + "paraswap", + "pmm", + "totle", + "zapper", + "zerion", + "zeroEx" + ], + "occurrences": 12 + } + }, + "currentNetworkTxList": [ + { + "id": 3387511061307736, + "time": 1528133130531, + "status": "confirmed", + "metamaskNetworkId": "4", + "loadingDefaults": false, + "txParams": { + "from": "0x3b222de3aaba8ec9771ca9e9af5d8ed757fb7f62", + "to": "0x92e659448c48fc926ec942d0da1459260d36bb33", + "value": "0x1bc16d674ec80000", + "gas": "0xcf08", + "gasPrice": "0x3b9aca00", + "nonce": "0xb5" + }, + "history": [ + { + "id": 3387511061307736, + "time": 1528133130531, + "status": "unapproved", + "metamaskNetworkId": "4", + "loadingDefaults": true, + "txParams": { + "from": "0x3b222de3aaba8ec9771ca9e9af5d8ed757fb7f62", + "to": "0x92e659448c48fc926ec942d0da1459260d36bb33", + "value": "0x1bc16d674ec80000", + "gas": "0xcf08", + "gasPrice": "0x3b9aca00" + } + }, + [ + { + "op": "replace", + "path": "/loadingDefaults", + "value": false, + "timestamp": 1528133130666 + } + ], + [ + { + "op": "add", + "path": "/origin", + "value": "MetaMask", + "note": "#newUnapprovedTransaction - adding the origin", + "timestamp": 1528133130667 + } + ], + [], + [ + { + "op": "replace", + "path": "/status", + "value": "approved", + "note": "txStateManager: setting status to approved", + "timestamp": 1528133131716 + } + ], + [ + { + "op": "add", + "path": "/txParams/nonce", + "value": "0xb5", + "note": "transactions#approveTransaction", + "timestamp": 1528133131806 + }, + { + "op": "add", + "path": "/nonceDetails", + "value": { + "params": { + "highestLocallyConfirmed": 0, + "highestSuggested": 181, + "nextNetworkNonce": 181 + }, + "local": { + "name": "local", + "nonce": 181, + "details": { + "startPoint": 181, + "highest": 181 + } + }, + "network": { + "name": "network", + "nonce": 181, + "details": { + "baseCount": 181 + } + } + } + } + ], + [ + { + "op": "replace", + "path": "/status", + "value": "signed", + "note": "transactions#publishTransaction", + "timestamp": 1528133131825 + }, + { + "op": "add", + "path": "/rawTx", + "value": "0xf86c81b5843b9aca0082cf089492e659448c48fc926ec942d0da1459260d36bb33881bc16d674ec80000802ba03f879cd33a31180da38545d0f809822e00ddf35954d8b0ece83bacf22347ce54a06ad050487978e425ca6a014ed55ea8e9a190069863ed96a0eefa88d729ea1eda" + } + ], + [], + [ + { + "op": "add", + "path": "/hash", + "value": "0x516b77569173a04c76fdb6545cf279ebd0c75f5d25d6e4ce019925205f0e3709", + "note": "transactions#setTxHash", + "timestamp": 1528133131951 + } + ], + [ + { + "op": "add", + "path": "/submittedTime", + "value": 1528133131951, + "note": "txStateManager - add submitted time stamp", + "timestamp": 1528133131952 + } + ], + [ + { + "op": "replace", + "path": "/status", + "value": "submitted", + "note": "txStateManager: setting status to submitted", + "timestamp": 1528133131955 + } + ], + [ + { + "op": "add", + "path": "/firstRetryBlockNumber", + "value": "0x24af6b", + "note": "transactions/pending-tx-tracker#event: tx:block-update", + "timestamp": 1528133134414 + } + ], + [ + { + "op": "replace", + "path": "/status", + "value": "confirmed", + "note": "txStateManager: setting status to confirmed", + "timestamp": 1528133158516 + } + ] + ], + "origin": "MetaMask", + "nonceDetails": { + "params": { + "highestLocallyConfirmed": 0, + "highestSuggested": 181, + "nextNetworkNonce": 181 + }, + "local": { + "name": "local", + "nonce": 181, + "details": { + "startPoint": 181, + "highest": 181 + } + }, + "network": { + "name": "network", + "nonce": 181, + "details": { + "baseCount": 181 + } + } + }, + "rawTx": "0xf86c81b5843b9aca0082cf089492e659448c48fc926ec942d0da1459260d36bb33881bc16d674ec80000802ba03f879cd33a31180da38545d0f809822e00ddf35954d8b0ece83bacf22347ce54a06ad050487978e425ca6a014ed55ea8e9a190069863ed96a0eefa88d729ea1eda", + "hash": "0x516b77569173a04c76fdb6545cf279ebd0c75f5d25d6e4ce019925205f0e3709", + "submittedTime": 1528133131951, + "firstRetryBlockNumber": "0x24af6b" + }, + { + "id": 3387511061307737, + "time": 1528133149983, + "status": "confirmed", + "metamaskNetworkId": "4", + "loadingDefaults": false, + "txParams": { + "from": "0x3b222de3aaba8ec9771ca9e9af5d8ed757fb7f62", + "to": "0x92e659448c48fc926ec942d0da1459260d36bb33", + "value": "0x1bc16d674ec80000", + "gas": "0xcf08", + "gasPrice": "0x3b9aca00", + "nonce": "0xb6" + }, + "history": [ + { + "id": 3387511061307737, + "time": 1528133149983, + "status": "unapproved", + "metamaskNetworkId": "4", + "loadingDefaults": true, + "txParams": { + "from": "0x3b222de3aaba8ec9771ca9e9af5d8ed757fb7f62", + "to": "0x92e659448c48fc926ec942d0da1459260d36bb33", + "value": "0x1bc16d674ec80000", + "gas": "0xcf08", + "gasPrice": "0x3b9aca00" + } + }, + [ + { + "op": "replace", + "path": "/loadingDefaults", + "value": false, + "timestamp": 1528133150011 + } + ], + [ + { + "op": "add", + "path": "/origin", + "value": "MetaMask", + "note": "#newUnapprovedTransaction - adding the origin", + "timestamp": 1528133150013 + } + ], + [], + [ + { + "op": "replace", + "path": "/status", + "value": "approved", + "note": "txStateManager: setting status to approved", + "timestamp": 1528133151102 + } + ], + [ + { + "op": "add", + "path": "/txParams/nonce", + "value": "0xb6", + "note": "transactions#approveTransaction", + "timestamp": 1528133151189 + }, + { + "op": "add", + "path": "/nonceDetails", + "value": { + "params": { + "highestLocallyConfirmed": 0, + "highestSuggested": 181, + "nextNetworkNonce": 181 + }, + "local": { + "name": "local", + "nonce": 182, + "details": { + "startPoint": 181, + "highest": 182 + } + }, + "network": { + "name": "network", + "nonce": 181, + "details": { + "baseCount": 181 + } + } + } + } + ], + [ + { + "op": "replace", + "path": "/status", + "value": "signed", + "note": "transactions#publishTransaction", + "timestamp": 1528133151203 + }, + { + "op": "add", + "path": "/rawTx", + "value": "0xf86c81b6843b9aca0082cf089492e659448c48fc926ec942d0da1459260d36bb33881bc16d674ec80000802ba0692deaabf0d79544d41e7c475ad43760679a4f25d0fee908b1da308db1a291a7a0384db85fc6c843ea25986a0760f3c50ab6504fc559fc71fc7f23f60950eb316d" + } + ], + [], + [ + { + "op": "add", + "path": "/hash", + "value": "0x9271b266d05022cfa841362fae43763ebafcee540d84278b0157ef4a68d4e26f", + "note": "transactions#setTxHash", + "timestamp": 1528133151342 + } + ], + [ + { + "op": "add", + "path": "/submittedTime", + "value": 1528133151347, + "note": "txStateManager - add submitted time stamp", + "timestamp": 1528133151347 + } + ], + [ + { + "op": "replace", + "path": "/status", + "value": "submitted", + "note": "txStateManager: setting status to submitted", + "timestamp": 1528133151368 + } + ], + [ + { + "op": "add", + "path": "/firstRetryBlockNumber", + "value": "0x24af6d", + "note": "transactions/pending-tx-tracker#event: tx:block-update", + "timestamp": 1528133158532 + } + ], + [ + { + "op": "replace", + "path": "/status", + "value": "confirmed", + "note": "txStateManager: setting status to confirmed", + "timestamp": 1528133190636 + } + ] + ], + "origin": "MetaMask", + "nonceDetails": { + "params": { + "highestLocallyConfirmed": 0, + "highestSuggested": 181, + "nextNetworkNonce": 181 + }, + "local": { + "name": "local", + "nonce": 182, + "details": { + "startPoint": 181, + "highest": 182 + } + }, + "network": { + "name": "network", + "nonce": 181, + "details": { + "baseCount": 181 + } + } + }, + "rawTx": "0xf86c81b6843b9aca0082cf089492e659448c48fc926ec942d0da1459260d36bb33881bc16d674ec80000802ba0692deaabf0d79544d41e7c475ad43760679a4f25d0fee908b1da308db1a291a7a0384db85fc6c843ea25986a0760f3c50ab6504fc559fc71fc7f23f60950eb316d", + "hash": "0x9271b266d05022cfa841362fae43763ebafcee540d84278b0157ef4a68d4e26f", + "submittedTime": 1528133151347, + "firstRetryBlockNumber": "0x24af6d" + }, + { + "id": 3387511061307738, + "time": 1528133180635, + "status": "confirmed", + "metamaskNetworkId": "4", + "loadingDefaults": false, + "txParams": { + "from": "0x3b222de3aaba8ec9771ca9e9af5d8ed757fb7f62", + "to": "0x92e659448c48fc926ec942d0da1459260d36bb33", + "value": "0x1bc16d674ec80000", + "gas": "0xcf08", + "gasPrice": "0x12a05f200", + "nonce": "0xb7" + }, + "history": [ + { + "id": 3387511061307738, + "time": 1528133180635, + "status": "unapproved", + "metamaskNetworkId": "4", + "loadingDefaults": true, + "txParams": { + "from": "0x3b222de3aaba8ec9771ca9e9af5d8ed757fb7f62", + "to": "0x92e659448c48fc926ec942d0da1459260d36bb33", + "value": "0x1bc16d674ec80000", + "gas": "0xcf08", + "gasPrice": "0x12a05f200" + } + }, + [ + { + "op": "replace", + "path": "/loadingDefaults", + "value": false, + "timestamp": 1528133180720 + } + ], + [ + { + "op": "add", + "path": "/origin", + "value": "MetaMask", + "note": "#newUnapprovedTransaction - adding the origin", + "timestamp": 1528133180722 + } + ], + [], + [ + { + "op": "replace", + "path": "/status", + "value": "approved", + "note": "txStateManager: setting status to approved", + "timestamp": 1528133181623 + } + ], + [ + { + "op": "add", + "path": "/txParams/nonce", + "value": "0xb7", + "note": "transactions#approveTransaction", + "timestamp": 1528133181726 + }, + { + "op": "add", + "path": "/nonceDetails", + "value": { + "params": { + "highestLocallyConfirmed": 182, + "highestSuggested": 182, + "nextNetworkNonce": 182 + }, + "local": { + "name": "local", + "nonce": 183, + "details": { + "startPoint": 182, + "highest": 183 + } + }, + "network": { + "name": "network", + "nonce": 182, + "details": { + "baseCount": 182 + } + } + } + } + ], + [ + { + "op": "replace", + "path": "/status", + "value": "signed", + "note": "transactions#publishTransaction", + "timestamp": 1528133181749 + }, + { + "op": "add", + "path": "/rawTx", + "value": "0xf86d81b785012a05f20082cf089492e659448c48fc926ec942d0da1459260d36bb33881bc16d674ec80000802ba086f9846798be6988c39a5cf85f0dbe267e59ca0b96a6a7077e92cba33e10a258a064ffa52ac90c238ce21e6f085283216191b185a1eccd7daae6e2ab66ba26ada0" + } + ], + [], + [ + { + "op": "add", + "path": "/hash", + "value": "0x4e061e977c099735bc9e5203e717f7d9dccb3fcb2f82031a12a3ed326f95d43b", + "note": "transactions#setTxHash", + "timestamp": 1528133181885 + } + ], + [ + { + "op": "add", + "path": "/submittedTime", + "value": 1528133181885, + "note": "txStateManager - add submitted time stamp", + "timestamp": 1528133181885 + } + ], + [ + { + "op": "replace", + "path": "/status", + "value": "submitted", + "note": "txStateManager: setting status to submitted", + "timestamp": 1528133181888 + } + ], + [ + { + "op": "add", + "path": "/firstRetryBlockNumber", + "value": "0x24af6f", + "note": "transactions/pending-tx-tracker#event: tx:block-update", + "timestamp": 1528133190653 + } + ], + [ + { + "op": "replace", + "path": "/status", + "value": "confirmed", + "note": "txStateManager: setting status to confirmed", + "timestamp": 1528133222745 + } + ] + ], + "origin": "MetaMask", + "nonceDetails": { + "params": { + "highestLocallyConfirmed": 182, + "highestSuggested": 182, + "nextNetworkNonce": 182 + }, + "local": { + "name": "local", + "nonce": 183, + "details": { + "startPoint": 182, + "highest": 183 + } + }, + "network": { + "name": "network", + "nonce": 182, + "details": { + "baseCount": 182 + } + } + }, + "rawTx": "0xf86d81b785012a05f20082cf089492e659448c48fc926ec942d0da1459260d36bb33881bc16d674ec80000802ba086f9846798be6988c39a5cf85f0dbe267e59ca0b96a6a7077e92cba33e10a258a064ffa52ac90c238ce21e6f085283216191b185a1eccd7daae6e2ab66ba26ada0", + "hash": "0x4e061e977c099735bc9e5203e717f7d9dccb3fcb2f82031a12a3ed326f95d43b", + "submittedTime": 1528133181885, + "firstRetryBlockNumber": "0x24af6f" + }, + { + "id": 3387511061307739, + "time": 1528133223918, + "status": "confirmed", + "metamaskNetworkId": "4", + "loadingDefaults": false, + "txParams": { + "from": "0x3b222de3aaba8ec9771ca9e9af5d8ed757fb7f62", + "to": "0xfe2149773b3513703e79ad23d05a778a185016ee", + "value": "0xaa87bee538000", + "data": "0xea94496b000000000000000000000000000000000000000000000000000000000001e1eb000000000000000000000000000000000000000000000000000000000001de33", + "gasPrice": "0x3b9aca00", + "gas": "0x6169e", + "nonce": "0xb8" + }, + "history": [ + { + "id": 3387511061307739, + "time": 1528133223918, + "status": "unapproved", + "metamaskNetworkId": "4", + "loadingDefaults": true, + "txParams": { + "from": "0x3b222de3aaba8ec9771ca9e9af5d8ed757fb7f62", + "to": "0xfe2149773b3513703e79ad23d05a778a185016ee", + "value": "0xaa87bee538000", + "data": "0xea94496b000000000000000000000000000000000000000000000000000000000001e1eb000000000000000000000000000000000000000000000000000000000001de33", + "gasPrice": "0x3b9aca00" + } + }, + [ + { + "op": "add", + "path": "/txParams/gas", + "value": "0x6169e", + "timestamp": 1528133225488 + }, + { + "op": "replace", + "path": "/loadingDefaults", + "value": false + } + ], + [ + { + "note": "#newUnapprovedTransaction - adding the origin", + "op": "add", + "path": "/origin", + "value": "crypko.ai" + } + ], + [], + [ + { + "op": "replace", + "path": "/status", + "value": "approved", + "note": "txStateManager: setting status to approved", + "timestamp": 1528133227279 + } + ], + [ + { + "op": "add", + "path": "/txParams/nonce", + "value": "0xb8", + "note": "transactions#approveTransaction", + "timestamp": 1528133227374 + }, + { + "op": "add", + "path": "/nonceDetails", + "value": { + "params": { + "highestLocallyConfirmed": 184, + "highestSuggested": 184, + "nextNetworkNonce": 184 + }, + "local": { + "name": "local", + "nonce": 184, + "details": { + "startPoint": 184, + "highest": 184 + } + }, + "network": { + "name": "network", + "nonce": 184, + "details": { + "baseCount": 184 + } + } + } + } + ], + [ + { + "op": "replace", + "path": "/status", + "value": "signed", + "note": "transactions#publishTransaction", + "timestamp": 1528133227405 + }, + { + "op": "add", + "path": "/rawTx", + "value": "0xf8b181b8843b9aca008306169e94fe2149773b3513703e79ad23d05a778a185016ee870aa87bee538000b844ea94496b000000000000000000000000000000000000000000000000000000000001e1eb000000000000000000000000000000000000000000000000000000000001de332ca07bb2efbb8529d67606f9f89e7934c594a31d50c7d24a3286c20a2944a3b8c2a9a07b55ebd8aa28728ce0e38dd3b3503b78fccedae80053626d8649c68346c7c49c" + } + ], + [], + [ + { + "op": "add", + "path": "/hash", + "value": "0x466ae7d4b7c270121f0a8d68fbc6c9091ffc4aa976a553a5bfa56a79cf9f63dd", + "note": "transactions#setTxHash", + "timestamp": 1528133227534 + } + ], + [ + { + "op": "add", + "path": "/submittedTime", + "value": 1528133227538, + "note": "txStateManager - add submitted time stamp", + "timestamp": 1528133227538 + } + ], + [ + { + "op": "replace", + "path": "/status", + "value": "submitted", + "note": "txStateManager: setting status to submitted", + "timestamp": 1528133227543 + } + ], + [ + { + "op": "add", + "path": "/firstRetryBlockNumber", + "value": "0x24af72", + "note": "transactions/pending-tx-tracker#event: tx:block-update", + "timestamp": 1528133238980 + } + ], + [ + { + "op": "replace", + "path": "/status", + "value": "confirmed", + "note": "txStateManager: setting status to confirmed", + "timestamp": 1528133255035 + } + ] + ], + "origin": "crypko.ai", + "nonceDetails": { + "params": { + "highestLocallyConfirmed": 184, + "highestSuggested": 184, + "nextNetworkNonce": 184 + }, + "local": { + "name": "local", + "nonce": 184, + "details": { + "startPoint": 184, + "highest": 184 + } + }, + "network": { + "name": "network", + "nonce": 184, + "details": { + "baseCount": 184 + } + } + }, + "rawTx": "0xf8b181b8843b9aca008306169e94fe2149773b3513703e79ad23d05a778a185016ee870aa87bee538000b844ea94496b000000000000000000000000000000000000000000000000000000000001e1eb000000000000000000000000000000000000000000000000000000000001de332ca07bb2efbb8529d67606f9f89e7934c594a31d50c7d24a3286c20a2944a3b8c2a9a07b55ebd8aa28728ce0e38dd3b3503b78fccedae80053626d8649c68346c7c49c", + "hash": "0x466ae7d4b7c270121f0a8d68fbc6c9091ffc4aa976a553a5bfa56a79cf9f63dd", + "submittedTime": 1528133227538, + "firstRetryBlockNumber": "0x24af72" + }, + { + "id": 3387511061307740, + "time": 1528133291381, + "status": "confirmed", + "metamaskNetworkId": "4", + "loadingDefaults": false, + "txParams": { + "from": "0x3b222de3aaba8ec9771ca9e9af5d8ed757fb7f62", + "to": "0x108cf70c7d384c552f42c07c41c0e1e46d77ea0d", + "value": "0x0", + "data": "0xa9059cbb00000000000000000000000092e659448c48fc926ec942d0da1459260d36bb330000000000000000000000000000000000000000000000000000000000000002", + "gas": "0xd508", + "gasPrice": "0x3b9aca00", + "nonce": "0xb9" + }, + "history": [ + { + "id": 3387511061307740, + "time": 1528133291381, + "status": "unapproved", + "metamaskNetworkId": "4", + "loadingDefaults": true, + "txParams": { + "from": "0x3b222de3aaba8ec9771ca9e9af5d8ed757fb7f62", + "to": "0x108cf70c7d384c552f42c07c41c0e1e46d77ea0d", + "value": "0x0", + "data": "0xa9059cbb00000000000000000000000092e659448c48fc926ec942d0da1459260d36bb330000000000000000000000000000000000000000000000000000000000000002", + "gas": "0xd508", + "gasPrice": "0x3b9aca00" + } + }, + [ + { + "op": "replace", + "path": "/loadingDefaults", + "value": false, + "timestamp": 1528133291486 + } + ], + [ + { + "op": "add", + "path": "/origin", + "value": "MetaMask", + "note": "#newUnapprovedTransaction - adding the origin", + "timestamp": 1528133291486 + } + ], + [], + [ + { + "op": "replace", + "path": "/status", + "value": "approved", + "note": "txStateManager: setting status to approved", + "timestamp": 1528133293588 + } + ], + [ + { + "op": "add", + "path": "/txParams/nonce", + "value": "0xb9", + "note": "transactions#approveTransaction", + "timestamp": 1528133293706 + }, + { + "op": "add", + "path": "/nonceDetails", + "value": { + "params": { + "highestLocallyConfirmed": 185, + "highestSuggested": 185, + "nextNetworkNonce": 185 + }, + "local": { + "name": "local", + "nonce": 185, + "details": { + "startPoint": 185, + "highest": 185 + } + }, + "network": { + "name": "network", + "nonce": 185, + "details": { + "baseCount": 185 + } + } + } + } + ], + [ + { + "op": "replace", + "path": "/status", + "value": "signed", + "note": "transactions#publishTransaction", + "timestamp": 1528133293724 + }, + { + "op": "add", + "path": "/rawTx", + "value": "0xf8a981b9843b9aca0082d50894108cf70c7d384c552f42c07c41c0e1e46d77ea0d80b844a9059cbb00000000000000000000000092e659448c48fc926ec942d0da1459260d36bb3300000000000000000000000000000000000000000000000000000000000000022ca04f05310490d3e3a9a159ae25f52cec9afb0a69527d30be832aaae12e64ff056ea075f81a5220bed481e764bab8830c57169c59fe528ca9cf3442f47f7618a9b4a9" + } + ], + [], + [ + { + "op": "add", + "path": "/hash", + "value": "0x3680dc9815cd05b620b6dd0017d949604ca7d92f051d5542fc8a5ecaa876af09", + "note": "transactions#setTxHash", + "timestamp": 1528133293853 + } + ], + [ + { + "op": "add", + "path": "/submittedTime", + "value": 1528133293859, + "note": "txStateManager - add submitted time stamp", + "timestamp": 1528133293862 + } + ], + [ + { + "op": "replace", + "path": "/status", + "value": "submitted", + "note": "txStateManager: setting status to submitted", + "timestamp": 1528133293867 + } + ], + [ + { + "op": "add", + "path": "/firstRetryBlockNumber", + "value": "0x24af76", + "note": "transactions/pending-tx-tracker#event: tx:block-update", + "timestamp": 1528133295200 + } + ], + [ + { + "op": "replace", + "path": "/status", + "value": "confirmed", + "note": "txStateManager: setting status to confirmed", + "timestamp": 1528133327522 + } + ] + ], + "origin": "MetaMask", + "nonceDetails": { + "params": { + "highestLocallyConfirmed": 185, + "highestSuggested": 185, + "nextNetworkNonce": 185 + }, + "local": { + "name": "local", + "nonce": 185, + "details": { + "startPoint": 185, + "highest": 185 + } + }, + "network": { + "name": "network", + "nonce": 185, + "details": { + "baseCount": 185 + } + } + }, + "rawTx": "0xf8a981b9843b9aca0082d50894108cf70c7d384c552f42c07c41c0e1e46d77ea0d80b844a9059cbb00000000000000000000000092e659448c48fc926ec942d0da1459260d36bb3300000000000000000000000000000000000000000000000000000000000000022ca04f05310490d3e3a9a159ae25f52cec9afb0a69527d30be832aaae12e64ff056ea075f81a5220bed481e764bab8830c57169c59fe528ca9cf3442f47f7618a9b4a9", + "hash": "0x3680dc9815cd05b620b6dd0017d949604ca7d92f051d5542fc8a5ecaa876af09", + "submittedTime": 1528133293859, + "firstRetryBlockNumber": "0x24af76" + }, + { + "id": 3387511061307741, + "time": 1528133318440, + "status": "rejected", + "metamaskNetworkId": "4", + "loadingDefaults": false, + "txParams": { + "from": "0x3b222de3aaba8ec9771ca9e9af5d8ed757fb7f62", + "to": "0x3b222de3aaba8ec9771ca9e9af5d8ed757fb7f62", + "value": "0x0", + "gasPrice": "0x3b9aca00", + "gas": "0x5208" + }, + "history": [ + { + "id": 3387511061307741, + "time": 1528133318440, + "status": "unapproved", + "metamaskNetworkId": "4", + "loadingDefaults": true, + "txParams": { + "from": "0x3b222de3aaba8ec9771ca9e9af5d8ed757fb7f62", + "to": "0x3b222de3aaba8ec9771ca9e9af5d8ed757fb7f62" + } + }, + [ + { + "op": "add", + "path": "/txParams/value", + "value": "0x0", + "timestamp": 1528133319641 + }, + { + "op": "add", + "path": "/txParams/gasPrice", + "value": "0x3b9aca00" + }, + { + "op": "add", + "path": "/txParams/gas", + "value": "0x5208" + }, + { + "op": "replace", + "path": "/loadingDefaults", + "value": false + } + ], + [ + { + "op": "add", + "path": "/origin", + "value": "tmashuang.github.io", + "note": "#newUnapprovedTransaction - adding the origin", + "timestamp": 1528133319642 + } + ], + [ + { + "op": "replace", + "path": "/status", + "value": "rejected", + "note": "txStateManager: setting status to rejected", + "timestamp": 1528133320924 + } + ] + ], + "origin": "tmashuang.github.io" + } + ] + }, + "send": { + "amountMode": "INPUT", + "currentTransactionUUID": "1-tx", + "draftTransactions": { + "1-tx": { + "amount": { + "error": null, + "value": "0xde0b6b3a7640000" + }, + "asset": { + "balance": "0x1158e460913d00000", + "details": null, + "error": null, + "type": "NATIVE" + }, + "fromAccount": null, + "gas": { + "error": null, + "gasLimit": "0x5208", + "gasPrice": "0x0", + "gasTotal": "0x1ca62a544678", + "maxFeePerGas": "0x59682f0f", + "maxPriorityFeePerGas": "0x59682f00", + "wasManuallyEdited": false + }, + "history": [], + "id": null, + "recipient": { + "address": "0xec1adf982415d2ef5ec55899b9bfb8bc0f29251b", + "error": null, + "nickname": "Account 2", + "warning": null, + "type": "", + "recipientWarningAcknowledged": false + }, + "status": "VALID", + "transactionType": "0x2", + "userInputHexData": null + } + }, + "eip1559support": true, + "gasEstimateIsLoading": false, + "gasEstimatePollToken": "", + "gasIsSetInModal": false, + "gasPriceEstimate": "0x0", + "gasLimitMinimum": "0x5208", + "gasTotalForLayer1": "0x0", + "recipientMode": "CONTACT_LIST", + "recipientInput": "0xec1adf982415d2ef5ec55899b9bfb8bc0f29251b", + "selectedAccount": { + "address": "0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc", + "balance": "0x4563918244f40000" + }, + "stage": "DRAFT" + } +} diff --git a/test/e2e/tests/settings-general.spec.js b/test/e2e/tests/settings-general.spec.js index bf4a1954d..4279f6908 100644 --- a/test/e2e/tests/settings-general.spec.js +++ b/test/e2e/tests/settings-general.spec.js @@ -31,7 +31,7 @@ describe('Settings', function () { // finds the jazzicon toggle turned on await driver.findElement( - '[data-test-id="jazz_icon"] .settings-page__content-item__identicon__item__icon--active', + '[data-testid="jazz_icon"] .settings-page__content-item__identicon__item__icon--active', ); const jazziconText = await driver.findElement({ diff --git a/ui/pages/send/send-content/send-amount-row/__snapshots__/send-amount-row.test.js.snap b/ui/pages/send/send-content/send-amount-row/__snapshots__/send-amount-row.test.js.snap new file mode 100644 index 000000000..307491078 --- /dev/null +++ b/ui/pages/send/send-content/send-amount-row/__snapshots__/send-amount-row.test.js.snap @@ -0,0 +1,217 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`SendAmountRow Component render Collectible Asset Type should match snapshot for token collectible type 1`] = ` +
+
+
+ Amount: + +
+
+
+
+
+
+ +
+ ETH +
+
+
+ No conversion rate available +
+
+ +
+
+
+
+
+
+`; + +exports[`SendAmountRow Component render Native Asset Type should match snapshot for native asset type 1`] = ` +
+
+
+ Amount: + +
+
+
+
+
+
+ +
+ ETH +
+
+
+ No conversion rate available +
+
+ +
+
+
+
+
+
+`; + +exports[`SendAmountRow Component render Token Asset Type should match snapshot for token asset type 1`] = ` +
+
+
+ Amount: + +
+
+
+
+
+
+ +
+ META +
+
+
+ No conversion rate available +
+
+
+
+
+
+
+
+`; diff --git a/ui/pages/send/send-content/send-amount-row/send-amount-row.component.test.js b/ui/pages/send/send-content/send-amount-row/send-amount-row.component.test.js deleted file mode 100644 index 21d7db8f3..000000000 --- a/ui/pages/send/send-content/send-amount-row/send-amount-row.component.test.js +++ /dev/null @@ -1,102 +0,0 @@ -import React from 'react'; -import { shallow } from 'enzyme'; -import sinon from 'sinon'; -import SendRowWrapper from '../send-row-wrapper/send-row-wrapper.component'; -import UserPreferencedTokenInput from '../../../../components/app/user-preferenced-token-input'; -import { ASSET_TYPES } from '../../../../../shared/constants/transaction'; -import SendAmountRow from './send-amount-row.component'; - -import AmountMaxButton from './amount-max-button/amount-max-button'; - -describe('SendAmountRow Component', () => { - describe('updateAmount', () => { - it('should call updateSendAmount', () => { - const { - instance, - propsMethodSpies: { updateSendAmount }, - } = shallowRenderSendAmountRow(); - - expect(updateSendAmount.callCount).toStrictEqual(0); - - instance.handleChange('someAmount'); - - expect( - updateSendAmount.calledOnceWithExactly('someAmount'), - ).toStrictEqual(true); - }); - }); - - describe('render', () => { - it('should render a SendRowWrapper component', () => { - const { wrapper } = shallowRenderSendAmountRow(); - - expect(wrapper.find(SendRowWrapper)).toHaveLength(1); - }); - - it('should pass the correct props to SendRowWrapper', () => { - const { wrapper } = shallowRenderSendAmountRow(); - const { errorType, label, showError } = wrapper - .find(SendRowWrapper) - .props(); - - expect(errorType).toStrictEqual('amount'); - expect(label).toStrictEqual('amount_t:'); - expect(showError).toStrictEqual(false); - }); - - it('should render an AmountMaxButton as the first child of the SendRowWrapper', () => { - const { wrapper } = shallowRenderSendAmountRow(); - - expect( - wrapper.find(SendRowWrapper).childAt(0).is(AmountMaxButton), - ).toStrictEqual(true); - }); - - it('should render a UserPreferencedTokenInput as the second child of the SendRowWrapper', () => { - const { wrapper } = shallowRenderSendAmountRow(); - - expect( - wrapper.find(SendRowWrapper).childAt(1).is(UserPreferencedTokenInput), - ).toStrictEqual(true); - }); - - it('should render the UserPreferencedTokenInput with the correct props', () => { - const { wrapper } = shallowRenderSendAmountRow(); - const { onChange, error, value } = wrapper - .find(SendRowWrapper) - .childAt(1) - .props(); - - expect(error).toStrictEqual(false); - expect(value).toStrictEqual('mockAmount'); - - onChange('mockNewAmount'); - }); - }); -}); - -function shallowRenderSendAmountRow() { - const updateSendAmount = sinon.spy(); - const wrapper = shallow( - , - { context: { t: (str) => `${str}_t` } }, - ); - const instance = wrapper.instance(); - - return { - instance, - wrapper, - propsMethodSpies: { - updateSendAmount, - }, - }; -} diff --git a/ui/pages/send/send-content/send-amount-row/send-amount-row.container.test.js b/ui/pages/send/send-content/send-amount-row/send-amount-row.container.test.js deleted file mode 100644 index 88b411b8e..000000000 --- a/ui/pages/send/send-content/send-amount-row/send-amount-row.container.test.js +++ /dev/null @@ -1,39 +0,0 @@ -import sinon from 'sinon'; - -import { updateSendAmount } from '../../../../ducks/send'; - -let mapDispatchToProps; - -jest.mock('react-redux', () => ({ - connect: (_, md) => { - mapDispatchToProps = md; - return () => ({}); - }, -})); - -jest.mock('../../../../ducks/send', () => ({ - updateSendAmount: jest.fn(), -})); - -require('./send-amount-row.container'); - -describe('send-amount-row container', () => { - describe('mapDispatchToProps()', () => { - let dispatchSpy; - let mapDispatchToPropsObject; - - beforeEach(() => { - dispatchSpy = sinon.spy(); - mapDispatchToPropsObject = mapDispatchToProps(dispatchSpy); - }); - - describe('updateSendAmount()', () => { - it('should dispatch an action', () => { - mapDispatchToPropsObject.updateSendAmount('mockAmount'); - expect(dispatchSpy.calledOnce).toStrictEqual(true); - expect(updateSendAmount).toHaveBeenCalled(); - expect(updateSendAmount).toHaveBeenCalledWith('mockAmount'); - }); - }); - }); -}); diff --git a/ui/pages/send/send-content/send-amount-row/send-amount-row.test.js b/ui/pages/send/send-content/send-amount-row/send-amount-row.test.js new file mode 100644 index 000000000..b27c35be1 --- /dev/null +++ b/ui/pages/send/send-content/send-amount-row/send-amount-row.test.js @@ -0,0 +1,110 @@ +import React from 'react'; +import { fireEvent } from '@testing-library/react'; +import configureMockStore from 'redux-mock-store'; +import thunk from 'redux-thunk'; +import mockSendState from '../../../../../test/data/mock-send-state.json'; +import { renderWithProvider } from '../../../../../test/lib/render-helpers'; +import { ASSET_TYPES } from '../../../../../shared/constants/transaction'; +import SendAmountRow from '.'; + +const mockUpdateSendAmount = jest.fn(); + +jest.mock('../../../../ducks/send', () => ({ + ...jest.requireActual('../../../../ducks/send'), + updateSendAmount: () => mockUpdateSendAmount, +})); + +describe('SendAmountRow Component', () => { + describe('render', () => { + describe('Native Asset Type', () => { + const mockStore = configureMockStore([thunk])(mockSendState); + + it('should match snapshot for native asset type', () => { + const { container } = renderWithProvider(, mockStore); + + expect(container).toMatchSnapshot(); + }); + }); + + describe('Token Asset Type', () => { + const tokenState = { + ...mockSendState, + send: { + currentTransactionUUID: '1-tx', + draftTransactions: { + '1-tx': { + asset: { + balance: '0x1158e460913d00000', // 20000000000000000000 + details: { + address: '0x617b3f8050a0BD94b6b1da02B4384eE5B4DF13F4', + symbol: 'META', + balance: '1000000000000000000', + decimals: 18, + string: '1', + balanceError: null, + isERC721: false, + image: '', + standard: 'ERC20', + }, + error: null, + type: ASSET_TYPES.TOKEN, + }, + }, + }, + }, + }; + const mockStore = configureMockStore([thunk])(tokenState); + + it('should match snapshot for token asset type', () => { + const { container } = renderWithProvider(, mockStore); + + expect(container).toMatchSnapshot(); + }); + }); + + describe('Collectible Asset Type', () => { + it('should match snapshot for token collectible type', () => { + const collectibleState = { + ...mockSendState, + send: { + currentTransactionUUID: '1-tx', + draftTransactions: { + '1-tx': { + asset: { + balance: '', + details: null, + error: null, + type: ASSET_TYPES.COLLECTIBLE, + }, + }, + }, + }, + }; + + const mockStore = configureMockStore([thunk])(collectibleState); + + const { container } = renderWithProvider(, mockStore); + + expect(container).toMatchSnapshot(); + }); + }); + }); + + describe('updateAmount', () => { + const mockStore = configureMockStore([thunk])(mockSendState); + + it('should call updateSendAmount', () => { + const { queryByTestId } = renderWithProvider( + , + mockStore, + ); + queryByTestId('currency-input'); + + fireEvent.change(queryByTestId('currency-input'), { + target: { value: 0.5 }, + }); + + expect(mockUpdateSendAmount).toHaveBeenCalled(); + }); + }); +}); diff --git a/ui/pages/send/send-content/send-row-wrapper/send-row-error-message/__snapshots__/send-row-error-message.test.js.snap b/ui/pages/send/send-content/send-row-wrapper/send-row-error-message/__snapshots__/send-row-error-message.test.js.snap new file mode 100644 index 000000000..7368419f2 --- /dev/null +++ b/ui/pages/send/send-content/send-row-wrapper/send-row-error-message/__snapshots__/send-row-error-message.test.js.snap @@ -0,0 +1,13 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`SendRowErrorMessage Component render should match snapshot with no error 1`] = `
`; + +exports[`SendRowErrorMessage Component render should render an error message if the passed errors contain an error of errorType 1`] = ` +
+
+ Insufficient funds. +
+
+`; diff --git a/ui/pages/send/send-content/send-row-wrapper/send-row-error-message/send-row-error-message.component.test.js b/ui/pages/send/send-content/send-row-wrapper/send-row-error-message/send-row-error-message.component.test.js deleted file mode 100644 index 2036b7a99..000000000 --- a/ui/pages/send/send-content/send-row-wrapper/send-row-error-message/send-row-error-message.component.test.js +++ /dev/null @@ -1,32 +0,0 @@ -import React from 'react'; -import { shallow } from 'enzyme'; -import SendRowErrorMessage from './send-row-error-message.component'; - -describe('SendRowErrorMessage Component', () => { - let wrapper; - - describe('render', () => { - beforeEach(() => { - wrapper = shallow( - , - { context: { t: (str) => `${str}_t` } }, - ); - }); - - it('should render null if the passed errors do not contain an error of errorType', () => { - expect(wrapper.find('.send-v2__error')).toHaveLength(0); - expect(wrapper.html()).toBeNull(); - }); - - it('should render an error message if the passed errors contain an error of errorType', () => { - wrapper.setProps({ - errors: { error1: 'abc', error2: 'def', error3: 'xyz' }, - }); - expect(wrapper.find('.send-v2__error')).toHaveLength(1); - expect(wrapper.find('.send-v2__error').text()).toStrictEqual('xyz_t'); - }); - }); -}); diff --git a/ui/pages/send/send-content/send-row-wrapper/send-row-error-message/send-row-error-message.container.test.js b/ui/pages/send/send-content/send-row-wrapper/send-row-error-message/send-row-error-message.container.test.js deleted file mode 100644 index cec2c2d8b..000000000 --- a/ui/pages/send/send-content/send-row-wrapper/send-row-error-message/send-row-error-message.container.test.js +++ /dev/null @@ -1,28 +0,0 @@ -/* eslint-disable import/unambiguous */ -let mapStateToProps; - -jest.mock('react-redux', () => ({ - connect: (ms) => { - mapStateToProps = ms; - return () => ({}); - }, -})); - -jest.mock('../../../../../ducks/send', () => ({ - getSendErrors: (s) => `mockErrors:${s}`, -})); - -require('./send-row-error-message.container'); - -describe('send-row-error-message container', () => { - describe('mapStateToProps()', () => { - it('should map the correct properties to props', () => { - expect( - mapStateToProps('mockState', { errorType: 'someType' }), - ).toStrictEqual({ - errors: 'mockErrors:mockState', - errorType: 'someType', - }); - }); - }); -}); diff --git a/ui/pages/send/send-content/send-row-wrapper/send-row-error-message/send-row-error-message.test.js b/ui/pages/send/send-content/send-row-wrapper/send-row-error-message/send-row-error-message.test.js new file mode 100644 index 000000000..7565838e6 --- /dev/null +++ b/ui/pages/send/send-content/send-row-wrapper/send-row-error-message/send-row-error-message.test.js @@ -0,0 +1,55 @@ +import React from 'react'; +import configureMockStore from 'redux-mock-store'; +import { INSUFFICIENT_FUNDS_ERROR_KEY } from '../../../../../helpers/constants/error-keys'; +import { renderWithProvider } from '../../../../../../test/lib/render-helpers'; +import SendRowErrorMessage from '.'; + +describe('SendRowErrorMessage Component', () => { + describe('render', () => { + it('should match snapshot with no error', () => { + const mockState = { + send: { + draftTransactions: {}, + }, + }; + + const mockStore = configureMockStore()(mockState); + const { container } = renderWithProvider( + , + mockStore, + ); + + expect(container).toMatchSnapshot(); + }); + + it('should render an error message if the passed errors contain an error of errorType', () => { + const props = { + errorType: 'amount', + }; + + const sendErrorState = { + send: { + currentTransactionUUID: '1-tx', + draftTransactions: { + '1-tx': { + gas: { + error: INSUFFICIENT_FUNDS_ERROR_KEY, + }, + amount: { + error: INSUFFICIENT_FUNDS_ERROR_KEY, + }, + }, + }, + }, + }; + const mockStore = configureMockStore()(sendErrorState); + + const { container } = renderWithProvider( + , + mockStore, + ); + + expect(container).toMatchSnapshot(); + }); + }); +}); diff --git a/ui/pages/settings/settings-tab/settings-tab.component.js b/ui/pages/settings/settings-tab/settings-tab.component.js index 35231813e..bf61b518d 100644 --- a/ui/pages/settings/settings-tab/settings-tab.component.js +++ b/ui/pages/settings/settings-tab/settings-tab.component.js @@ -100,6 +100,7 @@ export default class SettingsTab extends PureComponent {
@@ -197,7 +200,7 @@ export default class SettingsTab extends PureComponent {