From 0bbcbe6e90ac58c7f40f1134606af073d828db05 Mon Sep 17 00:00:00 2001 From: Thomas Huang Date: Tue, 27 Sep 2022 08:03:26 -0700 Subject: [PATCH] Continue converting tests from enzyme to @testing-library/react (#15956) * Update mock state data * Convert App Header test to tlr. * Convert Gas Timing test to tlr. * Convert Account Details Modal to tlr. * Update Sig Req test to match mock state changes. * Add test-ids to Editable Label for Account Details Modal * Adjust selectors test for the mock state update. * Add back gasIsLoading for selectors test. --- test/data/mock-state.json | 88 +++-- .../__snapshots__/app-header.test.js.snap | 309 ++++++++++++++++++ .../app/app-header/app-header.component.js | 1 + .../app/app-header/app-header.test.js | 174 ++++++---- .../gas-timing.component.test.js.snap | 3 + .../gas-timing/gas-timing.component.test.js | 175 ++++------ .../account-details-modal.test.js | 154 +++++---- .../signature-request-original.test.js.snap | 33 -- .../ui/editable-label/editable-label.js | 2 + ui/selectors/selectors.test.js | 2 +- 10 files changed, 631 insertions(+), 310 deletions(-) create mode 100644 ui/components/app/app-header/__snapshots__/app-header.test.js.snap create mode 100644 ui/components/app/gas-timing/__snapshots__/gas-timing.component.test.js.snap diff --git a/test/data/mock-state.json b/test/data/mock-state.json index b378b37c4..cc1b350a4 100644 --- a/test/data/mock-state.json +++ b/test/data/mock-state.json @@ -1,43 +1,50 @@ { "appState": { - "isLoading": false, + "networkDropdownOpen": false, "gasIsLoading": false, - "currentView": { - "name": "accountDetail", - "detailView": null, - "context": "0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc" + "isLoading": false, + "modal": { + "open": false, + "modalState": { + "name": null, + "props": {} + }, + "previousModalState": { + "name": null + } } }, "history": { "mostRecentOverviewPage": "/" }, "metamask": { + "gasEstimateType": "fee-market", "gasFeeEstimates": { "low": { - "suggestedMaxPriorityFeePerGas": "1.233864249", - "suggestedMaxFeePerGas": "19.308202033", - "minWaitTimeEstimate": 15000, - "maxWaitTimeEstimate": 30000 + "minWaitTimeEstimate": 180000, + "maxWaitTimeEstimate": 300000, + "suggestedMaxPriorityFeePerGas": "3", + "suggestedMaxFeePerGas": "53" }, "medium": { - "suggestedMaxPriorityFeePerGas": "1.5", - "suggestedMaxFeePerGas": "25.900356008", "minWaitTimeEstimate": 15000, - "maxWaitTimeEstimate": 45000 + "maxWaitTimeEstimate": 60000, + "suggestedMaxPriorityFeePerGas": "7", + "suggestedMaxFeePerGas": "70" }, "high": { - "suggestedMaxPriorityFeePerGas": "2", - "suggestedMaxFeePerGas": "32.726374232", - "minWaitTimeEstimate": 15000, - "maxWaitTimeEstimate": 60000 + "minWaitTimeEstimate": 0, + "maxWaitTimeEstimate": 15000, + "suggestedMaxPriorityFeePerGas": "10", + "suggestedMaxFeePerGas": "100" }, - "estimatedBaseFee": "18.074337783", - "historicalBaseFeeRange": ["10.621659703", "19.673392581"], + "estimatedBaseFee": "50", + "historicalBaseFeeRange": ["28.533098435", "70.351148354"], "baseFeeTrend": "up", - "latestPriorityFeeRange": ["1.5", "17.536644176"], - "historicalPriorityFeeRange": ["0.110624865", "718.303816711"], - "priorityFeeTrend": "up", - "networkCongestion": 0.87115 + "latestPriorityFeeRange": ["1", "40"], + "historicalPriorityFeeRange": ["0.1458417", "700.156384646"], + "priorityFeeTrend": "down", + "networkCongestion": 0.90625 }, "preferences": { "hideZeroBalanceTokens": false, @@ -46,17 +53,34 @@ "useNativeCurrencyAsPrimaryCurrency": true }, "ensResolutionsByAddress": {}, + "isAccountMenuOpen": false, + "isUnlocked": true, + "alertEnabledness": { + "unconnectedAccount": true + }, "featureFlags": { "showIncomingTransactions": true }, "network": "4", "provider": { + "type": "rpc", "chainId": "0x4" }, "keyrings": [ + { + "type": "HD Key Tree", + "accounts": [ + "0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc", + "0xec1adf982415d2ef5ec55899b9bfb8bc0f29251b" + ] + }, { "type": "Ledger Hardware", - "accounts": ["0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc"] + "accounts": ["0xc42edfcc21ed14dda456aa0756c153f7985d8813"] + }, + { + "type": "Simple Key Pair", + "accounts": ["0xeb9e64b93097bc15f01f13eae97015c57ab64823"] } ], "identities": { @@ -64,9 +88,17 @@ "address": "0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc", "name": "Test Account" }, + "0xec1adf982415d2ef5ec55899b9bfb8bc0f29251b": { + "address": "0xec1adf982415d2ef5ec55899b9bfb8bc0f29251b", + "name": "Test Account 2" + }, "0xc42edfcc21ed14dda456aa0756c153f7985d8813": { "address": "0xc42edfcc21ed14dda456aa0756c153f7985d8813", - "name": "Test Account 2" + "name": "Test Ledger 1" + }, + "0xeb9e64b93097bc15f01f13eae97015c57ab64823": { + "name": "Test Account 3", + "address": "0xeb9e64b93097bc15f01f13eae97015c57ab64823" } }, "networkDetails": { @@ -150,9 +182,17 @@ "balance": "0x0", "address": "0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc" }, + "0xec1adf982415d2ef5ec55899b9bfb8bc0f29251b": { + "address": "0xec1adf982415d2ef5ec55899b9bfb8bc0f29251b", + "balance": "0x0" + }, "0xc42edfcc21ed14dda456aa0756c153f7985d8813": { "address": "0xc42edfcc21ed14dda456aa0756c153f7985d8813", "balance": "0x0" + }, + "0xeb9e64b93097bc15f01f13eae97015c57ab64823": { + "address": "0xeb9e64b93097bc15f01f13eae97015c57ab64823", + "balance": "0x0" } }, "tokens": [ diff --git a/ui/components/app/app-header/__snapshots__/app-header.test.js.snap b/ui/components/app/app-header/__snapshots__/app-header.test.js.snap new file mode 100644 index 000000000..3949b9881 --- /dev/null +++ b/ui/components/app/app-header/__snapshots__/app-header.test.js.snap @@ -0,0 +1,309 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`App Header should match snapshot 1`] = ` +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+
+`; diff --git a/ui/components/app/app-header/app-header.component.js b/ui/components/app/app-header/app-header.component.js index 7355af677..7f1bbc253 100644 --- a/ui/components/app/app-header/app-header.component.js +++ b/ui/components/app/app-header/app-header.component.js @@ -74,6 +74,7 @@ export default class AppHeader extends PureComponent { return ( isUnlocked && (