aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Huang <tmashuang@users.noreply.github.com>2019-05-08 02:14:25 +0800
committerGitHub <noreply@github.com>2019-05-08 02:14:25 +0800
commit090d4a83679b0c94880012841d556ad530e7e49e (patch)
treec5d978a8382d1e93c6c13e34e400bc9d48bfd65a
parent50f46386ae122eb364681ff6c3c888cfee5ebd3f (diff)
parent936cbd7ec0bee70533f7daf00841b3954afe0dec (diff)
downloadtangerine-wallet-browser-090d4a83679b0c94880012841d556ad530e7e49e.tar
tangerine-wallet-browser-090d4a83679b0c94880012841d556ad530e7e49e.tar.gz
tangerine-wallet-browser-090d4a83679b0c94880012841d556ad530e7e49e.tar.bz2
tangerine-wallet-browser-090d4a83679b0c94880012841d556ad530e7e49e.tar.lz
tangerine-wallet-browser-090d4a83679b0c94880012841d556ad530e7e49e.tar.xz
tangerine-wallet-browser-090d4a83679b0c94880012841d556ad530e7e49e.tar.zst
tangerine-wallet-browser-090d4a83679b0c94880012841d556ad530e7e49e.zip
Merge pull request #6577 from MetaMask/fix-integration-tests
Fix integration tests: completedUiMigration state and fetch + ethquery mocking
-rw-r--r--development/states/confirm-new-ui.json3
-rw-r--r--development/states/confirm-sig-requests.json3
-rw-r--r--development/states/currency-localization.json3
-rw-r--r--development/states/send-edit.json3
-rw-r--r--development/states/send-new-ui.json3
-rw-r--r--development/states/tx-list-items.json3
-rw-r--r--test/integration/lib/confirm-sig-requests.js13
-rw-r--r--test/integration/lib/currency-localization.js11
-rw-r--r--test/integration/lib/send-new-ui.js3
-rw-r--r--test/integration/lib/tx-list-items.js11
10 files changed, 43 insertions, 13 deletions
diff --git a/development/states/confirm-new-ui.json b/development/states/confirm-new-ui.json
index 4310ed5b7..4019bede8 100644
--- a/development/states/confirm-new-ui.json
+++ b/development/states/confirm-new-ui.json
@@ -133,7 +133,8 @@
"preferences": {
"useNativeCurrencyAsPrimaryCurrency": true,
"showFiatInTestnets": true
- }
+ },
+ "completedUiMigration": true
},
"appState": {
"menuOpen": false,
diff --git a/development/states/confirm-sig-requests.json b/development/states/confirm-sig-requests.json
index aa3e8dfdf..9bf69c700 100644
--- a/development/states/confirm-sig-requests.json
+++ b/development/states/confirm-sig-requests.json
@@ -156,7 +156,8 @@
"currentLocale": "en",
"preferences": {
"useNativeCurrencyAsPrimaryCurrency": true
- }
+ },
+ "completedUiMigration": true
},
"appState": {
"menuOpen": false,
diff --git a/development/states/currency-localization.json b/development/states/currency-localization.json
index 8288b3020..faacb25de 100644
--- a/development/states/currency-localization.json
+++ b/development/states/currency-localization.json
@@ -115,7 +115,8 @@
"preferences": {
"useNativeCurrencyAsPrimaryCurrency": true,
"showFiatInTestnets": true
- }
+ },
+ "completedUiMigration": true
},
"appState": {
"menuOpen": false,
diff --git a/development/states/send-edit.json b/development/states/send-edit.json
index fda7d1a31..71421d29f 100644
--- a/development/states/send-edit.json
+++ b/development/states/send-edit.json
@@ -137,7 +137,8 @@
"preferences": {
"useNativeCurrencyAsPrimaryCurrency": true,
"showFiatInTestnets": true
- }
+ },
+ "completedUiMigration": true
},
"appState": {
"menuOpen": false,
diff --git a/development/states/send-new-ui.json b/development/states/send-new-ui.json
index b8a3ff128..8709d096b 100644
--- a/development/states/send-new-ui.json
+++ b/development/states/send-new-ui.json
@@ -116,7 +116,8 @@
"preferences": {
"useNativeCurrencyAsPrimaryCurrency": true,
"showFiatInTestnets": true
- }
+ },
+ "completedUiMigration": true
},
"appState": {
"menuOpen": false,
diff --git a/development/states/tx-list-items.json b/development/states/tx-list-items.json
index d4e3f3860..1f7539e7b 100644
--- a/development/states/tx-list-items.json
+++ b/development/states/tx-list-items.json
@@ -1058,7 +1058,8 @@
"currentLocale": "en",
"preferences": {
"useNativeCurrencyAsPrimaryCurrency": true
- }
+ },
+ "completedUiMigration": true
},
"appState": {
"menuOpen": false,
diff --git a/test/integration/lib/confirm-sig-requests.js b/test/integration/lib/confirm-sig-requests.js
index c3b0dfcff..4c2b56c21 100644
--- a/test/integration/lib/confirm-sig-requests.js
+++ b/test/integration/lib/confirm-sig-requests.js
@@ -15,16 +15,25 @@ QUnit.test('successful confirmation of sig requests', (assert) => {
})
})
+global.ethQuery = global.ethQuery || {}
+
async function runConfirmSigRequestsTest (assert, done) {
const selectState = await queryAsync($, 'select')
selectState.val('confirm sig requests')
reactTriggerChange(selectState[0])
+ const realFetch = window.fetch.bind(window)
global.fetch = (...args) => {
- if (args[0].match(/chromeextensionmm/)) {
+ if (args[0] === 'https://ethgasstation.info/json/ethgasAPI.json') {
+ return Promise.resolve({ json: () => Promise.resolve(JSON.parse(fetchMockResponses.ethGasBasic)) })
+ } else if (args[0] === 'https://ethgasstation.info/json/predictTable.json') {
+ return Promise.resolve({ json: () => Promise.resolve(JSON.parse(fetchMockResponses.ethGasPredictTable)) })
+ } else if (args[0] === 'https://dev.blockscale.net/api/gasexpress.json') {
+ return Promise.resolve({ json: () => Promise.resolve(JSON.parse(fetchMockResponses.gasExpress)) })
+ } else if (args[0].match(/chromeextensionmm/)) {
return Promise.resolve({ json: () => Promise.resolve(JSON.parse(fetchMockResponses.metametrics)) })
}
- return window.fetch(...args)
+ return realFetch.fetch(...args)
}
const pendingRequestItem = $.find('.transaction-list-item .transaction-list-item__grid')
diff --git a/test/integration/lib/currency-localization.js b/test/integration/lib/currency-localization.js
index cd10efa30..36837e059 100644
--- a/test/integration/lib/currency-localization.js
+++ b/test/integration/lib/currency-localization.js
@@ -21,11 +21,18 @@ async function runCurrencyLocalizationTest (assert, done) {
const selectState = await queryAsync($, 'select')
selectState.val('currency localization')
+ const realFetch = window.fetch.bind(window)
global.fetch = (...args) => {
- if (args[0].match(/chromeextensionmm/)) {
+ if (args[0] === 'https://ethgasstation.info/json/ethgasAPI.json') {
+ return Promise.resolve({ json: () => Promise.resolve(JSON.parse(fetchMockResponses.ethGasBasic)) })
+ } else if (args[0] === 'https://ethgasstation.info/json/predictTable.json') {
+ return Promise.resolve({ json: () => Promise.resolve(JSON.parse(fetchMockResponses.ethGasPredictTable)) })
+ } else if (args[0] === 'https://dev.blockscale.net/api/gasexpress.json') {
+ return Promise.resolve({ json: () => Promise.resolve(JSON.parse(fetchMockResponses.gasExpress)) })
+ } else if (args[0].match(/chromeextensionmm/)) {
return Promise.resolve({ json: () => Promise.resolve(JSON.parse(fetchMockResponses.metametrics)) })
}
- return window.fetch(...args)
+ return realFetch.fetch(...args)
}
await timeout(1000)
diff --git a/test/integration/lib/send-new-ui.js b/test/integration/lib/send-new-ui.js
index 6a58611d1..85487a59f 100644
--- a/test/integration/lib/send-new-ui.js
+++ b/test/integration/lib/send-new-ui.js
@@ -25,6 +25,7 @@ global.ethereumProvider = {}
async function runSendFlowTest (assert, done) {
const tempFetch = global.fetch
+ const realFetch = window.fetch.bind(window)
global.fetch = (...args) => {
if (args[0] === 'https://ethgasstation.info/json/ethgasAPI.json') {
return Promise.resolve({ json: () => Promise.resolve(JSON.parse(fetchMockResponses.ethGasBasic)) })
@@ -35,7 +36,7 @@ async function runSendFlowTest (assert, done) {
} else if (args[0].match(/chromeextensionmm/)) {
return Promise.resolve({ json: () => Promise.resolve(JSON.parse(fetchMockResponses.metametrics)) })
}
- return window.fetch(...args)
+ return realFetch.fetch(...args)
}
console.log('*** start runSendFlowTest')
diff --git a/test/integration/lib/tx-list-items.js b/test/integration/lib/tx-list-items.js
index c0056dd22..91645c5c5 100644
--- a/test/integration/lib/tx-list-items.js
+++ b/test/integration/lib/tx-list-items.js
@@ -26,11 +26,18 @@ async function runTxListItemsTest (assert, done) {
selectState.val('tx list items')
reactTriggerChange(selectState[0])
+ const realFetch = window.fetch.bind(window)
global.fetch = (...args) => {
- if (args[0].match(/chromeextensionmm/)) {
+ if (args[0] === 'https://ethgasstation.info/json/ethgasAPI.json') {
+ return Promise.resolve({ json: () => Promise.resolve(JSON.parse(fetchMockResponses.ethGasBasic)) })
+ } else if (args[0] === 'https://ethgasstation.info/json/predictTable.json') {
+ return Promise.resolve({ json: () => Promise.resolve(JSON.parse(fetchMockResponses.ethGasPredictTable)) })
+ } else if (args[0] === 'https://dev.blockscale.net/api/gasexpress.json') {
+ return Promise.resolve({ json: () => Promise.resolve(JSON.parse(fetchMockResponses.gasExpress)) })
+ } else if (args[0].match(/chromeextensionmm/)) {
return Promise.resolve({ json: () => Promise.resolve(JSON.parse(fetchMockResponses.metametrics)) })
}
- return window.fetch(...args)
+ return realFetch.fetch(...args)
}
const metamaskLogo = await queryAsync($, '.app-header__logo-container')