From 646dbaaff2f8d0f93e35cbd805bf0a3b247cf6e5 Mon Sep 17 00:00:00 2001 From: Thomas Huang Date: Fri, 4 Nov 2022 13:56:24 -0700 Subject: [PATCH] Continue converting tests from enzyme to @testing-library/react (#16373) * Add transaction activity log component * Remove duplicate tx activity log snapshot. * Convert Identicon test to tlr. * Convert Metafoxlogo test to tlr. * Convert Reveal Seed Phrase test to tlr. * Consolidate and convert Send Footer test to tlr. * Convert Settings test to tlr. * Consolidate and convert security tab test to tlr. * Convert null selectedOption to empty string, and add test id to Dropdown component. * Add Send state to mock-state * Lint mock-state.json --- test/data/mock-state.json | 41 +-- ui/components/ui/dropdown/dropdown.js | 8 +- .../identicon.component.test.js.snap | 70 +++++ .../ui/identicon/identicon.component.test.js | 61 +++-- .../metafox-logo.component.test.js.snap | 35 +++ .../metafox-logo.component.test.js | 29 +-- .../reveal-seed-phrase.test.js.snap | 135 ++++++++++ .../reveal-seed-phrase.component.js | 4 + .../reveal-seed-phrase.test.js | 46 ++-- .../__snapshots__/send-footer.test.js.snap | 55 ++++ .../send-footer/send-footer.component.test.js | 207 --------------- .../send-footer/send-footer.container.test.js | 87 ------- ui/pages/send/send-footer/send-footer.test.js | 136 ++++++++++ .../__snapshots__/security-tab.test.js.snap | 246 ++++++++++++++++++ .../security-tab/security-tab.component.js | 1 + .../security-tab.container.test.js | 63 ----- .../security-tab/security-tab.test.js | 86 ++++++ ui/pages/settings/settings.component.test.js | 61 ----- ui/pages/settings/settings.test.js | 45 ++++ 19 files changed, 909 insertions(+), 507 deletions(-) create mode 100644 ui/components/ui/identicon/__snapshots__/identicon.component.test.js.snap create mode 100644 ui/components/ui/metafox-logo/__snapshots__/metafox-logo.component.test.js.snap create mode 100644 ui/pages/first-time-flow/seed-phrase/reveal-seed-phrase/__snapshots__/reveal-seed-phrase.test.js.snap create mode 100644 ui/pages/send/send-footer/__snapshots__/send-footer.test.js.snap delete mode 100644 ui/pages/send/send-footer/send-footer.component.test.js delete mode 100644 ui/pages/send/send-footer/send-footer.container.test.js create mode 100644 ui/pages/send/send-footer/send-footer.test.js create mode 100644 ui/pages/settings/security-tab/__snapshots__/security-tab.test.js.snap delete mode 100644 ui/pages/settings/security-tab/security-tab.container.test.js create mode 100644 ui/pages/settings/security-tab/security-tab.test.js delete mode 100644 ui/pages/settings/settings.component.test.js create mode 100644 ui/pages/settings/settings.test.js diff --git a/test/data/mock-state.json b/test/data/mock-state.json index a376803df..963c88d42 100644 --- a/test/data/mock-state.json +++ b/test/data/mock-state.json @@ -12,12 +12,15 @@ "previousModalState": { "name": null } - } + }, + "warning": null }, "history": { - "mostRecentOverviewPage": "/" + "mostRecentOverviewPage": "/mostRecentOverviewPage" }, "metamask": { + "usePhishDetect": true, + "participateInMetaMetrics": false, "gasEstimateType": "fee-market", "gasFeeEstimates": { "low": { @@ -46,6 +49,7 @@ "priorityFeeTrend": "down", "networkCongestion": 0.90625 }, + "snaps": [{}], "preferences": { "hideZeroBalanceTokens": false, "showFiatInTestnets": false, @@ -241,20 +245,6 @@ "unapprovedEncryptionPublicKeyMsgCount": 0, "unapprovedTypedMessages": {}, "unapprovedTypedMessagesCount": 0, - "send": { - "gasLimit": "0x5208", - "gasPrice": "0xee6b2800", - "gasTotal": "0x4c65c6294000", - "tokenBalance": null, - "from": "0xc42edfcc21ed14dda456aa0756c153f7985d8813", - "to": "", - "amount": "1bc16d674ec80000", - "memo": "", - "errors": {}, - "maxModeOn": false, - "editingTransactionId": null, - "toNickname": "" - }, "useTokenDetection": true, "advancedGasFee": { "maxBaseFee": "75", @@ -1284,5 +1274,24 @@ "origin": "tmashuang.github.io" } ] + }, + "send": { + "amountMode": "INPUT", + "currentTransactionUUID": null, + "draftTransactions": {}, + "eip1559support": false, + "gasEstimateIsLoading": true, + "gasEstimatePollToken": null, + "gasIsSetInModal": false, + "gasPriceEstimate": "0x0", + "gasLimitMinimum": "0x5208", + "gasTotalForLayer1": "0x0", + "recipientMode": "CONTACT_LIST", + "recipientInput": "", + "selectedAccount": { + "address": "0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc", + "balance": "0x0" + }, + "stage": "INACTIVE" } } diff --git a/ui/components/ui/dropdown/dropdown.js b/ui/components/ui/dropdown/dropdown.js index 3a6de0dca..8bfde46ff 100644 --- a/ui/components/ui/dropdown/dropdown.js +++ b/ui/components/ui/dropdown/dropdown.js @@ -8,9 +8,10 @@ const Dropdown = ({ disabled = false, onChange, options, - selectedOption = null, + selectedOption = '', style, title, + 'data-testid': dataTestId, }) => { const _onChange = useCallback( (event) => { @@ -25,6 +26,7 @@ const Dropdown = ({
+
+
+ + Off + + + On + +
+ + + + +
+
+ + Use phishing detection + +
+ Display a warning for phishing domains targeting Ethereum users +
+
+
+
+